Revert "Some small changes for SemanticAnalyzer"
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This reverts commit dbde4e8047
.
This commit is contained in:
parent
dbde4e8047
commit
c6e61defce
@ -4,6 +4,5 @@ public enum TypeEnum {
|
|||||||
VOID,
|
VOID,
|
||||||
INT,
|
INT,
|
||||||
CHAR,
|
CHAR,
|
||||||
BOOL,
|
BOOL
|
||||||
NULL
|
|
||||||
}
|
}
|
||||||
|
@ -254,11 +254,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
|||||||
return new TypeCheckResult(true, type);
|
return new TypeCheckResult(true, type);
|
||||||
} else if (currentScope.getLocalVar(toCheck.identifier) != null) {
|
} else if (currentScope.getLocalVar(toCheck.identifier) != null) {
|
||||||
var type = currentScope.getLocalVar(toCheck.identifier);
|
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);
|
return new TypeCheckResult(true, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,16 +328,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
|||||||
if (toCheck.target != null) {
|
if (toCheck.target != null) {
|
||||||
if(toCheck.target.memberAccess == null){
|
if(toCheck.target.memberAccess == null){
|
||||||
MemberAccessNode memberAccessNode = new MemberAccessNode(false);
|
MemberAccessNode memberAccessNode = new MemberAccessNode(false);
|
||||||
var identifierType = currentFields.get(toCheck.target.identifier);
|
memberAccessNode.identifiers.add(currentClass.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);
|
memberAccessNode.identifiers.add(toCheck.target.identifier);
|
||||||
toCheck.target.memberAccess = memberAccessNode;
|
toCheck.target.memberAccess = memberAccessNode;
|
||||||
}
|
}
|
||||||
@ -702,9 +688,6 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
|||||||
case BOOLEAN_VALUE -> {
|
case BOOLEAN_VALUE -> {
|
||||||
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
|
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
|
||||||
}
|
}
|
||||||
case NULL_VALUE -> {
|
|
||||||
return new TypeCheckResult(true, currentNullType);
|
|
||||||
}
|
|
||||||
default -> {
|
default -> {
|
||||||
return new TypeCheckResult(false, null);
|
return new TypeCheckResult(false, null);
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,14 +1,8 @@
|
|||||||
public class Class1 {
|
public class If {
|
||||||
public int test(){
|
public If() {
|
||||||
Class2 class2 = new Class2();
|
int intValue = 5;
|
||||||
int a = class2.test();
|
if(intValue == 5) {
|
||||||
return a;
|
intValue--;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class Class2
|
|
||||||
{
|
|
||||||
public int test(){
|
|
||||||
return 6+2*2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user