Commit 6f8847a6 authored by Lulu Luong's avatar Lulu Luong

#55

parent b4a17252
Pipeline #29259 passed with stages
in 3 minutes and 29 seconds
......@@ -146,6 +146,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
Variable var = assignmentStatement.getLhs();
Expression expr = assignmentStatement.getRhs();
if (t != null) {
System.out.println("t = " + t+ var);
node.declareVariable(var, t);
}
......@@ -158,6 +159,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
if (fireVariableAssignmentHook(node, var.getIdentifier(), v)) {
node.setVariableValue(var, v);
}
System.out.println("v = " + v);
node.setVariableValue(var, v);
}
}
......
......@@ -54,11 +54,22 @@ public class GoalNode<T> {
this.id = id;
}
private GoalNode(int id, GoalNode<T> parent, VariableAssignment varas, T data, boolean isClosed) {
this(parent, varas, data, isClosed);
this.id = id;
}
private GoalNode(int id, T data, boolean isClosed) {
this(data);
this.isClosed = isClosed;
this.id = id;
}
private GoalNode(int id, VariableAssignment ass, T data, boolean isClosed) {
this(data);
this.assignments = ass;
this.isClosed = isClosed;
this.id = id;
}
/**
* @param varname
......@@ -128,10 +139,13 @@ public class GoalNode<T> {
* @return
*/
public GoalNode<T> deepCopy() {
VariableAssignment deepCopy = assignments.deepCopy();
if (parent != null) {
return new GoalNode<T>(id, parent.deepCopy(), data, isClosed);
return new GoalNode<T>(id, parent.deepCopy(), deepCopy, data, isClosed);
} else {
return new GoalNode<T>(id, data, isClosed);
return new GoalNode<T>(id, deepCopy, data, isClosed);
}
}
......
......@@ -4,10 +4,16 @@ import alice.tuprolog.Var;
import edu.kit.iti.formal.psdbg.gui.controls.Utils;
import edu.kit.iti.formal.psdbg.gui.model.InspectionModel;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import javafx.beans.Observable;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.BorderPane;
import lombok.Getter;
import lombok.Setter;
......@@ -26,18 +32,48 @@ public class VariableAssignmentWindow extends BorderPane {
TableColumn varCol = new TableColumn("Variable");
TableColumn typeCol = new TableColumn("Type");
TableColumn valCol = new TableColumn("Value");
tableView.getColumns().addAll(varCol, typeCol, valCol);
ObservableList<VariableModel> varmodell = FXCollections.observableArrayList();
if (assignment != null) {
//iterate over types map
assignment.getTypes().forEach((k, v) -> {
varCol.getColumns().add(k);
typeCol.getColumns().add(v);
valCol.getColumns().add(assignment.getValue(k));
varmodell.add(new VariableModel(k.getIdentifier(), v.symbol(), assignment.getValue(k).getData().toString()));
/* varCol.getColumns().add(k.toString());
typeCol.getColumns().add(v.toString());
valCol.getColumns().add(assignment.getValue(k).toString());*/
});
}
varCol.setCellValueFactory(
new PropertyValueFactory<VariableModel,String>("varname")
);
typeCol.setCellValueFactory(
new PropertyValueFactory<VariableModel,String>("vartype")
);
valCol.setCellValueFactory(
new PropertyValueFactory<VariableModel,String>("varval")
);
tableView.setItems(varmodell);
tableView.getColumns().addAll(varCol, typeCol, valCol);
}
public static class VariableModel {
@Getter
private final String varname;
@Getter
private final String vartype;
@Getter
private final String varval;
private VariableModel(String varname, String vartype, String varval) {
this.varname = varname;
this.vartype = vartype;
this.varval = varval;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment