[svn] r5902: nemerle/trunk/ncc: external/InternalTypes.n generation/HierarchyEmitter.n hierarchy/CustomAtt...

nazgul svnadmin at nemerle.org
Sun Nov 6 17:21:49 CET 2005


Log:
Emit Debuggable and other attributes, just like csc

Author: nazgul
Date: Sun Nov  6 17:21:37 2005
New Revision: 5902

Modified:
   nemerle/trunk/ncc/external/InternalTypes.n
   nemerle/trunk/ncc/generation/HierarchyEmitter.n
   nemerle/trunk/ncc/hierarchy/CustomAttribute.n

Modified: nemerle/trunk/ncc/external/InternalTypes.n
==============================================================================
--- nemerle/trunk/ncc/external/InternalTypes.n	(original)
+++ nemerle/trunk/ncc/external/InternalTypes.n	Sun Nov  6 17:21:37 2005
@@ -57,6 +57,9 @@
   public mutable Reflection_PropertyInfo : System.Type;
   public mutable Reflection_DefaultMemberAttribute : System.Type;
   public mutable Runtime_CompilerServices_IsVolatile : System.Type;
+  public mutable DebuggableAttribute : System.Type;
+  public mutable DebuggableAttribute_DebuggingModes : System.Type;
+  public mutable CompilationRelaxationsAttribute : System.Type;
   public mutable SByte : System.Type;
   public mutable Single : System.Type;
   public mutable String : System.Type;
@@ -165,6 +168,9 @@
     Reflection_PropertyInfo = Reflect ("System.Reflection.PropertyInfo");
     Reflection_AssemblyConfigurationAttribute = Reflect ("System.Reflection.AssemblyConfigurationAttribute");
     Runtime_CompilerServices_IsVolatile = Reflect ("System.Runtime.CompilerServices.IsVolatile");
+    DebuggableAttribute = Reflect ("System.Diagnostics.DebuggableAttribute");
+    DebuggableAttribute_DebuggingModes = Reflect ("System.Diagnostics.DebuggableAttribute.DebuggingModes");
+    CompilationRelaxationsAttribute = Reflect ("System.Runtime.CompilerServices.CompilationRelaxationsAttribute");
     SByte = Reflect ("System.SByte");
     Single = Reflect ("System.Single");
     String = Reflect ("System.String");

Modified: nemerle/trunk/ncc/generation/HierarchyEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/HierarchyEmitter.n	(original)
+++ nemerle/trunk/ncc/generation/HierarchyEmitter.n	Sun Nov  6 17:21:37 2005
@@ -33,6 +33,7 @@
 using System.Reflection;
 using System.IO;
 using System.Diagnostics.SymbolStore;
+using System.Diagnostics;
 
 using NC = Nemerle.Compiler;
 using SRE = System.Reflection.Emit;
@@ -186,6 +187,21 @@
         compile_all_tyinfos (false);
         foreach (x in AttributeCompiler.GetCompiledAssemblyAttributes ())
           _assembly_builder.SetCustomAttribute (x);
+          
+        // emit debug attributes
+        when (Options.EmitDebug) {
+          def attr = AttributeCompiler.MakeEmittedAttribute (SystemType.DebuggableAttribute, array [SystemType.DebuggableAttribute_DebuggingModes], 
+            DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.Default);
+          _assembly_builder.SetCustomAttribute (attr);
+        }
+
+        // do not require string literals interning
+        def attr = AttributeCompiler.MakeEmittedAttribute (SystemType.CompilationRelaxationsAttribute, 8);
+        _assembly_builder.SetCustomAttribute (attr);
+        
+        // wrap non exception throws
+        def (_, attr) = AttributeCompiler.CompileAttribute (GlobalEnv.Core, null, <[ System.Runtime.CompilerServices.RuntimeCompatibilityAttribute (WrapNonExceptionThrows=true) ]>);
+        _assembly_builder.SetCustomAttribute (attr);
       })
     }
 
@@ -207,8 +223,7 @@
 
       // if there are some nemerle specific metadata encoded in attributes
       when (contains_nemerle_specifics) {
-        def attr = make_string_attribute (SystemType.Reflection_AssemblyConfigurationAttribute,
-                                          "ContainsNemerleTypes");
+        def attr = AttributeCompiler.MakeEmittedAttribute (SystemType.Reflection_AssemblyConfigurationAttribute, "ContainsNemerleTypes");
         this._assembly_builder.SetCustomAttribute (attr);
       }
           
