mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-27 07:18:03 +00:00
Changed the retrieving of fields is allowed only with this
This commit is contained in:
parent
eee1c139a7
commit
4532d220d3
@ -70,7 +70,7 @@ public class TypedAssignment implements TypedStatement {
|
||||
if (currentMethod.isLocalVariableInMethod(name)) {
|
||||
return currentMethod.getLocalVariableType(name);
|
||||
} else if (currentClass.isThereField(name)) {
|
||||
return currentClass.getFieldType(name);
|
||||
throw new RuntimeException("Field Variable "+ name + " should be used with `this´");
|
||||
} else {
|
||||
throw new RuntimeException("Variable " + name + " not declared in method");
|
||||
}
|
||||
@ -80,7 +80,7 @@ public class TypedAssignment implements TypedStatement {
|
||||
if (currentConstructor.isLocalVariableInConstructor(name)) {
|
||||
return currentConstructor.getLocalVariableType(name);
|
||||
} else if (currentClass.isThereField(name)) {
|
||||
return currentClass.getFieldType(name);
|
||||
throw new RuntimeException("Field Variable "+ name+ " should be used with `this´");
|
||||
} else {
|
||||
throw new RuntimeException("Variable " + name + " not declared in constructor");
|
||||
}
|
||||
|
@ -32,14 +32,12 @@ public final class TypedLocalVariable implements TypedNode {
|
||||
if (typedProgram.getCurrentClass().getCurrentMethod().isLocalVariableInMethod(name)) {
|
||||
throw new RuntimeException("Variable " + name + " already declared");
|
||||
}
|
||||
typedProgram.getCurrentClass().getCurrentMethod().getLocalVariables().add(this);
|
||||
return type;
|
||||
}
|
||||
if (!typedProgram.getCurrentClass().isCurrentMethodPresent() && typedProgram.getCurrentClass().isCurrentConstructorPresent()) {
|
||||
if (typedProgram.getCurrentClass().getCurrentConstructor().isLocalVariableInConstructor(name)) {
|
||||
throw new RuntimeException("Variable " + name + " already declared");
|
||||
}
|
||||
typedProgram.getCurrentClass().getCurrentConstructor().getLocalVariables().add(this);
|
||||
return type;
|
||||
}
|
||||
throw new RuntimeException("not found method or constructor in class");
|
||||
|
Loading…
Reference in New Issue
Block a user