fixed thistar
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
Bruder John 2024-07-03 18:33:30 +02:00
parent 7ccff3208c
commit b7863d0684
3 changed files with 8 additions and 21 deletions

View File

@ -5,7 +5,6 @@ import bytecode.visitor.MethodVisitor;
import visitor.Visitable; import visitor.Visitable;
public class MainMethodNode extends MethodNode implements Visitable { public class MainMethodNode extends MethodNode implements Visitable {
public BlockNode block;
public MainMethodNode(BlockNode block) { public MainMethodNode(BlockNode block) {
this.block = block; this.block = block;

View File

@ -344,11 +344,13 @@ public class SemanticAnalyzer implements SemanticVisitor {
} }
} else { } else {
if (toCheck.target.thisTar != null) {
if (toCheck.target.thisTar) { if (toCheck.target.thisTar) {
var type = getTypeFromMethod(toCheck, new ReferenceType(currentClass.identifier)); var type = getTypeFromMethod(toCheck, new ReferenceType(currentClass.identifier));
if (type != null) { if (type != null) {
return new TypeCheckResult(true, type); return new TypeCheckResult(true, type);
} }
}
} else { } else {
var result = toCheck.target.accept(this); var result = toCheck.target.accept(this);
if (result.getType() instanceof ReferenceType reference) { if (result.getType() instanceof ReferenceType reference) {
@ -394,9 +396,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
if (context.containsClass(toCheck.identifier)) { if (context.containsClass(toCheck.identifier)) {
return new TypeCheckResult(true, new ReferenceType(toCheck.identifier)); return new TypeCheckResult(true, new ReferenceType(toCheck.identifier));
} else {
throw new RuntimeException("Cannot find class " + toCheck.identifier);
} }
return null;
} }
@Override @Override

View File

@ -1,21 +1,7 @@
public class CorrectTest {
int a;
boolean b;
char c;
public void controlStructures(int adf, boolean bool) { public class Run {
if (a > (10 + 8)) { public static void main(String[] args) {
} else { // Test t = new Test();
// System.out.println(t.test());
} }
while (a > adf) {
a--;
} }
for (int i = 0; i < 5; i++) {
}
}
}