+2002-03-13 Ravi Pratap <ravi@ximian.com>
+
+ * ecore.cs (StandardConversionExists): Modify to take an Expression
+ as the first parameter. Ensure we do null -> reference type conversion
+ checking.
+
+ * Everywhere : update calls accordingly, making use of MyEmptyExpr to store
+ temporary Expression objects.
Wed Mar 13 12:32:40 CET 2002 Paolo Molaro <lupus@ximian.com>
* attribute.cs (ApplyAttributes): Recognize the MarshalAs attribute
on parameters and accordingly set the marshalling info.
-
2002-03-09 Miguel de Icaza <miguel@ximian.com>
* class.cs: Optimizing slightly by removing redundant code after
if (expr_type.GetArrayRank () == target_type.GetArrayRank ()) {
Type expr_element_type = expr_type.GetElementType ();
+
+ if (MyEmptyExpr == null)
+ MyEmptyExpr = new EmptyExpression ();
+
+ MyEmptyExpr.SetType (expr_element_type);
Type target_element_type = target_type.GetElementType ();
if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
- if (StandardConversionExists (expr_element_type,
+ if (StandardConversionExists (MyEmptyExpr,
target_element_type))
return new EmptyCast (expr, target_type);
}
/// Determines if a standard implicit conversion exists from
/// expr_type to target_type
/// </summary>
- public static bool StandardConversionExists (Type expr_type, Type target_type)
+ public static bool StandardConversionExists (Expression expr, Type target_type)
{
+ Type expr_type = expr.Type;
+
if (expr_type == target_type)
return true;
return true;
} else {
- // Please remember that all code below actuall comes
+ // Please remember that all code below actually comes
// from ImplicitReferenceConversion so make sure code remains in sync
// from any class-type S to any interface-type T.
if (expr_type.GetArrayRank () == target_type.GetArrayRank ()) {
Type expr_element_type = expr_type.GetElementType ();
+
+ if (MyEmptyExpr == null)
+ MyEmptyExpr = new EmptyExpression ();
+
+ MyEmptyExpr.SetType (expr_element_type);
Type target_element_type = target_type.GetElementType ();
if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
- if (StandardConversionExists (expr_element_type,
+ if (StandardConversionExists (MyEmptyExpr,
target_element_type))
return true;
}
return true;
// from the null type to any reference-type.
- // FIXME : How do we do this ?
-
+ if (expr is NullLiteral && !target_type.IsValueType)
+ return true;
+
}
return false;
ParameterData pd = Invocation.GetParameterData (mb);
Type param_type = pd.ParameterType (0);
- if (StandardConversionExists (source_type, param_type)) {
+ Expression source = new EmptyExpression (source_type);
+ Expression param = new EmptyExpression (param_type);
+
+ if (StandardConversionExists (source, param_type)) {
if (best == null)
best = param_type;
- if (StandardConversionExists (param_type, best))
+ if (StandardConversionExists (param, best))
best = param_type;
}
}
MethodInfo mi = (MethodInfo) me.Methods [i];
Type ret_type = mi.ReturnType;
+
+ Expression ret = new EmptyExpression (ret_type);
- if (StandardConversionExists (ret_type, target)) {
+ if (StandardConversionExists (ret, target)) {
if (best == null)
best = ret_type;
- if (!StandardConversionExists (ret_type, best))
+ if (!StandardConversionExists (ret, best))
best = ret_type;
}
return 0;
}
- if (StandardConversionExists (p, q) == true &&
- StandardConversionExists (q, p) == false)
+ Expression p_tmp = new EmptyExpression (p);
+ Expression q_tmp = new EmptyExpression (q);
+
+ if (StandardConversionExists (p_tmp, q) == true &&
+ StandardConversionExists (q_tmp, p) == false)
return 1;
if (p == TypeManager.sbyte_type)
if (a_mod == p_mod) {
if (a_mod == Parameter.Modifier.NONE)
- if (!StandardConversionExists (a.Type, pd.ParameterType (i)))
+ if (!StandardConversionExists (a.Expr, pd.ParameterType (i)))
return false;
if (a_mod == Parameter.Modifier.REF ||
for (int i = pd_count - 1; i < arg_count; i++) {
Argument a = (Argument) arguments [i];
- if (!StandardConversionExists (a.Type, element_type))
+ if (!StandardConversionExists (a.Expr, element_type))
return false;
}
if (a_mod == p_mod) {
if (a_mod == Parameter.Modifier.NONE)
- if (!StandardConversionExists (a.Type, pd.ParameterType (i)))
+ if (!StandardConversionExists (a.Expr, pd.ParameterType (i)))
return false;
if (a_mod == Parameter.Modifier.REF ||
// Now we see if we can at least find a method with the same number of arguments
//
ParameterData pd;
- int method_count = 0;
+ int method_count = 0;
if (best_match_idx == -1) {
-
+
for (int i = me.Methods.Length; i > 0;) {
i--;
MethodBase mb = me.Methods [i];
if (method == null)
return null;
-
//
// Now check that there are no ambiguities i.e the selected method
// should be better than all the others