Add Type to TypedBlock

This commit is contained in:
ahmad 2024-05-11 11:46:26 +02:00
parent 34a20668b6
commit f40318f905

View File

@ -17,11 +17,17 @@ import java.util.Map;
public class TypedBlock implements TypedNode {
private List<TypedLocalVariable> vars = new ArrayList<>();
private List<TypedStatement> stmts = new ArrayList<>();
private Type type;
public TypedBlock(Map<String, Type> localVar, TypedClass clas, Block unTypedBlock) {
blockToTypedBlock(localVar, clas, unTypedBlock);
}
public TypedBlock(List<TypedLocalVariable> vars, List<TypedStatement> stmts) {
this.vars = vars;
this.stmts = stmts;
}
public void blockToTypedBlock(Map<String, Type> localVar, TypedClass clas, Block unTypedBlock) {
@ -90,6 +96,7 @@ public class TypedBlock implements TypedNode {
//TODO: implement this
}
}
this.typeCheck(localVar, clas);
}
@ -104,8 +111,8 @@ public class TypedBlock implements TypedNode {
stmt.typeCheck(localVar, clas);
}
return Type.VOID;
type = Type.VOID;
return type;
}
public void codeGen(MethodVisitor mv, MethodContext ctx) {