|
@@ -141,6 +141,13 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ private void expandToRoot()
|
|
|
+ {
|
|
|
+ if( parent != null )
|
|
|
+ ((PseudoCodeNode)parent).expandToRoot();
|
|
|
+ tree.expandPath( new TreePath( this.getPath() ) );
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* highlight this line of pseudocode.
|
|
|
* should be called when the line is entered, as it triggers breakpoints
|
|
@@ -155,7 +162,7 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
|
|
|
if( selected )
|
|
|
{
|
|
|
if( controller == null || controller.getStepOption() != 1 || breakPoint )
|
|
|
- tree.expandPath( new TreePath( this.getPath() ) );
|
|
|
+ expandToRoot();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -231,18 +238,21 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
|
|
|
{
|
|
|
if( !m.isDefined( "line_" + nodeId + "_call", false ) )
|
|
|
{
|
|
|
- ControlFlow cf = code.runForward( m );
|
|
|
+ StackFrame tmp = null;
|
|
|
+ if( function )
|
|
|
+ {
|
|
|
+ tmp = m.removeFrame();
|
|
|
+ m.addFrame( tmp ); // a little abuse of the stack to get direct access of the current frame before it could be destroyed by the user defined function
|
|
|
+ }ControlFlow cf = code.runForward( m );
|
|
|
switch( cf.getStatus() )
|
|
|
{
|
|
|
case ControlFlow.STEP_INTO:
|
|
|
function = true;
|
|
|
- StackFrame tmp = m.removeFrame();
|
|
|
if( children != null )
|
|
|
{
|
|
|
for( Object c : children )
|
|
|
((PseudoCodeNode)c).writeToStack( m );
|
|
|
}
|
|
|
- m.addFrame( tmp );
|
|
|
switch( stepInto( m ) )
|
|
|
{
|
|
|
case BREAKPOINT:
|
|
@@ -264,11 +274,13 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
|
|
|
case ControlFlow.STEP_OVER:
|
|
|
if( function )
|
|
|
{
|
|
|
+ m.addFrame( tmp ); // add old stack frame
|
|
|
if( children != null )
|
|
|
{
|
|
|
for( Object c : children )
|
|
|
- ((PseudoCodeNode)c).loadFromStack( m );
|
|
|
+ ((PseudoCodeNode)c).loadFromStack( m ); // load stored variables
|
|
|
}
|
|
|
+ m.removeFrame(); // remove the stack frame
|
|
|
}
|
|
|
return CodeStatus.FINISHED;
|
|
|
case ControlFlow.CALL:
|