2 // codegen.cs: The code generator
5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) 2001 Ximian, Inc.
12 using System.Collections;
13 using System.Reflection;
14 using System.Reflection.Emit;
15 using System.Runtime.InteropServices;
16 using System.Security.Cryptography;
18 using Mono.Security.Cryptography;
20 namespace Mono.CSharp {
23 /// Code generator class.
25 public class CodeGen {
26 static AppDomain current_domain;
27 static public SymbolWriter SymbolWriter;
29 public static AssemblyClass Assembly;
30 public static ModuleClass Module;
34 Assembly = new AssemblyClass ();
35 Module = new ModuleClass (RootContext.Unsafe);
38 public static string Basename (string name)
40 int pos = name.LastIndexOf ('/');
43 return name.Substring (pos + 1);
45 pos = name.LastIndexOf ('\\');
47 return name.Substring (pos + 1);
52 public static string Dirname (string name)
54 int pos = name.LastIndexOf ('/');
57 return name.Substring (0, pos);
59 pos = name.LastIndexOf ('\\');
61 return name.Substring (0, pos);
66 static string TrimExt (string name)
68 int pos = name.LastIndexOf ('.');
70 return name.Substring (0, pos);
73 static public string FileName;
76 // Initializes the symbol writer
78 static void InitializeSymbolWriter ()
80 SymbolWriter = SymbolWriter.GetSymbolWriter (Module.Builder);
83 // If we got an ISymbolWriter instance, initialize it.
85 if (SymbolWriter == null) {
87 -18, "Could not find the symbol writer assembly (Mono.CSharp.Debugger.dll). This is normally an installation problem. Please make sure to compile and install the mcs/class/Mono.CSharp.Debugger directory.");
93 // Initializes the code generator variables
95 static public void Init (string name, string output, bool want_debugging_support)
98 AssemblyName an = Assembly.GetAssemblyName (name, output);
100 if (an.KeyPair != null) {
101 // If we are going to strong name our assembly make
102 // sure all its refs are strong named
103 foreach (Assembly a in TypeManager.GetAssemblies ()) {
104 AssemblyName ref_name = a.GetName ();
105 byte [] b = ref_name.GetPublicKeyToken ();
106 if (b == null || b.Length == 0) {
107 Report.Warning (1577, "Assembly generation failed " +
108 "-- Referenced assembly '" +
110 "' does not have a strong name.");
111 //Environment.Exit (1);
116 current_domain = AppDomain.CurrentDomain;
119 Assembly.Builder = current_domain.DefineDynamicAssembly (an,
120 AssemblyBuilderAccess.Save, Dirname (name));
122 catch (ArgumentException) {
123 // specified key may not be exportable outside it's container
124 if (RootContext.StrongNameKeyContainer != null) {
125 Report.Error (1548, "Could not access the key inside the container `" +
126 RootContext.StrongNameKeyContainer + "'.");
127 Environment.Exit (1);
131 catch (CryptographicException) {
132 if ((RootContext.StrongNameKeyContainer != null) || (RootContext.StrongNameKeyFile != null)) {
133 Report.Error (1548, "Could not use the specified key to strongname the assembly.");
134 Environment.Exit (1);
140 // Pass a path-less name to DefineDynamicModule. Wonder how
141 // this copes with output in different directories then.
142 // FIXME: figure out how this copes with --output /tmp/blah
144 // If the third argument is true, the ModuleBuilder will dynamically
145 // load the default symbol writer.
147 Module.Builder = Assembly.Builder.DefineDynamicModule (
148 Basename (name), Basename (output), want_debugging_support);
150 if (want_debugging_support)
151 InitializeSymbolWriter ();
154 static public void Save (string name)
157 Assembly.Builder.Save (Basename (name));
159 catch (COMException) {
160 if ((RootContext.StrongNameKeyFile == null) || (!RootContext.StrongNameDelaySign))
163 // FIXME: it seems Microsoft AssemblyBuilder doesn't like to delay sign assemblies
164 Report.Error (1548, "Couldn't delay-sign the assembly with the '" +
165 RootContext.StrongNameKeyFile +
166 "', Use MCS with the Mono runtime or CSC to compile this assembly.");
168 catch (System.IO.IOException io) {
169 Report.Error (16, "Could not write to file `"+name+"', cause: " + io.Message);
175 // Provides "local" store across code that can yield: locals
176 // or fields, notice that this should not be used by anonymous
177 // methods to create local storage, those only require
180 public class VariableStorage {
187 public VariableStorage (EmitContext ec, Type t)
191 fb = IteratorHandler.Current.MapVariable ("s_", count.ToString (), t);
193 local = ec.ig.DeclareLocal (t);
197 public void EmitThis ()
200 ig.Emit (OpCodes.Ldarg_0);
203 public void EmitStore ()
206 ig.Emit (OpCodes.Stloc, local);
208 ig.Emit (OpCodes.Stfld, fb);
211 public void EmitLoad ()
214 ig.Emit (OpCodes.Ldloc, local);
216 ig.Emit (OpCodes.Ldfld, fb);
219 public void EmitCall (MethodInfo mi)
221 // FIXME : we should handle a call like tostring
222 // here, where boxing is needed. However, we will
223 // never encounter that with the current usage.
225 bool value_type_call;
228 value_type_call = local.LocalType.IsValueType;
231 ig.Emit (OpCodes.Ldloca, local);
233 ig.Emit (OpCodes.Ldloc, local);
235 value_type_call = fb.FieldType.IsValueType;
238 ig.Emit (OpCodes.Ldflda, fb);
240 ig.Emit (OpCodes.Ldfld, fb);
243 ig.Emit (value_type_call ? OpCodes.Call : OpCodes.Callvirt, mi);
248 /// An Emit Context is created for each body of code (from methods,
249 /// properties bodies, indexer bodies or constructor bodies)
251 public class EmitContext {
252 public DeclSpace DeclSpace;
253 public DeclSpace TypeContainer;
254 public ILGenerator ig;
257 /// This variable tracks the `checked' state of the compilation,
258 /// it controls whether we should generate code that does overflow
259 /// checking, or if we generate code that ignores overflows.
261 /// The default setting comes from the command line option to generate
262 /// checked or unchecked code plus any source code changes using the
263 /// checked/unchecked statements or expressions. Contrast this with
264 /// the ConstantCheckState flag.
267 public bool CheckState;
270 /// The constant check state is always set to `true' and cant be changed
271 /// from the command line. The source code can change this setting with
272 /// the `checked' and `unchecked' statements and expressions.
274 public bool ConstantCheckState;
277 /// Whether we are emitting code inside a static or instance method
279 public bool IsStatic;
282 /// Whether we are emitting a field initializer
284 public bool IsFieldInitializer;
287 /// The value that is allowed to be returned or NULL if there is no
290 public Type ReturnType;
293 /// Points to the Type (extracted from the TypeContainer) that
294 /// declares this body of code
296 public Type ContainerType;
299 /// Whether this is generating code for a constructor
301 public bool IsConstructor;
304 /// Whether we're control flow analysis enabled
306 public bool DoFlowAnalysis;
309 /// Keeps track of the Type to LocalBuilder temporary storage created
310 /// to store structures (used to compute the address of the structure
311 /// value on structure method invocations)
313 public Hashtable temporary_storage;
315 public Block CurrentBlock;
317 public int CurrentFile;
320 /// The location where we store the return value.
322 LocalBuilder return_value;
325 /// The location where return has to jump to return the
328 public Label ReturnLabel;
331 /// If we already defined the ReturnLabel
333 public bool HasReturnLabel;
336 /// Whether we are inside an iterator block.
338 public bool InIterator;
340 public bool IsLastStatement;
343 /// Whether remapping of locals, parameters and fields is turned on.
344 /// Used by iterators and anonymous methods.
346 public bool RemapToProxy;
349 /// Whether we are inside an unsafe block
351 public bool InUnsafe;
354 /// Whether we are in a `fixed' initialization
356 public bool InFixedInitializer;
359 /// Whether we are inside an anonymous method.
361 public bool InAnonymousMethod;
364 /// Location for this EmitContext
369 /// Used to flag that it is ok to define types recursively, as the
370 /// expressions are being evaluated as part of the type lookup
371 /// during the type resolution process
373 public bool ResolvingTypeTree;
376 /// Inside an enum definition, we do not resolve enumeration values
377 /// to their enumerations, but rather to the underlying type/value
378 /// This is so EnumVal + EnumValB can be evaluated.
380 /// There is no "E operator + (E x, E y)", so during an enum evaluation
381 /// we relax the rules
383 public bool InEnumContext;
385 FlowBranching current_flow_branching;
387 public EmitContext (DeclSpace parent, DeclSpace ds, Location l, ILGenerator ig,
388 Type return_type, int code_flags, bool is_constructor)
392 TypeContainer = parent;
394 CheckState = RootContext.Checked;
395 ConstantCheckState = true;
397 IsStatic = (code_flags & Modifiers.STATIC) != 0;
398 InIterator = (code_flags & Modifiers.METHOD_YIELDS) != 0;
399 RemapToProxy = InIterator;
400 ReturnType = return_type;
401 IsConstructor = is_constructor;
406 // Can only be null for the ResolveType contexts.
407 ContainerType = parent.TypeBuilder;
408 if (parent.UnsafeContext)
411 InUnsafe = (code_flags & Modifiers.UNSAFE) != 0;
415 if (ReturnType == TypeManager.void_type)
419 public EmitContext (TypeContainer tc, Location l, ILGenerator ig,
420 Type return_type, int code_flags, bool is_constructor)
421 : this (tc, tc, l, ig, return_type, code_flags, is_constructor)
425 public EmitContext (TypeContainer tc, Location l, ILGenerator ig,
426 Type return_type, int code_flags)
427 : this (tc, tc, l, ig, return_type, code_flags, false)
431 public FlowBranching CurrentBranching {
433 return current_flow_branching;
438 // Starts a new code branching. This inherits the state of all local
439 // variables and parameters from the current branching.
441 public FlowBranching StartFlowBranching (FlowBranching.BranchingType type, Location loc)
443 current_flow_branching = FlowBranching.CreateBranching (CurrentBranching, type, null, loc);
444 return current_flow_branching;
448 // Starts a new code branching for block `block'.
450 public FlowBranching StartFlowBranching (Block block)
452 FlowBranching.BranchingType type;
454 if (CurrentBranching.Type == FlowBranching.BranchingType.Switch)
455 type = FlowBranching.BranchingType.SwitchSection;
457 type = FlowBranching.BranchingType.Block;
459 current_flow_branching = FlowBranching.CreateBranching (CurrentBranching, type, block, block.StartLocation);
460 return current_flow_branching;
464 // Ends a code branching. Merges the state of locals and parameters
465 // from all the children of the ending branching.
467 public FlowBranching.UsageVector DoEndFlowBranching ()
469 FlowBranching old = current_flow_branching;
470 current_flow_branching = current_flow_branching.Parent;
472 return current_flow_branching.MergeChild (old);
476 // Ends a code branching. Merges the state of locals and parameters
477 // from all the children of the ending branching.
479 public FlowBranching.Reachability EndFlowBranching ()
481 FlowBranching.UsageVector vector = DoEndFlowBranching ();
483 return vector.Reachability;
487 // Kills the current code branching. This throws away any changed state
488 // information and should only be used in case of an error.
490 public void KillFlowBranching ()
492 current_flow_branching = current_flow_branching.Parent;
495 public void EmitTopBlock (Block block, InternalParameters ip, Location loc)
497 bool unreachable = false;
499 if (!Location.IsNull (loc))
500 CurrentFile = loc.File;
504 int errors = Report.Errors;
506 block.EmitMeta (this, ip);
508 if (Report.Errors == errors){
509 bool old_do_flow_analysis = DoFlowAnalysis;
510 DoFlowAnalysis = true;
512 current_flow_branching = FlowBranching.CreateBranching (
513 null, FlowBranching.BranchingType.Block, block, loc);
515 if (!block.Resolve (this)) {
516 current_flow_branching = null;
517 DoFlowAnalysis = old_do_flow_analysis;
521 FlowBranching.Reachability reachability = current_flow_branching.MergeTopBlock ();
522 current_flow_branching = null;
524 DoFlowAnalysis = old_do_flow_analysis;
528 if (reachability.AlwaysReturns ||
529 reachability.AlwaysThrows ||
530 reachability.IsUnreachable)
534 } catch (Exception e) {
535 Console.WriteLine ("Exception caught by the compiler while compiling:");
536 Console.WriteLine (" Block that caused the problem begin at: " + loc);
538 if (CurrentBlock != null){
539 Console.WriteLine (" Block being compiled: [{0},{1}]",
540 CurrentBlock.StartLocation, CurrentBlock.EndLocation);
542 Console.WriteLine (e.GetType ().FullName + ": " + e.Message);
543 Console.WriteLine (Report.FriendlyStackTrace (e));
545 Environment.Exit (1);
552 if (ReturnType != null && !unreachable){
554 Report.Error (161, loc, "Not all code paths return a value");
560 ig.MarkLabel (ReturnLabel);
561 if (return_value != null){
562 ig.Emit (OpCodes.Ldloc, return_value);
563 ig.Emit (OpCodes.Ret);
566 // If `HasReturnLabel' is set, then we already emitted a
567 // jump to the end of the method, so we must emit a `ret'
570 // Unfortunately, System.Reflection.Emit automatically emits
571 // a leave to the end of a finally block. This is a problem
572 // if no code is following the try/finally block since we may
573 // jump to a point after the end of the method.
574 // As a workaround, we're always creating a return label in
578 if ((block != null) && block.IsDestructor) {
579 // Nothing to do; S.R.E automatically emits a leave.
580 } else if (HasReturnLabel || (!unreachable && !InIterator)) {
581 if (ReturnType != null)
582 ig.Emit (OpCodes.Ldloc, TemporaryReturn ());
583 ig.Emit (OpCodes.Ret);
589 /// This is called immediately before emitting an IL opcode to tell the symbol
590 /// writer to which source line this opcode belongs.
592 public void Mark (Location loc, bool check_file)
594 if ((CodeGen.SymbolWriter == null) || Location.IsNull (loc))
597 if (check_file && (CurrentFile != loc.File))
600 ig.MarkSequencePoint (null, loc.Row, 0, 0, 0);
604 /// Returns a temporary storage for a variable of type t as
605 /// a local variable in the current body.
607 public LocalBuilder GetTemporaryLocal (Type t)
609 LocalBuilder location = null;
611 if (temporary_storage != null){
612 object o = temporary_storage [t];
615 ArrayList al = (ArrayList) o;
617 for (int i = 0; i < al.Count; i++){
619 location = (LocalBuilder) al [i];
625 location = (LocalBuilder) o;
626 if (location != null)
631 return ig.DeclareLocal (t);
634 public void FreeTemporaryLocal (LocalBuilder b, Type t)
636 if (temporary_storage == null){
637 temporary_storage = new Hashtable ();
638 temporary_storage [t] = b;
641 object o = temporary_storage [t];
643 temporary_storage [t] = b;
647 ArrayList al = (ArrayList) o;
648 for (int i = 0; i < al.Count; i++){
657 ArrayList replacement = new ArrayList ();
659 temporary_storage.Remove (t);
660 temporary_storage [t] = replacement;
664 /// Current loop begin and end labels.
666 public Label LoopBegin, LoopEnd;
669 /// Default target in a switch statement. Only valid if
672 public Label DefaultTarget;
675 /// If this is non-null, points to the current switch statement
677 public Switch Switch;
680 /// ReturnValue creates on demand the LocalBuilder for the
681 /// return value from the function. By default this is not
682 /// used. This is only required when returns are found inside
683 /// Try or Catch statements.
685 public LocalBuilder TemporaryReturn ()
687 if (return_value == null){
688 return_value = ig.DeclareLocal (ReturnType);
689 ReturnLabel = ig.DefineLabel ();
690 HasReturnLabel = true;
696 public void NeedReturnLabel ()
698 if (!HasReturnLabel) {
699 ReturnLabel = ig.DefineLabel ();
700 HasReturnLabel = true;
705 // Creates a field `name' with the type `t' on the proxy class
707 public FieldBuilder MapVariable (string name, Type t)
710 return IteratorHandler.Current.MapVariable ("v_", name, t);
713 throw new Exception ("MapVariable for an unknown state");
717 // Invoke this routine to remap a VariableInfo into the
718 // proper MemberAccess expression
720 public Expression RemapLocal (LocalInfo local_info)
722 FieldExpr fe = new FieldExpr (local_info.FieldBuilder, loc);
723 fe.InstanceExpression = new ProxyInstance ();
724 return fe.DoResolve (this);
727 public Expression RemapLocalLValue (LocalInfo local_info, Expression right_side)
729 FieldExpr fe = new FieldExpr (local_info.FieldBuilder, loc);
730 fe.InstanceExpression = new ProxyInstance ();
731 return fe.DoResolveLValue (this, right_side);
734 public Expression RemapParameter (int idx)
736 FieldExpr fe = new FieldExprNoAddress (IteratorHandler.Current.parameter_fields [idx], loc);
737 fe.InstanceExpression = new ProxyInstance ();
738 return fe.DoResolve (this);
741 public Expression RemapParameterLValue (int idx, Expression right_side)
743 FieldExpr fe = new FieldExprNoAddress (IteratorHandler.Current.parameter_fields [idx], loc);
744 fe.InstanceExpression = new ProxyInstance ();
745 return fe.DoResolveLValue (this, right_side);
749 // Emits the proper object to address fields on a remapped
750 // variable/parameter to field in anonymous-method/iterator proxy classes.
752 public void EmitThis ()
755 ig.Emit (OpCodes.Ldarg_0);
757 FieldBuilder this_field = IteratorHandler.Current.this_field;
758 if (TypeManager.IsValueType (this_field.FieldType))
759 ig.Emit (OpCodes.Ldflda, this_field);
761 ig.Emit (OpCodes.Ldfld, this_field);
764 ig.Emit (OpCodes.Ldarg_0);
767 public Expression GetThis (Location loc)
770 if (CurrentBlock != null)
771 my_this = new This (CurrentBlock, loc);
773 my_this = new This (loc);
775 if (!my_this.ResolveBase (this))
783 public abstract class CommonAssemblyModulClass: Attributable {
784 static string[] attribute_targets = new string [] { "assembly", "module" };
786 protected CommonAssemblyModulClass ():
791 public void AddAttributes (ArrayList attrs)
793 if (OptAttributes == null) {
794 OptAttributes = new Attributes (attrs);
797 OptAttributes.AddAttributes (attrs);
798 OptAttributes.CheckTargets (ValidAttributeTargets);
801 public virtual void Emit (TypeContainer tc)
803 if (OptAttributes == null)
806 EmitContext ec = new EmitContext (tc, Mono.CSharp.Location.Null, null, null, 0, false);
807 OptAttributes.Emit (ec, this);
810 protected Attribute GetClsCompliantAttribute ()
812 if (OptAttributes == null)
815 EmitContext temp_ec = new EmitContext (new TypeContainer (), Mono.CSharp.Location.Null, null, null, 0, false);
816 Attribute a = OptAttributes.Search (TypeManager.cls_compliant_attribute_type, temp_ec);
823 protected override string[] ValidAttributeTargets {
825 return attribute_targets;
830 public class AssemblyClass: CommonAssemblyModulClass {
831 // TODO: make it private and move all builder based methods here
832 public AssemblyBuilder Builder;
834 bool is_cls_compliant;
836 public AssemblyClass (): base ()
838 is_cls_compliant = false;
841 public bool IsClsCompliant {
843 return is_cls_compliant;
847 public override AttributeTargets AttributeTargets {
849 return AttributeTargets.Assembly;
853 public override bool IsClsCompliaceRequired(DeclSpace ds)
855 return is_cls_compliant;
858 public void ResolveClsCompliance ()
860 Attribute a = GetClsCompliantAttribute ();
864 is_cls_compliant = a.GetClsCompliantAttributeValue (null);
867 public AssemblyName GetAssemblyName (string name, string output)
869 if (OptAttributes != null) {
870 foreach (Attribute a in OptAttributes.Attrs) {
871 if (a.Target != "assembly")
873 // TODO: This code is buggy: comparing Attribute name without resolving it is wrong.
874 // However, this is invoked by CodeGen.Init, at which time none of the namespaces
877 case "AssemblyKeyFile":
878 case "AssemblyKeyFileAttribute":
879 case "System.Reflection.AssemblyKeyFileAttribute":
880 if (RootContext.StrongNameKeyFile != null) {
881 Report.Warning (1616, "Compiler option -keyfile overrides " +
882 "AssemblyKeyFileAttribute");
885 string value = a.GetString ();
886 if (value != String.Empty)
887 RootContext.StrongNameKeyFile = value;
890 case "AssemblyKeyName":
891 case "AssemblyKeyNameAttribute":
892 case "System.Reflection.AssemblyKeyNameAttribute":
893 if (RootContext.StrongNameKeyContainer != null) {
894 Report.Warning (1616, "Compiler option -keycontainer overrides " +
895 "AssemblyKeyNameAttribute");
898 string value = a.GetString ();
899 if (value != String.Empty)
900 RootContext.StrongNameKeyContainer = value;
903 case "AssemblyDelaySign":
904 case "AssemblyDelaySignAttribute":
905 case "System.Reflection.AssemblyDelaySignAttribute":
906 RootContext.StrongNameDelaySign = a.GetBoolean ();
912 AssemblyName an = new AssemblyName ();
913 an.Name = Path.GetFileNameWithoutExtension (name);
915 // note: delay doesn't apply when using a key container
916 if (RootContext.StrongNameKeyContainer != null) {
917 an.KeyPair = new StrongNameKeyPair (RootContext.StrongNameKeyContainer);
921 // strongname is optional
922 if (RootContext.StrongNameKeyFile == null)
925 string AssemblyDir = Path.GetDirectoryName (output);
927 // the StrongName key file may be relative to (a) the compiled
928 // file or (b) to the output assembly. See bugzilla #55320
929 // http://bugzilla.ximian.com/show_bug.cgi?id=55320
931 // (a) relative to the compiled file
932 string filename = Path.GetFullPath (RootContext.StrongNameKeyFile);
933 bool exist = File.Exists (filename);
934 if ((!exist) && (AssemblyDir != null) && (AssemblyDir != String.Empty)) {
935 // (b) relative to the outputed assembly
936 filename = Path.GetFullPath (Path.Combine (AssemblyDir, RootContext.StrongNameKeyFile));
937 exist = File.Exists (filename);
941 using (FileStream fs = new FileStream (filename, FileMode.Open, FileAccess.Read)) {
942 byte[] snkeypair = new byte [fs.Length];
943 fs.Read (snkeypair, 0, snkeypair.Length);
945 if (RootContext.StrongNameDelaySign) {
946 // delayed signing - DO NOT include private key
948 // check for possible ECMA key
949 if (snkeypair.Length == 16) {
950 // will be rejected if not "the" ECMA key
951 an.KeyPair = new StrongNameKeyPair (snkeypair);
954 // take it, with or without, a private key
955 RSA rsa = CryptoConvert.FromCapiKeyBlob (snkeypair);
956 // and make sure we only feed the public part to Sys.Ref
957 byte[] publickey = CryptoConvert.ToCapiPublicKeyBlob (rsa);
958 an.KeyPair = new StrongNameKeyPair (publickey);
962 Report.Error (1548, "Could not strongname the assembly. File `" +
963 RootContext.StrongNameKeyFile + "' incorrectly encoded.");
964 Environment.Exit (1);
968 // no delay so we make sure we have the private key
970 CryptoConvert.FromCapiPrivateKeyBlob (snkeypair);
971 an.KeyPair = new StrongNameKeyPair (snkeypair);
973 catch (CryptographicException) {
974 if (snkeypair.Length == 16) {
975 // error # is different for ECMA key
976 Report.Error (1606, "Could not strongname the assembly. " +
977 "ECMA key can only be used to delay-sign assemblies");
980 Report.Error (1548, "Could not strongname the assembly. File `" +
981 RootContext.StrongNameKeyFile +
982 "' doesn't have a private key.");
984 Environment.Exit (1);
990 Report.Error (1548, "Could not strongname the assembly. File `" +
991 RootContext.StrongNameKeyFile + "' not found.");
992 Environment.Exit (1);
997 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder customBuilder)
999 Builder.SetCustomAttribute (customBuilder);
1003 public class ModuleClass: CommonAssemblyModulClass {
1004 // TODO: make it private and move all builder based methods here
1005 public ModuleBuilder Builder;
1006 bool m_module_is_unsafe;
1008 public ModuleClass (bool is_unsafe)
1010 m_module_is_unsafe = is_unsafe;
1013 public override AttributeTargets AttributeTargets {
1015 return AttributeTargets.Module;
1019 public override bool IsClsCompliaceRequired(DeclSpace ds)
1021 return CodeGen.Assembly.IsClsCompliant;
1024 public override void Emit (TypeContainer tc)
1028 if (!m_module_is_unsafe)
1031 if (TypeManager.unverifiable_code_ctor == null) {
1032 Console.WriteLine ("Internal error ! Cannot set unverifiable code attribute.");
1036 ApplyAttributeBuilder (null, new CustomAttributeBuilder (TypeManager.unverifiable_code_ctor, new object [0]));
1039 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder customBuilder)
1041 if (a != null && a.Type == TypeManager.cls_compliant_attribute_type) {
1042 Report.Warning_T (3012, a.Location);
1046 Builder.SetCustomAttribute (customBuilder);