2009-07-27 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Mon, 27 Jul 2009 17:00:20 +0000 (17:00 -0000)
committerMarek Safar <marek.safar@gmail.com>
Mon, 27 Jul 2009 17:00:20 +0000 (17:00 -0000)
* typemanager.cs, argument.cs, convert.cs, assign.cs, expression.cs,
ecore.cs: Add TypeManager.IsDynamicType.

svn path=/trunk/mcs/; revision=138749

mcs/mcs/ChangeLog
mcs/mcs/argument.cs
mcs/mcs/assign.cs
mcs/mcs/convert.cs
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/typemanager.cs

index ddcdc7daa893f16be514c9ee65b5c1ea13baed00..7c66c9c0d22edc8105b74c5951f656231e901524 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-27  Marek Safar  <marek.safar@gmail.com>
+
+       * typemanager.cs, argument.cs, convert.cs, assign.cs, expression.cs,
+       ecore.cs: Add TypeManager.IsDynamicType.
+
 2009-07-27  Marek Safar  <marek.safar@gmail.com>
 
        A fix for bug #415375
index 013eb63ee5e9ca8506ad6011b7e7b2beeb3c1c6e..e7b0ed4d643080d053bfcf3cd03b7a30841e5db9 100644 (file)
@@ -368,7 +368,7 @@ namespace Mono.CSharp
                        dynamic = false;
                        foreach (Argument a in args) {
                                a.Resolve (ec);
-                               dynamic |= a.Type == InternalType.Dynamic;
+                               dynamic |= TypeManager.IsDynamicType (a.Type);
                        }
                }
 
