register block vars

This commit is contained in:
404Simon 2024-05-14 14:55:36 +02:00
parent 8cdbf7a23b
commit 21aa8b1a2b
3 changed files with 9 additions and 5 deletions

View File

@ -203,7 +203,6 @@ public class TypedBinary implements TypedExpression {
ctx.getMv().visitInsn(Opcodes.IMUL);
}
}
//TODO: implement other operators
ctx.popStack();
}
}

View File

@ -119,7 +119,7 @@ public class TypedBlock implements TypedNode {
public void codeGen(MethodContext ctx) {
for (TypedLocalVariable var : vars) {
//var.codeGen(ctx);
ctx.registerVariable(var.getName(), var.getType());
}
for (TypedStatement stmt : stmts) {
stmt.codeGen(ctx);

View File

@ -1,11 +1,16 @@
public class ClassCanBeTyped {
public ClassCanBeTyped c;
public ClassCanBeTyped p;
public int x;
public boolean y;
public boolean test(boolean b, boolean c) {
return b || c;
public int test(boolean b, boolean c) {
int y;
y = 0;
if (b && c) {
y = 12;
}
return y;
}
}