2010-05-27 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Tue, 27 Apr 2010 08:20:18 +0000 (08:20 -0000)
committerMarek Safar <marek.safar@gmail.com>
Tue, 27 Apr 2010 08:20:18 +0000 (08:20 -0000)
* *.cs: Sync with the latest gmcs.

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

14 files changed:
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinaryOperationBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpConvertBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpGetIndexBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpGetMemberBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeConstructorBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeMemberBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpIsEventBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpSetIndexBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpSetMemberBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpUnaryOperationBinder.cs
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/ChangeLog
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/RuntimeBinderContext.cs

index 2aac9a5417f5a1c79d101a24aff78e4fda377ead..72787fa3dc281370d4f4f8c9dad2597ff0eb0be8 100644 (file)
@@ -144,7 +144,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                                expr = new Compiler.Binary (oper, left, right, Compiler.Location.Null);
                        }
 
-                       expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+                       expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
                        
                        if ((flags & CSharpBinderFlags.CheckedContext) != 0)
                                expr = new Compiler.CheckedExpr (expr, Compiler.Location.Null);
index 11cc31f23838501b4a27230dd9c29f5b8f6df2f2..981252043cdc51339e5073c58bd16f8eb425cb94 100644 (file)
@@ -87,7 +87,7 @@ namespace Microsoft.CSharp.RuntimeBinder
 
                        Expression res;
                        try {
-                               var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, callingType), ResolveOptions);
+                               var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, TypeImporter.Import (callingType)), ResolveOptions);
 
                                // Static typemanager and internal caches are not thread-safe
                                lock (resolver) {
@@ -134,7 +134,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                                        return new Compiler.NullLiteral (Compiler.Location.Null);
 
                                InitializeCompiler (null);
-                               return Compiler.Constant.CreateConstantFromValue (value.LimitType, null, Compiler.Location.Null);
+                               return Compiler.Constant.CreateConstantFromValue (TypeImporter.Import (value.LimitType), null, Compiler.Location.Null);
                        }
 
                        bool is_compile_time;
@@ -142,18 +142,18 @@ namespace Microsoft.CSharp.RuntimeBinder
                        if (info != null) {
                                if ((info.Flags & CSharpArgumentInfoFlags.Constant) != 0) {
                                        InitializeCompiler (null);
-                                       return Compiler.Constant.CreateConstantFromValue (value.LimitType, value.Value, Compiler.Location.Null);
+                                       return Compiler.Constant.CreateConstantFromValue (TypeImporter.Import (value.LimitType), value.Value, Compiler.Location.Null);
                                }
 
                                if ((info.Flags & CSharpArgumentInfoFlags.IsStaticType) != 0)
-                                       return new Compiler.TypeExpression ((Type) value.Value, Compiler.Location.Null);
+                                       return new Compiler.TypeExpression (TypeImporter.Import ((Type) value.Value), Compiler.Location.Null);
 
                                is_compile_time = (info.Flags & CSharpArgumentInfoFlags.UseCompileTimeType) != 0;
                        } else {
                                is_compile_time = false;
                        }
 
-                       return new Compiler.RuntimeValueExpression (value, is_compile_time);
+                       return new Compiler.RuntimeValueExpression (value, TypeImporter.Import (is_compile_time ? value.LimitType : value.RuntimeType));
                }
 
                public static Compiler.Arguments CreateCompilerArguments (IEnumerable<CSharpArgumentInfo> info, DynamicMetaObject[] args)
@@ -208,27 +208,52 @@ namespace Microsoft.CSharp.RuntimeBinder
 
                public static void InitializeCompiler (Compiler.CompilerContext ctx)
                {
-                       if (Compiler.TypeManager.object_type != null)
+                       if (TypeImporter.Predefined == null)
                                return;
 
                        lock (compiler_initializer) {
-                               if (Compiler.TypeManager.object_type != null)
+                               if (TypeImporter.Predefined == null)
                                        return;
 
                                // I don't think dynamically loaded assemblies can be used as dynamic
-                               // expression without static type be loaded first
+                               // expression without static type to be loaded first
                                // AppDomain.CurrentDomain.AssemblyLoad += (sender, e) => { throw new NotImplementedException (); };
 
                                // Import all currently loaded assemblies
-                               foreach (System.Reflection.Assembly a in AppDomain.CurrentDomain.GetAssemblies ())
-                                       Compiler.GlobalRootNamespace.Instance.AddAssemblyReference (a);
+                               var ns = Compiler.GlobalRootNamespace.Instance;
+                               foreach (System.Reflection.Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
+                                       ns.AddAssemblyReference (a);
+                                       ns.ImportAssembly (a);
+                               }
 
                                if (ctx == null)
                                        ctx = CreateDefaultCompilerContext ();
 
-                               Compiler.TypeManager.InitCoreTypes (ctx);
+                               Compiler.TypeManager.InitCoreTypes (ctx, TypeImporter.Predefined);
+                               TypeImporter.Predefined = null;
+
                                Compiler.TypeManager.InitOptionalCoreTypes (ctx);
                        }
                }
        }
