|
@@ -24,18 +24,22 @@ public abstract class AbstractForLoop<T> extends CodeLine {
|
|
|
|
|
|
@Override
|
|
|
public ControlFlow runForward(Memory m) {
|
|
|
- if( !m.isDefined( loopVar, Visibility.LOCAL ) )
|
|
|
+ if( !m.isSomewhereDefined( "line_" + lineId + "_index", Visibility.LOCAL ) )
|
|
|
{
|
|
|
+ m.declare( "line_" + lineId + "_index", 0, Visibility.LOCAL );
|
|
|
m.addFrame( new StackFrame( FrameType.LOOP ) );
|
|
|
m.declare( loopVar, intialize( m.createReadOnlyMemory() ), Visibility.LOCAL );
|
|
|
if( !condition( m.createReadOnlyMemory() ) )
|
|
|
{
|
|
|
m.removeFrame();
|
|
|
- actions.push( (Memory mem) -> {} );
|
|
|
+ actions.push( (Memory mem) -> {
|
|
|
+ mem.undeclare( "line_" + lineId + "_index", Visibility.LOCAL );
|
|
|
+ } );
|
|
|
return new ControlFlow( ControlFlow.STEP_OVER );
|
|
|
}
|
|
|
actions.push( (Memory mem) -> {
|
|
|
mem.removeFrame();
|
|
|
+ mem.undeclare( "line_" + lineId + "_index", Visibility.LOCAL );
|
|
|
} );
|
|
|
return new ControlFlow( ControlFlow.STEP_INTO );
|
|
|
}
|