public override CheckTypesResult CheckExprTypeBounds() { CheckTypesResult result = new CheckTypesResult(); if (newType.arrayDim != 0) { foreach (Exprent dim in lstDims) { result.AddMinTypeExprent(dim, VarType.Vartype_Bytechar); result.AddMaxTypeExprent(dim, VarType.Vartype_Int); } if (newType.arrayDim == 1) { VarType leftType = newType.DecreaseArrayDim(); foreach (Exprent element in lstArrayElements) { result.AddMinTypeExprent(element, VarType.GetMinTypeInFamily(leftType.typeFamily) ); result.AddMaxTypeExprent(element, leftType); } } } else if (constructor != null) { return(constructor.CheckExprTypeBounds()); } return(result); }
public override CheckTypesResult CheckExprTypeBounds() { CheckTypesResult result = new CheckTypesResult(); if (exitType == Exit_Return && retType.type != ICodeConstants.Type_Void) { result.AddMinTypeExprent(value, VarType.GetMinTypeInFamily(retType.typeFamily)); result.AddMaxTypeExprent(value, retType); } return(result); }
public override CheckTypesResult CheckExprTypeBounds() { CheckTypesResult result = new CheckTypesResult(); for (int i = 0; i < lstParameters.Count; i++) { Exprent parameter = lstParameters[i]; VarType leftType = descriptor.@params[i]; result.AddMinTypeExprent(parameter, VarType.GetMinTypeInFamily(leftType.typeFamily )); result.AddMaxTypeExprent(parameter, leftType); } return(result); }
public override CheckTypesResult CheckExprTypeBounds() { CheckTypesResult result = new CheckTypesResult(); VarType typeLeft = left.GetExprType(); VarType typeRight = right.GetExprType(); if (typeLeft.typeFamily > typeRight.typeFamily) { result.AddMinTypeExprent(right, VarType.GetMinTypeInFamily(typeLeft.typeFamily)); } else if (typeLeft.typeFamily < typeRight.typeFamily) { result.AddMinTypeExprent(left, typeRight); } else { result.AddMinTypeExprent(left, VarType.GetCommonSupertype(typeLeft, typeRight)); } return(result); }
public override CheckTypesResult CheckExprTypeBounds() { CheckTypesResult result = new CheckTypesResult(); Exprent param1 = lstOperands[0]; VarType type1 = param1.GetExprType(); Exprent param2 = null; VarType type2 = null; if (lstOperands.Count > 1) { param2 = lstOperands[1]; type2 = param2.GetExprType(); } switch (funcType) { case Function_Iif: { VarType supertype = GetExprType(); result.AddMinTypeExprent(param1, VarType.Vartype_Boolean); result.AddMinTypeExprent(param2, VarType.GetMinTypeInFamily(supertype.typeFamily) ); result.AddMinTypeExprent(lstOperands[2], VarType.GetMinTypeInFamily(supertype.typeFamily )); break; } case Function_I2l: case Function_I2f: case Function_I2d: case Function_I2b: case Function_I2c: case Function_I2s: { result.AddMinTypeExprent(param1, VarType.Vartype_Bytechar); result.AddMaxTypeExprent(param1, VarType.Vartype_Int); break; } case Function_Imm: case Function_Ipp: case Function_Mmi: case Function_Ppi: { result.AddMinTypeExprent(param1, implicitType); result.AddMaxTypeExprent(param1, implicitType); break; } case Function_Add: case Function_Sub: case Function_Mul: case Function_Div: case Function_Rem: case Function_Shl: case Function_Shr: case Function_Ushr: case Function_Lt: case Function_Ge: case Function_Gt: case Function_Le: { result.AddMinTypeExprent(param2, VarType.Vartype_Bytechar); goto case Function_Bit_Not; } case Function_Bit_Not: case Function_Neg: { // case FUNCTION_BOOL_NOT: result.AddMinTypeExprent(param1, VarType.Vartype_Bytechar); break; } case Function_And: case Function_Or: case Function_Xor: case Function_Eq: case Function_Ne: { if (type1.type == ICodeConstants.Type_Boolean) { if (type2.IsStrictSuperset(type1)) { result.AddMinTypeExprent(param1, VarType.Vartype_Bytechar); } else { // both are booleans bool param1_false_boolean = type1.IsFalseBoolean() || (param1.type == Exprent.Exprent_Const && !((ConstExprent)param1).HasBooleanValue()); bool param2_false_boolean = type1.IsFalseBoolean() || (param2.type == Exprent.Exprent_Const && !((ConstExprent)param2).HasBooleanValue()); if (param1_false_boolean || param2_false_boolean) { result.AddMinTypeExprent(param1, VarType.Vartype_Bytechar); result.AddMinTypeExprent(param2, VarType.Vartype_Bytechar); } } } else if (type2.type == ICodeConstants.Type_Boolean) { if (type1.IsStrictSuperset(type2)) { result.AddMinTypeExprent(param2, VarType.Vartype_Bytechar); } } break; } } return(result); }