Commit dabdebca authored by Sarah Grebing's avatar Sarah Grebing

fixed errors

parent 4197f43b
Pipeline #14970 failed with stage
in 1 minute and 59 seconds
package edu.kit.iti.formal.psdbg.interpreter.graphs; package edu.kit.iti.formal.psdbg.interpreter.graphs;
import edu.kit.iti.formal.psdbg.interpreter.data.InterpreterExtendedState; import edu.kit.iti.formal.psdbg.interpreter.data.InterpreterExtendedState;
import edu.kit.iti.formal.psdbg.interpreter.data.State;
import edu.kit.iti.formal.psdbg.parser.ast.ASTNode; import edu.kit.iti.formal.psdbg.parser.ast.ASTNode;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
...@@ -19,12 +18,15 @@ public class PTreeNode<T> { ...@@ -19,12 +18,15 @@ public class PTreeNode<T> {
* State after statement * State after statement
*/ */
//private State<T> state; //private State<T> state;
@Getter
@Setter
private InterpreterExtendedState<T> extendedState = new InterpreterExtendedState<>(null); private InterpreterExtendedState<T> extendedState = new InterpreterExtendedState<>(null);
/** /**
* Statement * Statement
*/ */
@Getter
@Setter
private ASTNode scriptStmt; private ASTNode scriptStmt;
......
...@@ -119,7 +119,7 @@ public class StateGraphWrapper<T> { ...@@ -119,7 +119,7 @@ public class StateGraphWrapper<T> {
LOGGER.info("Stepover requested for null, therefore returning root"); LOGGER.info("Stepover requested for null, therefore returning root");
return this.rootProperty().get(); return this.rootProperty().get();
} }
LOGGER.info("Stepover requested for node {}@{}", statePointer.getScriptstmt(), statePointer.getScriptstmt().getNodeName()); LOGGER.info("Stepover requested for node {}@{}", statePointer.getScriptStmt(), statePointer.getScriptStmt().getNodeName());
//look for successors in the graph //look for successors in the graph
Set<PTreeNode<T>> successors = this.stateGraph.successors(statePointer); Set<PTreeNode<T>> successors = this.stateGraph.successors(statePointer);
//if there are no successors they have to be computed therefore return null, to trigger the proof tree controller //if there are no successors they have to be computed therefore return null, to trigger the proof tree controller
...@@ -209,10 +209,10 @@ public class StateGraphWrapper<T> { ...@@ -209,10 +209,10 @@ public class StateGraphWrapper<T> {
newStateNode.getContext().push(node); newStateNode.getContext().push(node);
State<T> currentInterpreterStateCopy = currentInterpreter.getCurrentState().copy(); State<T> currentInterpreterStateCopy = currentInterpreter.getCurrentState().copy();
//copy current state before executing statement //copy current state before executing statement
newStateNode.setState(currentInterpreterStateCopy); //newStateNode.setState(currentInterpreterStateCopy);
//create extended State //create extended State
InterpreterExtendedState<T> extState = new InterpreterExtendedState<>(); InterpreterExtendedState<T> extState = new InterpreterExtendedState<>(null);
extState.setStmt(node); extState.setStmt(node);
extState.setStateBeforeStmt(currentInterpreterStateCopy); extState.setStateBeforeStmt(currentInterpreterStateCopy);
newStateNode.setExtendedState(extState); newStateNode.setExtendedState(extState);
...@@ -263,7 +263,7 @@ public class StateGraphWrapper<T> { ...@@ -263,7 +263,7 @@ public class StateGraphWrapper<T> {
extState.setMappingOfCaseToStates(mappingOfCaseToStates); extState.setMappingOfCaseToStates(mappingOfCaseToStates);
//TODO default case: missing datastructure of supertype CaseStatement at the moment //TODO default case: missing datastructure of supertype CaseStatement at the moment
newStateNode.setState(lastState.copy()); // newStateNode.setState(lastState.copy());
} else { } else {
...@@ -282,17 +282,17 @@ public class StateGraphWrapper<T> { ...@@ -282,17 +282,17 @@ public class StateGraphWrapper<T> {
newStateNode.setExtendedState(extState); newStateNode.setExtendedState(extState);
stateGraph.addNode(newStateNode); stateGraph.addNode(newStateNode);
Collection<Pair<ControlFlowNode, EdgeTypes>> predecessorsAndTheirEdges = cfgVisitor.getPredecessorsAndTheirEdges(newStateNode.getScriptstmt()); Collection<Pair<ControlFlowNode, EdgeTypes>> predecessorsAndTheirEdges = cfgVisitor.getPredecessorsAndTheirEdges(newStateNode.getScriptStmt());
for (Pair<ControlFlowNode, EdgeTypes> predecessorsAndTheirEdge : predecessorsAndTheirEdges) { for (Pair<ControlFlowNode, EdgeTypes> predecessorsAndTheirEdge : predecessorsAndTheirEdges) {
if (predecessorsAndTheirEdge.getKey().equals(lastNode.getScriptstmt())) { if (predecessorsAndTheirEdge.getKey().equals(lastNode.getScriptStmt())) {
stateGraph.putEdgeValue(lastNode, newStateNode, predecessorsAndTheirEdge.getValue()); stateGraph.putEdgeValue(lastNode, newStateNode, predecessorsAndTheirEdge.getValue());
} }
} }
Collection<Pair<ControlFlowNode, EdgeTypes>> predecessorsAsTarget = cfgVisitor.getPredecessorsAsTarget(node); Collection<Pair<ControlFlowNode, EdgeTypes>> predecessorsAsTarget = cfgVisitor.getPredecessorsAsTarget(node);
for (Pair<ControlFlowNode, EdgeTypes> predecessorAsTarget : predecessorsAsTarget) { for (Pair<ControlFlowNode, EdgeTypes> predecessorAsTarget : predecessorsAsTarget) {
if (predecessorAsTarget.getKey().equals(lastNode.getScriptstmt())) { if (predecessorAsTarget.getKey().equals(lastNode.getScriptStmt())) {
stateGraph.putEdgeValue(newStateNode, lastNode, predecessorAsTarget.getValue()); stateGraph.putEdgeValue(newStateNode, lastNode, predecessorAsTarget.getValue());
} }
...@@ -322,8 +322,8 @@ public class StateGraphWrapper<T> { ...@@ -322,8 +322,8 @@ public class StateGraphWrapper<T> {
//copy Current Interpreter state //copy Current Interpreter state
State<T> currentState = currentInterpreter.getCurrentState().copy(); State<T> currentState = currentInterpreter.getCurrentState().copy();
//set the state //set the state
if (node != this.root.get().getScriptstmt()) { if (node != this.root.get().getScriptStmt()) {
newStateNode.setState(currentState); // newStateNode.setState(currentState);
newStateNode.getExtendedState().setStateAfterStmt(currentState); newStateNode.getExtendedState().setStateAfterStmt(currentState);
if (newStateNode.getContext().peek().equals(node)) { if (newStateNode.getContext().peek().equals(node)) {
newStateNode.getContext().pop(); newStateNode.getContext().pop();
...@@ -394,7 +394,9 @@ public class StateGraphWrapper<T> { ...@@ -394,7 +394,9 @@ public class StateGraphWrapper<T> {
public PTreeNode<T> getNode(List<GoalNode<T>> newValue) { public PTreeNode<T> getNode(List<GoalNode<T>> newValue) {
for (Map.Entry<ASTNode, PTreeNode<T>> next : addedNodes.entrySet()) { for (Map.Entry<ASTNode, PTreeNode<T>> next : addedNodes.entrySet()) {
PTreeNode value = next.getValue(); PTreeNode value = next.getValue();
if (value.getState().getGoals().equals(newValue)) {
//if (value.getState().getGoals().equals(newValue)) {
if (value.getExtendedState().getStateBeforeStmt().getGoals().equals(newValue)) {
return value; return value;
} }
} }
...@@ -422,9 +424,9 @@ public class StateGraphWrapper<T> { ...@@ -422,9 +424,9 @@ public class StateGraphWrapper<T> {
stateGraph.nodes().forEach(n -> { stateGraph.nodes().forEach(n -> {
sb.append(n.hashCode()) sb.append(n.hashCode())
.append(" [label=\"") .append(" [label=\"")
.append(n.getScriptstmt().getNodeName()) .append(n.getScriptStmt().getNodeName())
.append("@") .append("@")
.append(n.getScriptstmt().getStartPosition().getLineNumber()) .append(n.getScriptStmt().getStartPosition().getLineNumber())
.append(n.extendedStateToString()) .append(n.extendedStateToString())
.append("\"]\n"); .append("\"]\n");
}); });
...@@ -463,7 +465,7 @@ public class StateGraphWrapper<T> { ...@@ -463,7 +465,7 @@ public class StateGraphWrapper<T> {
if (root.get() == null) { if (root.get() == null) {
createRootNode(proofScript); createRootNode(proofScript);
} else { } else {
if (!root.get().getScriptstmt().equals(proofScript)) { if (!root.get().getScriptStmt().equals(proofScript)) {
createNewNode(proofScript); createNewNode(proofScript);
} }
} }
......
...@@ -123,7 +123,7 @@ public class ProofTreeController { ...@@ -123,7 +123,7 @@ public class ProofTreeController {
@Override @Override
public void graphChanged(NodeAddedEvent nodeAddedEvent) { public void graphChanged(NodeAddedEvent nodeAddedEvent) {
PTreeNode added = nodeAddedEvent.getAddedNode(); PTreeNode added = nodeAddedEvent.getAddedNode();
if (added.getState() != null) { if (added.getExtendedState() != null) {
LOGGER.info("Graph changed with the following PTreeNode: {} and the statepointer points to {}", nodeAddedEvent.getAddedNode(), statePointer); LOGGER.info("Graph changed with the following PTreeNode: {} and the statepointer points to {}", nodeAddedEvent.getAddedNode(), statePointer);
nextComputedNode.setValue(nodeAddedEvent.getAddedNode()); nextComputedNode.setValue(nodeAddedEvent.getAddedNode());
// Events.fire(new Events.NewNodeExecuted(nodeAddedEvent.getAddedNode().getScriptstmt())); // Events.fire(new Events.NewNodeExecuted(nodeAddedEvent.getAddedNode().getScriptstmt()));
...@@ -172,11 +172,11 @@ public class ProofTreeController { ...@@ -172,11 +172,11 @@ public class ProofTreeController {
nextComputedNode.addListener((observable, oldValue, newValue) -> { nextComputedNode.addListener((observable, oldValue, newValue) -> {
//update statepointer //update statepointer
if (newValue != null) { if (newValue != null) {
LOGGER.info("New node {} was computed and the statepointer was set to {}", newValue.getScriptstmt(), newValue); LOGGER.info("New node {} was computed and the statepointer was set to {}", newValue.getScriptStmt(), newValue);
this.statePointer = newValue; this.statePointer = newValue;
//setNewState(blocker.currentStateProperty().get()); //setNewState(blocker.currentStateProperty().get());
setNewState(newValue.getState()); setNewState(newValue.getExtendedState().getStateAfterStmt());
} }
}); });
...@@ -212,8 +212,8 @@ public class ProofTreeController { ...@@ -212,8 +212,8 @@ public class ProofTreeController {
LOGGER.debug("New State from this command: {}@{}", LOGGER.debug("New State from this command: {}@{}",
this.statePointer.getScriptstmt().getNodeName(), this.statePointer.getScriptStmt().getNodeName(),
this.statePointer.getScriptstmt().getStartPosition()); this.statePointer.getScriptStmt().getStartPosition());
} else { } else {
throw new RuntimeException("The state pointer was null when setting new state"); throw new RuntimeException("The state pointer was null when setting new state");
} }
...@@ -254,7 +254,7 @@ public class ProofTreeController { ...@@ -254,7 +254,7 @@ public class ProofTreeController {
//if nextnode is null ask interpreter to execute next statement and compute next state //if nextnode is null ask interpreter to execute next statement and compute next state
if (nextNode != null) { if (nextNode != null) {
setCurrentHighlightNode(nextNode.getScriptstmt()); setCurrentHighlightNode(nextNode.getScriptStmt());
} }
if (nextNode != null && nextNode.getExtendedState().getStateAfterStmt() != null) { if (nextNode != null && nextNode.getExtendedState().getStateAfterStmt() != null) {
...@@ -291,7 +291,7 @@ public class ProofTreeController { ...@@ -291,7 +291,7 @@ public class ProofTreeController {
this.statePointer = stateGraphWrapper.getStepBack(current); this.statePointer = stateGraphWrapper.getStepBack(current);
if (this.statePointer != null) { if (this.statePointer != null) {
setNewState(statePointer.getExtendedState().getStateBeforeStmt()); setNewState(statePointer.getExtendedState().getStateBeforeStmt());
setCurrentHighlightNode(statePointer.getScriptstmt()); setCurrentHighlightNode(statePointer.getScriptStmt());
} else { } else {
this.statePointer = current; this.statePointer = current;
} }
......
...@@ -119,7 +119,7 @@ public class SequentView extends CodeArea { ...@@ -119,7 +119,7 @@ public class SequentView extends CodeArea {
NamespaceSet nss = services.getNamespaces(); NamespaceSet nss = services.getNamespaces();
Sequent sequent = node.get().sequent(); Sequent sequent = node.get().sequent();
filter = new IdentitySequentPrintFilter(); filter = new IdentitySequentPrintFilter(sequent);
ProgramPrinter prgPrinter = new ProgramPrinter(new StringWriter()); ProgramPrinter prgPrinter = new ProgramPrinter(new StringWriter());
this.backend = new LogicPrinter.PosTableStringBackend(80); this.backend = new LogicPrinter.PosTableStringBackend(80);
......
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