From 5d7f7ef546192453f60a09d07db5b6b09704065d Mon Sep 17 00:00:00 2001 From: ahmad Date: Sat, 11 May 2024 21:41:01 +0200 Subject: [PATCH] Update TypedClass --- .../typedast/typedclass/TypedClass.java | 34 ++++++++++++------- .../typedast/typedclass/TypedMethodCall.java | 2 +- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedClass.java b/src/main/java/de/maishai/typedast/typedclass/TypedClass.java index 626818b..832f135 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedClass.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedClass.java @@ -32,16 +32,16 @@ public class TypedClass implements TypedNode { public TypedClass(Map localVar, Class c) { convertToTypedClass(localVar, c); } - public void enterMethod(TypedMethod method) { + public void enterCurrentMethod(TypedMethod method) { currentMethod = method; } - public void exitMethod() { + public void exitCurrentMethod() { currentMethod = null; } - public void enterConstructor(TypedConstructor constructor) { + public void enterCurrentConstructor(TypedConstructor constructor) { currentConstructor = constructor; } - public void exitConstructor() { + public void exitCurrentConstructor() { currentConstructor = null; } public boolean isCurrentMethodPresent() { @@ -80,19 +80,27 @@ public class TypedClass implements TypedNode { for (Declaration field : c.fieldDeclarations()) { typedFields.add(new TypedField(localVar, this, field)); } - - for (Constructor constructor : c.constructors()) { + for (Constructor constructor : c.constructors()){ typedConstructors.add(new TypedConstructor(localVar, this, constructor)); - enterConstructor(typedConstructors.get(typedConstructors.size() - 1)); - typedConstructors.get(typedConstructors.size() - 1).convertToBlock(localVar, this, constructor); - exitConstructor(); } - for (Method method : c.methods()) { typedMethods.add(new TypedMethod(localVar, this, method)); - enterMethod(typedMethods.get(typedMethods.size() - 1)); - typedMethods.get(typedMethods.size() - 1).convertToTypedBlock(localVar, this, method); - exitMethod(); + } + + int i = 0; + for (Constructor constructor : c.constructors()) { + enterCurrentConstructor(typedConstructors.get(i)); + typedConstructors.get(i).convertToBlock(localVar, this, constructor); + exitCurrentConstructor(); + i++; + } + + int j = 0; + for (Method method : c.methods()) { + enterCurrentMethod(typedMethods.get(j)); + typedMethods.get(j).convertToTypedBlock(localVar, this, method); + exitCurrentMethod(); + j++; } } diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedMethodCall.java b/src/main/java/de/maishai/typedast/typedclass/TypedMethodCall.java index 96dbf18..2bae2f9 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedMethodCall.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedMethodCall.java @@ -32,7 +32,7 @@ public class TypedMethodCall implements TypedExpression, TypedStatement { @Override public Type typeCheck(Map localVar, TypedClass clas) { - //TODO: Implement typeCheck + return null; }