Fixes cloning of a variable declarator.
[mono.git] / mcs / mcs / driver.cs
index ed82199c88814f9226ac45e4e764e88977e5fd79..372c06c738952fb17f033dca343a5864fbdeef78 100644 (file)
@@ -97,7 +97,7 @@ namespace Mono.CSharp
                //
                Encoding encoding;
 
-               readonly CompilerContext ctx;
+               internal readonly CompilerContext ctx;
 
                static readonly char[] argument_value_separator = new char [] { ';', ',' };
 
@@ -114,7 +114,7 @@ namespace Mono.CSharp
 
                public static Driver Create (string[] args, bool require_files, ReportPrinter printer)
                {
-                       Driver d = new Driver (new CompilerContext (new Report (printer)));
+                       Driver d = new Driver (new CompilerContext (new ReflectionMetaImporter (), new Report (printer)));
 
                        if (!d.ParseArguments (args, require_files))
                                return null;
@@ -413,9 +413,9 @@ namespace Mono.CSharp
 
                                // Extern aliased refs require special handling
                                if (alias == null)
-                                       GlobalRootNamespace.Instance.AddAssemblyReference (a);
+                                       ctx.GlobalRootNamespace.AddAssemblyReference (a);
                                else
-                                       GlobalRootNamespace.Instance.DefineRootNamespace (alias, a, ctx);
+                                       ctx.GlobalRootNamespace.DefineRootNamespace (alias, a, ctx);
 
                        } catch (BadImageFormatException f) {
                                // .NET 2.0 throws this if we try to load a module without an assembly manifest ...
@@ -455,7 +455,7 @@ namespace Mono.CSharp
                                        }
                                }
 
-                               GlobalRootNamespace.Instance.AddModuleReference (m);
+                               ctx.GlobalRootNamespace.AddModuleReference (m);
 
                        } catch (BadImageFormatException f) {
                                Error9 ("module", f.FileName, f.FusionLog);
@@ -487,7 +487,7 @@ namespace Mono.CSharp
                        foreach (var entry in external_aliases)
                                LoadAssembly (entry.Value, entry.Key, false);
                                
-                       GlobalRootNamespace.Instance.ComputeNamespaces (ctx);
+                       ctx.GlobalRootNamespace.ComputeNamespaces (ctx);
                }
 
                static string [] LoadArgs (string file)
@@ -1695,7 +1695,7 @@ namespace Mono.CSharp
                                set_method.Invoke (CodeGen.Assembly.Builder, BindingFlags.Default, null, new object[]{true}, null);
                        }
 
-                       GlobalRootNamespace.Instance.AddModuleReference (RootContext.ToplevelTypes.Builder);
+                       ctx.GlobalRootNamespace.AddModuleReference (RootContext.ToplevelTypes.Builder);
 
                        //
                        // Load assemblies required
@@ -1703,7 +1703,7 @@ namespace Mono.CSharp
                        if (timestamps)
                                ShowTime ("Loading references");
 
-                       Import.Initialize ();
+                       ctx.MetaImporter.Initialize ();
                        LoadReferences ();
                        
                        if (modules.Count > 0) {
@@ -1778,7 +1778,7 @@ namespace Mono.CSharp
                        if (timestamps)
                                ShowTime ("Closing types");
 
-                       RootContext.CloseTypes ();
+                       RootContext.CloseTypes (ctx);
 
                        PEFileKinds k = PEFileKinds.ConsoleApplication;
 
@@ -2031,13 +2031,11 @@ namespace Mono.CSharp
 
                        RootContext.Reset (full_flag);
                        TypeManager.Reset ();
-                       PredefinedAttributes.Reset ();
                        ArrayContainer.Reset ();
                        ReferenceContainer.Reset ();
                        PointerContainer.Reset ();
                        Parameter.Reset ();
 
-                       GlobalRootNamespace.Reset ();
                        Unary.Reset ();
                        Binary.Reset ();
                        ConstantFold.Reset ();
@@ -2055,7 +2053,6 @@ namespace Mono.CSharp
                        Linq.QueryBlock.TransparentParameter.Reset ();
                        Convert.Reset ();
                        TypeInfo.Reset ();
-                       DynamicExpressionStatement.Reset ();
                }
        }
 }