Updated with Xamarin copyrights
[mono.git] / mcs / mcs / ikvm.cs
index 28cc16766daca950484c7e4f7eb706e311b87637..18c97861a74fc71ae6a7cd91dad77cdd8f465447 100644 (file)
@@ -6,6 +6,7 @@
 // Dual licensed under the terms of the MIT X11 or GNU GPL
 //
 // Copyright 2009-2010 Novell, Inc. 
+// Copyright 2011 Xamarin Inc
 //
 //
 
@@ -22,7 +23,7 @@ namespace Mono.CSharp
 #if !STATIC
        public class StaticImporter
        {
-               public StaticImporter (BuildinTypes buildin)
+               public StaticImporter (BuiltinTypes builtin)
                {
                        throw new NotSupportedException ();
                }
@@ -88,11 +89,6 @@ namespace Mono.CSharp
                        return false;
                }
 
-               public override void GetCustomAttributeTypeName (CustomAttributeData cad, out string typeNamespace, out string typeName)
-               {
-                       cad.__TryReadTypeName (out typeNamespace, out typeName);
-               }
-
                public void ImportAssembly (Assembly assembly, RootNamespace targetNamespace)
                {
                        // It can be used more than once when importing same assembly
@@ -105,7 +101,7 @@ namespace Mono.CSharp
 
                public ImportedModuleDefinition ImportModule (Module module, RootNamespace targetNamespace)
                {
-                       var module_definition = new ImportedModuleDefinition (module, this);
+                       var module_definition = new ImportedModuleDefinition (module);
                        module_definition.ReadAttributes ();
 
                        var all_types = module.GetTypes ();
@@ -114,12 +110,12 @@ namespace Mono.CSharp
                        return module_definition;
                }
 
-               public void InitializeBuildinTypes (BuildinTypes buildin, Assembly corlib)
+               public void InitializeBuiltinTypes (BuiltinTypes builtin, Assembly corlib)
                {
                        //
                        // Setup mapping for build-in types to avoid duplication of their definition
                        //
-                       foreach (var type in buildin.AllTypes) {
+                       foreach (var type in builtin.AllTypes) {
                                compiled_types.Add (corlib.GetType (type.FullName), type);
                        }
                }
@@ -204,6 +200,7 @@ namespace Mono.CSharp
                        sdk_directory = new Dictionary<string, string[]> ();
                        sdk_directory.Add ("2", new string[] { "2.0", "net_2_0", "v2.0.50727" });
                        sdk_directory.Add ("4", new string[] { "4.0", "net_4_0", "v4.0.30319" });
+                       sdk_directory.Add ("4.5", new string[] { "4.5", "net_4_5", "v4.0.30319" });
                }
 
                public StaticLoader (StaticImporter importer, CompilerContext compiler)
@@ -217,28 +214,31 @@ namespace Mono.CSharp
 
                        var corlib_path = Path.GetDirectoryName (typeof (object).Assembly.Location);
                        string fx_path = corlib_path.Substring (0, corlib_path.LastIndexOf (Path.DirectorySeparatorChar));
-                       string sdk_path = null;
 
-                       string sdk_version = compiler.Settings.SdkVersion ?? "4";
-                       string[] sdk_sub_dirs;
+                       if (compiler.Settings.StdLib) {
+                               string sdk_path = null;
 
-                       if (!sdk_directory.TryGetValue (sdk_version, out sdk_sub_dirs))
-                               sdk_sub_dirs = new string[] { sdk_version };
+                               string sdk_version = compiler.Settings.SdkVersion ?? "4.5";
+                               string[] sdk_sub_dirs;
 
-                       foreach (var dir in sdk_sub_dirs) {
-                               sdk_path = Path.Combine (fx_path, dir);
-                               if (File.Exists (Path.Combine (sdk_path, "mscorlib.dll")))
-                                       break;
+                               if (!sdk_directory.TryGetValue (sdk_version, out sdk_sub_dirs))
+                                       sdk_sub_dirs = new string[] { sdk_version };
 
-                               sdk_path = null;
-                       }
+                               foreach (var dir in sdk_sub_dirs) {
+                                       sdk_path = Path.Combine (fx_path, dir);
+                                       if (File.Exists (Path.Combine (sdk_path, "mscorlib.dll")))
+                                               break;
 
-                       if (sdk_path == null) {
-                               compiler.Report.Warning (-1, 1, "SDK path could not be resolved");
-                               sdk_path = corlib_path;
-                       }
+                                       sdk_path = null;
+                               }
 
-                       paths.Add (sdk_path);
+                               if (sdk_path == null) {
+                                       compiler.Report.Warning (-1, 1, "SDK path could not be resolved");
+                                       sdk_path = corlib_path;
+                               }
+
+                               paths.Add (sdk_path);
+                       }
                }
 
                #region Properties
@@ -366,7 +366,7 @@ namespace Mono.CSharp
 
                public override bool HasObjectType (Assembly assembly)
                {
-                       return assembly.GetType (compiler.BuildinTypes.Object.FullName) != null;
+                       return assembly.GetType (compiler.BuiltinTypes.Object.FullName) != null;
                }
 
                public override Assembly LoadAssemblyFile (string fileName)
@@ -516,7 +516,7 @@ namespace Mono.CSharp
                                // System.Object was not found in any referenced assembly, use compiled assembly as corlib
                                corlib = module.DeclaringAssembly.Builder;
                        } else {
-                               importer.InitializeBuildinTypes (compiler.BuildinTypes, corlib);
+                               importer.InitializeBuiltinTypes (compiler.BuiltinTypes, corlib);
                                importer.ImportAssembly (corlib, module.GlobalRootNamespace);
                        }
 
@@ -535,7 +535,7 @@ namespace Mono.CSharp
                                        continue;
 
                                if (m.IsManifestModule) {
-                                       Error_FileCorrupted (moduleName);
+                                       Error_ModuleIsAssembly (moduleName);
                                        continue;
                                }