Revert "Some small changes for SemanticAnalyzer"
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This reverts commit dbde4e8047.
This commit is contained in:
Bruder John 2024-07-05 09:34:06 +02:00
parent dbde4e8047
commit c6e61defce
35 changed files with 8 additions and 32 deletions

View File

@ -4,6 +4,5 @@ public enum TypeEnum {
VOID,
INT,
CHAR,
BOOL,
NULL
BOOL
}

View File

@ -254,11 +254,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
return new TypeCheckResult(true, type);
} else if (currentScope.getLocalVar(toCheck.identifier) != null) {
var type = currentScope.getLocalVar(toCheck.identifier);
MemberAccessNode memberAccessNode = new MemberAccessNode(false);
memberAccessNode.identifiers.add(currentClass.identifier);
memberAccessNode.identifiers.add(toCheck.identifier);
toCheck.memberAccess = memberAccessNode;
toCheck.setTypeNode(type);
return new TypeCheckResult(true, type);
}
}
@ -333,16 +328,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
if (toCheck.target != null) {
if(toCheck.target.memberAccess == null){
MemberAccessNode memberAccessNode = new MemberAccessNode(false);
var identifierType = currentFields.get(toCheck.target.identifier);
if(identifierType == null){
identifierType = currentScope.getLocalVar(toCheck.target.identifier);
}
if(identifierType instanceof ReferenceType referenceType){
memberAccessNode.identifiers.add(referenceType.getIdentifier());
} else {
memberAccessNode.identifiers.add(currentClass.identifier);
}
memberAccessNode.identifiers.add(toCheck.target.identifier);
toCheck.target.memberAccess = memberAccessNode;
}
@ -702,9 +688,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
case BOOLEAN_VALUE -> {
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
}
case NULL_VALUE -> {
return new TypeCheckResult(true, currentNullType);
}
default -> {
return new TypeCheckResult(false, null);
}

View File

@ -1,14 +1,8 @@
public class Class1 {
public int test(){
Class2 class2 = new Class2();
int a = class2.test();
return a;
}
}
public class Class2
{
public int test(){
return 6+2*2;
public class If {
public If() {
int intValue = 5;
if(intValue == 5) {
intValue--;
}
}
}