+ static void AddConversionOperators (EmitContext ec, ArrayList list,
+ Expression source, Type target_type,
+ bool look_for_explicit,
+ MethodGroupExpr mg)
+ {
+ if (mg == null)
+ return;
+
+ Type source_type = source.Type;
+ EmptyExpression expr = EmptyExpression.Grab ();
+ foreach (MethodInfo m in mg.Methods) {
+ ParameterData pd = TypeManager.GetParameterData (m);
+ Type return_type = m.ReturnType;
+ Type arg_type = pd.ParameterType (0);
+
+ if (source_type != arg_type) {
+ if (!ImplicitStandardConversionExists (ec, source, arg_type)) {
+ if (!look_for_explicit)
+ continue;
+ expr.SetType (arg_type);
+ if (!ImplicitStandardConversionExists (ec, expr, source_type))
+ continue;
+ }
+ }
+
+ if (target_type != return_type) {
+ expr.SetType (return_type);
+ if (!ImplicitStandardConversionExists (ec, expr, target_type)) {
+ if (!look_for_explicit)
+ continue;
+ expr.SetType (target_type);
+ if (!ImplicitStandardConversionExists (ec, expr, return_type))
+ continue;
+ }
+ }
+
+ list.Add (m);
+ }
+
+ EmptyExpression.Release (expr);
+ }
+