@@ -262,8 +277,7 @@
           //Message.Debug ("make type builder for " + ti.FullName);
           ti.CreateEmitBuilder ();
           when (ti.Attributes %&& NemerleAttributes.Macro) {
-            def attr = make_string_attribute (SystemType.ContainsMacroAttribute,
-                                              ti.GetTypeBuilder ().FullName);
+            def attr = AttributeCompiler.MakeEmittedAttribute (SystemType.ContainsMacroAttribute, ti.GetTypeBuilder ().FullName);
             _assembly_builder.SetCustomAttribute (attr);
           }
         }
@@ -349,24 +363,6 @@
       ti.FullName.StartsWith ("Nemerle.Internal.")
     }
 
-
-    internal static make_string_attribute (attr_type : System.Type, value : string) : Emit.CustomAttributeBuilder
-    {
-      def constructor_param_types = array [SystemType.String];
-      def constructor_info = attr_type.GetConstructor (constructor_param_types);
-      assert (constructor_info != null);
-      def constructor_params = array [(value : object)];
-      Emit.CustomAttributeBuilder (constructor_info, constructor_params)
-    }
-
-
-    internal static make_void_attribute (attr_type : System.Type) : Emit.CustomAttributeBuilder
-    {
-      def constructor_info = attr_type.GetConstructor (System.Type.EmptyTypes);
-      Emit.CustomAttributeBuilder (constructor_info, array [])
-    }
-
-
     /* -- PRIVATE FIELDS --------------------------------------------------- */
 
     private mutable _assembly_name : System.Reflection.AssemblyName;
@@ -482,7 +478,7 @@
     private static make_nemerle_variant_attribute (decls : list [TypeInfo]) : Emit.CustomAttributeBuilder
     {
       def names = decls.Map (fun (decl) { decl.FullName });
-      TypesManager.make_string_attribute (SystemType.VariantAttribute, NString.Concat (",", names))
+      AttributeCompiler.MakeEmittedAttribute (SystemType.VariantAttribute, NString.Concat (",", names))
     }
 
 
@@ -491,7 +487,7 @@
      */
     private static make_nemerle_type_alias_attribute (t : MType) : Emit.CustomAttributeBuilder
     {
-      TypesManager.make_string_attribute (SystemType.TypeAliasAttribute, TyCodec.EncodeType (t))
+      AttributeCompiler.MakeEmittedAttribute (SystemType.TypeAliasAttribute, TyCodec.EncodeType (t))
     }
 
 
@@ -500,7 +496,7 @@
      */
     private static make_nemerle_variant_option_attribute (is_const : bool) : Emit.CustomAttributeBuilder
     {
-      TypesManager.make_void_attribute (if (is_const)
+      AttributeCompiler.MakeEmittedAttribute (if (is_const)
                              SystemType.ConstantVariantOptionAttribute
                            else
                              SystemType.VariantOptionAttribute)
@@ -1027,9 +1023,7 @@
       
       when (IsVolatile)
       {
-        def volatile_attr =
-          TypesManager.make_void_attribute (SystemType.VolatileModifier);
-
+        def volatile_attr = AttributeCompiler.MakeEmittedAttribute (SystemType.VolatileModifier);
         field_builder.SetCustomAttribute (volatile_attr)
       }
     }

Modified: nemerle/trunk/ncc/hierarchy/CustomAttribute.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/CustomAttribute.n	(original)
+++ nemerle/trunk/ncc/hierarchy/CustomAttribute.n	Sun Nov  6 17:21:37 2005
@@ -323,6 +323,31 @@
       assembly_macros += macro_attrs;
     }
     
+    internal MakeEmittedAttribute (attr_type : System.Type, value : string) : SR.Emit.CustomAttributeBuilder
+    {
+      MakeEmittedAttribute (attr_type, array [SystemType.String], value);
+    }
+
+    internal MakeEmittedAttribute (attr_type : System.Type) : SR.Emit.CustomAttributeBuilder
+    {
+      def constructor_info = attr_type.GetConstructor (System.Type.EmptyTypes);
+      SR.Emit.CustomAttributeBuilder (constructor_info, array [])
+    }
+
+    internal MakeEmittedAttribute (attr_type : System.Type, value : int) : SR.Emit.CustomAttributeBuilder
+    {
+      MakeEmittedAttribute (attr_type, array [SystemType.Int32], value);
+    }
+
+    internal MakeEmittedAttribute (attr_type : System.Type, param_types : array [System.Type], value : object) : SR.Emit.CustomAttributeBuilder
+    {
+      def constructor_info = attr_type.GetConstructor (param_types);
+      assert (constructor_info != null);
+      def constructor_params = array [value];
+      SR.Emit.CustomAttributeBuilder (constructor_info, constructor_params)
+    }
+    
+        
     public CreateAssemblyName () : SR.AssemblyName
     {
       /* create an assembly name and set its properties according to defined



More information about the svn mailing list