2 // System.Reflection.Emit/ConstructorBuilder.cs
5 // Paolo Molaro (lupus@ximian.com)
7 // (C) 2001 Ximian, Inc. http://www.ximian.com
11 using System.Reflection;
12 using System.Reflection.Emit;
13 using System.Globalization;
14 using System.Security;
15 using System.Security.Permissions;
17 namespace System.Reflection.Emit {
18 public sealed class ConstructorBuilder : ConstructorInfo {
19 private ILGenerator ilgen;
20 private Type[] parameters;
21 private MethodAttributes attrs;
22 private MethodImplAttributes iattrs;
23 private int table_idx;
24 private CallingConventions call_conv;
25 private TypeBuilder type;
27 internal ConstructorBuilder (TypeBuilder tb, MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes) {
29 call_conv = callingConvention;
30 if (parameterTypes != null) {
31 this.parameters = new Type [parameterTypes.Length];
32 System.Array.Copy (parameterTypes, this.parameters, parameterTypes.Length);
35 table_idx = get_next_table_index (0x06, true);
38 internal TypeBuilder TypeBuilder {
42 public override MethodImplAttributes GetMethodImplementationFlags() {
45 public override ParameterInfo[] GetParameters() {
48 public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) {
51 public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) {
55 public override RuntimeMethodHandle MethodHandle { get {return new RuntimeMethodHandle ();} }
56 public override MethodAttributes Attributes {
59 public override Type ReflectedType { get {return type;}}
60 public override Type DeclaringType { get {return type;}}
61 public Type ReturnType { get {return null;}}
62 public override string Name {
63 get {return (attrs & MethodAttributes.Static) != 0 ? ".cctor" : ".ctor";}
65 public string Signature {
66 get {return "constructor signature";}
70 public bool InitLocals { /* FIXME */
75 public void AddDeclarativeSecurity( SecurityAction action, PermissionSet pset) {
79 public ParameterBuilder DefineParameter(int iSequence, ParameterAttributes attributes, string strParamName)
81 ParameterBuilder pb = new ParameterBuilder (this, iSequence, attributes, strParamName);
82 /* FIXME: add it to pinfo */
86 public override bool IsDefined (Type attribute_type, bool inherit) {return false;}
88 public override object [] GetCustomAttributes (bool inherit) {return null;}
90 public override object [] GetCustomAttributes (Type attribute_type, bool inherit) {return null;}
92 public ILGenerator GetILGenerator () {
93 return GetILGenerator (256);
95 public ILGenerator GetILGenerator (int size) {
96 ilgen = new ILGenerator (this, size);
100 public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
102 public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
104 public void SetImplementationFlags( MethodImplAttributes attributes) {
107 public Module GetModule() {
110 public MethodToken GetToken() {
111 return new MethodToken (0x06000000 | table_idx);
113 public void SetSymCustomAttribute( string name, byte[] data) {
115 public override string ToString() {
116 return "constructor";
119 internal void fixup () {
121 ilgen.label_fixup ();
123 internal override int get_next_table_index (int table, bool inc) {
124 return type.get_next_table_index (table, inc);