+
+       static class TypeImporter
+       {
+               static object lock_object;
+               public static IList<Compiler.PredefinedTypeSpec> Predefined;
+
+               static TypeImporter ()
+               {
+                       lock_object = new object ();
+                       Predefined = Compiler.TypeManager.InitCoreTypes ();
+                       Compiler.Import.Initialize ();
+               }
+
+               public static Compiler.TypeSpec Import (Type type)
+               {
+                       lock (lock_object) {
+                               return Compiler.Import.ImportType (type);
+                       }
+               }
+       }
 }
index d125c4bbcc8460204ebbd78f703576d5387838b9..5af6409c0c14a85d8593c3e430d8dbb0df68350b 100644 (file)
@@ -51,9 +51,9 @@ namespace Microsoft.CSharp.RuntimeBinder
                        var expr = CSharpBinder.CreateCompilerExpression (null, target);
 
                        if (Explicit)
-                               expr = new Compiler.Cast (new Compiler.TypeExpression (Type, Compiler.Location.Null), expr);
+                               expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (Type), Compiler.Location.Null), expr);
                        else
-                               expr = new Compiler.ImplicitCast (expr, Type, (flags & CSharpBinderFlags.ConvertArrayIndex) != 0);
+                               expr = new Compiler.ImplicitCast (expr, TypeImporter.Import (Type), (flags & CSharpBinderFlags.ConvertArrayIndex) != 0);
 
                        if ((flags & CSharpBinderFlags.CheckedContext) != 0)
                                expr = new Compiler.CheckedExpr (expr, Compiler.Location.Null);
index 85e009ba229b343877902e03103b6593434decc7..a11bd9bae21f53fa4a25eb684c294287ee37041d 100644 (file)
@@ -58,7 +58,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                        var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
                        var args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), indexes);
                        expr = new Compiler.ElementAccess (expr, args);
-                       expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+                       expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
 
                        var binder = new CSharpBinder (this, expr, errorSuggestion);
                        binder.AddRestrictions (target);
index bf9bf3a208bd5cddf3d6a6e962bfaf069bd21d6f..9f9fad0b93105459cf7a9b45f902295829eeeccc 100644 (file)
@@ -50,7 +50,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                {
                        var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
                        expr = new Compiler.MemberAccess (expr, Name);
-                       expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+                       expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
 
                        var binder = new CSharpBinder (this, expr, errorSuggestion);
                        binder.AddRestrictions (target);
index 3748ba0e5e303d940c3b1b534006b553bf25f106..ded455c50b9221aaa746c1e58a217b6ed3a5dae3 100644 (file)
@@ -55,9 +55,9 @@ namespace Microsoft.CSharp.RuntimeBinder
                        expr = new Compiler.Invocation (expr, c_args);
 
                        if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
-                               expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+                               expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
                        else
-                               expr = new Compiler.DynamicResultCast (ReturnType, expr);
+                               expr = new Compiler.DynamicResultCast (TypeImporter.Import (ReturnType), expr);
 
                        var binder = new CSharpBinder (this, expr, errorSuggestion);
                        binder.AddRestrictions (target);
index 87ac5f7ffb83fa1277c4465819a3f9c8d15d605a..b42cc43873d44d0e7eb729b3ade06f8a0d5bb8c9 100644 (file)
@@ -49,7 +49,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                public override DynamicMetaObject Bind (DynamicMetaObject target, DynamicMetaObject[] args)
                {
                        var type = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
-                       target_return_type = type.Type;
+                       target_return_type = type.Type.GetMetaInfo ();
 
                        var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);
 
index b578e499ea3ed01df66dd774c579d7756a9399bb..3417cfda5d7f1bd0f450c38858b58038439849ce 100644 (file)
@@ -63,7 +63,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                        var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);
                        var t_args = typeArguments == null ?
                                null :
