2 // class.cs: Class and Struct handlers
4 // Author: Miguel de Icaza (miguel@gnu.org)
6 // Licensed under the terms of the GNU GPL
8 // (C) 2001 Ximian, Inc (http://www.ximian.com)
12 using System.Collections;
13 using System.Reflection;
14 using System.Reflection.Emit;
19 public class TypeContainer : DeclSpace {
20 protected int mod_flags;
22 // Holds a list of classes and structures
25 // Holds the list of properties
28 // Holds the list of enumerations
31 // Holds the list of delegates
34 // Holds the list of constructors
35 ArrayList constructors;
37 // Holds the list of fields
40 // Holds a list of fields that have initializers
41 ArrayList initialized_fields;
43 // Holds a list of static fields that have initializers
44 ArrayList initialized_static_fields;
46 // Holds the list of constants
61 // Holds the operators
65 // Pointers to the default constructor and the default static constructor
67 Constructor default_constructor;
68 Constructor default_static_constructor;
71 // Whether we have seen a static constructor for this class or not
73 bool have_static_constructor = false;
76 // This is the namespace in which this typecontainer
77 // was declared. We use this to resolve names.
79 Namespace my_namespace;
82 // This one is computed after we can distinguish interfaces
83 // from classes from the arraylist `type_bases'
85 string base_class_name;
91 // This behaves like a property ;-)
93 public readonly RootContext RootContext;
95 // Attributes for this type
96 protected Attributes attributes;
98 public TypeContainer (RootContext rc, TypeContainer parent, string name) : base (name)
101 types = new ArrayList ();
102 this.parent = parent;
105 object a = rc.Report;
112 base_class_name = null;
114 //Console.WriteLine ("New class " + name + " inside " + n);
117 public AdditionResult AddConstant (Constant constant)
120 string name = constant.Name;
122 if ((res = IsValid (name)) != AdditionResult.Success)
125 if (constants == null)
126 constants = new ArrayList ();
128 constants.Add (constant);
129 DefineName (name, constant);
131 return AdditionResult.Success;
134 public AdditionResult AddEnum (CIR.Enum e)
137 string name = e.Name;
139 if ((res = IsValid (name)) != AdditionResult.Success)
143 enums = new ArrayList ();
146 DefineName (name, e);
148 return AdditionResult.Success;
151 public AdditionResult AddClass (Class c)
154 string name = c.Name;
157 if ((res = IsValid (name)) != AdditionResult.Success)
160 DefineName (name, c);
163 return AdditionResult.Success;
166 public AdditionResult AddStruct (Struct s)
169 string name = s.Name;
171 if ((res = IsValid (name)) != AdditionResult.Success)
174 DefineName (name, s);
177 return AdditionResult.Success;
180 public AdditionResult AddDelegate (Delegate d)
183 string name = d.Name;
185 if ((res = IsValid (name)) != AdditionResult.Success)
188 if (delegates == null)
189 delegates = new ArrayList ();
191 DefineName (name, d);
194 return AdditionResult.Success;
197 public AdditionResult AddMethod (Method method)
199 string name = method.Name;
200 Object value = defined_names [name];
202 if (value != null && (!(value is Method)))
203 return AdditionResult.NameExists;
206 methods = new ArrayList ();
208 methods.Add (method);
209 DefineName (name, method);
211 return AdditionResult.Success;
214 public AdditionResult AddConstructor (Constructor c)
216 if (c.Name != Basename)
217 return AdditionResult.NotAConstructor;
219 if (constructors == null)
220 constructors = new ArrayList ();
222 constructors.Add (c);
224 bool is_static = (c.ModFlags & Modifiers.STATIC) != 0;
227 have_static_constructor = true;
231 default_static_constructor = c;
233 default_constructor = c;
236 return AdditionResult.Success;
239 public AdditionResult AddInterface (Interface iface)
242 string name = iface.Name;
244 if ((res = IsValid (name)) != AdditionResult.Success)
247 if (interfaces == null)
248 interfaces = new ArrayList ();
249 interfaces.Add (iface);
250 DefineName (name, iface);
252 return AdditionResult.Success;
255 public AdditionResult AddField (Field field)
258 string name = field.Name;
260 if ((res = IsValid (name)) != AdditionResult.Success)
264 fields = new ArrayList ();
267 if (field.Initializer != null){
268 if ((field.ModFlags & Modifiers.STATIC) != 0){
269 if (initialized_static_fields == null)
270 initialized_static_fields = new ArrayList ();
272 initialized_static_fields.Add (field);
275 // We have not seen a static constructor,
276 // but we will provide static initialization of fields
278 have_static_constructor = true;
280 if (initialized_fields == null)
281 initialized_fields = new ArrayList ();
283 initialized_fields.Add (field);
287 DefineName (name, field);
288 return AdditionResult.Success;
291 public AdditionResult AddProperty (Property prop)
294 string name = prop.Name;
296 if ((res = IsValid (name)) != AdditionResult.Success)
299 if (properties == null)
300 properties = new ArrayList ();
302 properties.Add (prop);
303 DefineName (name, prop);
305 return AdditionResult.Success;
308 public AdditionResult AddEvent (Event e)
311 string name = e.Name;
313 if ((res = IsValid (name)) != AdditionResult.Success)
317 events = new ArrayList ();
320 DefineName (name, e);
322 return AdditionResult.Success;
325 public AdditionResult AddIndexer (Indexer i)
327 if (indexers == null)
328 indexers = new ArrayList ();
332 return AdditionResult.Success;
335 public AdditionResult AddOperator (Operator op)
337 if (operators == null)
338 operators = new ArrayList ();
342 return AdditionResult.Success;
345 public TypeContainer Parent {
351 public ArrayList Types {
357 public ArrayList Methods {
363 public ArrayList Constants {
369 public ArrayList Interfaces {
375 public int ModFlags {
383 return base_class_name;
387 public ArrayList Bases {
397 public ArrayList Fields {
403 public ArrayList Constructors {
409 public ArrayList Properties {
415 public ArrayList Events {
421 public ArrayList Enums {
427 public ArrayList Indexers {
433 public ArrayList Operators {
439 public ArrayList Delegates {
445 public Attributes OptAttributes {
451 public Namespace Namespace {
457 my_namespace = value;
462 // The Toplevel is `root_types'Â which is a containerfor all
463 // types defined, hence the non-obviios parent.parent.
465 // If we were not tracking Namespaces we could remove this.
470 if (parent.parent == null)
479 // Returns the TypeAttributes for this TypeContainer
481 public virtual TypeAttributes TypeAttr {
483 TypeAttributes x = 0;
486 // FIXME: Figure out exactly how private, public and protected
487 // map to the TypeAttribute flags.
489 // FIXME: Figure out what `new' in the context of a class/struct means.
491 // FIXME: figure out what `internal' means in the context of class/structs
493 if ((mod_flags & Modifiers.PUBLIC) != 0)
494 x |= TypeAttributes.Public;
496 if ((mod_flags & Modifiers.PRIVATE) != 0)
497 x |= TypeAttributes.NotPublic;
499 if ((mod_flags & Modifiers.ABSTRACT) != 0)
500 x |= TypeAttributes.Abstract;
502 if ((mod_flags & Modifiers.SEALED) != 0)
503 x |= TypeAttributes.Sealed;
506 if ((mod_flags & Modifiers.PUBLIC) != 0)
507 x |= TypeAttributes.NestedPublic;
509 x |= TypeAttributes.NestedPrivate;
513 // If we have static constructors, the runtime needs to
514 // initialize the class, otherwise we can optimize
517 if (!have_static_constructor)
518 x |= TypeAttributes.BeforeFieldInit;
523 void EmitField (Field f)
525 Type t = LookupType (f.Type, false);
530 TypeBuilder.DefineField (f.Name, t, Modifiers.FieldAttr (f.ModFlags));
534 // Emits the class field initializers
536 void EmitStaticFieldInitializers (ConstructorBuilder cb)
542 // Emits the instance field initializers
544 void EmitFieldInitializers (ConstructorBuilder cb)
550 // Emits a constructor
552 void EmitConstructor (Constructor c)
554 if ((c.ModFlags & Modifiers.STATIC) != 0){
555 if (initialized_static_fields != null)
556 EmitStaticFieldInitializers (c.ConstructorBuilder);
558 if (initialized_fields != null)
559 EmitFieldInitializers (c.ConstructorBuilder);
565 // This function is used to emit instance and static constructors
566 // when the user did not provide one.
568 void EmitDefaultConstructor (bool is_static)
570 ConstructorBuilder cb;
571 MethodAttributes ca = (MethodAttributes.RTSpecialName |
572 MethodAttributes.SpecialName);
575 ca |= MethodAttributes.Static;
578 // Default constructors provided by the compiler should be `protected'
579 // if the class is abstract, otherwise it is public
581 if ((mod_flags & Modifiers.ABSTRACT) != 0)
582 ca |= MethodAttributes.Family;
584 ca |= MethodAttributes.Public;
586 cb = TypeBuilder.DefineDefaultConstructor (ca);
589 EmitStaticFieldInitializers (cb);
591 EmitFieldInitializers (cb);
595 // Populates our TypeBuilder with fields and methods
597 public void Populate ()
599 if (Constants != null){
600 foreach (Constant c in Constants)
601 c.EmitConstant (RootContext, this);
605 foreach (Field f in Fields)
609 if (Constructors != null){
610 foreach (Constructor c in Constructors)
614 if (Methods != null){
615 foreach (Method m in Methods)
619 if (Properties != null) {
620 foreach (Property p in Properties)
625 foreach (Enum e in Enums)
629 if (Events != null) {
630 foreach (Event e in Events)
634 if (Indexers != null) {
635 foreach (Indexer i in Indexers)
639 if (Operators != null) {
640 foreach (Operator o in Operators)
644 if (Delegates != null) {
645 foreach (Delegate d in Delegates)
653 // Emits the code, this step is performed after all
654 // the types, enumerations, constructors
658 if (default_constructor == null)
659 EmitDefaultConstructor (false);
661 if (initialized_static_fields != null && default_static_constructor == null)
662 EmitDefaultConstructor (true);
664 if (Constructors != null)
665 foreach (Constructor c in Constructors)
669 foreach (Method m in Methods)
673 public delegate void ExamineType (TypeContainer container, object cback_data);
675 void WalkTypesAt (TypeContainer root, ExamineType visit, object cback_data)
680 foreach (TypeContainer type in root.Types){
681 visit (type, cback_data);
682 WalkTypesAt (type, visit, cback_data);
686 public void WalkTypes (ExamineType visit, object cback)
688 WalkTypesAt (this, visit, cback);
691 public Type LookupType (string name, bool silent)
693 return RootContext.LookupType (this, name, silent);
697 public class Class : TypeContainer {
699 // Modifiers allowed in a class declaration
701 public const int AllowedModifiers =
704 Modifiers.PROTECTED |
710 public Class (RootContext rc, TypeContainer parent, string name, int mod, Attributes attrs)
711 : base (rc, parent, name)
715 if (parent.Parent == null)
716 accmods = Modifiers.INTERNAL;
718 accmods = Modifiers.PRIVATE;
720 this.mod_flags = Modifiers.Check (AllowedModifiers, mod, accmods);
721 this.attributes = attrs;
725 // FIXME: How do we deal with the user specifying a different
728 public override TypeAttributes TypeAttr {
730 return base.TypeAttr | TypeAttributes.AutoLayout;
735 public class Struct : TypeContainer {
737 // Modifiers allowed in a struct declaration
739 public const int AllowedModifiers =
742 Modifiers.PROTECTED |
746 public Struct (RootContext rc, TypeContainer parent, string name, int mod, Attributes attrs)
747 : base (rc, parent, name)
751 if (parent.Parent == null)
752 accmods = Modifiers.INTERNAL;
754 accmods = Modifiers.PRIVATE;
756 this.mod_flags = Modifiers.Check (AllowedModifiers, mod, accmods);
758 this.mod_flags |= Modifiers.SEALED;
759 this.attributes = attrs;
764 // FIXME: Allow the user to specify a different set of attributes
765 // in some cases (Sealed for example is mandatory for a class,
766 // but what SequentialLayout can be changed
768 public override TypeAttributes TypeAttr {
770 return base.TypeAttr |
771 TypeAttributes.SequentialLayout |
772 TypeAttributes.Sealed |
773 TypeAttributes.BeforeFieldInit;
778 public class Method {
779 public readonly Parameters Parameters;
780 public readonly string ReturnType;
781 public readonly string Name;
782 public readonly int ModFlags;
783 public MethodBuilder MethodBuilder;
784 public readonly Attributes OptAttributes;
788 // return_type can be "null" for VOID values.
789 public Method (string return_type, int mod, string name, Parameters parameters, Attributes attrs)
792 ReturnType = return_type;
793 Parameters = parameters;
794 ModFlags = Modifiers.Check (AllowedModifiers, mod, Modifiers.PRIVATE);
795 OptAttributes = attrs;
799 // Modifiers allowed in a class declaration
801 const int AllowedModifiers =
804 Modifiers.PROTECTED |
825 // Returns the `System.Type' for the ReturnType of this
826 // function. Provides a nice cache. (used between semantic analysis
827 // and actual code generation
829 Type type_return_type;
830 public Type GetReturnType (TypeContainer parent)
832 if (type_return_type == null)
833 type_return_type = parent.LookupType (ReturnType, false);
835 return type_return_type;
839 // Returns the System.Type array for the parameters of this method
841 Type [] parameter_types;
842 public Type [] ParameterTypes (TypeContainer parent)
844 if (Parameters == null)
847 if (parameter_types == null)
848 parameter_types = Parameters.GetParameterInfo (parent);
850 return parameter_types;
853 public CallingConventions GetCallingConvention (bool is_class)
855 CallingConventions cc = 0;
857 cc = Parameters.GetCallingConvention ();
860 if ((ModFlags & Modifiers.STATIC) == 0)
861 cc |= CallingConventions.HasThis;
869 public void Define (TypeContainer parent)
871 Type ret_type = GetReturnType (parent);
872 Type [] parameters = ParameterTypes (parent);
877 MethodBuilder = parent.TypeBuilder.DefineMethod (
878 Name, Modifiers.MethodAttr (ModFlags),
879 GetCallingConvention (parent is Class),
880 ret_type, parameters);
883 // This is used to track the Entry Point,
885 // FIXME: Allow pluggable entry point, check arguments, etc.
888 if ((ModFlags & Modifiers.STATIC) != 0){
889 parent.RootContext.EntryPoint = MethodBuilder;
894 // Define each type attribute (in/out/ref) and
895 // the argument names.
897 Parameter [] p = Parameters.FixedParameters;
901 for (i = 0; i < p.Length; i++)
902 MethodBuilder.DefineParameter (
903 i + 1, p [i].Attributes, p [i].Name);
905 if (i != parameters.Length)
906 Console.WriteLine ("Implement the type definition for params");
913 public void Emit (TypeContainer parent)
915 ILGenerator ig = MethodBuilder.GetILGenerator ();
916 EmitContext ec = new EmitContext (parent, ig);
918 ec.EmitTopBlock (block);
923 public readonly string Type;
924 public readonly Object Initializer;
925 public readonly string Name;
926 public readonly int ModFlags;
927 public readonly Attributes OptAttributes;
930 // Modifiers allowed in a class declaration
932 const int AllowedModifiers =
935 Modifiers.PROTECTED |
941 public Field (string type, int mod, string name, Object expr_or_array_init, Attributes attrs)
944 ModFlags = Modifiers.Check (AllowedModifiers, mod, Modifiers.PRIVATE);
946 Initializer = expr_or_array_init;
947 OptAttributes = attrs;
951 public abstract class ConstructorInitializer {
952 ArrayList argument_list;
954 public ConstructorInitializer (ArrayList argument_list)
956 this.argument_list = argument_list;
959 public ArrayList Arguments {
961 return argument_list;
966 public class ConstructorBaseInitializer : ConstructorInitializer {
967 public ConstructorBaseInitializer (ArrayList argument_list) : base (argument_list)
972 public class ConstructorThisInitializer : ConstructorInitializer {
973 public ConstructorThisInitializer (ArrayList argument_list) : base (argument_list)
978 public class Constructor {
979 public ConstructorBuilder ConstructorBuilder;
980 public readonly ConstructorInitializer Initializer;
981 public readonly Parameters Parameters;
982 public readonly string Name;
987 // Modifiers allowed for a constructor.
989 const int AllowedModifiers =
991 Modifiers.PROTECTED |
997 // The spec claims that static is not permitted, but
998 // my very own code has static constructors.
1000 public Constructor (string name, Parameters args, ConstructorInitializer init)
1008 // Returns true if this is a default constructor
1010 public bool IsDefault ()
1012 return (Parameters == null) &&
1013 (Initializer is ConstructorBaseInitializer) &&
1014 (Initializer.Arguments == null);
1017 public int ModFlags {
1027 public Block Block {
1037 public CallingConventions GetCallingConvention (bool parent_is_class)
1039 CallingConventions cc = 0;
1041 if (Parameters.ArrayParameter != null)
1042 cc |= CallingConventions.VarArgs;
1044 cc |= CallingConventions.Standard;
1046 if (parent_is_class)
1047 if ((ModFlags & Modifiers.STATIC) != 0)
1048 cc |= CallingConventions.HasThis;
1050 // FIXME: How is `ExplicitThis' used in C#?
1056 // Cached representation
1058 Type [] parameter_types;
1059 public Type [] ParameterTypes (TypeContainer tc)
1061 if (Parameters == null)
1064 if (parameter_types == null)
1065 parameter_types = Parameters.GetParameterInfo (tc);
1067 return parameter_types;
1071 // Creates the ConstructorBuilder
1073 public void Define (TypeContainer parent)
1075 MethodAttributes ca = (MethodAttributes.RTSpecialName |
1076 MethodAttributes.SpecialName);
1078 if ((ModFlags & Modifiers.STATIC) != 0)
1079 ca |= MethodAttributes.Static;
1081 ConstructorBuilder = parent.TypeBuilder.DefineConstructor (
1082 ca, GetCallingConvention (parent is Class),
1083 ParameterTypes (parent));
1094 public class Property {
1096 public readonly string Type;
1097 public readonly string Name;
1098 public readonly int ModFlags;
1099 public Block Get, Set;
1100 public PropertyBuilder PropertyBuilder;
1101 public Attributes OptAttributes;
1103 const int AllowedModifiers =
1106 Modifiers.PROTECTED |
1107 Modifiers.INTERNAL |
1111 Modifiers.OVERRIDE |
1112 Modifiers.ABSTRACT |
1115 public Property (string type, string name, int mod_flags, Block get_block, Block set_block, Attributes attrs)
1119 ModFlags = Modifiers.Check (AllowedModifiers, mod_flags, Modifiers.PRIVATE);
1122 OptAttributes = attrs;
1125 public void Define (TypeContainer parent)
1128 MethodAttributes method_attr = Modifiers.MethodAttr(ModFlags);
1130 // FIXME - how to handle PropertyAttributes.HasDefault
1132 PropertyAttributes prop_attr = PropertyAttributes.RTSpecialName |
1133 PropertyAttributes.SpecialName;
1136 Type tp = parent.LookupType (Type, false);
1137 Type [] prop_type = new Type [1];
1142 PropertyBuilder = parent.TypeBuilder.DefineProperty(Name, prop_attr, tp, null);
1146 mb = parent.TypeBuilder.DefineMethod("get_" + Name, method_attr, tp, null);
1147 PropertyBuilder.SetGetMethod (mb);
1152 mb = parent.TypeBuilder.DefineMethod("set_" + Name, method_attr, null, prop_type);
1153 mb.DefineParameter(1, ParameterAttributes.None, "value");
1154 PropertyBuilder.SetSetMethod (mb);
1161 public class Event {
1163 const int AllowedModifiers =
1166 Modifiers.PROTECTED |
1167 Modifiers.INTERNAL |
1172 Modifiers.OVERRIDE |
1175 public readonly string Type;
1176 public readonly string Name;
1177 public readonly Object Initializer;
1178 public readonly int ModFlags;
1179 public readonly Block Add;
1180 public readonly Block Remove;
1181 public EventBuilder EventBuilder;
1182 public Attributes OptAttributes;
1184 public Event (string type, string name, Object init, int flags, Block add_block, Block rem_block,
1190 ModFlags = Modifiers.Check (AllowedModifiers, flags, Modifiers.PRIVATE);
1193 OptAttributes = attrs;
1196 public void Define (TypeContainer parent)
1198 MethodAttributes m_attr = Modifiers.MethodAttr (ModFlags);
1200 EventAttributes e_attr = EventAttributes.RTSpecialName | EventAttributes.SpecialName;
1204 Type t = parent.LookupType (Type, false);
1205 Type [] p_type = new Type [1];
1208 EventBuilder = parent.TypeBuilder.DefineEvent (Name, e_attr, t);
1211 mb = parent.TypeBuilder.DefineMethod ("add_" + Name, m_attr, null, p_type);
1212 mb.DefineParameter (1, ParameterAttributes.None, "value");
1213 EventBuilder.SetAddOnMethod (mb);
1216 if (Remove != null) {
1217 mb = parent.TypeBuilder.DefineMethod ("remove_" + Name, m_attr, null, p_type);
1218 mb.DefineParameter (1, ParameterAttributes.None, "value");
1219 EventBuilder.SetRemoveOnMethod (mb);
1225 public class Indexer {
1227 const int AllowedModifiers =
1230 Modifiers.PROTECTED |
1231 Modifiers.INTERNAL |
1235 Modifiers.OVERRIDE |
1238 public readonly string Type;
1239 public readonly string InterfaceType;
1240 public readonly Parameters FormalParameters;
1241 public readonly int ModFlags;
1242 public readonly Block Get;
1243 public readonly Block Set;
1244 public Attributes OptAttributes;
1245 public MethodBuilder GetMethodBuilder;
1246 public MethodBuilder SetMethodBuilder;
1249 public Indexer (string type, string int_type, int flags, Parameters parms,
1250 Block get_block, Block set_block, Attributes attrs)
1254 InterfaceType = int_type;
1255 ModFlags = Modifiers.Check (AllowedModifiers, flags, Modifiers.PRIVATE);
1256 FormalParameters = parms;
1259 OptAttributes = attrs;
1262 public void Define (TypeContainer parent)
1264 MethodAttributes attr = Modifiers.MethodAttr (ModFlags);
1266 Type ret_type = parent.LookupType (Type, false);
1267 Type [] param_types = FormalParameters.GetParameterInfo (parent);
1269 GetMethodBuilder = parent.TypeBuilder.DefineMethod ("get_Item", attr, ret_type, param_types);
1270 SetMethodBuilder = parent.TypeBuilder.DefineMethod ("set_Item", attr, ret_type, param_types);
1272 Parameter [] p = FormalParameters.FixedParameters;
1277 for (i = 0; i < p.Length; ++i) {
1278 GetMethodBuilder.DefineParameter (i + 1, p [i].Attributes, p [i].Name);
1279 SetMethodBuilder.DefineParameter (i + 1, p [i].Attributes, p [i].Name);
1282 if (i != param_types.Length)
1283 Console.WriteLine ("Implement type definition for params");
1290 public class Operator {
1292 const int AllowedModifiers =
1296 public enum OpType {
1306 // Unary and Binary operators
1326 // Implicit and Explicit
1331 public readonly OpType OperatorType;
1332 public readonly string ReturnType;
1333 public readonly string FirstArgType;
1334 public readonly string FirstArgName;
1335 public readonly string SecondArgType;
1336 public readonly string SecondArgName;
1337 public readonly int ModFlags;
1338 public readonly Block Block;
1339 public Attributes OptAttributes;
1340 public MethodBuilder OperatorMethodBuilder;
1342 public Operator (OpType type, string ret_type, int flags, string arg1type, string arg1name,
1343 string arg2type, string arg2name, Block block, Attributes attrs)
1345 OperatorType = type;
1346 ReturnType = ret_type;
1347 ModFlags = Modifiers.Check (AllowedModifiers, flags, Modifiers.PUBLIC);
1348 FirstArgType = arg1type;
1349 FirstArgName = arg1name;
1350 SecondArgType = arg2type;
1351 SecondArgName = arg2name;
1353 OptAttributes = attrs;
1356 public void Define (TypeContainer parent)
1358 MethodAttributes attr = Modifiers.MethodAttr (ModFlags);
1360 string name = "Operator" + OperatorType;
1362 Type ret_type = parent.LookupType (ReturnType, false);
1364 Type [] param_types = new Type [2];
1366 param_types [0] = parent.LookupType (FirstArgType, false);
1367 if (SecondArgType != null)
1368 param_types [1] = parent.LookupType (SecondArgType, false);
1370 OperatorMethodBuilder = parent.TypeBuilder.DefineMethod (name, attr, ret_type, param_types);
1372 OperatorMethodBuilder.DefineParameter (1, ParameterAttributes.None, FirstArgName);
1374 if (SecondArgType != null)
1375 OperatorMethodBuilder.DefineParameter (2, ParameterAttributes.None, SecondArgName);