index 8a4a98d0c11db91014a95b6ce29b4a810d13fb51..8be80e55a9fec7178c889b2a2162124eebdc2410 100644 (file)
@@ -368,7 +368,7 @@ namespace Mono.CSharp {
                        }
 
                        if (!TypeManager.IsEqual (target_type, source_type)) {
-                               if (source_type == InternalType.Dynamic) {
+                               if (TypeManager.IsDynamicType (source_type)) {
                                        Arguments args = new Arguments (1);
                                        args.Add (new Argument (source));
                                        return new DynamicConversion (target_type, false, args, loc).Resolve (ec);
index 0cec5cb2a9a87f731ca894376307ffa088f09536..053a0b0d78a9f0251153f801e423f94677916b83 100644 (file)
@@ -290,7 +290,7 @@ namespace Mono.CSharp {
                        // notice that it is possible to write "ValueType v = 1", the ValueType here
                        // is an abstract class, and not really a value type, so we apply the same rules.
                        //
-                       if (target_type == TypeManager.object_type || target_type == InternalType.Dynamic) {
+                       if (target_type == TypeManager.object_type || TypeManager.IsDynamicType (target_type)) {
                                //
                                // A pointer type cannot be converted to object
                                //
@@ -395,7 +395,7 @@ namespace Mono.CSharp {
                        //
                        // From any value-type to the type object.
                        //
-                       if (target_type == TypeManager.object_type || target_type == InternalType.Dynamic) {
+                       if (target_type == TypeManager.object_type || TypeManager.IsDynamicType (target_type)) {
                                //
                                // A pointer type cannot be converted to object
                                //
index c7230c43e7b98d31f8af9dff396df1f7c57c6102..f2e3f5ea79d1ee850448f23621af2376141c284f 100644 (file)
@@ -978,7 +978,7 @@ namespace Mono.CSharp {
                        if (e.Type == TypeManager.bool_type)
                                return e;
 
-                       if (e.Type == InternalType.Dynamic) {
+                       if (TypeManager.IsDynamicType (e.Type)) {
                                Arguments args = new Arguments (1);
                                args.Add (new Argument (e));
                                return new DynamicUnaryConversion ("IsTrue", args, loc);
@@ -1216,7 +1216,7 @@ namespace Mono.CSharp {
                //
                protected Expression ConvertExpressionToArrayIndex (EmitContext ec, Expression source)
                {
-                       if (source.type == InternalType.Dynamic) {
+                       if (TypeManager.IsDynamicType (source.type)) {
                                Arguments args = new Arguments (1);
                                args.Add (new Argument (source));
                                return new DynamicConversion (TypeManager.int32_type, false, args, loc).Resolve (ec);
index 5be4a236830dbd7042ab1d31eec9ce8700941bbd..b3809c95e3d195b59f2c0e279bb627f81b25cf85 100644 (file)
@@ -447,7 +447,7 @@ namespace Mono.CSharp {
                        if (Expr == null)
                                return null;
 
-                       if (Expr.Type == InternalType.Dynamic) {
+                       if (TypeManager.IsDynamicType (Expr.Type)) {
                                Arguments args = new Arguments (1);
                                args.Add (new Argument (Expr));
                                return new DynamicUnaryConversion (GetOperatorExpressionTypeName (), args, loc).DoResolve (ec);
@@ -2609,7 +2609,7 @@ namespace Mono.CSharp {
                                CheckUselessComparison (rc, left.Type);
                        }
 
-                       if (left.Type == InternalType.Dynamic || right.Type == InternalType.Dynamic) {
+                       if (TypeManager.IsDynamicType (left.Type) || TypeManager.IsDynamicType (right.Type)) {
                                Arguments args = new Arguments (2);
                                args.Add (new Argument (left));
                                args.Add (new Argument (right));
@@ -4704,7 +4704,7 @@ namespace Mono.CSharp {
                        Type expr_type = expr_resolved.Type;
                        mg = expr_resolved as MethodGroupExpr;
 
-                       if (expr_type == InternalType.Dynamic || dynamic_arg) {
+                       if (dynamic_arg || TypeManager.IsDynamicType (expr_type)) {
                                if (mg != null && mg.IsBase) {
                                        Report.Error (1971, loc,
                                                "The base call to method `{0}' cannot be dynamically dispatched. Consider casting the dynamic arguments or eliminating the base access",
@@ -7208,7 +7208,7 @@ namespace Mono.CSharp {
                        }
 
                        Type expr_type = expr_resolved.Type;
-                       if (expr_type == InternalType.Dynamic) {
+                       if (TypeManager.IsDynamicType (expr_type)) {
                                Arguments args = new Arguments (2);
                                args.Add (new Argument (expr_resolved.Resolve (ec)));
                                if (right_side != null)
@@ -8284,7 +8284,7 @@ namespace Mono.CSharp {
                {
                        bool dynamic;
                        arguments.Resolve (ec, out dynamic);
-                       if (dynamic || indexer_type == InternalType.Dynamic) {
+                       if (dynamic || TypeManager.IsDynamicType (indexer_type)) {
                                int additional = right_side == null ? 1 : 2;
                                Arguments args = new Arguments (arguments.Count + additional);
                                if (is_base_indexer) {
index c73fe56ef75c9afd0d7fc25c009b297d2b4fd775..1f697daa5dd7e5519a318a7b879f44639f610bd1 100644 (file)
@@ -1281,6 +1281,23 @@ namespace Mono.CSharp {
                t = DropGenericTypeArguments (t);
                return IsSubclassOf (t, TypeManager.delegate_type);
        }
+
+       //
+       // Is a type of dynamic type
+       //
+       public static bool IsDynamicType (Type t)
+       {
+               if (t == InternalType.Dynamic)
+                       return true;
+
+               if (t != object_type)
+                       return false;
+
+               if (t.Module == RootContext.ToplevelTypes.Builder)
+                       return false;
+
+               throw new NotImplementedException ("imported dynamic type");
+       }
        
        public static bool IsEnumType (Type t)
        {
@@ -2181,7 +2198,7 @@ namespace Mono.CSharp {
        public static Type TypeToReflectionType (Type type)
        {
                // TODO: Very lame and painful, GetReference () is enough for mcs-cecil
-               return type == InternalType.Dynamic ? object_type : type;
+               return IsDynamicType (type) ? object_type : type;
        }
 
        /// <summary>