-                               new Compiler.TypeArguments (typeArguments.Select (l => new Compiler.TypeExpression (l, Compiler.Location.Null)).ToArray ());
+                               new Compiler.TypeArguments (typeArguments.Select (l => new Compiler.TypeExpression (TypeImporter.Import (l), Compiler.Location.Null)).ToArray ());
 
                        Compiler.Expression expr;
                        if ((flags & CSharpBinderFlags.InvokeSimpleName) != 0) {
@@ -76,9 +76,9 @@ namespace Microsoft.CSharp.RuntimeBinder
                        expr = new Compiler.Invocation (expr, c_args);
 
                        if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
-                               expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+                               expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
                        else
-                               expr = new Compiler.DynamicResultCast (ReturnType, expr);
+                               expr = new Compiler.DynamicResultCast (TypeImporter.Import (ReturnType), expr);
 
                        var binder = new CSharpBinder (this, expr, errorSuggestion);
                        binder.AddRestrictions (target);
index 52996e40d1adef5f250d4c3db36ec7ceb0cb42cf..ee74d85cb5984a6bb0c83ee65e5a1d60c09092d4 100644 (file)
@@ -49,8 +49,9 @@ namespace Microsoft.CSharp.RuntimeBinder
                {
                        var ctx = CSharpBinder.CreateDefaultCompilerContext ();
                        CSharpBinder.InitializeCompiler (ctx);
+                       var context = TypeImporter.Import (callingContext);
 
-                       var expr = Compiler.Expression.MemberLookup (ctx, callingContext, callingContext, name, Compiler.Location.Null);
+                       var expr = Compiler.Expression.MemberLookup (ctx, context, context, name, 0, Compiler.BindingRestriction.None, Compiler.Location.Null);
 
                        var binder = new CSharpBinder (
                                this, new Compiler.BoolConstant (expr is Compiler.EventExpr, Compiler.Location.Null), null);
index 4a6a0ef37e4e5519ba142cb20392d5d7ac2115b4..e5da8410d70030e64ccc716b9f0807948376d9b9 100644 (file)
@@ -61,7 +61,7 @@ namespace Microsoft.CSharp.RuntimeBinder
 
                        var source = CSharpBinder.CreateCompilerExpression (argumentInfo [indexes.Length + 1], value);
                        expr = new Compiler.SimpleAssign (expr, source);
-                       expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+                       expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
 
                        var binder = new CSharpBinder (this, expr, errorSuggestion);
                        binder.AddRestrictions (target);
index 2e323c8b1ac851bed528fc440e7e9c1d02d5a1f9..b9e9d4a0fc64985d443cfa03c959c7caf5d99909 100644 (file)
@@ -54,7 +54,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                        // Field assignment
                        expr = new Compiler.MemberAccess (expr, Name);
                        expr = new Compiler.SimpleAssign (expr, source);
-                       expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+                       expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
 
                        var binder = new CSharpBinder (this, expr, errorSuggestion);
                        binder.AddRestrictions (target);
index 05a27c1ce1d2f702c1f7ca7528a800a025d3fe14..5e495c15abe13e1f7833bb09e12c83765546dd71 100644 (file)
@@ -83,7 +83,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                                else
                                        expr = new Compiler.Unary (GetOperator (), expr, Compiler.Location.Null);
 
-                               expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+                               expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
 
                                if ((flags & CSharpBinderFlags.CheckedContext) != 0)
                                        expr = new Compiler.CheckedExpr (expr, Compiler.Location.Null);
index 356030f3d3a07437ca912d9d425970d6a46205a7..797be5203df6e428f75c0a09da6bf73dd04237d0 100644 (file)
@@ -1,3 +1,7 @@
+2010-05-27  Marek Safar  <marek.safar@gmail.com>
+
+       * *.cs: Sync with the latest gmcs.
+
 2010-02-10  Marek Safar  <marek.safar@gmail.com>
 
        * *.cs: Track RC API changes.
index 00fb0d4af2f0ac242abd7b053ad511e89a3834c3..ee3f7a48d19962a5ec2a54d581e53abebf77fe35 100644 (file)
@@ -34,9 +34,9 @@ namespace Microsoft.CSharp.RuntimeBinder
        class RuntimeBinderContext : Compiler.IMemberContext
        {
                readonly Compiler.CompilerContext ctx;
-               readonly Type currentType;
+               readonly Compiler.TypeSpec currentType;
 
-               public RuntimeBinderContext (Compiler.CompilerContext ctx, Type currentType)
+               public RuntimeBinderContext (Compiler.CompilerContext ctx, Compiler.TypeSpec currentType)
                {
                        this.ctx = ctx;
                        this.currentType = currentType;
@@ -44,7 +44,7 @@ namespace Microsoft.CSharp.RuntimeBinder
 
                #region IMemberContext Members
 
-               public Type CurrentType {
+               public Compiler.TypeSpec CurrentType {
                        get { return currentType; }
                }
 
@@ -52,13 +52,19 @@ namespace Microsoft.CSharp.RuntimeBinder
                        get { throw new NotImplementedException (); }
                }
 
-               public Compiler.TypeContainer CurrentTypeDefinition {
+               public Compiler.MemberCore CurrentMemberDefinition {
                        get {
                                // For operators and methods
                                return new Compiler.ModuleContainer (currentType.Assembly);
                        }
                }
 
+               public bool HasUnresolvedConstraints {
+                       get {
+                               return false;
+                       }
+               }
+
                public bool IsObsolete {
                        get {
                                // Always true to ignore obsolete attribute checks
@@ -82,13 +88,13 @@ namespace Microsoft.CSharp.RuntimeBinder
                        throw new NotImplementedException ();
                }
 
-               public Compiler.ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Mono.CSharp.Location loc)
+               public Compiler.ExtensionMethodGroupExpr LookupExtensionMethod (Compiler.TypeSpec extensionType, string name, int arity, Mono.CSharp.Location loc)
                {
                        // No extension method lookup in this context
                        return null;
                }
 
-               public Compiler.FullNamedExpression LookupNamespaceOrType (string name, Mono.CSharp.Location loc, bool ignore_cs0104)
+               public Compiler.FullNamedExpression LookupNamespaceOrType (string name, int arity, Mono.CSharp.Location loc, bool ignore_cs0104)
                {
                        throw new NotImplementedException ();
                }