@Test public void testIsOfTypeForAssign() throws IOException { ASTExpression bool1 = p.parse_StringExpression("true").get(); bool1.accept(flatExpressionScopeSetter); ASTExpression bool2 = p.parse_StringExpression("false").get(); bool2.accept(flatExpressionScopeSetter); ASTExpression float1 = p.parse_StringExpression("3.4f").get(); float1.accept(flatExpressionScopeSetter); ASTExpression int1 = p.parse_StringExpression("3").get(); int1.accept(flatExpressionScopeSetter); ASTExpression double1 = p.parse_StringExpression("3.46").get(); double1.accept(flatExpressionScopeSetter); ASTExpression long1 = p.parse_StringExpression("5L").get(); long1.accept(flatExpressionScopeSetter); ASTExpression char1 = p.parse_StringExpression("\'a\'").get(); char1.accept(flatExpressionScopeSetter); assertTrue(tc.isOfTypeForAssign(tc.typeOf(bool1), bool2)); assertTrue(tc.isOfTypeForAssign(tc.typeOf(double1), int1)); assertFalse(tc.isOfTypeForAssign(tc.typeOf(bool1), int1)); assertTrue(tc.isOfTypeForAssign(tc.typeOf(float1), int1)); assertTrue(tc.isOfTypeForAssign(tc.typeOf(long1), int1)); assertTrue(tc.isOfTypeForAssign(tc.typeOf(char1), char1)); assertFalse(tc.isOfTypeForAssign(tc.typeOf(char1), int1)); assertFalse(tc.isOfTypeForAssign(tc.typeOf(double1), bool1)); assertFalse(tc.isOfTypeForAssign(tc.typeOf(long1), float1)); assertTrue(tc.isOfTypeForAssign(tc.typeOf(float1), int1)); ASTExpression pers = p.parse_StringExpression("Person").get(); pers.accept(flatExpressionScopeSetter); ASTExpression stud = p.parse_StringExpression("Student").get(); stud.accept(flatExpressionScopeSetter); ASTExpression fstud = p.parse_StringExpression("FirstSemesterStudent").get(); fstud.accept(flatExpressionScopeSetter); assertTrue(tc.isOfTypeForAssign(tc.typeOf(pers), stud)); assertTrue(tc.isOfTypeForAssign(tc.typeOf(pers), fstud)); assertTrue(tc.isOfTypeForAssign(tc.typeOf(stud), fstud)); assertFalse(tc.isOfTypeForAssign(tc.typeOf(stud), pers)); assertFalse(tc.isOfTypeForAssign(tc.typeOf(fstud), pers)); assertFalse(tc.isOfTypeForAssign(tc.typeOf(fstud), stud)); assertTrue(tc.isOfTypeForAssign(tc.typeOf(pers), pers)); assertFalse(tc.isOfTypeForAssign(tc.typeOf(int1), pers)); }
public boolean isOfTypeForAssign(SymTypeExpression type, ASTExpression exp) { return compatible( type, typeOf(exp)); }
TypeCheck { public boolean isOfTypeForAssign(SymTypeExpression type, ASTExpression exp) { return compatible( type, typeOf(exp)); } }
TypeCheck { public boolean isOfTypeForAssign(SymTypeExpression type, ASTExpression exp) { return compatible( type, typeOf(exp)); } TypeCheck(ISynthesize synthesizeSymType,
                   ITypesCalculator iTypesCalculator);  TypeCheck(ISynthesize synthesizeSymType);  TypeCheck(ITypesCalculator iTypesCalculator); }
TypeCheck { public boolean isOfTypeForAssign(SymTypeExpression type, ASTExpression exp) { return compatible( type, typeOf(exp)); } TypeCheck(ISynthesize synthesizeSymType,
                   ITypesCalculator iTypesCalculator);  TypeCheck(ISynthesize synthesizeSymType);  TypeCheck(ITypesCalculator iTypesCalculator); SymTypeExpression symTypeFromAST(ASTMCType astMCType); SymTypeExpression symTypeFromAST(ASTMCVoidType astMCVoidType); SymTypeExpression symTypeFromAST(ASTMCReturnType astMCReturnType); SymTypeExpression symTypeFromAST(ASTMCQualifiedName astMCQualifiedName); SymTypeExpression typeOf(ASTExpression expr); SymTypeExpression typeOf(ASTLiteral lit); SymTypeExpression typeOf(ASTSignedLiteral lit); static boolean compatible(SymTypeExpression left, SymTypeExpression right); boolean isOfTypeForAssign(SymTypeExpression type, ASTExpression exp); static boolean isSubtypeOf(SymTypeExpression subType, SymTypeExpression superType); static boolean isBoolean(SymTypeExpression type); static boolean isInt(SymTypeExpression type); static boolean isDouble(SymTypeExpression type); static boolean isFloat(SymTypeExpression type); static boolean isLong(SymTypeExpression type); static boolean isChar(SymTypeExpression type); static boolean isShort(SymTypeExpression type); static boolean isByte(SymTypeExpression type); static boolean isVoid(SymTypeExpression type); static boolean isString(SymTypeExpression type); }
TypeCheck { public boolean isOfTypeForAssign(SymTypeExpression type, ASTExpression exp) { return compatible( type, typeOf(exp)); } TypeCheck(ISynthesize synthesizeSymType,
                   ITypesCalculator iTypesCalculator);  TypeCheck(ISynthesize synthesizeSymType);  TypeCheck(ITypesCalculator iTypesCalculator); SymTypeExpression symTypeFromAST(ASTMCType astMCType); SymTypeExpression symTypeFromAST(ASTMCVoidType astMCVoidType); SymTypeExpression symTypeFromAST(ASTMCReturnType astMCReturnType); SymTypeExpression symTypeFromAST(ASTMCQualifiedName astMCQualifiedName); SymTypeExpression typeOf(ASTExpression expr); SymTypeExpression typeOf(ASTLiteral lit); SymTypeExpression typeOf(ASTSignedLiteral lit); static boolean compatible(SymTypeExpression left, SymTypeExpression right); boolean isOfTypeForAssign(SymTypeExpression type, ASTExpression exp); static boolean isSubtypeOf(SymTypeExpression subType, SymTypeExpression superType); static boolean isBoolean(SymTypeExpression type); static boolean isInt(SymTypeExpression type); static boolean isDouble(SymTypeExpression type); static boolean isFloat(SymTypeExpression type); static boolean isLong(SymTypeExpression type); static boolean isChar(SymTypeExpression type); static boolean isShort(SymTypeExpression type); static boolean isByte(SymTypeExpression type); static boolean isVoid(SymTypeExpression type); static boolean isString(SymTypeExpression type);  }