mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 17:08:03 +00:00
Update the typeCheck of methods TypedFieldVarAccess
This commit is contained in:
parent
5cad5992f2
commit
9e45c65ea3
@ -28,38 +28,36 @@ public class TypedFieldVarAccess implements TypedExpression {
|
||||
recursiveOwnerChain = getKindOfExpression(localVar, clas, unTypedFieldVarAccess.recursiveOwnerChain());
|
||||
name = unTypedFieldVarAccess.id();
|
||||
|
||||
if(field) {
|
||||
if (clas.isThereField(name)) {
|
||||
type = clas.getFieldType(name);
|
||||
}
|
||||
} else if(localVar.containsKey(name)){
|
||||
type = localVar.get(name);
|
||||
}else{
|
||||
throw new RuntimeException("Variable not declared");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type typeCheck(Map<String, Type> localVar, TypedClass clas) {
|
||||
|
||||
|
||||
if(field){
|
||||
if (clas.isThereField(name)) {
|
||||
type = clas.getFieldType(name);
|
||||
return clas.getFieldType(name);
|
||||
}
|
||||
}else{
|
||||
if (clas.isThereField(name)) {
|
||||
type = clas.getFieldType(name);
|
||||
return clas.getFieldType(name);
|
||||
}else if(clas.isCurrentConstructorPresent()){
|
||||
if(clas.isParameterNameInCurrentConstructor(name)){
|
||||
type = clas.getParameterTypeInCurrentConstructor(name);
|
||||
return clas.getParameterTypeInCurrentConstructor(name);
|
||||
}
|
||||
}else if(clas.isCurrentMethodPresent()){
|
||||
if(clas.isParameterWitNameInMethod(name)){
|
||||
type = clas.getParameterType(name);
|
||||
}else if(localVar.containsKey(name)){
|
||||
type = clas.getParameterTypeInCurrentMethod(name);
|
||||
return clas.getParameterTypeInCurrentMethod(name);
|
||||
}
|
||||
}
|
||||
if(localVar.containsKey(name)) {
|
||||
type = localVar.get(name);
|
||||
return localVar.get(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return type;
|
||||
throw new RuntimeException("Variable "+name+" not declared ");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user