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)
533 } catch (Exception e) {
534 Console.WriteLine ("Exception caught by the compiler while compiling:");
535 Console.WriteLine (" Block that caused the problem begin at: " + loc);
537 if (CurrentBlock != null){
538 Console.WriteLine (" Block being compiled: [{0},{1}]",
539 CurrentBlock.StartLocation, CurrentBlock.EndLocation);
541 Console.WriteLine (e.GetType ().FullName + ": " + e.Message);
542 Console.WriteLine (Report.FriendlyStackTrace (e));
544 Environment.Exit (1);
548 if (ReturnType != null && !unreachable){
550 Report.Error (161, loc, "Not all code paths return a value");
556 ig.MarkLabel (ReturnLabel);
557 if (return_value != null){
558 ig.Emit (OpCodes.Ldloc, return_value);
559 ig.Emit (OpCodes.Ret);
562 // If `HasReturnLabel' is set, then we already emitted a
563 // jump to the end of the method, so we must emit a `ret'
566 // Unfortunately, System.Reflection.Emit automatically emits
567 // a leave to the end of a finally block. This is a problem
568 // if no code is following the try/finally block since we may
569 // jump to a point after the end of the method.
570 // As a workaround, we're always creating a return label in
574 if ((block != null) && block.IsDestructor) {
575 // Nothing to do; S.R.E automatically emits a leave.
576 } else if (HasReturnLabel || (!unreachable && !InIterator)) {
577 if (ReturnType != null)
578 ig.Emit (OpCodes.Ldloc, TemporaryReturn ());
579 ig.Emit (OpCodes.Ret);
585 /// This is called immediately before emitting an IL opcode to tell the symbol
586 /// writer to which source line this opcode belongs.
588 public void Mark (Location loc, bool check_file)
590 if ((CodeGen.SymbolWriter == null) || Location.IsNull (loc))
593 if (check_file && (CurrentFile != loc.File))
596 ig.MarkSequencePoint (null, loc.Row, 0, 0, 0);
600 /// Returns a temporary storage for a variable of type t as
601 /// a local variable in the current body.
603 public LocalBuilder GetTemporaryLocal (Type t)
605 LocalBuilder location = null;
607 if (temporary_storage != null){
608 object o = temporary_storage [t];
611 ArrayList al = (ArrayList) o;
613 for (int i = 0; i < al.Count; i++){
615 location = (LocalBuilder) al [i];
621 location = (LocalBuilder) o;
622 if (location != null)
627 return ig.DeclareLocal (t);
630 public void FreeTemporaryLocal (LocalBuilder b, Type t)
632 if (temporary_storage == null){
633 temporary_storage = new Hashtable ();
634 temporary_storage [t] = b;
637 object o = temporary_storage [t];
639 temporary_storage [t] = b;
643 ArrayList al = (ArrayList) o;
644 for (int i = 0; i < al.Count; i++){
653 ArrayList replacement = new ArrayList ();
655 temporary_storage.Remove (t);
656 temporary_storage [t] = replacement;
660 /// Current loop begin and end labels.
662 public Label LoopBegin, LoopEnd;
665 /// Default target in a switch statement. Only valid if
668 public Label DefaultTarget;
671 /// If this is non-null, points to the current switch statement
673 public Switch Switch;
676 /// ReturnValue creates on demand the LocalBuilder for the
677 /// return value from the function. By default this is not
678 /// used. This is only required when returns are found inside
679 /// Try or Catch statements.
681 public LocalBuilder TemporaryReturn ()
683 if (return_value == null){
684 return_value = ig.DeclareLocal (ReturnType);
685 ReturnLabel = ig.DefineLabel ();
686 HasReturnLabel = true;
692 public void NeedReturnLabel ()
694 if (!HasReturnLabel) {
695 ReturnLabel = ig.DefineLabel ();
696 HasReturnLabel = true;
701 // Creates a field `name' with the type `t' on the proxy class
703 public FieldBuilder MapVariable (string name, Type t)
706 return IteratorHandler.Current.MapVariable ("v_", name, t);
709 throw new Exception ("MapVariable for an unknown state");
713 // Invoke this routine to remap a VariableInfo into the
714 // proper MemberAccess expression
716 public Expression RemapLocal (LocalInfo local_info)
718 FieldExpr fe = new FieldExpr (local_info.FieldBuilder, loc);
719 fe.InstanceExpression = new ProxyInstance ();
720 return fe.DoResolve (this);
723 public Expression RemapLocalLValue (LocalInfo local_info, Expression right_side)
725 FieldExpr fe = new FieldExpr (local_info.FieldBuilder, loc);
726 fe.InstanceExpression = new ProxyInstance ();
727 return fe.DoResolveLValue (this, right_side);
730 public Expression RemapParameter (int idx)
732 FieldExpr fe = new FieldExprNoAddress (IteratorHandler.Current.parameter_fields [idx], loc);
733 fe.InstanceExpression = new ProxyInstance ();
734 return fe.DoResolve (this);
737 public Expression RemapParameterLValue (int idx, Expression right_side)
739 FieldExpr fe = new FieldExprNoAddress (IteratorHandler.Current.parameter_fields [idx], loc);
740 fe.InstanceExpression = new ProxyInstance ();
741 return fe.DoResolveLValue (this, right_side);
745 // Emits the proper object to address fields on a remapped
746 // variable/parameter to field in anonymous-method/iterator proxy classes.
748 public void EmitThis ()
751 ig.Emit (OpCodes.Ldarg_0);
753 FieldBuilder this_field = IteratorHandler.Current.this_field;
754 if (TypeManager.IsValueType (this_field.FieldType))
755 ig.Emit (OpCodes.Ldflda, this_field);
757 ig.Emit (OpCodes.Ldfld, this_field);
760 ig.Emit (OpCodes.Ldarg_0);
763 public Expression GetThis (Location loc)
766 if (CurrentBlock != null)
767 my_this = new This (CurrentBlock, loc);
769 my_this = new This (loc);
771 if (!my_this.ResolveBase (this))
779 public abstract class CommonAssemblyModulClass: Attributable {
780 static string[] attribute_targets = new string [] { "assembly", "module" };
782 protected CommonAssemblyModulClass ():
787 public void AddAttributes (ArrayList attrs)
789 if (OptAttributes == null) {
790 OptAttributes = new Attributes (attrs);
793 OptAttributes.AddAttributes (attrs);
794 OptAttributes.CheckTargets (ValidAttributeTargets);
797 public virtual void Emit (TypeContainer tc)
799 if (OptAttributes == null)
802 EmitContext ec = new EmitContext (tc, Mono.CSharp.Location.Null, null, null, 0, false);
803 OptAttributes.Emit (ec, this);
806 protected Attribute GetClsCompliantAttribute ()
808 if (OptAttributes == null)
811 EmitContext temp_ec = new EmitContext (new TypeContainer (), Mono.CSharp.Location.Null, null, null, 0, false);
812 Attribute a = OptAttributes.Search (TypeManager.cls_compliant_attribute_type, temp_ec);
819 protected override string[] ValidAttributeTargets {
821 return attribute_targets;
827 public class AssemblyClass: CommonAssemblyModulClass {
828 // TODO: make it private and move all builder based methods here
829 public AssemblyBuilder Builder;
830 bool is_cls_compliant;
832 public AssemblyClass (): base ()
834 is_cls_compliant = false;
837 public bool IsClsCompliant {
839 return is_cls_compliant;
843 public override AttributeTargets AttributeTargets {
845 return AttributeTargets.Assembly;
849 public override bool IsClsCompliaceRequired(DeclSpace ds)
851 return is_cls_compliant;
854 public void ResolveClsCompliance ()
856 Attribute a = GetClsCompliantAttribute ();
860 is_cls_compliant = a.GetClsCompliantAttributeValue (null);
863 public AssemblyName GetAssemblyName (string name, string output)
865 if (OptAttributes != null) {
866 foreach (Attribute a in OptAttributes.Attrs) {
867 if (a.Target != "assembly")
869 // TODO: This code is buggy: comparing Attribute name without resolving it is wrong.
870 // However, this is invoked by CodeGen.Init, at which time none of the namespaces
873 case "AssemblyKeyFile":
874 case "AssemblyKeyFileAttribute":
875 case "System.Reflection.AssemblyKeyFileAttribute":
876 if (RootContext.StrongNameKeyFile != null) {
877 Report.Warning (1616, "Compiler option -keyfile overrides " +
878 "AssemblyKeyFileAttribute");
881 string value = a.GetString ();
882 if (value != String.Empty)
883 RootContext.StrongNameKeyFile = value;
886 case "AssemblyKeyName":
887 case "AssemblyKeyNameAttribute":
888 case "System.Reflection.AssemblyKeyNameAttribute":
889 if (RootContext.StrongNameKeyContainer != null) {
890 Report.Warning (1616, "Compiler option -keycontainer overrides " +
891 "AssemblyKeyNameAttribute");
894 string value = a.GetString ();
895 if (value != String.Empty)
896 RootContext.StrongNameKeyContainer = value;
899 case "AssemblyDelaySign":
900 case "AssemblyDelaySignAttribute":
901 case "System.Reflection.AssemblyDelaySignAttribute":
902 RootContext.StrongNameDelaySign = a.GetBoolean ();
908 AssemblyName an = new AssemblyName ();
909 an.Name = Path.GetFileNameWithoutExtension (name);
911 // note: delay doesn't apply when using a key container
912 if (RootContext.StrongNameKeyContainer != null) {
913 an.KeyPair = new StrongNameKeyPair (RootContext.StrongNameKeyContainer);
917 // strongname is optional
918 if (RootContext.StrongNameKeyFile == null)
921 string AssemblyDir = Path.GetDirectoryName (output);
923 // the StrongName key file may be relative to (a) the compiled
924 // file or (b) to the output assembly. See bugzilla #55320
925 // http://bugzilla.ximian.com/show_bug.cgi?id=55320
927 // (a) relative to the compiled file
928 string filename = Path.GetFullPath (RootContext.StrongNameKeyFile);
929 bool exist = File.Exists (filename);
930 if ((!exist) && (AssemblyDir != null) && (AssemblyDir != String.Empty)) {
931 // (b) relative to the outputed assembly
932 filename = Path.GetFullPath (Path.Combine (AssemblyDir, RootContext.StrongNameKeyFile));
933 exist = File.Exists (filename);
937 using (FileStream fs = new FileStream (filename, FileMode.Open, FileAccess.Read)) {
938 byte[] snkeypair = new byte [fs.Length];
939 fs.Read (snkeypair, 0, snkeypair.Length);
941 if (RootContext.StrongNameDelaySign) {
942 // delayed signing - DO NOT include private key
944 // check for possible ECMA key
945 if (snkeypair.Length == 16) {
946 // will be rejected if not "the" ECMA key
947 an.KeyPair = new StrongNameKeyPair (snkeypair);
950 // take it, with or without, a private key
951 RSA rsa = CryptoConvert.FromCapiKeyBlob (snkeypair);
952 // and make sure we only feed the public part to Sys.Ref
953 byte[] publickey = CryptoConvert.ToCapiPublicKeyBlob (rsa);
954 an.KeyPair = new StrongNameKeyPair (publickey);
958 Report.Error (1548, "Could not strongname the assembly. File `" +
959 RootContext.StrongNameKeyFile + "' incorrectly encoded.");
960 Environment.Exit (1);
964 // no delay so we make sure we have the private key
966 CryptoConvert.FromCapiPrivateKeyBlob (snkeypair);
967 an.KeyPair = new StrongNameKeyPair (snkeypair);
969 catch (CryptographicException) {
970 if (snkeypair.Length == 16) {
971 // error # is different for ECMA key
972 Report.Error (1606, "Could not strongname the assembly. " +
973 "ECMA key can only be used to delay-sign assemblies");
976 Report.Error (1548, "Could not strongname the assembly. File `" +
977 RootContext.StrongNameKeyFile +
978 "' doesn't have a private key.");
980 Environment.Exit (1);
986 Report.Error (1548, "Could not strongname the assembly. File `" +
987 RootContext.StrongNameKeyFile + "' not found.");
988 Environment.Exit (1);
993 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder customBuilder)
995 Builder.SetCustomAttribute (customBuilder);
999 public class ModuleClass: CommonAssemblyModulClass {
1000 // TODO: make it private and move all builder based methods here
1001 public ModuleBuilder Builder;
1002 bool m_module_is_unsafe;
1004 public ModuleClass (bool is_unsafe)
1006 m_module_is_unsafe = is_unsafe;
1009 public override AttributeTargets AttributeTargets {
1011 return AttributeTargets.Module;
1015 public override bool IsClsCompliaceRequired(DeclSpace ds)
1017 return CodeGen.Assembly.IsClsCompliant;
1020 public override void Emit (TypeContainer tc)
1024 if (!m_module_is_unsafe)
1027 if (TypeManager.unverifiable_code_ctor == null) {
1028 Console.WriteLine ("Internal error ! Cannot set unverifiable code attribute.");
1032 ApplyAttributeBuilder (null, new CustomAttributeBuilder (TypeManager.unverifiable_code_ctor, new object [0]));
1035 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder customBuilder)
1037 if (a != null && a.Type == TypeManager.cls_compliant_attribute_type) {
1038 Report.Warning_T (3012, a.Location);
1042 Builder.SetCustomAttribute (customBuilder);