From f40318f9058f6a9c969fd3af5f94aa0941e6bf81 Mon Sep 17 00:00:00 2001 From: ahmad Date: Sat, 11 May 2024 11:46:26 +0200 Subject: [PATCH] Add Type to TypedBlock --- .../de/maishai/typedast/typedclass/TypedBlock.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java b/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java index 304c7c7..06d4ebc 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java @@ -17,11 +17,17 @@ import java.util.Map; public class TypedBlock implements TypedNode { private List vars = new ArrayList<>(); private List stmts = new ArrayList<>(); + private Type type; + public TypedBlock(Map localVar, TypedClass clas, Block unTypedBlock) { blockToTypedBlock(localVar, clas, unTypedBlock); } + public TypedBlock(List vars, List stmts) { + this.vars = vars; + this.stmts = stmts; + } public void blockToTypedBlock(Map 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) {