Update TypedClass

This commit is contained in:
ahmad 2024-05-11 21:41:01 +02:00
parent d5879e6539
commit 5d7f7ef546
2 changed files with 22 additions and 14 deletions

View File

@ -32,16 +32,16 @@ public class TypedClass implements TypedNode {
public TypedClass(Map<String, Type> localVar, Class c) { public TypedClass(Map<String, Type> localVar, Class c) {
convertToTypedClass(localVar, c); convertToTypedClass(localVar, c);
} }
public void enterMethod(TypedMethod method) { public void enterCurrentMethod(TypedMethod method) {
currentMethod = method; currentMethod = method;
} }
public void exitMethod() { public void exitCurrentMethod() {
currentMethod = null; currentMethod = null;
} }
public void enterConstructor(TypedConstructor constructor) { public void enterCurrentConstructor(TypedConstructor constructor) {
currentConstructor = constructor; currentConstructor = constructor;
} }
public void exitConstructor() { public void exitCurrentConstructor() {
currentConstructor = null; currentConstructor = null;
} }
public boolean isCurrentMethodPresent() { public boolean isCurrentMethodPresent() {
@ -80,19 +80,27 @@ public class TypedClass implements TypedNode {
for (Declaration field : c.fieldDeclarations()) { for (Declaration field : c.fieldDeclarations()) {
typedFields.add(new TypedField(localVar, this, field)); typedFields.add(new TypedField(localVar, this, field));
} }
for (Constructor constructor : c.constructors()){
for (Constructor constructor : c.constructors()) {
typedConstructors.add(new TypedConstructor(localVar, this, constructor)); 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()) { for (Method method : c.methods()) {
typedMethods.add(new TypedMethod(localVar, this, method)); 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++;
} }
} }

View File

@ -32,7 +32,7 @@ public class TypedMethodCall implements TypedExpression, TypedStatement {
@Override @Override
public Type typeCheck(Map<String, Type> localVar, TypedClass clas) { public Type typeCheck(Map<String, Type> localVar, TypedClass clas) {
//TODO: Implement typeCheck
return null; return null;
} }