Эх сурвалжийг харах

removed wrong skip behavior

Kolja Strohm 6 жил өмнө
parent
commit
2de2dfcb3f

+ 30 - 2
src/animation/PseudoCodeProcessor.java

@@ -18,6 +18,7 @@ public class PseudoCodeProcessor {
     private Memory mem;
     private PseudoCodeNode programPointer;
     private Stack<ControlFlow> controlStack;
+    private boolean skip = false;
     
     public PseudoCodeProcessor( PseudoCodeNode tree )
     {
@@ -35,9 +36,10 @@ public class PseudoCodeProcessor {
         switch( next.setSelected( true ) )
         {
         case CONTINUE:
+            skip = false;
             return CodeStatus.UNFINISHED;
         case SKIP:
-            return forwardStepOver();
+            return forwardStepOverUntilNotSkip();
         case STOP:
             return CodeStatus.BREAKPOINT;
         }
@@ -113,6 +115,18 @@ public class PseudoCodeProcessor {
         throw new IllegalStateException( "Unknown ControlFlow action" );
     }
     
+    private CodeStatus forwardStepOverUntilNotSkip() {
+        skip = true;
+        if( programPointer == null )
+            return CodeStatus.FINISHED;
+        int stackSize = mem.getSize();
+        CodeStatus status = CodeStatus.UNFINISHED;
+        do {
+            status = forwardStep();
+        } while( mem.getSize() > stackSize && status == CodeStatus.UNFINISHED && skip );
+        return status;
+    }
+    
     public CodeStatus forwardStepOver()
     {
         if( programPointer == null )
@@ -144,9 +158,10 @@ public class PseudoCodeProcessor {
         switch( next.setSelected( true ) )
         {
         case CONTINUE:
+            //skip = false;
             return CodeStatus.UNFINISHED;
         case SKIP:
-            return backwardStepOver();
+            return backwardStepOverUntilNotSkip();
         case STOP:
             return CodeStatus.BREAKPOINT;
         }
@@ -165,6 +180,19 @@ public class PseudoCodeProcessor {
         return selectBeforeNode( nextPC, programPointer );
     }
     
+    public CodeStatus backwardStepOverUntilNotSkip()
+    {
+        skip = true;
+        if( programPointer == null )
+            return CodeStatus.FINISHED;
+        int stackSize = mem.getSize();
+        CodeStatus status = CodeStatus.UNFINISHED;
+        do {
+            status = backwardStep();
+        } while( mem.getSize() > stackSize && status == CodeStatus.UNFINISHED && skip );
+        return status;
+    }
+    
     public CodeStatus backwardStepOver()
     {
         if( programPointer == null )