From bfcbb4dc2d9afc8375e64802e8e94043a0791a6f Mon Sep 17 00:00:00 2001 From: Ahmad Date: Wed, 8 May 2024 16:05:32 +0200 Subject: [PATCH] Updated convertToTypedAST of TypedConstructor --- .../typedast/typedclass/TypedConstructor.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedConstructor.java b/src/main/java/de/maishai/typedast/typedclass/TypedConstructor.java index 0a5e9fc..7a832b5 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedConstructor.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedConstructor.java @@ -14,6 +14,7 @@ import org.objectweb.asm.ClassWriter; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -22,12 +23,10 @@ import java.util.Map; @Data public class TypedConstructor implements TypedNode { - private Boolean isPublic; private String name; private List typedParameters; private TypedBlock typedBlock; - //constructor: PUBLIC? id '(' params? ')' block; @Override public Type typeCheck(Map localVar, Map classes) { if (localVar.containsKey(name)) { @@ -70,20 +69,22 @@ public class TypedConstructor implements TypedNode { Constructor untyped = (Constructor) unTypedAST; TypedConstructor typedConstructor = new TypedConstructor(); typedConstructor.setName(untyped.className()); + typedConstructor.setTypedParameters(new ArrayList<>()); if (untyped.params().isEmpty()) { typedConstructor.setTypedParameters(null); } else { + for (Parameter param : untyped.params()) { TypedParameter typedParam = new TypedParameter(); - typedParam.convertToTypedAST(localVar, classes, param); + typedParam.setType(param.type()); + typedParam.setParaName(param.name()); typedConstructor.getTypedParameters().add(typedParam); } + } - Block block = untyped.block(); TypedBlock typedBlock = new TypedBlock(); - typedBlock.convertToTypedAST(localVar, classes, block); - typedConstructor.setTypedBlock(typedBlock); + typedConstructor.setTypedBlock(typedBlock.unTypedBlockToTypedBlock(untyped.block())); return typedConstructor; }