Commit ee92cd85 authored by Lulu Luong's avatar Lulu Luong

bugfix foreachstart and closed goals

TODO: bugfix foreachend + qs infinity loop
parent b5c97400
Pipeline #26984 passed with stages
in 2 minutes and 55 seconds
...@@ -290,11 +290,12 @@ public class ScriptTreeGraph { ...@@ -290,11 +290,12 @@ public class ScriptTreeGraph {
case 0: case 0:
putIntoFront(callnode); putIntoFront(callnode);
checkIfForeachEnd(callnode); checkIfForeachEnd(callnode);
addPlaceholder(sn, sn.getNode());
break; break;
case 1: case 1:
// putIntoMapping(children.get(0).getData().getNode(), null); // putIntoMapping(children.get(0).getData().getNode(), null);
putIntoFront(children.get(0).getData().getNode()); putIntoFront(children.get(0).getData().getNode());
addPlaceholder(sn, children.get(0).getData().getNode(), false); addPlaceholder(sn, children.get(0).getData().getNode());
break; break;
default: //multiple open goals/children -> branch labels default: //multiple open goals/children -> branch labels
int branchcounter = 1; int branchcounter = 1;
...@@ -310,7 +311,7 @@ public class ScriptTreeGraph { ...@@ -310,7 +311,7 @@ public class ScriptTreeGraph {
Lists.reverse(branchlabel).forEach(k -> System.out.println(k.getNode().serialNr() + " " + k.getLabelName())); Lists.reverse(branchlabel).forEach(k -> System.out.println(k.getNode().serialNr() + " " + k.getLabelName()));
insertBranchLabels(callnode, branchlabel); insertBranchLabels(callnode, branchlabel);
addPlaceholder(branchlabel.get(0), gn.getData().getNode(), true); addPlaceholder(branchlabel.get(0), gn.getData().getNode());
} else { } else {
BranchLabelNode branchNode = new BranchLabelNode(childnode, "Case " + branchcounter); BranchLabelNode branchNode = new BranchLabelNode(childnode, "Case " + branchcounter);
...@@ -321,7 +322,7 @@ public class ScriptTreeGraph { ...@@ -321,7 +322,7 @@ public class ScriptTreeGraph {
if (mapping.get(childnode) != null) putIntoMapping(childnode, branchNode); if (mapping.get(childnode) != null) putIntoMapping(childnode, branchNode);
addPlaceholder(branchNode, childnode, true); addPlaceholder(branchNode, childnode);
branchcounter++; branchcounter++;
} }
...@@ -352,7 +353,7 @@ public class ScriptTreeGraph { ...@@ -352,7 +353,7 @@ public class ScriptTreeGraph {
replacePlaceholder(n, match); replacePlaceholder(n, match);
putIntoMapping(n, match); putIntoMapping(n, match);
addPlaceholder(match, n, false); addPlaceholder(match, n);
//front.remove(n); //front.remove(n);
return null; return null;
} }
...@@ -366,7 +367,7 @@ public class ScriptTreeGraph { ...@@ -366,7 +367,7 @@ public class ScriptTreeGraph {
Node n = nextintoptn.getStateBeforeStmt().getSelectedGoalNode().getData().getNode(); Node n = nextintoptn.getStateBeforeStmt().getSelectedGoalNode().getData().getNode();
replacePlaceholder(n, match); replacePlaceholder(n, match);
putIntoMapping(n, match); putIntoMapping(n, match);
addPlaceholder(match, n, false); addPlaceholder(match, n);
//front.remove(n); //front.remove(n);
return null; return null;
} }
...@@ -376,10 +377,20 @@ public class ScriptTreeGraph { ...@@ -376,10 +377,20 @@ public class ScriptTreeGraph {
List<GoalNode<KeyData>> goals = nextPtreeNode.getStateBeforeStmt().getGoals(); List<GoalNode<KeyData>> goals = nextPtreeNode.getStateBeforeStmt().getGoals();
if (goals.size() == 0) return null; if (goals.size() == 0) return null;
//TODO: sometime goals on different branches goals.forEach(k -> {
goals.forEach(k -> putIntoMapping(searchParentInMapping(k.getData().getNode()), new ForeachTreeNode(k.getData().getNode(), nextPtreeNode, nextPtreeNode.getStatement().getStartPosition().getLineNumber(),true))); ForeachTreeNode ftn = new ForeachTreeNode(
k.getData().getNode(),
nextPtreeNode,
nextPtreeNode.getStatement().getStartPosition().getLineNumber(),
true);
// add to foreachNodes lsit replacePlaceholder(
searchParentInMapping(k.getData().getNode()), ftn);
addPlaceholder(ftn, k.getData().getNode());
});
// add to foreachNodes list -> so the end of a foreach can be catched
List<GoalNode<KeyData>> aftergoals = (nextPtreeNode.getStateAfterStmt() != null)? nextPtreeNode.getStateAfterStmt().getGoals() List<GoalNode<KeyData>> aftergoals = (nextPtreeNode.getStateAfterStmt() != null)? nextPtreeNode.getStateAfterStmt().getGoals()
: (nextPtreeNode.getStepOver() != null && nextPtreeNode.getStepOver().getStateBeforeStmt() != null) ? nextPtreeNode.getStepOver().getStateBeforeStmt().getGoals() : (nextPtreeNode.getStepOver() != null && nextPtreeNode.getStepOver().getStateBeforeStmt() != null) ? nextPtreeNode.getStepOver().getStateBeforeStmt().getGoals()
: new ArrayList<>(); : new ArrayList<>();
...@@ -390,7 +401,7 @@ public class ScriptTreeGraph { ...@@ -390,7 +401,7 @@ public class ScriptTreeGraph {
} }
} }
private void addPlaceholder(AbstractTreeNode parent, Node current, boolean isSplit) { private void addPlaceholder(AbstractTreeNode parent, Node current) {
PlaceholderNode phn = new PlaceholderNode(current); PlaceholderNode phn = new PlaceholderNode(current);
phn.setParent(parent); phn.setParent(parent);
...@@ -476,12 +487,14 @@ public class ScriptTreeGraph { ...@@ -476,12 +487,14 @@ public class ScriptTreeGraph {
private void checkIfForeachEnd(Node n) { private void checkIfForeachEnd(Node n) {
if(foreachNodes.containsKey(n)) { if(foreachNodes.containsKey(n)) {
PTreeNode ptn = foreachNodes.get(n); PTreeNode ptn = foreachNodes.get(n);
ForeachTreeNode ftn = new ForeachTreeNode(n, ptn, ptn.getStatement().getStartPosition().getLineNumber(), false); ForeachTreeNode ftn = new ForeachTreeNode(
addToSubChildren(nextPtreeNode.getStateBeforeStmt().getSelectedGoalNode().getData().getNode(), ftn); n,
ptn,
if(mapping.get(n) == null) { ptn.getStatement().getStartPosition().getLineNumber(),
putIntoMapping(n,ftn); false);
}
replacePlaceholder(nextPtreeNode.getStateBeforeStmt().getSelectedGoalNode().getData().getNode(), ftn);
addPlaceholder(ftn, n);
foreachNodes.remove(n); foreachNodes.remove(n);
......
...@@ -2,16 +2,12 @@ script full0(){ ...@@ -2,16 +2,12 @@ script full0(){
impRight; impRight;
impRight; impRight;
impLeft; impLeft;
cases { foreach{
case match `!q ==> p`: notLeft;
notLeft; }
foreach{
auto;
}
case match `q==>!p`:
notLeft;
}
} }
script full(){ script full(){
......
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