mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 16:28:04 +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());
|
recursiveOwnerChain = getKindOfExpression(localVar, clas, unTypedFieldVarAccess.recursiveOwnerChain());
|
||||||
name = unTypedFieldVarAccess.id();
|
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
|
@Override
|
||||||
public Type typeCheck(Map<String, Type> localVar, TypedClass clas) {
|
public Type typeCheck(Map<String, Type> localVar, TypedClass clas) {
|
||||||
|
if(field){
|
||||||
|
if (clas.isThereField(name)) {
|
||||||
if(field){
|
type = clas.getFieldType(name);
|
||||||
if(clas.isThereField(name)){
|
return clas.getFieldType(name);
|
||||||
type = 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.getParameterTypeInCurrentMethod(name);
|
||||||
|
return clas.getParameterTypeInCurrentMethod(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(localVar.containsKey(name)) {
|
||||||
|
type = localVar.get(name);
|
||||||
|
return localVar.get(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else{
|
throw new RuntimeException("Variable "+name+" not declared ");
|
||||||
if(clas.isParameterWitNameInMethod(name)){
|
|
||||||
type = clas.getParameterType(name);
|
|
||||||
}else if(localVar.containsKey(name)){
|
|
||||||
type = localVar.get(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user