mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-27 08:38:03 +00:00
add for
This commit is contained in:
parent
de4082eff3
commit
cc68035406
@ -5,6 +5,8 @@ import de.maishai.typedast.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import static de.maishai.typedast.Help.TypedExpressionHelp.convertExpression;
|
||||
|
||||
@ -42,6 +44,20 @@ public class TypedFor implements TypedStatement {
|
||||
|
||||
@Override
|
||||
public void codeGen(MethodContext ctx) {
|
||||
Label loopStart = new Label();
|
||||
Label loopUpdate = new Label();
|
||||
Label loopEnd = new Label();
|
||||
|
||||
assign.codeGen(ctx);
|
||||
ctx.getMv().visitLabel(loopStart);
|
||||
cond.codeGen(ctx);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.IFEQ, loopEnd);
|
||||
ctx.popStack();
|
||||
|
||||
typedBlock.codeGen(ctx);
|
||||
ctx.getMv().visitLabel(loopUpdate);
|
||||
inc.codeGen(ctx);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, loopStart);
|
||||
ctx.getMv().visitLabel(loopEnd);
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,10 @@ public class ClassCanBeBytecoded {
|
||||
}
|
||||
|
||||
public int test(int var1) {
|
||||
do {
|
||||
int i;
|
||||
for (i = 0; i < 12; i = i + 1) {
|
||||
var1 = var1 + 1;
|
||||
} while (var1 < 10);
|
||||
}
|
||||
return var1;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user