mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-27 08:18:03 +00:00
Fixing bugs
This commit is contained in:
parent
b0ee9781ab
commit
8a2b54d3f4
@ -53,7 +53,8 @@ public class TypedBinary implements TypedExpression {
|
|||||||
throw new RuntimeException("Type mismatch in " + op);
|
throw new RuntimeException("Type mismatch in " + op);
|
||||||
}
|
}
|
||||||
} else if (op == Operator.EQ || op == Operator.NE ) {
|
} else if (op == Operator.EQ || op == Operator.NE ) {
|
||||||
if (leftType == Type.INT && rightType == Type.INT || leftType == Type.BOOL && rightType == Type.BOOL) {
|
if (leftType == Type.INT && rightType == Type.INT || leftType == Type.BOOL && rightType == Type.BOOL
|
||||||
|
|| leftType == Type.CHAR && rightType == Type.CHAR) {
|
||||||
type = Type.BOOL;
|
type = Type.BOOL;
|
||||||
return Type.BOOL;
|
return Type.BOOL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -58,7 +58,7 @@ public class TypedFieldVarAccess implements TypedExpression {
|
|||||||
} else if (recursiveOwnerChain instanceof TypedFieldVarAccess typedFieldVarAccess) {
|
} else if (recursiveOwnerChain instanceof TypedFieldVarAccess typedFieldVarAccess) {
|
||||||
boolean isClassWithNamePresent = typedProgram.isClassWithNamePresent(recursiveOwnerChain.getType().getReference());
|
boolean isClassWithNamePresent = typedProgram.isClassWithNamePresent(recursiveOwnerChain.getType().getReference());
|
||||||
if (isClassWithNamePresent) {
|
if (isClassWithNamePresent) {
|
||||||
Type typeofFieldNameInClass = typedProgram.getTypeOfFieldNameInClass(recursiveOwnerChain.getType().getReference(), name);
|
Type typeofFieldNameInClass = typedProgram.getTypeOfFieldOrMethodNameInClass(recursiveOwnerChain.getType().getReference(), name);
|
||||||
if (typeofFieldNameInClass != null) {
|
if (typeofFieldNameInClass != null) {
|
||||||
return typeofFieldNameInClass;
|
return typeofFieldNameInClass;
|
||||||
} else {
|
} else {
|
||||||
|
@ -51,6 +51,19 @@ public class TypedProgram {
|
|||||||
public Type getTypeOfFieldNameInClass(String className, String fieldName) {
|
public Type getTypeOfFieldNameInClass(String className, String fieldName) {
|
||||||
return typedClasses.stream().filter(clas -> clas.getClassName().equals(className)).findFirst().get().getFieldType(fieldName);
|
return typedClasses.stream().filter(clas -> clas.getClassName().equals(className)).findFirst().get().getFieldType(fieldName);
|
||||||
}
|
}
|
||||||
|
public Type getTypeOfFieldOrMethodNameInClass(String className, String fieldName) {
|
||||||
|
if(className == null || fieldName == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
TypedClass c = typedClasses.stream().filter(clas -> clas.getClassName().equals(className)).findFirst().get();
|
||||||
|
if(c.isThereField(fieldName)){
|
||||||
|
return c.getFieldType(fieldName);
|
||||||
|
}else if(c.isMethodOfCurrentClass(fieldName)){
|
||||||
|
return c.getMethodType(fieldName);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public TypedClass getTypedClass(String className) {
|
public TypedClass getTypedClass(String className) {
|
||||||
return typedClasses.stream().filter(clas -> clas.getClassName().equals(className)).findFirst().get();
|
return typedClasses.stream().filter(clas -> clas.getClassName().equals(className)).findFirst().get();
|
||||||
|
Loading…
Reference in New Issue
Block a user