public int GetCoercionScore(int type) { Validity.Assert(null != CoerceTypes); int score = (int)ProtoCore.DSASM.ProcedureDistance.NotMatchScore; if (type == ID) { return((int)ProtoCore.DSASM.ProcedureDistance.ExactMatchScore); } if ((int)PrimitiveType.Null == ID) { score = (int)ProtoCore.DSASM.ProcedureDistance.CoerceScore; } else { if (CoerceTypes.ContainsKey(type)) { score = CoerceTypes[type]; } } return(score); }
public bool ConvertibleTo(int type) { Validity.Assert(null != CoerceTypes); Validity.Assert((int)PrimitiveType.InvalidType != ID); if ((int)PrimitiveType.Null == ID || CoerceTypes.ContainsKey(type)) { return true; } //chars are convertible to string else if (ID == (int)PrimitiveType.Char && type==(int)PrimitiveType.String) { return true; } //user defined type to bool else if (ID >=(int)PrimitiveType.MaxPrimitive && type == (int)PrimitiveType.Bool) { return true; } //string to boolean else if (ID == (int)PrimitiveType.String && type == (int)PrimitiveType.Bool) { return true; } //char to boolean else if (ID == (int)PrimitiveType.Char && type == (int)PrimitiveType.Bool) { return true; } return false; }