fixed constructor node parameter decleration
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
Bruder John 2024-07-02 08:48:37 +02:00
parent 71ffb8bb83
commit 561eafbf4c
4 changed files with 42 additions and 76 deletions

View File

@ -9,13 +9,10 @@ import java.util.List;
import java.util.Objects;
public class ConstructorNode extends MethodNode {
public AccessModifierNode accessType;
public String identifier;
public List<ParameterNode> parameters = new ArrayList<>();
public BlockNode block;
public ConstructorNode(String accessType, String identifier, BlockNode block) {
this.accessType = new AccessModifierNode(accessType);
this.accesModifier = new AccessModifierNode(accessType);
this.identifier = identifier;
this.block = block;
}

View File

@ -16,7 +16,7 @@ public class Scope {
public void addLocalVar(String name, ITypeNode type) {
if (this.contains(name)) {
throw new AlreadyDeclaredException("Variable " + name + " already exists in this scope");
SemanticAnalyzer.errors.add(new AlreadyDeclaredException("Duplicate local variable " + name));
}
localVars.peek().put(name, type);
}

View File

@ -112,9 +112,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
@Override
public TypeCheckResult analyze(MethodNode methodNode) {
if (methodNode instanceof ConstructorNode) {
return new TypeCheckResult(true, new BaseType(TypeEnum.VOID));
} else {
var valid = true;
@ -159,7 +156,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
return new TypeCheckResult(valid, resultType);
}
}
@Override
public TypeCheckResult analyze(FieldNode toCheck) {

View File

@ -1,38 +1,11 @@
public class AllFeaturesClassExample {
int a;
boolean b;
char c;
public void controlStructures(int adf, boolean bool) {
if (a > (10 + 8)) {
} else {
}
while (a > adf) {
a--;
}
for (int i = 0; i < 5; i++) {
}
public void controlStructures(int a, boolean b) {
}
// void logicalOperations() {
// Logische UND-Operation
// if (b && a > 5) {
// System.out.println("a ist größer als 5 und b ist wahr");
// }
public AllFeaturesClassExample(boolean b){
}
// Logische ODER-Operation
// if (b || a < 5) {
// System.out.println("b ist wahr oder a ist kleiner als 5");
// }
// }
// public static void main(String[] args) {
// AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a');
// obj.controlStructures();
// }
}