2002-01-05 Ravi Pratap <ravi@ximian.com>
[mono.git] / mcs / class / corlib / System.Reflection.Emit / ConstructorBuilder.cs
1 //
2 // System.Reflection.Emit/ConstructorBuilder.cs
3 //
4 // Author:
5 //   Paolo Molaro (lupus@ximian.com)
6 //
7 // (C) 2001 Ximian, Inc.  http://www.ximian.com
8 //
9
10 using System;
11 using System.Reflection;
12 using System.Reflection.Emit;
13 using System.Globalization;
14 using System.Security;
15 using System.Security.Permissions;
16
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;
26
27                 internal ConstructorBuilder (TypeBuilder tb, MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes) {
28                         attrs = attributes;
29                         call_conv = callingConvention;
30                         if (parameterTypes != null) {
31                                 this.parameters = new Type [parameterTypes.Length];
32                                 System.Array.Copy (parameterTypes, this.parameters, parameterTypes.Length);
33                         }
34                         type = tb;
35                         table_idx = get_next_table_index (0x06, true);
36                 }
37                 
38                 internal TypeBuilder TypeBuilder {
39                         get {return type;}
40                 }
41                 
42                 public override MethodImplAttributes GetMethodImplementationFlags() {
43                         return iattrs;
44                 }
45                 public override ParameterInfo[] GetParameters() {
46                         return null;
47                 }
48                 public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) {
49                         return null;
50                 }
51                 public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) {
52                         return null;
53                 }
54
55                 public override RuntimeMethodHandle MethodHandle { get {return new RuntimeMethodHandle ();} }
56                 public override MethodAttributes Attributes { 
57                         get {return attrs;} 
58                 }
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";}
64                 }
65                 public string Signature {
66                         get {return "constructor signature";}
67                 }
68
69                 [MonoTODO]
70                 public bool InitLocals { /* FIXME */
71                         get {return false;} 
72                         set {return;}
73                 }
74
75                 public void AddDeclarativeSecurity( SecurityAction action, PermissionSet pset) {
76                 }
77
78                 [MonoTODO]
79                 public ParameterBuilder DefineParameter(int iSequence, ParameterAttributes attributes, string strParamName)
80                 {
81                         ParameterBuilder pb = new ParameterBuilder (this, iSequence, attributes, strParamName);
82                         /* FIXME: add it to pinfo */
83                         return pb;
84                 }
85
86                 public override bool IsDefined (Type attribute_type, bool inherit) {return false;}
87
88                 public override object [] GetCustomAttributes (bool inherit) {return null;}
89
90                 public override object [] GetCustomAttributes (Type attribute_type, bool inherit) {return null;}
91
92                 public ILGenerator GetILGenerator () {
93                         return GetILGenerator (256);
94                 }
95                 public ILGenerator GetILGenerator (int size) {
96                         ilgen = new ILGenerator (this, size);
97                         return ilgen;
98                 }
99
100                 public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
101                 }
102                 public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
103                 }
104                 public void SetImplementationFlags( MethodImplAttributes attributes) {
105                         iattrs = attributes;
106                 }
107                 public Module GetModule() {
108                         return null;
109                 }
110                 public MethodToken GetToken() {
111                         return new MethodToken (0x06000000 | table_idx);
112                 }
113                 public void SetSymCustomAttribute( string name, byte[] data) {
114                 }
115                 public override string ToString() {
116                         return "constructor";
117                 }
118
119                 internal void fixup () {
120                         if (ilgen != null)
121                                 ilgen.label_fixup ();
122                 }
123                 internal override int get_next_table_index (int table, bool inc) {
124                         return type.get_next_table_index (table, inc);
125                 }
126
127         }
128 }