internal static void CheckReflectedMethod(ErrorCollector collector, AstNode where, List <System.Reflection.MethodInfo> methods, List <expression> arguments, Type return_type) { /* If there are no candidate methods, don't bother checking the types. */ if (methods.Count == 0) { return; } /* Find all the methods that match the needed type. */ var candidate_methods = from method in methods where (TypeFromClrType(method.ReturnType) & return_type) != 0 select method; if (candidate_methods.Count() == 0) { /* Produce an error for the union of all the types. */ Type candiate_return = 0; foreach (var method in methods) { candiate_return |= TypeFromClrType(method.ReturnType); } collector.ReportTypeError(where, return_type, candiate_return); return; } /* Check that the arguments match the union of the parameters of all the methods. This means that we might still not have a valid method, but we can check again during codegen. */ for (var it = 0; it < arguments.Count; it++) { Type candidate_parameter_type = 0; foreach (var method in methods) { var param_type = method.IsStatic ? method.GetParameters()[it].ParameterType : (it == 0 ? method.ReflectedType : method.GetParameters()[it - 1].ParameterType); candidate_parameter_type |= TypeFromClrType(param_type); } arguments[it].EnsureType(collector, candidate_parameter_type); } }
public override void EnsureType(ErrorCollector collector, Type type) { if ((RealType & type) == 0) { collector.ReportTypeError(Environment, Name, RealType, type); } else { RealType &= type; } }
public override void EnsureType(ErrorCollector collector, Type type) { if (ForceBack) { Source.EnsureType(collector, type); } else { if ((Mask & type) == 0) { collector.ReportTypeError(Environment, Name, Mask, type); } Mask &= type; } }
internal void EnsureIntrinsic <T>(ErrorCollector collector, T node, Type type) where T : AstNode, ITypeableElement { if (IntrinsicTypes.ContainsKey(node)) { var original_type = IntrinsicTypes[node]; var result = original_type & type; if (result == 0) { collector.ReportTypeError(node, original_type, type); } else { IntrinsicTypes[node] = result; } } else { IntrinsicTypes[node] = type; } }