[ilasm] Adds noautoinherit option
authorMarek Safar <marek.safar@gmail.com>
Tue, 29 Aug 2017 14:23:00 +0000 (16:23 +0200)
committerMarek Safar <marek.safar@gmail.com>
Tue, 29 Aug 2017 17:51:08 +0000 (19:51 +0200)
mcs/ilasm/Driver.cs
mcs/ilasm/codegen/CodeGen.cs
mcs/ilasm/codegen/TypeDef.cs
mcs/ilasm/ilasm.csproj

index af7120dce5878fc481227faf290c186e52eb5662..fc2e213bc8730dfb332386dbb5b7447eab669dac 100644 (file)
@@ -53,6 +53,7 @@ namespace Mono.ILASM {
                        private bool keycontainer = false;
                        private string keyname;
                        private StrongName sn;
+                        bool noautoinherit;
 
                         public DriverMain (string[] args)
                         {
@@ -67,7 +68,7 @@ namespace Mono.ILASM {
                                 if (output_file == null)
                                         output_file = CreateOutputFilename ();
                                 try {
-                                        codegen = new CodeGen (output_file, target == Target.Dll, debugging_info);
+                                        codegen = new CodeGen (output_file, target == Target.Dll, debugging_info, noautoinherit);
                                         foreach (string file_path in il_file_list) {
                                                 Report.FilePath = file_path;
                                                 ProcessFile (file_path);
@@ -270,6 +271,9 @@ namespace Mono.ILASM {
                                                else
                                                        keyname = command_arg;
                                                break;
+                                        case "noautoinherit":
+                                                noautoinherit = true;
+                                                break;
                                         case "scan_only":
                                                 scan_only = true;
                                                 break;
@@ -336,16 +340,17 @@ namespace Mono.ILASM {
 
                         private void Usage ()
                         {
-                                Console.WriteLine ("Mono ILasm compiler\n" +
+                                Console.WriteLine ("Mono IL assembler compiler\n" +
                                         "ilasm [options] source-files\n" +
-                                        "   --about            About the Mono ILasm compiler\n" +
-                                        "   --version          Print the version number of the Mono ILasm compiler\n" +
+                                        "   --about            About the Mono IL assembler compiler\n" +
+                                        "   --version          Print the version number of the compiler\n" +
                                         "   /output:file_name  Specifies output file.\n" +
                                         "   /exe               Compile to executable.\n" +
                                         "   /dll               Compile to library.\n" +
                                         "   /debug             Include debug information.\n" +
                                        "   /key:keyfile       Strongname using the specified key file\n" +
                                        "   /key:@container    Strongname using the specified key container\n" +
+                                        "   /noautoinherit     Disable inheriting from System.Object by default\n" +
                                         "Options can be of the form -option or /option\n");
                                 Environment.Exit (1);
                         }
@@ -361,7 +366,7 @@ namespace Mono.ILASM {
                         private void Version ()
                         {
                                 string version = System.Reflection.Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
-                                Console.WriteLine ("Mono ILasm compiler version {0}", version);
+                                Console.WriteLine ("Mono IL assembler compiler version {0}", version);
                                 Environment.Exit (0);
                         }
 
index 6b9aadfc80ecd363d6e14baea059ba95c60e5d29..1d9ebe4b1ccee3a9220bdbe91356b2f89ee19096 100644 (file)
@@ -63,14 +63,16 @@ namespace Mono.ILASM {
                 private string output_file;\r
                 private bool is_dll;\r
                 private bool entry_point;\r
+                bool noautoinherit;\r
 \r
                 private Module this_module;\r
 \r
-                public CodeGen (string output_file, bool is_dll, bool debugging_info)\r
+                public CodeGen (string output_file, bool is_dll, bool debugging_info, bool noautoinherit)\r
                 {\r
                         this.output_file = output_file;\r
                         this.is_dll = is_dll;\r
-\r
+                        this.noautoinherit = noautoinherit;\r
+                        \r
                        if (debugging_info)\r
                                symwriter = new SymbolWriter (output_file);\r
 \r
@@ -313,7 +315,7 @@ namespace Mono.ILASM {
 \r
                         typedef = new TypeDef (attr, current_namespace,\r
                                         name, parent, impl_list, location, gen_params, outer);\r
-\r
+                        typedef.NoAutoInherit = noautoinherit && parent == null;\r
                         type_manager[cache_name] = typedef;\r
                         current_customattrtarget = current_typedef = typedef;\r
                         current_declsectarget = typedef;\r
index 74200cddf49e06d741e1bfdce3d04f019c0bb672..f35dca0bd4a4216d1a8a9f7cdca45ec62799c43c 100644 (file)
@@ -93,6 +93,8 @@ namespace Mono.ILASM {
                                 this.attr |= PEAPI.TypeAttr.Abstract;
                 }
 
+                               public bool NoAutoInherit { get; set; }
+
                 public string Name {
                         get { return name; }
                 }
@@ -389,7 +391,7 @@ namespace Mono.ILASM {
                                                         name_space, name);
                                         }
                                 }
-                                if (FullName == "System.Object")
+                                if (FullName == "System.Object" || NoAutoInherit)
                                         classdef.SpecialNoSuper ();
                         }
 
index 4c2a6cfd26dc4514426999c3eab5507d3d4ee9e5..a72cd9f0060d791b234405c2fefc8ba8b80e6b9e 100644 (file)
@@ -35,7 +35,7 @@
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="PEAPI">
-      <HintPath>..\class\lib\net_4_5\PEAPI.dll</HintPath>
+      <HintPath>..\class\lib\net_4_x\PEAPI.dll</HintPath>
     </Reference>
     <Reference Include="Mono.CompilerServices.SymbolWriter" />
     <Reference Include="Mono.Security" />