Merge remote-tracking branch 'origin/Endabgabe' into Endabgabe
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
Lucas 2024-07-04 16:49:27 +02:00
commit ea97f34398
2 changed files with 22 additions and 13 deletions

View File

@ -253,6 +253,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
if (toCheck.memberAccess != null) {
var result = toCheck.memberAccess.accept(this);
toCheck.identifier = toCheck.memberAccess.identifiers.getLast();
toCheck.setTypeNode(result.getType());
return result;
} else {
@ -608,11 +609,15 @@ public class SemanticAnalyzer implements SemanticVisitor {
ITypeNode currentType = null;
int start = 0;
if(!memberAccessNode.identifiers.isEmpty()){
if(currentFields.get(memberAccessNode.identifiers.get(0)) != null){
memberAccessNode.identifiers.add(0, currentClass.identifier);
start = 1;
if(currentFields.get(memberAccessNode.identifiers.getFirst()) != null){
memberAccessNode.identifiers.addFirst(currentClass.identifier);
start++;
}
}
if(context.getClasses().get(memberAccessNode.identifiers.getFirst()) == null){
memberAccessNode.identifiers.addFirst(currentClass.identifier);
start++;
}
for (int i = start; i < memberAccessNode.identifiers.size(); i++) {
String s = memberAccessNode.identifiers.get(i);
@ -630,7 +635,8 @@ public class SemanticAnalyzer implements SemanticVisitor {
} else {
if (currentType instanceof ReferenceType reference) {
var currentTypeClass = context.getClass(reference.getIdentifier());
memberAccessNode.identifiers.add(i, reference.getIdentifier());
i++;
var currentField = currentTypeClass.getField(s);
if (currentField.getAccessModifier().accessType == EnumAccessModifierNode.PUBLIC) {
currentType = currentField.getType();

View File

@ -1,13 +1,16 @@
public class Klasse1 {
public int test;
public int test1() {
test = 5;
return 1;
}
public void test2() {
int testInt;
testInt = this.test1();
public class Compiler {
Node node;
public int add(int i, int j) {
node = new Node();
node.x = 1;
return i+j;
}
}
public class Node {
public int x;
public void main() {
Compiler compiler = new Compiler();
int i = compiler.add(5, 8);
}
}