|
@@ -6,7 +6,10 @@ import java.util.Stack;
|
|
import javax.swing.JTree;
|
|
import javax.swing.JTree;
|
|
|
|
|
|
import animation.AlgorithmStage;
|
|
import animation.AlgorithmStage;
|
|
-import animation.BackwardAction;
|
|
+import animation.AnimatedAlgorithm;
|
|
|
|
+import animation.CodeLine;
|
|
|
|
+import animation.ControlFlow;
|
|
|
|
+import animation.Memory;
|
|
import animation.PseudoCodeNode;
|
|
import animation.PseudoCodeNode;
|
|
import animation.PseudoCodeNode.CodeAction;
|
|
import animation.PseudoCodeNode.CodeAction;
|
|
import graph.LayeredGraphEdge;
|
|
import graph.LayeredGraphEdge;
|
|
@@ -22,396 +25,52 @@ import lib.TextLayoutHelper;
|
|
public class ConflictDetection implements AlgorithmStage {
|
|
public class ConflictDetection implements AlgorithmStage {
|
|
|
|
|
|
private LayeredGraphNode graph;
|
|
private LayeredGraphNode graph;
|
|
- private Stack<BackwardAction> actions;
|
|
+ private AnimatedAlgorithm alg;
|
|
|
|
|
|
- private int i;
|
|
+ public ConflictDetection(LayeredGraphNode graph, AnimatedAlgorithm alg) {
|
|
- private int l1;
|
|
|
|
- private int k0;
|
|
|
|
- private int k1;
|
|
|
|
- private int l;
|
|
|
|
- private int k;
|
|
|
|
- private int hidden_k;
|
|
|
|
-
|
|
|
|
- * line number in Carstens' pseudocode listing 3.1
|
|
|
|
- */
|
|
|
|
- private int pseudo_line;
|
|
|
|
- private PseudoCodeNode lines[];
|
|
|
|
- private boolean breakPoint;
|
|
|
|
- private boolean skip;
|
|
|
|
- private ArrayList< PseudoCodeNode > subgraphNodes;
|
|
|
|
- private ArrayList< ConflictDetection > subgraphAlgs;
|
|
|
|
- private int vIndex;
|
|
|
|
- private boolean insideSubgraph;
|
|
|
|
-
|
|
|
|
- public ConflictDetection(LayeredGraphNode graph) {
|
|
|
|
this.graph = graph;
|
|
this.graph = graph;
|
|
- actions = new Stack<>();
|
|
+ this.alg = alg;
|
|
- i = 0;
|
|
|
|
- l1 = -1;
|
|
|
|
- k0 = 0;
|
|
|
|
- k1 = 0;
|
|
|
|
- l = 0;
|
|
|
|
- k = 0;
|
|
|
|
- hidden_k = 0;
|
|
|
|
- pseudo_line = 1;
|
|
|
|
- breakPoint = false;
|
|
|
|
- skip = false;
|
|
|
|
- subgraphAlgs = new ArrayList<>();
|
|
|
|
- subgraphNodes = new ArrayList<>();
|
|
|
|
- vIndex = 0;
|
|
|
|
- insideSubgraph = false;
|
|
|
|
- for( @SuppressWarnings("unused") LayeredGraphNode n : graph.getContainedNodes() )
|
|
|
|
- {
|
|
|
|
- subgraphAlgs.add( null );
|
|
|
|
- subgraphNodes.add( null );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public StageStatus forwardStep() {
|
|
|
|
- int old_line = pseudo_line;
|
|
|
|
- int old_k = k;
|
|
|
|
- int old_k0 = k0;
|
|
|
|
- int old_k1 = k1;
|
|
|
|
- int old_l = l;
|
|
|
|
- int old_l1 = l1;
|
|
|
|
- int old_hidden_k = hidden_k;
|
|
|
|
-
|
|
|
|
- switch (pseudo_line) {
|
|
|
|
- case 1:
|
|
|
|
- i++;
|
|
|
|
- actions.push(() -> {
|
|
|
|
- i--;
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- if (i <= graph.getContainedLayers().size() - 2) {
|
|
|
|
- pseudo_line++;
|
|
|
|
- } else {
|
|
|
|
- pseudo_line = 16;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- k0 = 0;
|
|
|
|
- l = 0;
|
|
|
|
- l1 = -1;
|
|
|
|
- pseudo_line++;
|
|
|
|
- actions.push(() -> {
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- k0 = old_k0;
|
|
|
|
- l = old_l;
|
|
|
|
- l1 = old_l1;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- break;
|
|
|
|
- case 3:
|
|
|
|
- l1++;
|
|
|
|
- actions.push(() -> {
|
|
|
|
- l1--;
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- if (l1 < graph.getContainedLayers().get(i + 1).size()) {
|
|
|
|
- pseudo_line += 1;
|
|
|
|
- } else {
|
|
|
|
- pseudo_line = 1;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 4:
|
|
|
|
- actions.push(() -> {
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- if (graph.getContainedLayers().get(i + 1).size() == l1 || incidentToInnerSegmentBetweenLiPlusOneAndLi()) {
|
|
|
|
- pseudo_line++;
|
|
|
|
- } else {
|
|
|
|
- pseudo_line = 3;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 5:
|
|
|
|
- actions.push(() -> {
|
|
|
|
- k1 = old_k1;
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- k1 = graph.getContainedLayers().get(i).size() - 1;
|
|
|
|
- pseudo_line++;
|
|
|
|
- break;
|
|
|
|
- case 6:
|
|
|
|
- actions.push(() -> {
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- if (incidentToInnerSegmentBetweenLiPlusOneAndLi()) {
|
|
|
|
- pseudo_line++;
|
|
|
|
- } else {
|
|
|
|
- pseudo_line = 9;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 7:
|
|
|
|
- actions.push(() -> {
|
|
|
|
- k1 = old_k1;
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- k1 = graph.getContainedLayers().get(i).indexOf(
|
|
|
|
- graph.getContainedLayers().get(i + 1).get(l1).getSortedIncomingEdges().get(0).getSources().get(0));
|
|
|
|
- pseudo_line = 9;
|
|
|
|
- break;
|
|
|
|
- case 9:
|
|
|
|
- actions.push(() -> {
|
|
|
|
- hidden_k = old_hidden_k;
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- if (l <= l1) {
|
|
|
|
- pseudo_line++;
|
|
|
|
- hidden_k = 0;
|
|
|
|
- k = graph.getContainedLayers().get(i).indexOf(graph.getContainedLayers().get(i + 1).get(l)
|
|
|
|
- .getSortedIncomingEdges().get(hidden_k).getSources().get(0));
|
|
|
|
- } else {
|
|
|
|
- pseudo_line = 15;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 10:
|
|
|
|
- actions.push(() -> {
|
|
|
|
- k = old_k;
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- if (hidden_k < graph.getContainedLayers().get(i + 1).get(l).getSortedIncomingEdges().size()) {
|
|
|
|
- k = graph.getContainedLayers().get(i).indexOf(graph.getContainedLayers().get(i + 1).get(l)
|
|
|
|
- .getSortedIncomingEdges().get(hidden_k).getSources().get(0));
|
|
|
|
- pseudo_line++;
|
|
|
|
- } else {
|
|
|
|
- pseudo_line = 13;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 11:
|
|
|
|
- actions.push(() -> {
|
|
|
|
- hidden_k--;
|
|
|
|
- graph.getContainedLayers().get(i + 1).get(l).getSortedIncomingEdges().get(hidden_k).setConflicted(false,
|
|
|
|
- null);
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- if (k < k0 || k > k1) {
|
|
|
|
- graph.getContainedLayers().get(i + 1).get(l).getSortedIncomingEdges().get(hidden_k).setConflicted(true,
|
|
|
|
- null);
|
|
|
|
- }
|
|
|
|
- hidden_k++;
|
|
|
|
- pseudo_line = 10;
|
|
|
|
- break;
|
|
|
|
- case 13:
|
|
|
|
- actions.push(() -> {
|
|
|
|
- l--;
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- l++;
|
|
|
|
- pseudo_line = 9;
|
|
|
|
- break;
|
|
|
|
- case 15:
|
|
|
|
- actions.push(() -> {
|
|
|
|
- k0 = old_k0;
|
|
|
|
- pseudo_line = old_line;
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- });
|
|
|
|
- k0 = k1;
|
|
|
|
- pseudo_line = 3;
|
|
|
|
- break;
|
|
|
|
- case 16:
|
|
|
|
- if( vIndex < graph.getContainedNodes().size() )
|
|
|
|
- {
|
|
|
|
- while( vIndex < graph.getContainedNodes().size() && graph.getContainedNodes().get( vIndex ).getContainedNodes().size() == 0 )
|
|
|
|
- vIndex++;
|
|
|
|
- if( vIndex < graph.getContainedNodes().size() )
|
|
|
|
- {
|
|
|
|
- LayeredGraphNode current = graph.getContainedNodes().get( vIndex );
|
|
|
|
- current.setSelected( null );
|
|
|
|
- if( current.getContainedNodes().size() > 0 )
|
|
|
|
- {
|
|
|
|
- insideSubgraph = true;
|
|
|
|
- breakPoint = false;
|
|
|
|
- boolean sel = subgraphNodes.get( vIndex ).isSelected();
|
|
|
|
- CodeAction ac = subgraphNodes.get( vIndex ).setSelected( true );
|
|
|
|
- if( !sel )
|
|
|
|
- breakPoint |= ac == CodeAction.STOP;
|
|
|
|
- do {
|
|
|
|
- switch( subgraphAlgs.get( vIndex ).forwardStep() )
|
|
|
|
- {
|
|
|
|
- case BREAKPOINT:
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- case UNFINISHED:
|
|
|
|
- break;
|
|
|
|
- case FINISHED:
|
|
|
|
- insideSubgraph = false;
|
|
|
|
- subgraphNodes.get( vIndex ).setSelected( false );
|
|
|
|
- vIndex++;
|
|
|
|
- ac = null;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- } while( ac == CodeAction.SKIP && !breakPoint );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if( vIndex >= graph.getContainedNodes().size() )
|
|
|
|
- {
|
|
|
|
- for( PseudoCodeNode p : lines )
|
|
|
|
- {
|
|
|
|
- if( p != null )
|
|
|
|
- p.setSelected( false );
|
|
|
|
- }
|
|
|
|
- return StageStatus.FINISHED;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- selectNodes(pseudo_line);
|
|
|
|
- if( breakPoint )
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- if( skip )
|
|
|
|
- return forwardStep();
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void selectNodes(int next_line) {
|
|
|
|
- if( pseudo_line < 16 )
|
|
|
|
- {
|
|
|
|
- if (next_line >= 3 && l < graph.getContainedLayers().get(i + 1).size()) {
|
|
|
|
- graph.getContainedLayers().get(i + 1).get(l).setSelected(null);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (next_line >= 4) {
|
|
|
|
- graph.getContainedLayers().get(i + 1).get(l1).setSelected(null);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (next_line >= 3) {
|
|
|
|
- graph.getContainedLayers().get(i).get(k0).setSelected(null);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (next_line >= 6) {
|
|
|
|
- graph.getContainedLayers().get(i).get(k1).setSelected(null);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (next_line == 10 || next_line == 11) {
|
|
|
|
- graph.getContainedLayers().get(i).get(k).setSelected(null);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- breakPoint = false;
|
|
|
|
- skip = false;
|
|
|
|
- for( PseudoCodeNode p : lines )
|
|
|
|
- {
|
|
|
|
- if( p != null )
|
|
|
|
- p.setSelected( false );
|
|
|
|
- }
|
|
|
|
- markCode( lines[ next_line - 1 ] );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private int getCodeDepth( PseudoCodeNode n )
|
|
|
|
- {
|
|
|
|
- if( n == lines[ 0 ].getParent() )
|
|
|
|
- return 0;
|
|
|
|
- return 1 + getCodeDepth( (PseudoCodeNode)n.getParent() );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void markCode( PseudoCodeNode n )
|
|
|
|
- {
|
|
|
|
- if( n == lines[ 0 ].getRoot() )
|
|
|
|
- return;
|
|
|
|
- if( !n.hasSelectedSubnode() )
|
|
|
|
- {
|
|
|
|
- CodeAction action = n.setSelected( true );
|
|
|
|
- breakPoint |= action == CodeAction.STOP;
|
|
|
|
- skip |= action == CodeAction.SKIP;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- CodeAction action = n.setSelected( true );
|
|
|
|
- skip |= action == CodeAction.SKIP;
|
|
|
|
- }
|
|
|
|
- if( n == lines[ 0 ] )
|
|
|
|
- return;
|
|
|
|
- markCode( (PseudoCodeNode)n.getParent() );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public StageStatus backwardStep() {
|
|
|
|
- if( pseudo_line == 16 )
|
|
|
|
- {
|
|
|
|
- while( vIndex >= graph.getContainedNodes().size() || ( vIndex >= 0 && graph.getContainedNodes().get( vIndex ).getContainedNodes().size() == 0 ) )
|
|
|
|
- vIndex--;
|
|
|
|
- if( vIndex >= 0 )
|
|
|
|
- {
|
|
|
|
- LayeredGraphNode current = graph.getContainedNodes().get( vIndex );
|
|
|
|
- current.setSelected( null );
|
|
|
|
- if( subgraphAlgs.get( vIndex ) != null )
|
|
|
|
- {
|
|
|
|
- insideSubgraph = true;
|
|
|
|
- breakPoint = false;
|
|
|
|
- boolean selected = subgraphNodes.get( vIndex ).isSelected();
|
|
|
|
- CodeAction action = subgraphNodes.get( vIndex ).setSelected( true );
|
|
|
|
- if( !selected )
|
|
|
|
- breakPoint |= action == CodeAction.STOP;
|
|
|
|
- do {
|
|
|
|
- switch( subgraphAlgs.get( vIndex ).backwardStep() )
|
|
|
|
- {
|
|
|
|
- case BREAKPOINT:
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- case UNFINISHED:
|
|
|
|
- break;
|
|
|
|
- case FINISHED:
|
|
|
|
- insideSubgraph = false;
|
|
|
|
- subgraphNodes.get( vIndex ).setSelected( false );
|
|
|
|
- vIndex--;
|
|
|
|
- action = null;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- } while( !breakPoint && action == CodeAction.SKIP );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if( vIndex < 0 )
|
|
|
|
- {
|
|
|
|
- vIndex = 0;
|
|
|
|
- if (actions.size() == 0) {
|
|
|
|
- for( PseudoCodeNode p : lines )
|
|
|
|
- {
|
|
|
|
- if( p != null )
|
|
|
|
- p.setSelected( false );
|
|
|
|
- }
|
|
|
|
- return StageStatus.FINISHED;
|
|
|
|
- }
|
|
|
|
- actions.pop().reverse();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if (actions.size() == 0) {
|
|
|
|
- for( PseudoCodeNode p : lines )
|
|
|
|
- {
|
|
|
|
- if( p != null )
|
|
|
|
- p.setSelected( false );
|
|
|
|
- }
|
|
|
|
- return StageStatus.FINISHED;
|
|
|
|
- }
|
|
|
|
- actions.pop().reverse();
|
|
|
|
- }
|
|
|
|
- if( breakPoint )
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- if( skip )
|
|
|
|
- return forwardStep();
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public PseudoCodeNode createPseudocodeTree(JTree tree) {
|
|
public PseudoCodeNode createPseudocodeTree(JTree tree) {
|
|
- PseudoCodeNode root = new PseudoCodeNode(TextLayoutHelper.setupPseudoCodeStage("Preprocessing (mark type 1 conflicts)"), tree);
|
|
+ String vars[] = { "i", "L", "k0", "l", "l1", "k1", "k", "v", "graph" };
|
|
- lines = new PseudoCodeNode[16];
|
|
+ PseudoCodeNode root = new PseudoCodeNode(TextLayoutHelper.setupPseudoCode("mark_conflicts( graph )", vars), tree, new CodeLine() {
|
|
- String vars[] = { "i", "L", "k0", "l", "l1", "k1", "k", "v" };
|
|
+
|
|
- lines[ 0 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "for i=1 to |L|-2 do", vars ), tree );
|
|
+ @Override
|
|
|
|
+ public ControlFlow runForward(Memory m) {
|
|
|
|
+ if( !m.isDefined( "param1", true ) )
|
|
|
|
+ return new ControlFlow( ControlFlow.STEP_OVER );
|
|
|
|
+
|
|
|
|
+ LayeredGraphNode param = m.<LayeredGraphNode>read( "param1", true );
|
|
|
|
+ m.undeclare( "param1", true );
|
|
|
|
+ m.declare( "graph", param, false );
|
|
|
|
+ m.declare( "Layers", param.getContainedLayers(), false );
|
|
|
|
+ return new ControlFlow( ControlFlow.STEP_INTO );
|
|
|
|
+ }
|
|
|
|
+ }, alg );
|
|
|
|
+ PseudoCodeNode[] lines = new PseudoCodeNode[16];
|
|
|
|
+ lines[ 0 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "for i=1 to |L|-2 do", vars ), tree, new CodeLine() {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ControlFlow runForward(Memory m) {
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }, alg );
|
|
root.add( lines[ 0 ] );
|
|
root.add( lines[ 0 ] );
|
|
- lines[ 1 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "k0 = 0; l = 0;", vars ), tree );
|
|
+ lines[ 1 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "k0 = 0; l = 0;", vars ), tree, new CodeLine() {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ControlFlow runForward(Memory m) {
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }, alg);
|
|
lines[ 0 ].add( lines[ 1 ] );
|
|
lines[ 0 ].add( lines[ 1 ] );
|
|
|
|
+
|
|
lines[ 2 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "for l1=0 to |L[i+1]|-1 do", vars ), tree );
|
|
lines[ 2 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "for l1=0 to |L[i+1]|-1 do", vars ), tree );
|
|
lines[ 0 ].add( lines[ 2 ] );
|
|
lines[ 0 ].add( lines[ 2 ] );
|
|
lines[ 3 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "if l1==|L[i+1]|-1 or L[i+1][l1] incident to inner segment between L[i+1] and L[i] then", vars ), tree );
|
|
lines[ 3 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "if l1==|L[i+1]|-1 or L[i+1][l1] incident to inner segment between L[i+1] and L[i] then", vars ), tree );
|
|
@@ -433,212 +92,12 @@ public class ConflictDetection implements AlgorithmStage {
|
|
lines[ 14 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "k0 = k1;", vars ), tree );
|
|
lines[ 14 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "k0 = k1;", vars ), tree );
|
|
lines[ 3 ].add( lines[ 14 ] );
|
|
lines[ 3 ].add( lines[ 14 ] );
|
|
lines[ 15 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCodeStage( "mark conflicts in subgraphs" ), tree );
|
|
lines[ 15 ] = new PseudoCodeNode( TextLayoutHelper.setupPseudoCodeStage( "mark conflicts in subgraphs" ), tree );
|
|
- root.add( lines[ 15 ] );
|
|
+ root.add( lines[ 15 ] );*/
|
|
- for( int i = 0; i < graph.getContainedNodes().size(); i++ )
|
|
|
|
- {
|
|
|
|
- LayeredGraphNode current = graph.getContainedNodes().get( i );
|
|
|
|
- if( current.getContainedNodes().size() > 0 )
|
|
|
|
- {
|
|
|
|
- ConflictDetection extcalc = new ConflictDetection( current );
|
|
|
|
- PseudoCodeNode subNode = extcalc.createPseudocodeTree( tree );
|
|
|
|
- lines[ 15 ].add( subNode );
|
|
|
|
- subgraphAlgs.set( i, extcalc );
|
|
|
|
- subgraphNodes.set( i, subNode );
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
return root;
|
|
return root;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public StageStatus forwardStepOver() {
|
|
+ public String getDebugString() {
|
|
- if( !insideSubgraph )
|
|
|
|
- {
|
|
|
|
- int depth = getCodeDepth( lines[ pseudo_line - 1 ] );
|
|
|
|
- do
|
|
|
|
- {
|
|
|
|
- switch( forwardStep() )
|
|
|
|
- {
|
|
|
|
- case BREAKPOINT:
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- case FINISHED:
|
|
|
|
- return StageStatus.FINISHED;
|
|
|
|
- case UNFINISHED:
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- } while( depth < getCodeDepth( lines[ pseudo_line - 1 ] ) );
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- boolean breakpoint = false;
|
|
|
|
- boolean selected = subgraphNodes.get( vIndex ).isSelected();
|
|
|
|
- CodeAction action = subgraphNodes.get( vIndex ).setSelected( true );
|
|
|
|
- if( !selected )
|
|
|
|
- breakpoint |= action == CodeAction.STOP;
|
|
|
|
- do {
|
|
|
|
- switch( subgraphAlgs.get( vIndex ).forwardStepOver() )
|
|
|
|
- {
|
|
|
|
- case BREAKPOINT:
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- case UNFINISHED:
|
|
|
|
- if( breakpoint )
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- case FINISHED:
|
|
|
|
- insideSubgraph = false;
|
|
|
|
- subgraphNodes.get( vIndex ).setSelected( false );
|
|
|
|
- action = null;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- } while( !breakpoint && action == CodeAction.SKIP );
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public StageStatus forwardStepOut() {
|
|
|
|
- if( !insideSubgraph )
|
|
|
|
- {
|
|
|
|
- int depth = getCodeDepth( lines[ pseudo_line - 1 ] );
|
|
|
|
- do
|
|
|
|
- {
|
|
|
|
- switch( forwardStep() )
|
|
|
|
- {
|
|
|
|
- case BREAKPOINT:
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- case FINISHED:
|
|
|
|
- return StageStatus.FINISHED;
|
|
|
|
- case UNFINISHED:
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- } while( depth <= getCodeDepth( lines[ pseudo_line - 1 ] ) );
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- boolean breakpoint = false;
|
|
|
|
- boolean selected = subgraphNodes.get( vIndex ).isSelected();
|
|
|
|
- CodeAction action = subgraphNodes.get( vIndex ).setSelected( true );
|
|
|
|
- if( !selected )
|
|
|
|
- breakpoint |= action == CodeAction.STOP;
|
|
|
|
- do {
|
|
|
|
- switch( subgraphAlgs.get( vIndex ).forwardStepOut() )
|
|
|
|
- {
|
|
|
|
- case BREAKPOINT:
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- case UNFINISHED:
|
|
|
|
- if( breakpoint )
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- case FINISHED:
|
|
|
|
- insideSubgraph = false;
|
|
|
|
- subgraphNodes.get( vIndex ).setSelected( false );
|
|
|
|
- action = null;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- } while( !breakpoint && action == CodeAction.SKIP );
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public StageStatus backwardStepOver() {
|
|
|
|
- if( !insideSubgraph )
|
|
|
|
- {
|
|
|
|
- int depth = getCodeDepth( lines[ pseudo_line - 1 ] );
|
|
|
|
- do
|
|
|
|
- {
|
|
|
|
- switch( backwardStep() )
|
|
|
|
- {
|
|
|
|
- case BREAKPOINT:
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- case FINISHED:
|
|
|
|
- return StageStatus.FINISHED;
|
|
|
|
- case UNFINISHED:
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- } while( depth < getCodeDepth( lines[ pseudo_line - 1 ] ) );
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- boolean breakpoint = false;
|
|
|
|
- boolean selected = subgraphNodes.get( vIndex ).isSelected();
|
|
|
|
- CodeAction action = subgraphNodes.get( vIndex ).setSelected( true );
|
|
|
|
- if( !selected )
|
|
|
|
- breakpoint |= action == CodeAction.STOP;
|
|
|
|
- do {
|
|
|
|
- switch( subgraphAlgs.get( vIndex ).backwardStepOver() )
|
|
|
|
- {
|
|
|
|
- case BREAKPOINT:
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- case UNFINISHED:
|
|
|
|
- LayeredGraphNode current = graph.getContainedNodes().get( vIndex );
|
|
|
|
- current.setSelected( null );
|
|
|
|
- if( breakpoint )
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- case FINISHED:
|
|
|
|
- insideSubgraph = false;
|
|
|
|
- subgraphNodes.get( vIndex ).setSelected( false );
|
|
|
|
- action = null;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- } while( !breakpoint && action == CodeAction.SKIP );
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public StageStatus backwardStepOut() {
|
|
|
|
- if( !insideSubgraph )
|
|
|
|
- {
|
|
|
|
- int depth = getCodeDepth( lines[ pseudo_line - 1 ] );
|
|
|
|
- do
|
|
|
|
- {
|
|
|
|
- switch( backwardStep() )
|
|
|
|
- {
|
|
|
|
- case BREAKPOINT:
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- case FINISHED:
|
|
|
|
- return StageStatus.FINISHED;
|
|
|
|
- case UNFINISHED:
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- } while( depth <= getCodeDepth( lines[ pseudo_line - 1 ] ) );
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- boolean breakpoint = false;
|
|
|
|
- boolean selected = subgraphNodes.get( vIndex ).isSelected();
|
|
|
|
- CodeAction action = subgraphNodes.get( vIndex ).setSelected( true );
|
|
|
|
- if( !selected )
|
|
|
|
- breakpoint |= action == CodeAction.STOP;
|
|
|
|
- do {
|
|
|
|
- switch( subgraphAlgs.get( vIndex ).backwardStepOut() )
|
|
|
|
- {
|
|
|
|
- case BREAKPOINT:
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- case UNFINISHED:
|
|
|
|
- LayeredGraphNode current = graph.getContainedNodes().get( vIndex );
|
|
|
|
- current.setSelected( null );
|
|
|
|
- if( breakpoint )
|
|
|
|
- return StageStatus.BREAKPOINT;
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- case FINISHED:
|
|
|
|
- insideSubgraph = false;
|
|
|
|
- subgraphNodes.get( vIndex ).setSelected( false );
|
|
|
|
- action = null;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- } while( !breakpoint && action == CodeAction.SKIP );
|
|
|
|
- return StageStatus.UNFINISHED;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public String getDebugString() {
|
|
|
|
String info = "| i | l | l1 | k0 | k1 | k |\n";
|
|
String info = "| i | l | l1 | k0 | k1 | k |\n";
|
|
info += "|----|----|----|----|----|----|\n";
|
|
info += "|----|----|----|----|----|----|\n";
|
|
info += "|" + TextLayoutHelper.strToLen( "" + i, 4 ) +
|
|
info += "|" + TextLayoutHelper.strToLen( "" + i, 4 ) +
|
|
@@ -654,21 +113,8 @@ public class ConflictDetection implements AlgorithmStage {
|
|
info += tmp;
|
|
info += tmp;
|
|
return info;
|
|
return info;
|
|
}
|
|
}
|
|
- return info;
|
|
+ return info;*/
|
|
|
|
+ return "";
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- * part of line 4 and 6 in the pseudocode
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- private boolean incidentToInnerSegmentBetweenLiPlusOneAndLi() {
|
|
|
|
- LayeredGraphNode curr = graph.getContainedLayers().get(i + 1).get(l1);
|
|
|
|
- for (LayeredGraphEdge e : curr.getIncomingEdges()) {
|
|
|
|
- if (e.isDummyEdge()) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|