2002-03-23 Martin Baulig <martin@gnome.org>
[mono.git] / mcs / class / corlib / System.Reflection.Emit / SignatureHelper.cs
1
2 //
3 // System.Reflection.Emit/SignatureHelper.cs
4 //
5 // Author:
6 //   Paolo Molaro (lupus@ximian.com)
7 //
8 // (C) 2001 Ximian, Inc.  http://www.ximian.com
9 //
10
11 using System;
12 using System.Reflection;
13 using System.Reflection.Emit;
14 using System.Globalization;
15 using System.Runtime.CompilerServices;
16 using System.Runtime.InteropServices;
17
18 namespace System.Reflection.Emit {
19         public sealed class SignatureHelper {
20                 internal enum SignatureHelperType {
21                         HELPER_FIELD,
22                         HELPER_LOCAL,
23                         HELPER_METHOD,
24                         HELPER_PROPERTY
25                 }
26
27                 private ModuleBuilder module;
28                 private Type[] arguments;
29                 private SignatureHelperType type;
30
31                 internal SignatureHelper (ModuleBuilder module, SignatureHelperType type)
32                 {
33                         this.type = type;
34                         this.module = module;
35                 }
36
37                 public static SignatureHelper GetFieldSigHelper (Module mod)
38                 {
39                         if (!(mod is ModuleBuilder))
40                                 throw new NotImplementedException ();
41
42                         return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_FIELD);
43                 }
44                 public static SignatureHelper GetLocalVarSigHelper (Module mod)
45                 {
46                         if (!(mod is ModuleBuilder))
47                                 throw new NotImplementedException ();
48
49                         return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_LOCAL);
50                 }
51                 [MonoTODO]
52                 public static SignatureHelper GetMethodSigHelper( Module mod, CallingConventions callingConvention, Type returnType)
53                 {
54                         throw new NotImplementedException ();
55                 }
56                 [MonoTODO]
57                 public static SignatureHelper GetMethodSigHelper( Module mod, Type returnType, Type[] parameterTypes)
58                 {
59                         throw new NotImplementedException ();
60                 }
61                 [MonoTODO]
62                 public static SignatureHelper GetPropertySigHelper( Module mod, Type returnType, Type[] parameterTypes)
63                 {
64                         throw new NotImplementedException ();
65                 }
66                 public void AddArgument (Type clsArgument)
67                 {
68                         if (arguments != null) {
69                                 Type[] new_a = new Type [arguments.Length + 1];
70                                 System.Array.Copy (arguments, new_a, arguments.Length);
71                                 new_a [arguments.Length] = clsArgument;
72                                 arguments = new_a;
73                         } else {
74                                 arguments = new Type [1];
75                                 arguments [0] = clsArgument;
76                         }
77                 }
78                 [MonoTODO]
79                 public void AddSentinel ()
80                 {
81                         throw new NotImplementedException ();
82                 }
83                 [MonoTODO]
84                 public override bool Equals (object obj)
85                 {
86                         throw new NotImplementedException ();
87                 }
88                 [MonoTODO]
89                 public override int GetHashCode ()
90                 {
91                         throw new NotImplementedException ();
92                 }
93
94                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
95                 internal extern byte[] get_signature_local ();
96
97                 [MethodImplAttribute(MethodImplOptions.InternalCall)]
98                 internal extern byte[] get_signature_field ();
99
100                 public byte[] GetSignature ()
101                 {
102                         switch (type) {
103                         case SignatureHelperType.HELPER_LOCAL:
104                                 return get_signature_local ();
105                         case SignatureHelperType.HELPER_FIELD:
106                                 return get_signature_field ();
107                         default:
108                                 throw new NotImplementedException ();
109                         }
110                 }
111
112                 public override string ToString() {
113                         return "SignatureHelper";
114                 }
115
116
117
118         }
119 }
120