Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/corlib/System.Reflection.Emit')
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs351
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs16
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/ChangeLog560
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.cs161
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs123
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs188
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/EventBuilder.cs85
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/EventToken.cs70
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs129
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/FieldToken.cs70
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/FlowControl.cs63
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs645
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/Label.cs29
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/LocalBuilder.cs70
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs178
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/MethodToken.cs70
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs363
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs111
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/OpCode.cs129
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/OpCodeType.cs49
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/OpCodes.cs486
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/OperandType.cs87
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/PEFileKinds.cs8
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/PackingSize.cs41
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/ParameterBuilder.cs102
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/ParameterToken.cs70
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/PropertyBuilder.cs124
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/PropertyToken.cs70
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/SignatureHelper.cs121
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/SignatureToken.cs70
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/StackBehaviour.cs126
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/StringToken.cs70
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs748
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/TypeToken.cs70
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/UnmanagedMarshal.cs75
35 files changed, 5728 insertions, 0 deletions
diff --git a/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
new file mode 100755
index 00000000000..4241be02826
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
@@ -0,0 +1,351 @@
+//
+// System.Reflection.Emit/AssemblyBuilder.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.IO;
+using System.Security.Policy;
+using System.Runtime.Serialization;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Collections;
+
+namespace System.Reflection.Emit {
+
+ internal struct MonoResource {
+ public byte[] data;
+ public string name;
+ public string filename;
+ public ResourceAttributes attrs;
+ }
+
+ public sealed class AssemblyBuilder : Assembly {
+ private IntPtr dynamic_assembly;
+ private MethodInfo entry_point;
+ private ModuleBuilder[] modules;
+ private string name;
+ private string dir;
+ private CustomAttributeBuilder[] cattrs;
+ private MonoResource[] resources;
+ string keyfile;
+ string version;
+ string culture;
+ uint algid;
+ uint flags;
+ PEFileKinds pekind = PEFileKinds.Dll;
+ bool delay_sign;
+ internal Type corlib_object_type = typeof (System.Object);
+ internal Type corlib_value_type = typeof (System.ValueType);
+ internal Type corlib_enum_type = typeof (System.Enum);
+ private int[] table_indexes;
+ internal ArrayList methods;
+ Hashtable us_string_cache = new Hashtable ();
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern void basic_init (AssemblyBuilder ab);
+
+ internal AssemblyBuilder (AssemblyName n, string directory, AssemblyBuilderAccess access) {
+ name = n.Name;
+ dir = directory;
+ basic_init (this);
+ }
+
+ internal int get_next_table_index (object obj, int table, bool inc) {
+ if (table_indexes == null) {
+ table_indexes = new int [64];
+ for (int i=0; i < 64; ++i)
+ table_indexes [i] = 1;
+ /* allow room for .<Module> in TypeDef table */
+ table_indexes [0x02] = 2;
+ }
+ // Console.WriteLine ("getindex for table "+table.ToString()+" got "+table_indexes [table].ToString());
+ if (inc) {
+ if ((table == 0x06) && (methods != null))
+ methods.Add (obj);
+ return table_indexes [table]++;
+ }
+ return table_indexes [table];
+ }
+
+ public override string CodeBase {
+ get {
+ return null;
+ }
+ }
+
+ public override MethodInfo EntryPoint {
+ get {
+ return entry_point;
+ }
+ }
+
+ public override string Location {
+ get {
+ return null;
+ }
+ }
+
+ public void AddResourceFile (string name, string fileName)
+ {
+ AddResourceFile (name, fileName, ResourceAttributes.Public);
+ }
+
+ public void AddResourceFile (string name, string fileName, ResourceAttributes attribute)
+ {
+ if (resources != null) {
+ MonoResource[] new_r = new MonoResource [resources.Length + 1];
+ System.Array.Copy(resources, new_r, resources.Length);
+ resources = new_r;
+ } else {
+ resources = new MonoResource [1];
+ }
+ int p = resources.Length - 1;
+ resources [p].name = name;
+ resources [p].filename = fileName;
+ resources [p].attrs = attribute;
+ }
+
+ public void EmbedResourceFile (string name, string fileName)
+ {
+ EmbedResourceFile (name, fileName, ResourceAttributes.Public);
+ }
+
+ public void EmbedResourceFile (string name, string fileName, ResourceAttributes attribute)
+ {
+ if (resources != null) {
+ MonoResource[] new_r = new MonoResource [resources.Length + 1];
+ System.Array.Copy(resources, new_r, resources.Length);
+ resources = new_r;
+ } else {
+ resources = new MonoResource [1];
+ }
+ int p = resources.Length - 1;
+ resources [p].name = name;
+ resources [p].attrs = attribute;
+ try {
+ FileStream s = new FileStream (fileName, FileMode.Open, FileAccess.Read);
+ long len = s.Length;
+ resources [p].data = new byte [len];
+ s.Read (resources [p].data, 0, (int)len);
+ s.Close ();
+ } catch {
+ /* do something */
+ }
+ }
+
+ public ModuleBuilder DefineDynamicModule (string name)
+ {
+ return DefineDynamicModule (name, name, false);
+ }
+
+ public ModuleBuilder DefineDynamicModule (string name, bool emitSymbolInfo)
+ {
+ return DefineDynamicModule (name, name, emitSymbolInfo);
+ }
+
+ public ModuleBuilder DefineDynamicModule(string name, string fileName)
+ {
+ return DefineDynamicModule (name, fileName, false);
+ }
+
+ public ModuleBuilder DefineDynamicModule (string name, string fileName,
+ bool emitSymbolInfo)
+ {
+ ModuleBuilder r = new ModuleBuilder (this, name, fileName, emitSymbolInfo);
+
+ if (modules != null) {
+ ModuleBuilder[] new_modules = new ModuleBuilder [modules.Length + 1];
+ System.Array.Copy(modules, new_modules, modules.Length);
+ new_modules [modules.Length] = r;
+ modules = new_modules;
+ } else {
+ modules = new ModuleBuilder [1];
+ modules [0] = r;
+ }
+ return r;
+ }
+
+ public IResourceWriter DefineResource (string name, string description, string fileName)
+ {
+ return DefineResource (name, description, fileName, ResourceAttributes.Public);
+ }
+
+ public IResourceWriter DefineResource (string name, string description,
+ string fileName, ResourceAttributes attribute)
+ {
+ return null;
+ }
+
+ public void DefineUnmanagedResource (byte[] resource)
+ {
+ }
+
+ public void DefineUnmanagedResource (string resourceFileName)
+ {
+ }
+
+ public void DefineVersionInfoResource ()
+ {
+ }
+
+ public void DefineVersionInfoResource (string product, string productVersion,
+ string company, string copyright, string trademark)
+ {
+ }
+
+ public ModuleBuilder GetDynamicModule (string name)
+ {
+ return null;
+ }
+
+ public override Type[] GetExportedTypes ()
+ {
+ return null;
+ }
+
+ public override FileStream GetFile (string name)
+ {
+ return null;
+ }
+
+ /*public virtual FileStream[] GetFiles() {
+ return null;
+ }
+ public override FileStream[] GetFiles(bool getResourceModules) {
+ return null;
+ }*/
+
+ /*public virtual ManifestResourceInfo GetManifestResourceInfo(string resourceName)
+ {
+ return null;
+ }
+ public virtual string[] GetManifestResourceNames() {
+ return null;
+ }
+ public virtual Stream GetManifestResourceStream(string name) {
+ return null;
+ }
+ public virtual Stream GetManifestResourceStream(Type type, string name) {
+ return null;
+ }*/
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern int getUSIndex (AssemblyBuilder ab, string str);
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern int getToken (AssemblyBuilder ab, MemberInfo member);
+
+ internal int GetToken (string str) {
+ if (us_string_cache.Contains (str))
+ return (int)us_string_cache [str];
+ int result = getUSIndex (this, str);
+ us_string_cache [str] = result;
+ return result;
+ }
+
+ internal int GetToken (MemberInfo member) {
+ return getToken (this, member);
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern int getDataChunk (AssemblyBuilder ab, byte[] buf, int offset);
+
+ public void Save (string assemblyFileName)
+ {
+ byte[] buf = new byte [65536];
+ FileStream file;
+ int count, offset;
+
+ if (dir != null) {
+ assemblyFileName = String.Format ("{0}{1}{2}", dir, System.IO.Path.DirectorySeparatorChar, assemblyFileName);
+ }
+
+ file = new FileStream (assemblyFileName, FileMode.Create, FileAccess.Write);
+
+ offset = 0;
+ while ((count = getDataChunk (this, buf, offset)) != 0) {
+ file.Write (buf, 0, count);
+ offset += count;
+ }
+ file.Close ();
+ }
+
+ public void SetEntryPoint (MethodInfo entryMethod)
+ {
+ SetEntryPoint (entryMethod, PEFileKinds.ConsoleApplication);
+ }
+
+ public void SetEntryPoint (MethodInfo entryMethod, PEFileKinds fileKind)
+ {
+ entry_point = entryMethod;
+ pekind = fileKind;
+ }
+
+ public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
+ string attrname = customBuilder.Ctor.ReflectedType.FullName;
+ byte[] data;
+ int len, pos;
+ if (attrname == "System.Reflection.AssemblyVersionAttribute") {
+ data = customBuilder.Data;
+ pos = 2;
+ len = CustomAttributeBuilder.decode_len (data, pos, out pos);
+ version = CustomAttributeBuilder.string_from_bytes (data, pos, len);
+ return;
+ } else if (attrname == "System.Reflection.AssemblyKeyFileAttribute") {
+ data = customBuilder.Data;
+ pos = 2;
+ len = CustomAttributeBuilder.decode_len (data, pos, out pos);
+ keyfile = CustomAttributeBuilder.string_from_bytes (data, pos, len);
+ } else if (attrname == "System.Reflection.AssemblyCultureAttribute") {
+ data = customBuilder.Data;
+ pos = 2;
+ len = CustomAttributeBuilder.decode_len (data, pos, out pos);
+ culture = CustomAttributeBuilder.string_from_bytes (data, pos, len);
+ } else if (attrname == "System.Reflection.AssemblyAlgorithmIdAttribute") {
+ data = customBuilder.Data;
+ pos = 2;
+ algid = (uint)data [pos];
+ algid |= ((uint)data [pos + 1]) << 8;
+ algid |= ((uint)data [pos + 2]) << 16;
+ algid |= ((uint)data [pos + 3]) << 24;
+ } else if (attrname == "System.Reflection.AssemblyFlagsAttribute") {
+ data = customBuilder.Data;
+ pos = 2;
+ flags = (uint)data [pos];
+ flags |= ((uint)data [pos + 1]) << 8;
+ flags |= ((uint)data [pos + 2]) << 16;
+ flags |= ((uint)data [pos + 3]) << 24;
+ return;
+ } else if (attrname == "System.Reflection.AssemblyDelaySignAttribute") {
+ data = customBuilder.Data;
+ pos = 2;
+ delay_sign = data [2] != 0;
+ }
+ if (cattrs != null) {
+ CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
+ cattrs.CopyTo (new_array, 0);
+ new_array [cattrs.Length] = customBuilder;
+ cattrs = new_array;
+ } else {
+ cattrs = new CustomAttributeBuilder [1];
+ cattrs [0] = customBuilder;
+ }
+ }
+ public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
+ SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
+ }
+
+ public void SetCorlibTypeBuilders (Type corlib_object_type, Type corlib_value_type, Type corlib_enum_type) {
+ this.corlib_object_type = corlib_object_type;
+ this.corlib_value_type = corlib_value_type;
+ this.corlib_enum_type = corlib_enum_type;
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs
new file mode 100644
index 00000000000..2c6a97d9aca
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs
@@ -0,0 +1,16 @@
+//--------------------------
+// System.Reflection.Emit
+// Author: Mandar Nanivadekar
+//
+// Created: 29/08/2001
+//------------------------------
+
+namespace System.Reflection.Emit
+{
+ public enum AssemblyBuilderAccess
+ {
+ Run = 1,
+ Save = 2,
+ RunAndSave = 3
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/ChangeLog b/mcs/class/corlib/System.Reflection.Emit/ChangeLog
new file mode 100644
index 00000000000..c8e0916bc0f
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/ChangeLog
@@ -0,0 +1,560 @@
+2003-01-17 Zoltan Varga <vargaz@freemail.hu>
+
+ * MethodBuilder.cs ConstructorBuilder.cs: modify GetParameters() so it
+ returns information even when the app did not use DefineParameter() to
+ define the parameters.
+
+ * ConstructorBuilder.cs (ctor): allways define SpecialName attribute
+ for constructors as done by MS.
+
+Mon Jan 13 11:37:14 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs, ModuleBuilder.cs: better type name cache.
+
+2003-01-10 Zoltan Varga <vargaz@freemail.hu>
+
+ * ILGenerator.cs: Implemented EmitWriteLine(string).
+
+ * TypeBuilder.cs (DefineInitializedData): Call DefineNestedType()
+ instead of DefineType() so the auxiliary types do not pollute the
+ global namespace. This is consistent with the behaviour of MS .NET.
+
+Fri Jan 10 16:03:30 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs, MethodBuilder.cs, TypeBuilder.cs,
+ ConstructorBuilder.cs: some tweaks to reduce memory usage.
+
+Thu Jan 2 18:46:09 CET 2003 Paolo Molaro <lupus@ximian.com>
+
+ * ModuleBuilder.cs, TypeBuilder.cs: support global fields and methods.
+
+Thu Dec 19 00:06:57 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: remove duplicated user string entries.
+
+2002-12-11 Zoltan Varga <vargaz@freemail.hu>
+
+ * FieldBuilder.cs: added 'handle' field which is needed by some new
+ code in reflection.c.
+
+2002-12-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * TypeBuilder.cs: implemented GetInterfaceMap () when the Type has been
+ created.
+
+Fri Nov 8 14:53:03 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: account for the exception object being passed to the
+ catch handler to calc max_stack.
+
+2002-09-21 Martin Baulig <martin@gnome.org>
+
+ * ModuleBuilder.cs (ModuleBuilder.symbol_writer): Make this
+ field internal, not private.
+ (ModuleBuilder.SymWriter_DefineLocalVariable): Removed.
+
+ * LocalBuilder.cs (LocalBuilder.SetLocalSymInfo): Use the
+ ISymbolWriter's DefineLocalVariable() method instead of the
+ IMonoSymbolWriter hack.
+
+Mon Sep 16 19:02:58 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.c: special case some custom attributes.
+
+2002-09-12 Dick Porter <dick@ximian.com>
+
+ * TypeBuilder.cs: Say _which_ Type has already been created
+
+2002-09-11 Miguel de Icaza <miguel@ximian.com>
+
+ * ModuleBuilder.cs (GetTypes): Implement.
+
+Tue Sep 10 12:12:51 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ConstructorBuilder.cs: added a field to hold the handle.
+
+Mon Sep 9 17:31:12 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs: prepare for the real CreateType implementation.
+
+Tue Aug 27 16:57:18 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs: remove duplicate code and fix
+ named field reading in custom attr.
+
+2002-08-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * TypeBuilder.cs: UnspecifiedTypeSize is 0.
+
+Wed Aug 14 17:38:41 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs: ReflectedType and CreateType fixes.
+
+Thu Aug 8 10:25:51 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: added API to embed managed resources.
+
+2002-08-03 Martin Baulig <martin@gnome.org>
+
+ * TypeBuilder.cs (TypeBuilder.DeclaringType): Implemented.
+
+Thu Jul 25 13:57:46 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: support linking external resources.
+
+2002-07-19 Martin Baulig <martin@gnome.org>
+
+ * ILGenerator.cs (Emit (OpCode, LocalBuilder)): Throw an exception
+ when trying to emit a local that was defined in a different ILGenerator.
+
+ * LocalBuilder.cs (LocalBuilder): Added `ILGenetator' argument to
+ the constructor.
+
+Tue Jul 16 19:32:08 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: stack size check fix.
+
+Sat Jul 13 17:30:51 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: add also the enum_type for compiling corlib.
+ * TypeBuilder.cs: complete IsValueType.
+
+Sat Jul 13 15:08:12 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs: better IsValueType.
+
+2002-07-13 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * CustomAttributeBuilder.cs: removed compile warning.
+
+Fri Jul 12 11:34:58 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: fixup typebuilder tokens as well.
+
+Tue Jul 9 19:03:03 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs: special case SerializarionAttribute.
+ Tweaks to get correct code in corlib.
+
+2002-07-06 Miguel de Icaza <miguel@ximian.com>
+
+ * ILGenerator.cs (ILGenerator.Emit): For doubles and floats, swap
+ the bytes on big endian systems.
+
+2002-07-03 Martin Baulig <martin@gnome.org>
+
+ * AssemblyBuilder.cs (corlib_object_type, corlib_value_type): Moved
+ these fields up after the last entry in MonoReflectionAssemblyBuilder
+ in reflection.h.
+
+ * TypeBuilder.cs (IsValueTypeImpl): Use the AssemblyBuilder's
+ `corlib_value_type' instead of `typeof (System.ValueType)'.
+ (DefineNestedType): Use the AssemblyBuilder's `corlib_object_type'
+ instead of `typeof (object)'.
+
+2002-07-02 Martin Baulig <martin@gnome.org>
+
+ * AssemblyBuilder.cs (corlib_object_type, corlib_value_type): New
+ internal fields. When compiling corlib, they point to the newly
+ created System.Object and System.ValueType types.
+ (SetCorlibTypeBuilders): New public function. This will be
+ dynamically called from MCS when compiling corlib.
+
+ * TypeBuilder.cs (DefineInitializedData): Use the AssemblyBuilder's
+ `corlib_value_type' as parent type instead of `typeof (System.ValueType)'
+ to make it work when compiling corlib.
+
+ * ModuleBuilder.cs (assemblyb): Made this field internal, not private.
+
+Tue Jul 2 18:34:49 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs: implemented AssemblyQualifiedName.
+ * MethodBuilder.cs, ConstructorBuilder.cs: special case custom attr.
+
+Mon Jul 1 16:17:29 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs: implemented AddInterfaceImplementation().
+
+2002-06-28 Martin Baulig <martin@gnome.org>
+
+ * MethodBuilder.cs (GetParameters): Return all parameters, not all
+ but the last one.
+
+2002-06-27 Martin Baulig <martin@gnome.org>
+
+ * ConstructorBuilder.cs (GetParameters): Implemented.
+
+Mon Jun 17 14:55:43 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ModuleBuilder.cs, TypeBuilder.cs: fixes for nested types handling.
+
+Fri Jun 14 16:21:54 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * CustomAttributeBuilder.cs: added custom attribute related internal
+ helper methods.
+ * FieldBuilder.cs, ParameterBuilder.cs: handle MarshalAs attribute.
+ * UnmanagedMarshal.cs: implemented.
+
+Mon Jun 10 18:58:18 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * PropertyBuilder.cs: implemented ReflectedType and DeclaringType
+ properties.
+
+2002-06-07 Martin Baulig <martin@gnome.org>
+
+ * TypeBuilder.cs (TypeBuilder): Added `PackingSize packing_size' and
+ `int type_size' fields to the constructor.
+ (DefineNestedType): Pass packing_size and type_size to the constructor.
+
+ * ModuleBuilder.cs (DefineType): Pass the packing_size and type_size
+ fields to the TypeBuilder's constructor.
+
+2002-06-07 Martin Baulig <martin@gnome.org>
+
+ * TypeBuilder.cs (DefineNestedType): There is no overload for this
+ method which takes 5 args in the specs, removed it.
+
+Fri Jun 7 17:04:06 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: updates for PE/COFF rewrite.
+
+2002-05-30 Martin Baulig <martin@gnome.org>
+
+ * AssemblyBuilder.cs (methods): Made this internal and don't
+ initialize it. It will be initialized by the ModuleBuilder's
+ GetSymbolWriter() method.
+ (get_next_table_index): Only store the method in the `methods'
+ array if it's not null.
+
+ * ModuleBuilder.cs (GetSymbolWriter): Initialize the AssemblyBuilder's
+ `methods' field if necessary and pass it as third argument to the
+ symbol writer's constructor.
+
+2002-05-25 Martin Baulig <martin@gnome.org>
+
+ * TypeBuilder.cs (TypeToken): Implemented.
+
+2002-05-24 Martin Baulig <martin@gnome.org>
+
+ * ModuleBuilder.cs (symwriter_define_local): New private variable.
+ (GetSymbolWriter): Look for a custom version of "DefineLocalVariable"
+ and store it in `symwriter_define_local'.
+ (SymWriter_DefineLocalVariable): New internal method to call the
+ symbol writer's custom DefineLocalVariable() method. It is safe to
+ call this method if there's no symbol writer.
+
+ * LocalBuilder.cs (SetLocalSymInfo): Use the MethodBuilder'snew
+ SymWriter_DefineLocalVariable().
+
+ * MethodBuilder.cs (GetParameters): Implemented.
+
+2002-05-22 Martin Baulig <martin@gnome.org>
+
+ * ModuleBuilder.cs (GetSymbolWriter): Pass the this pointer to the
+ symbol writer's constructor.
+
+2002-05-22 Martin Baulig <martin@gnome.org>
+
+ * AssemblyBuilder.cs (methods): New field.
+ (get_next_table_index): Record all methods and constructors
+ (table 0x06) in the `methods' array. This is read by the
+ Mono.CSharp.Debugger.MonoSymbolWriter::get_method interncall to
+ get the MethodBuilder / ConstructorBuilder back from the token.
+
+ * *Builder.cs (get_next_table_index): Added `object obj' argument.
+ (<constructors>): pass the this pointer to get_next_table_index ().
+
+2002-05-20 Martin Baulig <martin@gnome.org>
+
+ * TypeBuilder.cs (DefineField): Call the new `create_internal_class'
+ interncall after adding the first field. This is used when creating
+ enum types to set `klass->enum_basetype'.
+
+Thu May 16 16:09:51 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs: complete special acse support for CharSet, Size and
+ Pack named args in StructLayout attribute.
+
+Tue May 14 17:13:48 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * MethodBuilder.cs: revert change in accessibility of
+ GetILGenerator(int).
+
+Tue May 14 13:31:17 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * FieldBuilder.cs, ParameterBuilder.cs: more special-casing of
+ attributes.
+
+Fri May 10 20:57:27 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * CustomAttributeBuilder.cs: expose internal data for use in
+ reflection.
+ * FieldBuilder.cs, TypeBuilder.cs: special case FieldOffset and
+ StructLayout attributes.
+
+Fri May 10 16:30:57 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * MethodBuilder.cs, ConstructorBuilder.cs: implemented InitLocals
+ property.
+
+2002-04-26 Martin Baulig <martin@gnome.org>
+
+ * ModuleBuilder.cs (DefineDocument): Implemented.
+
+Tue Apr 16 13:02:28 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: pad output file to file alignment.
+ * FieldBuilder.cs: ReflectedType.
+ * ModuleBuilder.cs: added guid generation and array method creation.
+ * MonoArrayMethod.cs: array method support code.
+
+Wed Apr 10 12:57:31 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: use a stack to keep track of exception blocks.
+
+Mon Apr 8 06:19:01 2002 Piers Haken <piersh@friskit.com>
+
+ * ILGenerator.cs: added LabelField.label_base to allow for
+ arbitrary offsets (for switch statement)
+
+Fri Apr 5 15:41:19 CEST 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: simpler protocol wih the runtime to
+ get the assembly data.
+
+Tue Mar 26 20:10:24 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: use FileMode.Create.
+ * ILGenerator.cs: optimize localbuilder related opcodes.
+ Track parameters to adjust maxstack.
+ * LocalBuilder.cS: use unsigned for position.
+
+2002-03-23 Miguel de Icaza <miguel@ximian.com>
+
+ * LocalBuilder.cs: Drop the symbol_writer as LocalBuilder fields.
+ Do this lazily in SetLocalSymInfo.
+
+2002-03-24 Martin Baulig <martin@gnome.org>
+
+ * ModuleBuilder.cs (GetSymbolWriter): The MonoSymbolWriter's constructor
+ now takes a `string assembly_filename' argument, pass it our fully
+ qualified assembly name.
+
+2002-03-24 Nick Drochak <ndrochak@gol.com>
+
+ * ILGenerator.cs: Use #if-#endif instead of if(false){} to disable
+ code. This way there is no compiler warning.
+
+ * TypeBuilder.cs: Removed the returns that came after the throws.
+ This removes a few more compiler warnings. Also marked with MonoTODO
+ all places where we throw NotImplemented exceptions.
+
+2002-03-23 Martin Baulig <martin@gnome.org>
+
+ * SignatureHelper.cs (GetFieldSignatureHelper, GetLocalSignatureHelper):
+ Implemented.
+
+ * LocalBuilder.cs (LocalBuilder): This internal constructor now takes
+ a ModuleBuilder argument instead of a ISymbolWriter one.
+ (SetLocalSymInfo): Create and pass type signature to DefineLocalVariable.
+
+2002-03-23 Martin Baulig <martin@gnome.org>
+
+ * ILGenerator.cs (BeginScope, EndScope): Implemented.
+
+2002-03-20 Martin Baulig <martin@gnome.org>
+
+ * ModuleBuilder.cs (GetSymbolWriter): New internal function. Dynamically
+ loads the default symbol writer, catch all possible exceptions and return
+ null on failure.
+ (ModuleBuilder): Added `bool emitSymbolInfo' argument to this internal
+ constructor; if set, call GetSymbolWriter ().
+ (GetSymWriter): Implemented.
+
+ * LocalBuilder.cs (LocalBuilder): Added ISymbolWriter argument to this
+ internal method.
+ (SetLocalSymInfo): Implemented, call ISymbolWriter.DefineLocalVariable ()
+ if the symbol writer is not null.
+
+ * ILGenerator.cs (ILGenerator): Call ModuleBuilder.GetSymWriter () to get
+ and store the symbol writer.
+ (DeclareLocal): Pass the symbol writer to LocalBuilder's constructor.
+ (MarkSequencePoint): Implemented, call ISymbolWriter.DefineSequencePoints ()
+ if the symbol writer is not null.
+
+ * AssemblyBuilder.cs (DefineDynamicModule): Pass the `bool emitSymbolInfo'
+ to ModuleBuilder's constructor.
+
+Sat Mar 16 19:11:47 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ModuleBuilder.cs: handle modified types correctly.
+
+Thu Mar 7 17:10:42 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: allow saving bigger assemblies.
+ * ILGenerator.cs: add fixup table for fields and methods, since
+ at the end of the compile they may end up with a different table
+ index.
+ * ModuleBuilder.cs: add cache for type names to speed up the type
+ lookups from the compiler.
+ * TypeBuilder.cs: GetInterfaces () returns only interfaces in the
+ current type, not in parents (the docs are wrong).
+
+Tue Mar 5 18:09:34 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * EventBuilder.cs: implemented.
+ * TypeBuilder.cs: implemented DefineEvent() method and UnderlyingSystemType
+ property.
+
+Mon Mar 4 20:34:52 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: make enough room in the byte array for string
+ tokens.
+ * TypeBuilder.cs: fixed GetInterfaces().
+
+Mon Mar 4 11:30:40 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs: implemented GetConstructors(), GetFields(),
+ GetMethods(), GetProperties().
+
+Thu Feb 28 19:15:10 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: call into the runtime to init some basic
+ assembly stuff. Reserve slot 1 of typedef table for .<Module>.
+ * ModuleBuilder.cs: call into the runtime if we need to create a
+ modief type, such as arrays, byref etc.
+ * TypeBuilder.cs: call into the runtime to create the MonoClass
+ representation for the type. Throw exceptions with not implemented
+ stuff.
+
+Wed Feb 27 18:48:47 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: fix nested exception blocks.
+
+Wed Feb 20 22:30:49 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: upped compiled assembly size limit.
+ Implemented SetCustomAttribute () methods.
+ * CustomAttributeBuilder.cs: implemented the needed constructor
+ stuff.
+ * Cosntructorbuilder.cs, EnumBuilder.cs, FieldBuilder.cs,
+ MethodBuilder.cs, ModuleBuilder.cs, ParameterBuilder.cs,
+ PropertyBuilder.cs, TypeBuilder.cs: Implemented SetCustomAttribute () methods.
+
+Wed Feb 20 14:54:01 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: add SetCustomAttribute () to keep the compiler
+ going.
+
+Fri Feb 15 18:15:04 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: finally block support and fixes.
+
+Thu Feb 14 18:55:52 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * FieldBuilder.cs: Add SetRVAData().
+ * ILGenerator.cs: speed up code array growth.
+ * TypeBuilder.cs: fix IsValueTypeImpl(). Add class_size member.
+ Implement DefineInitializedData().
+
+Tue Jan 22 23:01:11 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * EnumBuilder.cs, TypeBuilder.cs: updates for changes in Type.cs.
+ * ModuleBuilder.cs: fix lookup of nested types.
+
+Tue Jan 15 22:46:21 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: implement some of the exception support methods.
+
+Mon Jan 14 17:07:32 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ModulerBuilder.cs: search also for subtypes in GetTypes().
+ * TypeBuilder.cs: bugfix in FullName. Implemented DefineNestedType().
+
+Fri Jan 11 19:00:29 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * MethodBuilder.cs, ConstructorBuilder.cs: save parameter info.
+
+Thu Jan 10 21:07:54 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: handle type tokens (used for box opcode).
+
+Wed Jan 9 19:37:55 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: emit float and doubles.
+ * ModuleBuilder.cs: off-by-one error fix and GetType()
+ implementations.
+ * TypeBuilder.cs: AttributesImpl added.
+ * UnmanagedMarshal.cs: stubbed out class.
+
+Sat Jan 5 15:59:05 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: fix emission of two-bytes opcodes.
+ Missing slot for locals array. Throw exceptions on unimplemented
+ methods.
+ * OpCode.cs: add a comment: the Value property is useless.
+ * OpCodes.cs: fix name of tail opcode (Tail -> Tailcall).
+
+2002-01-05 Ravi Pratap <ravi@ximian.com>
+
+ * ConstructorBuilder.cs : Use the MonoTODO attribute.
+
+ * ILGenerator.cs, Label.cs, MethodBuilder.cs, ModuleBuilder.cs,
+ ParameterBuilder.cs, TypeBuilder.cs : Ditto.
+
+Thu Jan 3 23:26:15 CET 2002 Paolo Molaro <lupus@ximian.com>
+
+ * ILGenerator.cs: typo fix.
+
+Mon Dec 24 17:21:30 CET 2001 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs: added DefineMethodOverride().
+ * MethodBuilder.cs: add override_method member and setter.
+
+Mon Nov 19 13:58:01 CET 2001 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: add method to register a string in the "#US"
+ stream.
+ * EnumBuilder.cs, SignatureHelper.cs: added stubs.
+ * ILGenerator.cs: more stuff implemented.
+ * LocalBuilder.cs: keep track of local var index.
+
+Thu Nov 15 18:11:23 CET 2001 Paolo Molaro <lupus@ximian.com>
+
+ * ConstructorBuilder.cs: implement the interesting methods.
+ * ILGenerator.cs: adapt for use with both a MethodBuilder and a
+ ConstructorBuilder.
+ * MethodBuilder.cs: add ImplAttributes.
+ * ParameterBuilder.cs: adapt for ConstructorBuilder.
+ * TypeBuilder.cs: add constructors handling.
+
+Wed Nov 14 17:01:45 CET 2001 Paolo Molaro <lupus@ximian.com>
+
+ * ConstructorBuilder.cs: added missing stubs and some implementation.
+ * CustomAttributeBuilder.cs: added.
+ * EventBuilder.cs: added.
+ * FieldBuilder.cs: updates.
+ * MethodBuilder.cs: stuff to implement P/Invoke methods.
+ * ModuleBuilder.cs: added GetArrayMethod() stub.
+ * ParameterBuilder.cs, PropertyBuilder.cs: updates.
+ * TypeBuilder.cs: updates and stubs.
+
+2001-11-10 Sean MacIsaac <macisaac@ximian.com>
+
+ * TypeBuilder.cs: Added implementation for TypeHandle.
+
+Tue Nov 6 09:13:45 CET 2001 Paolo Molaro <lupus@ximian.com>
+
+ * AssemblyBuilder.cs: define an internal constructor.
+
+2001-10-07 Miguel de Icaza <miguel@ximian.com>
+
+ * AssemblyBuilder.cs: Reformatted.
+
+ Added override keywords to those that needed them.
+
+ Removed methods that we do not override, but just inherit
+
+Tue Sep 25 16:53:08 CEST 2001 Paolo Molaro <lupus@ximian.com>
+
+ * TypeBuilder.cs, ConstructorBuilder.cs, ModuleBuilder.cs: added.
diff --git a/mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.cs
new file mode 100644
index 00000000000..a577f0d3036
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.cs
@@ -0,0 +1,161 @@
+//
+// System.Reflection.Emit/ConstructorBuilder.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Globalization;
+using System.Security;
+using System.Security.Permissions;
+
+namespace System.Reflection.Emit {
+ public sealed class ConstructorBuilder : ConstructorInfo {
+ private RuntimeMethodHandle mhandle;
+ private ILGenerator ilgen;
+ private Type[] parameters;
+ private MethodAttributes attrs;
+ private MethodImplAttributes iattrs;
+ private int table_idx;
+ private CallingConventions call_conv;
+ private TypeBuilder type;
+ private ParameterBuilder[] pinfo;
+ private CustomAttributeBuilder[] cattrs;
+ private bool init_locals = true;
+
+ internal ConstructorBuilder (TypeBuilder tb, MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes) {
+ attrs = attributes | MethodAttributes.SpecialName;
+ call_conv = callingConvention;
+ if (parameterTypes != null) {
+ this.parameters = new Type [parameterTypes.Length];
+ System.Array.Copy (parameterTypes, this.parameters, parameterTypes.Length);
+ }
+ type = tb;
+ table_idx = get_next_table_index (this, 0x06, true);
+ }
+
+ public bool InitLocals {
+ get {return init_locals;}
+ set {init_locals = value;}
+ }
+
+ internal TypeBuilder TypeBuilder {
+ get {return type;}
+ }
+
+ public override MethodImplAttributes GetMethodImplementationFlags() {
+ return iattrs;
+ }
+ public override ParameterInfo[] GetParameters() {
+ if (parameters == null)
+ return null;
+
+ ParameterInfo[] retval = new ParameterInfo [parameters.Length];
+ for (int i = 0; i < parameters.Length; i++) {
+ retval [i] = new ParameterInfo (pinfo == null ? null : pinfo [i+1], parameters [i], this, i + 1);
+ }
+
+ return retval;
+ }
+ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) {
+ return null;
+ }
+ public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) {
+ return null;
+ }
+
+ public override RuntimeMethodHandle MethodHandle { get {return new RuntimeMethodHandle ();} }
+ public override MethodAttributes Attributes {
+ get {return attrs;}
+ }
+ public override Type ReflectedType { get {return type;}}
+ public override Type DeclaringType { get {return type;}}
+ public Type ReturnType { get {return null;}}
+ public override string Name {
+ get {return (attrs & MethodAttributes.Static) != 0 ? ".cctor" : ".ctor";}
+ }
+ public string Signature {
+ get {return "constructor signature";}
+ }
+
+ public void AddDeclarativeSecurity( SecurityAction action, PermissionSet pset) {
+ }
+
+ [MonoTODO]
+ public ParameterBuilder DefineParameter(int iSequence, ParameterAttributes attributes, string strParamName)
+ {
+ ParameterBuilder pb = new ParameterBuilder (this, iSequence, attributes, strParamName);
+ // check iSequence
+ if (pinfo == null)
+ pinfo = new ParameterBuilder [parameters.Length + 1];
+ pinfo [iSequence] = pb;
+ return pb;
+ }
+
+ public override bool IsDefined (Type attribute_type, bool inherit) {return false;}
+
+ public override object [] GetCustomAttributes (bool inherit) {return null;}
+
+ public override object [] GetCustomAttributes (Type attribute_type, bool inherit) {return null;}
+
+ public ILGenerator GetILGenerator () {
+ return GetILGenerator (64);
+ }
+ internal ILGenerator GetILGenerator (int size) {
+ ilgen = new ILGenerator (this, size);
+ return ilgen;
+ }
+
+ public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
+ string attrname = customBuilder.Ctor.ReflectedType.FullName;
+ if (attrname == "System.Runtime.CompilerServices.MethodImplAttribute") {
+ byte[] data = customBuilder.Data;
+ int impla; // the (stupid) ctor takes a short or an int ...
+ impla = (int)data [2];
+ impla |= ((int)data [3]) << 8;
+ SetImplementationFlags ((MethodImplAttributes)impla);
+ return;
+ }
+ if (cattrs != null) {
+ CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
+ cattrs.CopyTo (new_array, 0);
+ new_array [cattrs.Length] = customBuilder;
+ cattrs = new_array;
+ } else {
+ cattrs = new CustomAttributeBuilder [1];
+ cattrs [0] = customBuilder;
+ }
+ }
+ public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
+ SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
+ }
+ public void SetImplementationFlags( MethodImplAttributes attributes) {
+ iattrs = attributes;
+ }
+ public Module GetModule() {
+ return null;
+ }
+ public MethodToken GetToken() {
+ return new MethodToken (0x06000000 | table_idx);
+ }
+ public void SetSymCustomAttribute( string name, byte[] data) {
+ }
+ public override string ToString() {
+ return "constructor";
+ }
+
+ internal void fixup () {
+ if (ilgen != null)
+ ilgen.label_fixup ();
+ }
+ internal override int get_next_table_index (object obj, int table, bool inc) {
+ return type.get_next_table_index (obj, table, inc);
+ }
+
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs
new file mode 100755
index 00000000000..c77bec598fe
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs
@@ -0,0 +1,123 @@
+
+//
+// System.Reflection.Emit/CustomAttributeBuilder.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System.Reflection.Emit {
+ public class CustomAttributeBuilder {
+ ConstructorInfo ctor;
+ byte[] data;
+
+ internal ConstructorInfo Ctor {
+ get {return ctor;}
+ }
+
+ internal byte[] Data {
+ get {return data;}
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ static extern byte[] GetBlob(ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues, FieldInfo[] namedFields, object[] fieldValues);
+
+ internal CustomAttributeBuilder( ConstructorInfo con, byte[] cdata) {
+ ctor = con;
+ data = (byte[])cdata.Clone ();
+ /* should we check that the user supplied data is correct? */
+ }
+
+ public CustomAttributeBuilder( ConstructorInfo con, object[] constructorArgs)
+ : this (con, constructorArgs, null, null, null, null) {
+ }
+ public CustomAttributeBuilder( ConstructorInfo con, object[] constructorArgs, FieldInfo[] namedFields, object[] fieldValues)
+ : this (con, constructorArgs, null, null, namedFields, fieldValues) {
+ }
+ public CustomAttributeBuilder( ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues)
+ : this (con, constructorArgs, namedProperties, propertyValues, null, null) {
+ }
+ public CustomAttributeBuilder( ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues, FieldInfo[] namedFields, object[] fieldValues) {
+ ctor = con;
+ data = GetBlob (con, constructorArgs, namedProperties, propertyValues, namedFields, fieldValues);
+ }
+
+ /* helper methods */
+ internal static int decode_len (byte[] data, int pos, out int rpos) {
+ int len = 0;
+ if ((data [pos] & 0x80) == 0) {
+ len = (int)(data [pos++] & 0x7f);
+ } else if ((data [pos] & 0x40) == 0) {
+ len = ((data [pos] & 0x3f) << 8) + data [pos + 1];
+ pos += 2;
+ } else {
+ len = ((data [pos] & 0x1f) << 24) + (data [pos + 1] << 16) + (data [pos + 2] << 8) + data [pos + 3];
+ pos += 4;
+ }
+ rpos = pos;
+ return len;
+ }
+
+ internal static string string_from_bytes (byte[] data, int pos, int len) {
+ char[] chars = new char [len];
+ // FIXME: use a utf8 decoder here
+ for (int i = 0; i < len; ++i)
+ chars [i] = (char)data [pos + i];
+ return new String (chars);
+ }
+
+ internal static UnmanagedMarshal get_umarshal (CustomAttributeBuilder customBuilder, bool is_field) {
+ byte[] data = customBuilder.Data;
+ UnmanagedType subtype = UnmanagedType.I4;
+ int value;
+ int utype; /* the (stupid) ctor takes a short or an enum ... */
+ utype = (int)data [2];
+ utype |= ((int)data [3]) << 8;
+
+ string first_type_name = customBuilder.Ctor.GetParameters()[0].ParameterType.FullName;
+ int pos = 6;
+ if (first_type_name == "System.Int16")
+ pos = 4;
+ int nnamed = (int)data [pos++];
+ nnamed |= ((int)data [pos++]) << 8;
+
+ for (int i = 0; i < nnamed; ++i) {
+ byte type = data [pos++];
+ int len = decode_len (data, pos, out pos);
+ string named_name = string_from_bytes (data, pos, len);
+ pos += len;
+ switch (named_name) {
+ case "ArraySubType":
+ value = (int)data [pos++];
+ value |= ((int)data [pos++]) << 8;
+ value |= ((int)data [pos++]) << 16;
+ value |= ((int)data [pos++]) << 24;
+ subtype = (UnmanagedType)value;
+ break;
+ default:
+ break;
+ }
+ }
+
+ switch ((UnmanagedType)utype) {
+ case UnmanagedType.LPArray:
+ return UnmanagedMarshal.DefineLPArray (subtype);
+ case UnmanagedType.SafeArray:
+ return UnmanagedMarshal.DefineSafeArray (subtype);
+ case UnmanagedType.ByValArray:
+ case UnmanagedType.ByValTStr:
+ default:
+ return UnmanagedMarshal.DefineUnmanagedMarshal ((UnmanagedType)utype);
+ }
+ }
+
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs
new file mode 100755
index 00000000000..d82d116ad84
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs
@@ -0,0 +1,188 @@
+
+//
+// System.Reflection.Emit/EnumBuilder.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+
+namespace System.Reflection.Emit {
+ public sealed class EnumBuilder : Type {
+ CustomAttributeBuilder[] cattrs;
+
+ public override Assembly Assembly {
+ get {return null;}
+ }
+ public override string AssemblyQualifiedName {
+ get {return null;}
+ }
+ public override Type BaseType {
+ get {return null;}
+ }
+ public override Type DeclaringType {
+ get {return null;}
+ }
+ public override string FullName {
+ get {return null;}
+ }
+ public override Guid GUID {
+ get {return Guid.Empty;}
+ }
+ public override Module Module {
+ get {return null;}
+ }
+ public override string Name {
+ get {return null;}
+ }
+ public override string Namespace {
+ get {return null;}
+ }
+ public override Type ReflectedType {
+ get {return null;}
+ }
+ public override RuntimeTypeHandle TypeHandle {
+ get {return new RuntimeTypeHandle ();}
+ }
+ public TypeToken TypeToken {
+ get {return new TypeToken ();}
+ }
+ public FieldBuilder UnderlyingField {
+ get {return null;}
+ }
+ public override Type UnderlyingSystemType {
+ get {return null;}
+ }
+/* no need to override
+ public override MemberTypes MemberType {
+ get {return MemberTypes.TypeInfo;}
+ }
+*/
+
+ internal EnumBuilder (ModuleBuilder mb, string name, TypeAttributes visibility, Type underlyingType) {
+ }
+ public Type CreateType() {
+ return null;
+ }
+ public FieldBuilder DefineLiteral( string literalName, object literalValue) {
+ return null;
+ }
+ protected override TypeAttributes GetAttributeFlagsImpl() {
+ return (TypeAttributes)0;
+ }
+ protected override ConstructorInfo GetConstructorImpl( BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) {
+ return null;
+ }
+ public override ConstructorInfo[] GetConstructors( BindingFlags bindingAttr) {
+ return null;
+ }
+ public override object[] GetCustomAttributes(bool inherit) {
+ return null;
+ }
+ public override object[] GetCustomAttributes(Type attributeType, bool inherit) {
+ return null;
+ }
+ public override Type GetElementType() {
+ throw new NotSupportedException ();
+ }
+ public override EventInfo GetEvent( string name, BindingFlags bindingAttr) {
+ return null;
+ }
+ public override EventInfo[] GetEvents() {
+ return null;
+ }
+ public override EventInfo[] GetEvents( BindingFlags bindingAttr) {
+ return null;
+ }
+ public override FieldInfo GetField( string name, BindingFlags bindingAttr) {
+ return null;
+ }
+ public override FieldInfo[] GetFields( BindingFlags bindingAttr) {
+ return null;
+ }
+ public override Type GetInterface( string name, bool ignoreCase) {
+ return null;
+ }
+ public override InterfaceMapping GetInterfaceMap( Type interfaceType) {
+ throw new NotImplementedException ();
+ }
+ public override Type[] GetInterfaces() {
+ return null;
+ }
+ public override MemberInfo[] GetMember( string name, MemberTypes type, BindingFlags bindingAttr) {
+ return null;
+ }
+ public override MemberInfo[] GetMembers( BindingFlags bindingAttr) {
+ return null;
+ }
+ protected override MethodInfo GetMethodImpl( string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) {
+ // FIXME
+ return null;
+ }
+
+ public override MethodInfo[] GetMethods( BindingFlags bindingAttr) {
+ return null;
+ }
+ public override Type GetNestedType( string name, BindingFlags bindingAttr) {
+ return null;
+ }
+ public override Type[] GetNestedTypes( BindingFlags bindingAttr) {
+ return null;
+ }
+ public override PropertyInfo[] GetProperties( BindingFlags bindingAttr) {
+ return null;
+ }
+ protected override PropertyInfo GetPropertyImpl( string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) {
+ return null;
+ }
+ protected override bool HasElementTypeImpl() {
+ throw new NotSupportedException ();
+ }
+ public override object InvokeMember( string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) {
+ return null;
+ }
+ protected override bool IsArrayImpl() {
+ return false;
+ }
+ protected override bool IsByRefImpl() {
+ return false;
+ }
+ protected override bool IsCOMObjectImpl() {
+ return false;
+ }
+ protected override bool IsPointerImpl() {
+ return false;
+ }
+ protected override bool IsPrimitiveImpl() {
+ return false;
+ }
+ protected override bool IsValueTypeImpl() {
+ return true;
+ }
+ public override bool IsDefined( Type attributeType, bool inherit) {
+ return false;
+ }
+
+ public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
+ if (cattrs != null) {
+ CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
+ cattrs.CopyTo (new_array, 0);
+ new_array [cattrs.Length] = customBuilder;
+ cattrs = new_array;
+ } else {
+ cattrs = new CustomAttributeBuilder [1];
+ cattrs [0] = customBuilder;
+ }
+ }
+ public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
+ SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/EventBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/EventBuilder.cs
new file mode 100755
index 00000000000..507620a4764
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/EventBuilder.cs
@@ -0,0 +1,85 @@
+
+//
+// System.Reflection.Emit/EventBuilder.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System.Reflection.Emit {
+ public sealed class EventBuilder {
+ string name;
+ Type type;
+ TypeBuilder typeb;
+ CustomAttributeBuilder[] cattrs;
+ MethodBuilder add_method;
+ MethodBuilder remove_method;
+ MethodBuilder raise_method;
+ MethodBuilder[] other_methods;
+ EventAttributes attrs;
+ int table_idx;
+
+ internal EventBuilder (TypeBuilder tb, string eventName, EventAttributes eventAttrs, Type eventType) {
+ name = eventName;
+ attrs = eventAttrs;
+ type = eventType;
+ typeb = tb;
+ table_idx = get_next_table_index (this, 0x14, true);
+ }
+
+ internal int get_next_table_index (object obj, int table, bool inc) {
+ return typeb.get_next_table_index (obj, table, inc);
+ }
+
+ public void AddOtherMethod( MethodBuilder mdBuilder) {
+ if (other_methods != null) {
+ MethodBuilder[] newv = new MethodBuilder [other_methods.Length + 1];
+ other_methods.CopyTo (newv, 0);
+ other_methods = newv;
+ } else {
+ other_methods = new MethodBuilder [1];
+ }
+ other_methods [other_methods.Length - 1] = mdBuilder;
+ }
+
+ public EventToken GetEventToken () {
+ return new EventToken (0x14000000 | table_idx);
+ }
+ public void SetAddOnMethod( MethodBuilder mdBuilder) {
+ add_method = mdBuilder;
+ }
+ public void SetRaiseMethod( MethodBuilder mdBuilder) {
+ raise_method = mdBuilder;
+ }
+ public void SetRemoveOnMethod( MethodBuilder mdBuilder) {
+ remove_method = mdBuilder;
+ }
+
+ public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
+ if (cattrs != null) {
+ CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
+ cattrs.CopyTo (new_array, 0);
+ new_array [cattrs.Length] = customBuilder;
+ cattrs = new_array;
+ } else {
+ cattrs = new CustomAttributeBuilder [1];
+ cattrs [0] = customBuilder;
+ }
+ }
+ public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
+ SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
+ }
+
+
+ }
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/EventToken.cs b/mcs/class/corlib/System.Reflection.Emit/EventToken.cs
new file mode 100644
index 00000000000..4cc97be7ea1
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/EventToken.cs
@@ -0,0 +1,70 @@
+// EventToken.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+
+ /// <summary>
+ /// Represents the Token returned by the metadata to represent a Event.
+ /// </summary>
+ [Serializable]
+ public struct EventToken {
+
+ internal int tokValue;
+
+ public static readonly EventToken Empty;
+
+
+ static EventToken ()
+ {
+ Empty = new EventToken ();
+ }
+
+
+ internal EventToken (int val)
+ {
+ tokValue = val;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public override bool Equals (object obj)
+ {
+ bool res = obj is EventToken;
+
+ if (res) {
+ EventToken that = (EventToken) obj;
+ res = (this.tokValue == that.tokValue);
+ }
+
+ return res;
+ }
+
+
+ /// <summary>
+ /// Tests whether the given object is an instance of
+ /// EventToken and has the same token value.
+ /// </summary>
+ public override int GetHashCode ()
+ {
+ return tokValue;
+ }
+
+
+ /// <summary>
+ /// Returns the metadata token for this Event.
+ /// </summary>
+ public int Token {
+ get {
+ return tokValue;
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs
new file mode 100755
index 00000000000..5f876b1743e
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs
@@ -0,0 +1,129 @@
+
+//
+// System.Reflection.Emit/FieldBuilder.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001-2002 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System.Reflection.Emit {
+ public sealed class FieldBuilder : FieldInfo {
+ private FieldAttributes attrs;
+ private Type type;
+ private String name;
+ private object def_value;
+ private int offset;
+ private int table_idx;
+ internal TypeBuilder typeb;
+ private byte[] rva_data;
+ private CustomAttributeBuilder[] cattrs;
+ private UnmanagedMarshal marshal_info;
+ private RuntimeFieldHandle handle;
+
+ internal FieldBuilder (TypeBuilder tb, string fieldName, Type type, FieldAttributes attributes) {
+ attrs = attributes;
+ name = fieldName;
+ this.type = type;
+ offset = -1;
+ typeb = tb;
+ table_idx = tb.get_next_table_index (this, 0x04, true);
+ }
+
+ public override FieldAttributes Attributes {
+ get {return attrs;}
+ }
+ public override Type DeclaringType {
+ get {return typeb;}
+ }
+ public override RuntimeFieldHandle FieldHandle {
+ get {return new RuntimeFieldHandle();}
+ }
+ public override Type FieldType {
+ get {return type;}
+ }
+ public override string Name {
+ get {return name;}
+ }
+ public override Type ReflectedType {
+ get {return typeb;}
+ }
+
+ public override object[] GetCustomAttributes(bool inherit) {
+ return null;
+ }
+ public override object[] GetCustomAttributes(Type attributeType, bool inherit) {
+ return null;
+ }
+ public FieldToken GetToken() {
+ return new FieldToken (0x04000000 | table_idx);
+ }
+ public override object GetValue(object obj) {
+ return null;
+ }
+ public override bool IsDefined( Type attributeType, bool inherit) {
+ return false;
+ }
+ internal void SetRVAData (byte[] data) {
+ rva_data = (byte[])data.Clone ();
+ }
+ public void SetConstant( object defaultValue) {
+ /*if (defaultValue.GetType() != type)
+ throw new ArgumentException ("Constant doesn't match field type");*/
+ def_value = defaultValue;
+ }
+
+ public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
+ string attrname = customBuilder.Ctor.ReflectedType.FullName;
+ if (attrname == "System.Runtime.InteropServices.FieldOffsetAttribute") {
+ byte[] data = customBuilder.Data;
+ offset = (int)data [2];
+ offset |= ((int)data [3]) << 8;
+ offset |= ((int)data [4]) << 16;
+ offset |= ((int)data [5]) << 24;
+ return;
+ } else if (attrname == "System.NonSerializedAttribute") {
+ attrs |= FieldAttributes.NotSerialized;
+ return;
+ } else if (attrname == "System.Runtime.InteropServices.MarshalAsAttribute") {
+ marshal_info = CustomAttributeBuilder.get_umarshal (customBuilder, true);
+ /* FIXME: check for errors */
+ return;
+ }
+ if (cattrs != null) {
+ CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
+ cattrs.CopyTo (new_array, 0);
+ new_array [cattrs.Length] = customBuilder;
+ cattrs = new_array;
+ } else {
+ cattrs = new CustomAttributeBuilder [1];
+ cattrs [0] = customBuilder;
+ }
+ }
+
+ public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
+ SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
+ }
+
+ public void SetMarshal( UnmanagedMarshal unmanagedMarshal) {
+ marshal_info = unmanagedMarshal;
+ attrs |= FieldAttributes.HasFieldMarshal;
+ }
+
+ public void SetOffset( int iOffset) {
+ offset = iOffset;
+ }
+ public override void SetValue( object obj, object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture) {
+ }
+
+ }
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/FieldToken.cs b/mcs/class/corlib/System.Reflection.Emit/FieldToken.cs
new file mode 100644
index 00000000000..b3f5a5dade1
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/FieldToken.cs
@@ -0,0 +1,70 @@
+// FieldToken.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+
+ /// <summary>
+ /// Represents the Token returned by the metadata to represent a Field.
+ /// </summary>
+ [Serializable]
+ public struct FieldToken {
+
+ internal int tokValue;
+
+ public static readonly FieldToken Empty;
+
+
+ static FieldToken ()
+ {
+ Empty = new FieldToken ();
+ }
+
+
+ internal FieldToken (int val)
+ {
+ tokValue = val;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public override bool Equals (object obj)
+ {
+ bool res = obj is FieldToken;
+
+ if (res) {
+ FieldToken that = (FieldToken) obj;
+ res = (this.tokValue == that.tokValue);
+ }
+
+ return res;
+ }
+
+
+ /// <summary>
+ /// Tests whether the given object is an instance of
+ /// FieldToken and has the same token value.
+ /// </summary>
+ public override int GetHashCode ()
+ {
+ return tokValue;
+ }
+
+
+ /// <summary>
+ /// Returns the metadata token for this Field.
+ /// </summary>
+ public int Token {
+ get {
+ return tokValue;
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/FlowControl.cs b/mcs/class/corlib/System.Reflection.Emit/FlowControl.cs
new file mode 100644
index 00000000000..b714362cb11
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/FlowControl.cs
@@ -0,0 +1,63 @@
+// FlowControl.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+
+namespace System.Reflection.Emit {
+
+ /// <summary>
+ /// Describes how an instruction alters the flow of control.
+ /// </summary>
+ public enum FlowControl {
+
+ /// <summary>
+ /// Branch instruction (ex: br, leave).
+ /// </summary>
+ Branch = 0,
+
+ /// <summary>
+ /// Break instruction (ex: break).
+ /// </summary>
+ Break = 1,
+
+ /// <summary>
+ /// Call instruction (ex: jmp, call, callvirt).
+ /// </summary>
+ Call = 2,
+
+ /// <summary>
+ /// Conditional branch instruction (ex: brtrue, brfalse).
+ /// </summary>
+ Cond_Branch = 3,
+
+ /// <summary>
+ /// Changes the behaviour of or provides additional
+ /// about a subsequent instruction.
+ /// (ex: prefixes such as volatile, unaligned).
+ /// </summary>
+ Meta = 4,
+
+ /// <summary>
+ /// Transition to the next instruction.
+ /// </summary>
+ Next = 5,
+
+ /// <summary>
+ /// Annotation for ann.phi instruction.
+ /// </summary>
+ Phi = 6,
+
+ /// <summary>
+ /// Return instruction.
+ /// </summary>
+ Return = 7,
+
+ /// <summary>
+ /// Throw instruction.
+ /// </summary>
+ Throw = 8
+ }
+
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs b/mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs
new file mode 100644
index 00000000000..6276b3677e0
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs
@@ -0,0 +1,645 @@
+
+//
+// System.Reflection.Emit/ILGenerator.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Collections;
+using System.Diagnostics.SymbolStore;
+
+namespace System.Reflection.Emit {
+
+ internal struct ILExceptionBlock {
+ public const int CATCH = 0;
+ public const int FILTER = 1;
+ public const int FINALLY = 2;
+ public const int FAULT = 4;
+
+ internal Type extype;
+ internal int type;
+ internal int start;
+ internal int len;
+ internal int filter_offset;
+
+ internal void Debug () {
+#if NO
+ System.Console.Write ("\ttype="+type.ToString()+" start="+start.ToString()+" len="+len.ToString());
+ if (extype != null)
+ System.Console.WriteLine (" extype="+extype.ToString());
+ else
+ System.Console.WriteLine ("");
+#endif
+ }
+ }
+ internal struct ILExceptionInfo {
+ ILExceptionBlock[] handlers;
+ internal int start;
+ int len;
+ internal Label end;
+
+ internal int NumHandlers () {
+ return handlers.Length;
+ }
+
+ internal void AddCatch (Type extype, int offset) {
+ int i;
+ End (offset);
+ add_block (offset);
+ i = handlers.Length - 1;
+ handlers [i].type = ILExceptionBlock.CATCH;
+ handlers [i].start = offset;
+ handlers [i].extype = extype;
+ }
+
+ internal void AddFinally (int offset) {
+ int i;
+ End (offset);
+ add_block (offset);
+ i = handlers.Length - 1;
+ handlers [i].type = ILExceptionBlock.FINALLY;
+ handlers [i].start = offset;
+ handlers [i].extype = null;
+ }
+
+ internal void End (int offset) {
+ if (handlers == null)
+ return;
+ int i = handlers.Length - 1;
+ if (i >= 0)
+ handlers [i].len = offset - handlers [i].start;
+ }
+
+ internal int LastClauseType () {
+ if (handlers != null)
+ return handlers [handlers.Length-1].type;
+ else
+ return ILExceptionBlock.CATCH;
+ }
+
+ internal void Debug (int b) {
+#if NO
+ System.Console.WriteLine ("Handler {0} at {1}, len: {2}", b, start, len);
+ for (int i = 0; i < handlers.Length; ++i)
+ handlers [i].Debug ();
+#endif
+ }
+
+ void add_block (int offset) {
+ if (handlers != null) {
+ int i = handlers.Length;
+ ILExceptionBlock[] new_b = new ILExceptionBlock [i + 1];
+ System.Array.Copy (handlers, new_b, i);
+ handlers = new_b;
+ handlers [i].len = offset - handlers [i].start;
+ } else {
+ handlers = new ILExceptionBlock [1];
+ len = offset - start;
+ }
+ }
+ }
+
+ internal struct ILTokenInfo {
+ public MemberInfo member;
+ public int code_pos;
+ }
+
+ public class ILGenerator: Object {
+ private struct LabelFixup {
+ public int size;
+ public int pos; // the location of the fixup
+ public int label_base; // the base address for this fixup
+ public int label_idx;
+ };
+ static Type void_type = typeof (void);
+ private byte[] code;
+ private MethodBase mbuilder; /* a MethodBuilder or ConstructorBuilder */
+ private int code_len;
+ private int max_stack;
+ private int cur_stack;
+ private LocalBuilder[] locals;
+ private ILExceptionInfo[] ex_handlers;
+ private int num_token_fixups;
+ private ILTokenInfo[] token_fixups;
+ private int[] label_to_addr;
+ private int num_labels;
+ private LabelFixup[] fixups;
+ private int num_fixups;
+ private ModuleBuilder module;
+ private AssemblyBuilder abuilder;
+ private ISymbolWriter sym_writer;
+ private Stack scopes;
+ private int cur_block;
+ private Stack open_blocks;
+
+ internal ILGenerator (MethodBase mb, int size) {
+ if (size < 0)
+ size = 128;
+ code_len = 0;
+ code = new byte [size];
+ mbuilder = mb;
+ cur_stack = max_stack = 0;
+ num_fixups = num_labels = 0;
+ label_to_addr = new int [8];
+ fixups = new LabelFixup [8];
+ token_fixups = new ILTokenInfo [8];
+ num_token_fixups = 0;
+ if (mb is MethodBuilder) {
+ module = (ModuleBuilder)((MethodBuilder)mb).TypeBuilder.Module;
+ } else if (mb is ConstructorBuilder) {
+ module = (ModuleBuilder)((ConstructorBuilder)mb).TypeBuilder.Module;
+ }
+ abuilder = (AssemblyBuilder)module.Assembly;
+ sym_writer = module.GetSymWriter ();
+ open_blocks = new Stack ();
+ }
+
+ private void add_token_fixup (MemberInfo mi) {
+ if (num_token_fixups == token_fixups.Length) {
+ ILTokenInfo[] ntf = new ILTokenInfo [num_token_fixups * 2];
+ token_fixups.CopyTo (ntf, 0);
+ token_fixups = ntf;
+ }
+ token_fixups [num_token_fixups].member = mi;
+ token_fixups [num_token_fixups++].code_pos = code_len;
+ }
+
+ private void make_room (int nbytes) {
+ if (code_len + nbytes < code.Length)
+ return;
+ byte[] new_code = new byte [(code_len + nbytes) * 2 + 128];
+ System.Array.Copy (code, 0, new_code, 0, code.Length);
+ code = new_code;
+ }
+ private void emit_int (int val) {
+ code [code_len++] = (byte) (val & 0xFF);
+ code [code_len++] = (byte) ((val >> 8) & 0xFF);
+ code [code_len++] = (byte) ((val >> 16) & 0xFF);
+ code [code_len++] = (byte) ((val >> 24) & 0xFF);
+ }
+ /* change to pass by ref to avoid copy */
+ private void ll_emit (OpCode opcode) {
+ /*
+ * there is already enough room allocated in code.
+ */
+ // access op1 and op2 directly since the Value property is useless
+ if (opcode.Size == 2)
+ code [code_len++] = opcode.op1;
+ code [code_len++] = opcode.op2;
+ /*
+ * We should probably keep track of stack needs here.
+ * Or we may want to run the verifier on the code before saving it
+ * (this may be needed anyway when the ILGenerator is not used...).
+ */
+ switch (opcode.StackBehaviourPush) {
+ case StackBehaviour.Push1:
+ case StackBehaviour.Pushi:
+ case StackBehaviour.Pushi8:
+ case StackBehaviour.Pushr4:
+ case StackBehaviour.Pushr8:
+ case StackBehaviour.Pushref:
+ case StackBehaviour.Varpush: /* again we are conservative and assume it pushes 1 */
+ cur_stack ++;
+ break;
+ case StackBehaviour.Push1_push1:
+ cur_stack += 2;
+ break;
+ }
+ if (max_stack < cur_stack)
+ max_stack = cur_stack;
+ /*
+ * Note that we adjust for the pop behaviour _after_ setting max_stack.
+ */
+ switch (opcode.StackBehaviourPop) {
+ case StackBehaviour.Varpop:
+ break; /* we are conservative and assume it doesn't decrease the stack needs */
+ case StackBehaviour.Pop1:
+ case StackBehaviour.Popi:
+ case StackBehaviour.Popref:
+ cur_stack --;
+ break;
+ case StackBehaviour.Pop1_pop1:
+ case StackBehaviour.Popi_pop1:
+ case StackBehaviour.Popi_popi:
+ case StackBehaviour.Popi_popi8:
+ case StackBehaviour.Popi_popr4:
+ case StackBehaviour.Popi_popr8:
+ case StackBehaviour.Popref_pop1:
+ case StackBehaviour.Popref_popi:
+ cur_stack -= 2;
+ break;
+ case StackBehaviour.Popi_popi_popi:
+ case StackBehaviour.Popref_popi_popi:
+ case StackBehaviour.Popref_popi_popi8:
+ case StackBehaviour.Popref_popi_popr4:
+ case StackBehaviour.Popref_popi_popr8:
+ case StackBehaviour.Popref_popi_popref:
+ cur_stack -= 3;
+ break;
+ }
+ }
+
+ private static int target_len (OpCode opcode) {
+ if (opcode.operandType == OperandType.InlineBrTarget)
+ return 4;
+ return 1;
+ }
+
+ private void InternalEndClause () {
+ switch (ex_handlers [cur_block].LastClauseType ()) {
+ case ILExceptionBlock.CATCH:
+ // how could we optimize code size here?
+ Emit (OpCodes.Leave, ex_handlers [cur_block].end);
+ break;
+ case ILExceptionBlock.FAULT:
+ case ILExceptionBlock.FINALLY:
+ Emit (OpCodes.Endfinally);
+ break;
+ case ILExceptionBlock.FILTER:
+ Emit (OpCodes.Endfilter);
+ break;
+ }
+ }
+
+ public virtual void BeginCatchBlock (Type exceptionType) {
+ if (open_blocks.Count <= 0)
+ throw new NotSupportedException ("Not in an exception block");
+ InternalEndClause ();
+ ex_handlers [cur_block].AddCatch (exceptionType, code_len);
+ cur_stack = 1; // the exception object is on the stack by default
+ if (max_stack < cur_stack)
+ max_stack = cur_stack;
+ //System.Console.WriteLine ("Begin catch Block: {0} {1}",exceptionType.ToString(), max_stack);
+ //throw new NotImplementedException ();
+ }
+ public virtual void BeginExceptFilterBlock () {
+ throw new NotImplementedException ();
+ }
+ public virtual Label BeginExceptionBlock () {
+ //System.Console.WriteLine ("Begin Block");
+
+ if (ex_handlers != null) {
+ cur_block = ex_handlers.Length;
+ ILExceptionInfo[] new_ex = new ILExceptionInfo [cur_block + 1];
+ System.Array.Copy (ex_handlers, new_ex, cur_block);
+ ex_handlers = new_ex;
+ } else {
+ ex_handlers = new ILExceptionInfo [1];
+ cur_block = 0;
+ }
+ open_blocks.Push (cur_block);
+ ex_handlers [cur_block].start = code_len;
+ return ex_handlers [cur_block].end = DefineLabel ();
+ }
+ public virtual void BeginFaultBlock() {
+ if (open_blocks.Count <= 0)
+ throw new NotSupportedException ("Not in an exception block");
+ //System.Console.WriteLine ("Begin fault Block");
+ //throw new NotImplementedException ();
+ }
+ public virtual void BeginFinallyBlock() {
+ if (open_blocks.Count <= 0)
+ throw new NotSupportedException ("Not in an exception block");
+ InternalEndClause ();
+ //System.Console.WriteLine ("Begin finally Block");
+ ex_handlers [cur_block].AddFinally (code_len);
+ }
+ public virtual void BeginScope () {
+ if (sym_writer != null) {
+ if (scopes == null)
+ scopes = new Stack ();
+ scopes.Push (sym_writer.OpenScope (code_len));
+ }
+ }
+ public LocalBuilder DeclareLocal (Type localType) {
+ LocalBuilder res = new LocalBuilder (module, localType, this);
+ if (locals != null) {
+ LocalBuilder[] new_l = new LocalBuilder [locals.Length + 1];
+ System.Array.Copy (locals, new_l, locals.Length);
+ new_l [locals.Length] = res;
+ locals = new_l;
+ } else {
+ locals = new LocalBuilder [1];
+ locals [0] = res;
+ }
+ res.position = (uint)(locals.Length - 1);
+ return res;
+ }
+ public virtual Label DefineLabel () {
+ if (num_labels >= label_to_addr.Length) {
+ int[] new_l = new int [label_to_addr.Length * 2];
+ System.Array.Copy (label_to_addr, new_l, label_to_addr.Length);
+ label_to_addr = new_l;
+ }
+ label_to_addr [num_labels] = -1;
+ return new Label (num_labels++);
+ }
+ public virtual void Emit (OpCode opcode) {
+ make_room (2);
+ ll_emit (opcode);
+ }
+ public virtual void Emit (OpCode opcode, Byte val) {
+ make_room (3);
+ ll_emit (opcode);
+ code [code_len++] = val;
+ }
+ public virtual void Emit (OpCode opcode, ConstructorInfo constructor) {
+ int token = abuilder.GetToken (constructor);
+ make_room (6);
+ ll_emit (opcode);
+ if (constructor is ConstructorBuilder)
+ add_token_fixup (constructor);
+ emit_int (token);
+ ParameterInfo[] mparams = constructor.GetParameters();
+ if (mparams != null)
+ cur_stack -= mparams.Length;
+ }
+ public virtual void Emit (OpCode opcode, double val) {
+ byte[] s = System.BitConverter.GetBytes (val);
+ make_room (10);
+ ll_emit (opcode);
+ if (BitConverter.IsLittleEndian){
+ System.Array.Copy (s, 0, code, code_len, 8);
+ code_len += 8;
+ } else {
+ code [code_len++] = s [7];
+ code [code_len++] = s [6];
+ code [code_len++] = s [5];
+ code [code_len++] = s [4];
+ code [code_len++] = s [3];
+ code [code_len++] = s [2];
+ code [code_len++] = s [1];
+ code [code_len++] = s [0];
+ }
+ }
+ public virtual void Emit (OpCode opcode, FieldInfo field) {
+ int token = abuilder.GetToken (field);
+ make_room (6);
+ ll_emit (opcode);
+ if (field is FieldBuilder)
+ add_token_fixup (field);
+ emit_int (token);
+ }
+ public virtual void Emit (OpCode opcode, Int16 val) {
+ make_room (4);
+ ll_emit (opcode);
+ code [code_len++] = (byte) (val & 0xFF);
+ code [code_len++] = (byte) ((val >> 8) & 0xFF);
+ }
+ public virtual void Emit (OpCode opcode, int val) {
+ make_room (6);
+ ll_emit (opcode);
+ emit_int (val);
+ }
+ public virtual void Emit (OpCode opcode, long val) {
+ make_room (10);
+ ll_emit (opcode);
+ code [code_len++] = (byte) (val & 0xFF);
+ code [code_len++] = (byte) ((val >> 8) & 0xFF);
+ code [code_len++] = (byte) ((val >> 16) & 0xFF);
+ code [code_len++] = (byte) ((val >> 24) & 0xFF);
+ code [code_len++] = (byte) ((val >> 32) & 0xFF);
+ code [code_len++] = (byte) ((val >> 40) & 0xFF);
+ code [code_len++] = (byte) ((val >> 48) & 0xFF);
+ code [code_len++] = (byte) ((val >> 56) & 0xFF);
+ }
+ public virtual void Emit (OpCode opcode, Label label) {
+ int tlen = target_len (opcode);
+ make_room (6);
+ ll_emit (opcode);
+ if (num_fixups >= fixups.Length) {
+ LabelFixup[] newf = new LabelFixup [fixups.Length + 16];
+ System.Array.Copy (fixups, newf, fixups.Length);
+ fixups = newf;
+ }
+ fixups [num_fixups].size = tlen;
+ fixups [num_fixups].pos = code_len;
+ fixups [num_fixups].label_base = code_len;
+ fixups [num_fixups].label_idx = label.label;
+ num_fixups++;
+ code_len += tlen;
+
+ }
+ public virtual void Emit (OpCode opcode, Label[] labels) {
+ /* opcode needs to be switch. */
+ int count = labels.Length;
+ make_room (6 + count * 4);
+ ll_emit (opcode);
+ int switch_base = code_len + count*4;
+ emit_int (count);
+ if (num_fixups + count >= fixups.Length) {
+ LabelFixup[] newf = new LabelFixup [fixups.Length + count + 16];
+ System.Array.Copy (fixups, newf, fixups.Length);
+ fixups = newf;
+ }
+ for (int i = 0; i < count; ++i) {
+ fixups [num_fixups].size = 4;
+ fixups [num_fixups].pos = code_len;
+ fixups [num_fixups].label_base = switch_base;
+ fixups [num_fixups].label_idx = labels [i].label;
+ num_fixups++;
+ code_len += 4;
+ }
+ }
+ public virtual void Emit (OpCode opcode, LocalBuilder lbuilder) {
+ uint pos = lbuilder.position;
+ bool load_addr = false;
+ bool is_store = false;
+ make_room (6);
+
+ if (lbuilder.ilgen != this)
+ throw new Exception ("Trying to emit a local from a different ILGenerator.");
+
+ /* inline the code from ll_emit () to optimize il code size */
+ if (opcode.StackBehaviourPop == StackBehaviour.Pop1) {
+ cur_stack --;
+ is_store = true;
+ } else {
+ cur_stack++;
+ if (cur_stack > max_stack)
+ max_stack = cur_stack;
+ load_addr = opcode.StackBehaviourPush == StackBehaviour.Pushi;
+ }
+ if (load_addr) {
+ if (pos < 256) {
+ code [code_len++] = (byte)0x12;
+ code [code_len++] = (byte)pos;
+ } else {
+ code [code_len++] = (byte)0xfe;
+ code [code_len++] = (byte)0x0d;
+ code [code_len++] = (byte)(pos & 0xff);
+ code [code_len++] = (byte)((pos >> 8) & 0xff);
+ }
+ } else {
+ if (is_store) {
+ if (pos < 4) {
+ code [code_len++] = (byte)(0x0a + pos);
+ } else if (pos < 256) {
+ code [code_len++] = (byte)0x13;
+ code [code_len++] = (byte)pos;
+ } else {
+ code [code_len++] = (byte)0xfe;
+ code [code_len++] = (byte)0x0e;
+ code [code_len++] = (byte)(pos & 0xff);
+ code [code_len++] = (byte)((pos >> 8) & 0xff);
+ }
+ } else {
+ if (pos < 4) {
+ code [code_len++] = (byte)(0x06 + pos);
+ } else if (pos < 256) {
+ code [code_len++] = (byte)0x11;
+ code [code_len++] = (byte)pos;
+ } else {
+ code [code_len++] = (byte)0xfe;
+ code [code_len++] = (byte)0x0c;
+ code [code_len++] = (byte)(pos & 0xff);
+ code [code_len++] = (byte)((pos >> 8) & 0xff);
+ }
+ }
+ }
+ }
+ public virtual void Emit (OpCode opcode, MethodInfo method) {
+ int token = abuilder.GetToken (method);
+ make_room (6);
+ ll_emit (opcode);
+ if (method is MethodBuilder)
+ add_token_fixup (method);
+ emit_int (token);
+ if (method.ReturnType != void_type)
+ cur_stack ++;
+ ParameterInfo[] mparams = method.GetParameters();
+ if (mparams != null)
+ cur_stack -= mparams.Length;
+ }
+ [CLSCompliant(false)]
+ public void Emit (OpCode opcode, sbyte val) {
+ make_room (3);
+ ll_emit (opcode);
+ code [code_len++] = (byte)val;
+ }
+
+ [MonoTODO]
+ public virtual void Emit (OpCode opcode, SignatureHelper shelper) {
+ int token = 0; // FIXME: request a token from the modulebuilder
+ make_room (6);
+ ll_emit (opcode);
+ emit_int (token);
+ }
+ public virtual void Emit (OpCode opcode, float val) {
+ byte[] s = System.BitConverter.GetBytes (val);
+ make_room (6);
+ ll_emit (opcode);
+ if (BitConverter.IsLittleEndian){
+ System.Array.Copy (s, 0, code, code_len, 4);
+ code_len += 4;
+ } else {
+ code [code_len++] = s [3];
+ code [code_len++] = s [2];
+ code [code_len++] = s [1];
+ code [code_len++] = s [0];
+ }
+ }
+ public virtual void Emit (OpCode opcode, string val) {
+ int token = abuilder.GetToken (val);
+ make_room (6);
+ ll_emit (opcode);
+ emit_int (token);
+ }
+ public virtual void Emit (OpCode opcode, Type type) {
+ make_room (6);
+ ll_emit (opcode);
+ if (type is TypeBuilder)
+ add_token_fixup (type);
+ emit_int (abuilder.GetToken (type));
+ }
+
+ public void EmitCall (OpCode opcode, MethodInfo methodinfo, Type[] optionalParamTypes) {
+ throw new NotImplementedException ();
+ }
+ public void EmitCalli (OpCode opcode, CallingConventions call_conv, Type returnType, Type[] paramTypes, Type[] optionalParamTypes) {
+ throw new NotImplementedException ();
+ }
+
+ public virtual void EmitWriteLine (FieldInfo field) {
+ throw new NotImplementedException ();
+ }
+ public virtual void EmitWriteLine (LocalBuilder lbuilder) {
+ throw new NotImplementedException ();
+ }
+ public virtual void EmitWriteLine (string val) {
+ Emit (OpCodes.Ldstr, val);
+ Emit (OpCodes.Call,
+ typeof (Console).GetMethod ("WriteLine",
+ new Type[1] { typeof(string)}));
+ }
+
+ public virtual void EndExceptionBlock () {
+ if (open_blocks.Count <= 0)
+ throw new NotSupportedException ("Not in an exception block");
+ InternalEndClause ();
+ MarkLabel (ex_handlers [cur_block].end);
+ ex_handlers [cur_block].End (code_len);
+ ex_handlers [cur_block].Debug (cur_block);
+ //System.Console.WriteLine ("End Block {0} (handlers: {1})", cur_block, ex_handlers [cur_block].NumHandlers ());
+ open_blocks.Pop ();
+ if (open_blocks.Count > 0)
+ cur_block = (int)open_blocks.Peek ();
+ //Console.WriteLine ("curblock restored to {0}", cur_block);
+ //throw new NotImplementedException ();
+ }
+ public virtual void EndScope () {
+ if (sym_writer != null) {
+ sym_writer.CloseScope (code_len);
+ if (scopes == null)
+ throw new InvalidOperationException ();
+ scopes.Pop ();
+ }
+ }
+ public virtual void MarkLabel (Label loc) {
+ if (loc.label < 0 || loc.label >= num_labels)
+ throw new System.ArgumentException ("The label is not valid");
+ if (label_to_addr [loc.label] >= 0)
+ throw new System.ArgumentException ("The label was already defined");
+ label_to_addr [loc.label] = code_len;
+ }
+ public virtual void MarkSequencePoint (ISymbolDocumentWriter document, int startLine,
+ int startColumn, int endLine, int endColumn) {
+ if (sym_writer == null)
+ return;
+
+ int[] offsets = { code_len };
+ int[] startLines = { startLine };
+ int[] startColumns = { startColumn };
+ int[] endLines = { endLine };
+ int[] endColumns = { endColumn };
+
+ sym_writer.DefineSequencePoints (document, offsets, startLines, startColumns,
+ endLines, endColumns);
+ }
+ public virtual void ThrowException (Type exceptionType) {
+ throw new NotImplementedException ();
+ }
+ public void UsingNamespace (String usingNamespace) {
+ throw new NotImplementedException ();
+ }
+
+ internal void label_fixup () {
+ int i;
+ for (i = 0; i < num_fixups; ++i) {
+ int diff = label_to_addr [fixups [i].label_idx] - fixups [i].label_base;
+ if (fixups [i].size == 1) {
+ code [fixups [i].pos] = (byte)((sbyte) diff - 1);
+ } else {
+ int old_cl = code_len;
+ code_len = fixups [i].pos;
+ emit_int (diff - 4);
+ code_len = old_cl;
+ }
+ }
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/Label.cs b/mcs/class/corlib/System.Reflection.Emit/Label.cs
new file mode 100644
index 00000000000..19be26c6dea
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/Label.cs
@@ -0,0 +1,29 @@
+//
+// System.Reflection.Emit/Label.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+namespace System.Reflection.Emit {
+ [Serializable]
+ public struct Label {
+ internal int label;
+
+ internal Label (int val) {
+ label = val;
+ }
+
+ [MonoTODO]
+ public override bool Equals (object obj) {
+ /* FIXME */
+ return false;
+ }
+
+ public override int GetHashCode () {
+ return label.GetHashCode ();
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/LocalBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/LocalBuilder.cs
new file mode 100755
index 00000000000..6ab80c7f2a7
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/LocalBuilder.cs
@@ -0,0 +1,70 @@
+
+//
+// System.Reflection.Emit/LocalBuilder.cs
+//
+// Authors:
+// Paolo Molaro (lupus@ximian.com)
+// Martin Baulig (martin@gnome.org)
+// Miguel de Icaza (miguel@ximian.com)
+//
+// (C) 2001, 2002 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Diagnostics.SymbolStore;
+
+namespace System.Reflection.Emit {
+ public sealed class LocalBuilder {
+ //
+ // These are kept in sync with reflection.h
+ //
+ #region Sync with reflection.h
+ private Type type;
+ private string name;
+ #endregion
+
+ //
+ // Order does not matter after here
+ //
+ private ModuleBuilder module;
+ internal uint position;
+ internal ILGenerator ilgen;
+
+ internal LocalBuilder (ModuleBuilder m, Type t, ILGenerator ilgen)
+ {
+ this.module = m;
+ this.type = t;
+ this.ilgen = ilgen;
+ }
+ public void SetLocalSymInfo (string lname, int startOffset, int endOffset)
+ {
+ this.name = lname;
+
+ SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
+ sighelper.AddArgument (type);
+ byte[] signature = sighelper.GetSignature ();
+
+ module.symbol_writer.DefineLocalVariable (lname, FieldAttributes.Private,
+ signature, SymAddressKind.ILOffset,
+ (int) position, 0, 0,
+ startOffset, endOffset);
+ }
+
+ public void SetLocalSymInfo (string lname)
+ {
+ SetLocalSymInfo (lname, 0, 0);
+ }
+
+
+ public Type LocalType
+ {
+ get {
+ return type;
+ }
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs
new file mode 100755
index 00000000000..b8190f13e6b
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs
@@ -0,0 +1,178 @@
+
+//
+// System.Reflection.Emit/MethodBuilder.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System.Reflection.Emit {
+ public sealed class MethodBuilder : MethodInfo {
+ private RuntimeMethodHandle mhandle;
+ private Type rtype;
+ private Type[] parameters;
+ private MethodAttributes attrs;
+ private MethodImplAttributes iattrs;
+ private string name;
+ private int table_idx;
+ private byte[] code;
+ private ILGenerator ilgen;
+ private TypeBuilder type;
+ private ParameterBuilder[] pinfo;
+ private CustomAttributeBuilder[] cattrs;
+ private MethodInfo override_method;
+ private string pi_dll;
+ private string pi_entry;
+ private CharSet ncharset;
+ private CallingConvention native_cc;
+ private CallingConventions call_conv;
+ private bool init_locals = true;
+
+ internal MethodBuilder (TypeBuilder tb, string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
+ this.name = name;
+ this.attrs = attributes;
+ this.call_conv = callingConvention;
+ this.rtype = returnType;
+ if (parameterTypes != null) {
+ this.parameters = new Type [parameterTypes.Length];
+ System.Array.Copy (parameterTypes, this.parameters, parameterTypes.Length);
+ }
+ type = tb;
+ table_idx = get_next_table_index (this, 0x06, true);
+ //Console.WriteLine ("index for "+name+" set to "+table_idx.ToString());
+ }
+
+ internal MethodBuilder (TypeBuilder tb, string name, MethodAttributes attributes,
+ CallingConventions callingConvention, Type returnType, Type[] parameterTypes,
+ String dllName, String entryName, CallingConvention nativeCConv, CharSet nativeCharset)
+ : this (tb, name, attributes, callingConvention, returnType, parameterTypes) {
+ pi_dll = dllName;
+ pi_entry = entryName;
+ native_cc = nativeCConv;
+ ncharset = nativeCharset;
+ }
+
+ public bool InitLocals {
+ get {return init_locals;}
+ set {init_locals = value;}
+ }
+
+ internal TypeBuilder TypeBuilder {
+ get {return type;}
+ }
+
+ public override Type ReturnType {get {return rtype;}}
+ public override Type ReflectedType {get {return type;}}
+ public override Type DeclaringType {get {return type;}}
+ public override string Name {get {return name;}}
+ public override RuntimeMethodHandle MethodHandle {get {return mhandle;}}
+ public override MethodAttributes Attributes {get {return attrs;}}
+ public override ICustomAttributeProvider ReturnTypeCustomAttributes {
+ get {return null;}
+ }
+ public MethodToken GetToken() {
+ return new MethodToken(0x06000000 | table_idx);
+ }
+
+ public override MethodInfo GetBaseDefinition() {
+ return null;
+ }
+ public override MethodImplAttributes GetMethodImplementationFlags() {
+ return iattrs;
+ }
+ public override ParameterInfo[] GetParameters() {
+ if (parameters == null)
+ return null;
+
+ ParameterInfo[] retval = new ParameterInfo [parameters.Length];
+ for (int i = 0; i < parameters.Length; i++) {
+ retval [i] = new ParameterInfo (pinfo == null ? null : pinfo [i + 1], parameters [i], this, i + 1);
+ }
+ return retval;
+ }
+
+ public void CreateMethodBody( byte[] il, int count) {
+ code = new byte [count];
+ System.Array.Copy(il, code, count);
+ }
+ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) {
+ return null;
+ }
+ public override bool IsDefined (Type attribute_type, bool inherit) {
+ return false;
+ }
+ public override object[] GetCustomAttributes( bool inherit) {
+ return null;
+ }
+ public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
+ return null;
+ }
+ public ILGenerator GetILGenerator () {
+ return GetILGenerator (64);
+ }
+ public ILGenerator GetILGenerator (int size) {
+ ilgen = new ILGenerator (this, size);
+ return ilgen;
+ }
+
+ [MonoTODO]
+ public ParameterBuilder DefineParameter (int position, ParameterAttributes attributes, string strParamName)
+ {
+ ParameterBuilder pb = new ParameterBuilder (this, position, attributes, strParamName);
+ // check position
+ if (pinfo == null)
+ pinfo = new ParameterBuilder [parameters.Length + 1];
+ pinfo [position] = pb;
+ return pb;
+ }
+
+ internal void fixup () {
+ if (ilgen != null)
+ ilgen.label_fixup ();
+ }
+
+ public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
+ string attrname = customBuilder.Ctor.ReflectedType.FullName;
+ if (attrname == "System.Runtime.CompilerServices.MethodImplAttribute") {
+ byte[] data = customBuilder.Data;
+ int impla; // the (stupid) ctor takes a short or an int ...
+ impla = (int)data [2];
+ impla |= ((int)data [3]) << 8;
+ SetImplementationFlags ((MethodImplAttributes)impla);
+ return;
+ }
+ if (cattrs != null) {
+ CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
+ cattrs.CopyTo (new_array, 0);
+ new_array [cattrs.Length] = customBuilder;
+ cattrs = new_array;
+ } else {
+ cattrs = new CustomAttributeBuilder [1];
+ cattrs [0] = customBuilder;
+ }
+ }
+ public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
+ SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
+ }
+ public void SetImplementationFlags( MethodImplAttributes attributes) {
+ iattrs = attributes;
+ }
+ internal override int get_next_table_index (object obj, int table, bool inc) {
+ return type.get_next_table_index (obj, table, inc);
+ }
+
+ internal void set_override (MethodInfo mdecl) {
+ override_method = mdecl;
+ }
+ }
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/MethodToken.cs b/mcs/class/corlib/System.Reflection.Emit/MethodToken.cs
new file mode 100644
index 00000000000..a08d4247571
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/MethodToken.cs
@@ -0,0 +1,70 @@
+// MethodToken.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+
+ /// <summary>
+ /// Represents the Token returned by the metadata to represent a Method.
+ /// </summary>
+ [Serializable]
+ public struct MethodToken {
+
+ internal int tokValue;
+
+ public static readonly MethodToken Empty;
+
+
+ static MethodToken ()
+ {
+ Empty = new MethodToken ();
+ }
+
+
+ internal MethodToken (int val)
+ {
+ tokValue = val;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public override bool Equals (object obj)
+ {
+ bool res = obj is MethodToken;
+
+ if (res) {
+ MethodToken that = (MethodToken) obj;
+ res = (this.tokValue == that.tokValue);
+ }
+
+ return res;
+ }
+
+
+ /// <summary>
+ /// Tests whether the given object is an instance of
+ /// MethodToken and has the same token value.
+ /// </summary>
+ public override int GetHashCode ()
+ {
+ return tokValue;
+ }
+
+
+ /// <summary>
+ /// Returns the metadata token for this Method.
+ /// </summary>
+ public int Token {
+ get {
+ return tokValue;
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
new file mode 100644
index 00000000000..0e35694a361
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
@@ -0,0 +1,363 @@
+
+//
+// System.Reflection.Emit/ModuleBuilder.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Collections;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Diagnostics.SymbolStore;
+using System.IO;
+
+namespace System.Reflection.Emit {
+ public class ModuleBuilder : Module {
+ private TypeBuilder[] types;
+ private CustomAttributeBuilder[] cattrs;
+ private byte[] guid;
+ private int table_idx;
+ internal AssemblyBuilder assemblyb;
+ private MethodBuilder[] global_methods;
+ private FieldBuilder[] global_fields;
+ private TypeBuilder global_type;
+ private Type global_type_created;
+ internal ISymbolWriter symbol_writer;
+ Hashtable name_cache;
+
+ internal ModuleBuilder (AssemblyBuilder assb, string name, string fullyqname, bool emitSymbolInfo) {
+ this.name = this.scopename = name;
+ this.fqname = fullyqname;
+ this.assembly = this.assemblyb = assb;
+ guid = Guid.NewGuid().ToByteArray ();
+ table_idx = get_next_table_index (this, 0x00, true);
+ name_cache = new Hashtable ();
+
+ if (emitSymbolInfo)
+ GetSymbolWriter (fullyqname);
+ }
+
+ internal void GetSymbolWriter (string filename)
+ {
+ Assembly assembly;
+ try {
+ assembly = Assembly.Load ("Mono.CSharp.Debugger");
+ } catch (FileNotFoundException) {
+ return;
+ }
+
+ Type type = assembly.GetType ("Mono.CSharp.Debugger.MonoSymbolWriter");
+ if (type == null)
+ return;
+
+ if (assemblyb.methods == null)
+ assemblyb.methods = new ArrayList ();
+
+ // First get the constructor.
+ {
+ Type[] arg_types = new Type [3];
+ arg_types [0] = typeof (ModuleBuilder);
+ arg_types [1] = typeof (string);
+ arg_types [2] = typeof (ArrayList);
+ ConstructorInfo constructor = type.GetConstructor (arg_types);
+
+ object[] args = new object [3];
+ args [0] = this;
+ args [1] = filename;
+ args [2] = assemblyb.methods;
+
+ if (constructor == null)
+ return;
+
+ Object instance = constructor.Invoke (args);
+ if (instance == null)
+ return;
+
+ if (!(instance is ISymbolWriter))
+ return;
+
+ symbol_writer = (ISymbolWriter) instance;
+ }
+ }
+
+ public override string FullyQualifiedName {get { return fqname;}}
+
+ public void CreateGlobalFunctions ()
+ {
+ if (global_type_created != null)
+ throw new InvalidOperationException ("global methods already created");
+ if (global_type != null)
+ global_type_created = global_type.CreateType ();
+ }
+
+
+ public FieldBuilder DefineInitializedData( string name, byte[] data, FieldAttributes attributes) {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ if (global_type_created != null)
+ throw new InvalidOperationException ("global fields already created");
+ if (global_type == null)
+ global_type = new TypeBuilder (this, 0);
+
+ FieldBuilder fb = global_type.DefineInitializedData (name, data, attributes);
+
+ if (global_fields != null) {
+ FieldBuilder[] new_fields = new FieldBuilder [global_fields.Length+1];
+ System.Array.Copy (global_fields, new_fields, global_fields.Length);
+ new_fields [global_fields.Length] = fb;
+ global_fields = new_fields;
+ } else {
+ global_fields = new FieldBuilder [1];
+ global_fields [0] = fb;
+ }
+ return fb;
+ }
+
+ public FieldBuilder DefineUninitializedData( string name, int size, FieldAttributes attributes) {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ if (global_type_created != null)
+ throw new InvalidOperationException ("global fields already created");
+ if (global_type == null)
+ global_type = new TypeBuilder (this, 0);
+
+ FieldBuilder fb = global_type.DefineUninitializedData (name, size, attributes);
+
+ if (global_fields != null) {
+ FieldBuilder[] new_fields = new FieldBuilder [global_fields.Length+1];
+ System.Array.Copy (global_fields, new_fields, global_fields.Length);
+ new_fields [global_fields.Length] = fb;
+ global_fields = new_fields;
+ } else {
+ global_fields = new FieldBuilder [1];
+ global_fields [0] = fb;
+ }
+ return fb;
+ }
+
+ public MethodBuilder DefineGlobalMethod (string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes)
+ {
+ return DefineGlobalMethod (name, attributes, CallingConventions.Standard, returnType, parameterTypes);
+ }
+
+ public MethodBuilder DefineGlobalMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ if ((attributes & MethodAttributes.Static) == 0)
+ throw new ArgumentException ("global methods must be static");
+ if (global_type_created != null)
+ throw new InvalidOperationException ("global methods already created");
+ if (global_type == null)
+ global_type = new TypeBuilder (this, 0);
+ MethodBuilder mb = global_type.DefineMethod (name, attributes, callingConvention, returnType, parameterTypes);
+
+ if (global_methods != null) {
+ MethodBuilder[] new_methods = new MethodBuilder [global_methods.Length+1];
+ System.Array.Copy (global_methods, new_methods, global_methods.Length);
+ new_methods [global_methods.Length] = mb;
+ global_methods = new_methods;
+ } else {
+ global_methods = new MethodBuilder [1];
+ global_methods [0] = mb;
+ }
+ return mb;
+ }
+
+ [MonoTODO]
+ public TypeBuilder DefineType (string name) {
+ // FIXME: LAMESPEC: what other attributes should we use here as default?
+ return DefineType (name, TypeAttributes.Public, typeof(object), null);
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr) {
+ return DefineType (name, attr, typeof(object), null);
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent) {
+ return DefineType (name, attr, parent, null);
+ }
+
+ private TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packsize, int typesize) {
+ TypeBuilder res = new TypeBuilder (this, name, attr, parent, interfaces, packsize, typesize);
+ if (types != null) {
+ TypeBuilder[] new_types = new TypeBuilder [types.Length + 1];
+ System.Array.Copy (types, new_types, types.Length);
+ new_types [types.Length] = res;
+ types = new_types;
+ } else {
+ types = new TypeBuilder [1];
+ types [0] = res;
+ }
+ name_cache.Add (name, res);
+ return res;
+ }
+
+ internal void RegisterTypeName (TypeBuilder tb, string name) {
+ name_cache.Add (name, tb);
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, Type[] interfaces) {
+ return DefineType (name, attr, parent, interfaces, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize);
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, int typesize) {
+ return DefineType (name, attr, parent, null, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize);
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, PackingSize packsize) {
+ return DefineType (name, attr, parent, null, packsize, TypeBuilder.UnspecifiedTypeSize);
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, PackingSize packsize, int typesize) {
+ return DefineType (name, attr, parent, null, packsize, typesize);
+ }
+
+ public MethodInfo GetArrayMethod( Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
+ return new MonoArrayMethod (arrayClass, methodName, callingConvention, returnType, parameterTypes);
+ }
+
+ public EnumBuilder DefineEnum( string name, TypeAttributes visibility, Type underlyingType) {
+ EnumBuilder eb = new EnumBuilder (this, name, visibility, underlyingType);
+ return eb;
+ }
+
+ public override Type GetType( string className) {
+ return GetType (className, false, false);
+ }
+
+ public override Type GetType( string className, bool ignoreCase) {
+ return GetType (className, false, ignoreCase);
+ }
+
+ private TypeBuilder search_in_array (TypeBuilder[] arr, string className) {
+ int i;
+ for (i = 0; i < arr.Length; ++i) {
+ if (String.Compare (className, arr [i].FullName, true) == 0) {
+ return arr [i];
+ }
+ }
+ return null;
+ }
+
+ private TypeBuilder search_nested_in_array (TypeBuilder[] arr, string className) {
+ int i;
+ for (i = 0; i < arr.Length; ++i) {
+ if (String.Compare (className, arr [i].Name, true) == 0)
+ return arr [i];
+ }
+ return null;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern Type create_modified_type (TypeBuilder tb, string modifiers);
+
+ static char[] type_modifiers = {'&', '[', '*'};
+
+ private TypeBuilder GetMaybeNested (TypeBuilder t, string className) {
+ int subt;
+ string pname, rname;
+
+ subt = className.IndexOf ('+');
+ if (subt < 0) {
+ if (t.subtypes != null)
+ return search_nested_in_array (t.subtypes, className);
+ return null;
+ }
+ if (t.subtypes != null) {
+ pname = className.Substring (0, subt);
+ rname = className.Substring (subt + 1);
+ TypeBuilder result = search_nested_in_array (t.subtypes, pname);
+ if (result != null)
+ return GetMaybeNested (result, rname);
+ }
+ return null;
+ }
+
+ public override Type GetType (string className, bool throwOnError, bool ignoreCase) {
+ int subt;
+ string orig = className;
+ string modifiers;
+ TypeBuilder result = null;
+
+ if (types == null && throwOnError)
+ throw new TypeLoadException (className);
+
+ subt = className.IndexOfAny (type_modifiers);
+ if (subt >= 0) {
+ modifiers = className.Substring (subt);
+ className = className.Substring (0, subt);
+ } else
+ modifiers = null;
+
+ if (!ignoreCase) {
+ result = name_cache [className] as TypeBuilder;
+ } else {
+ subt = className.IndexOf ('+');
+ if (subt < 0) {
+ if (types != null)
+ result = search_in_array (types, className);
+ } else {
+ string pname, rname;
+ pname = className.Substring (0, subt);
+ rname = className.Substring (subt + 1);
+ result = search_in_array (types, pname);
+ if (result != null)
+ result = GetMaybeNested (result, rname);
+ }
+ }
+ if ((result == null) && throwOnError)
+ throw new TypeLoadException (orig);
+ if (result != null && (modifiers != null))
+ return create_modified_type (result, modifiers);
+ return result;
+ }
+
+ internal int get_next_table_index (object obj, int table, bool inc) {
+ return assemblyb.get_next_table_index (obj, table, inc);
+ }
+
+ public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
+ if (cattrs != null) {
+ CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
+ cattrs.CopyTo (new_array, 0);
+ new_array [cattrs.Length] = customBuilder;
+ cattrs = new_array;
+ } else {
+ cattrs = new CustomAttributeBuilder [1];
+ cattrs [0] = customBuilder;
+ }
+ }
+ public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
+ SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
+ }
+
+ public ISymbolWriter GetSymWriter () {
+ return symbol_writer;
+ }
+
+ public ISymbolDocumentWriter DefineDocument (string url, Guid language, Guid languageVendor, Guid documentType) {
+ if (symbol_writer == null)
+ throw new InvalidOperationException ();
+
+ return symbol_writer.DefineDocument (url, language, languageVendor, documentType);
+ }
+
+ public override Type [] GetTypes ()
+ {
+ if (types == null)
+ return new TypeBuilder [0];
+
+ int n = types.Length;
+ TypeBuilder [] copy = new TypeBuilder [n];
+ Array.Copy (types, copy, n);
+
+ return copy;
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs b/mcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs
new file mode 100755
index 00000000000..130cd3e5623
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/MonoArrayMethod.cs
@@ -0,0 +1,111 @@
+//
+// System.Reflection/MonoMethod.cs
+// The class used to represent methods from the mono runtime.
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System.Reflection {
+ internal class MonoArrayMethod: MethodInfo {
+ internal RuntimeMethodHandle mhandle;
+ internal Type parent;
+ internal Type ret;
+ internal Type[] parameters;
+ internal string name;
+ internal int table_idx;
+ internal CallingConventions call_conv;
+
+ internal MonoArrayMethod (Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
+ name = methodName;
+ parent = arrayClass;
+ ret = returnType;
+ parameters = (Type[])parameterTypes.Clone();
+ call_conv = callingConvention;
+ }
+
+ [MonoTODO]
+ public override MethodInfo GetBaseDefinition() {
+ return this; /* FIXME */
+ }
+ public override Type ReturnType {
+ get {
+ return ret;
+ }
+ }
+ [MonoTODO]
+ public override ICustomAttributeProvider ReturnTypeCustomAttributes {
+ get {return null;}
+ }
+
+ [MonoTODO]
+ public override MethodImplAttributes GetMethodImplementationFlags() {
+ return (MethodImplAttributes)0;
+ }
+
+ [MonoTODO]
+ public override ParameterInfo[] GetParameters() {
+ return new ParameterInfo [0];
+ }
+
+ [MonoTODO]
+ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) {
+ throw new NotImplementedException ();
+ }
+
+ public override RuntimeMethodHandle MethodHandle {
+ get {return mhandle;}
+ }
+ [MonoTODO]
+ public override MethodAttributes Attributes {
+ get {
+ return (MethodAttributes)0;
+ }
+ }
+
+ public override Type ReflectedType {
+ get {
+ return parent;
+ }
+ }
+ public override Type DeclaringType {
+ get {
+ return parent;
+ }
+ }
+ public override string Name {
+ get {
+ return name;
+ }
+ }
+
+ public override bool IsDefined (Type attributeType, bool inherit) {
+ return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
+ }
+
+ public override object[] GetCustomAttributes( bool inherit) {
+ return MonoCustomAttrs.GetCustomAttributes (this, inherit);
+ }
+ public override object[] GetCustomAttributes( Type attributeType, bool inherit) {
+ return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
+ }
+
+ public override string ToString () {
+ string parms = "";
+ ParameterInfo[] p = GetParameters ();
+ for (int i = 0; i < p.Length; ++i) {
+ if (i > 0)
+ parms = parms + ", ";
+ parms = parms + p [i].ParameterType.Name;
+ }
+ return ReturnType.Name+" "+Name+"("+parms+")";
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/OpCode.cs b/mcs/class/corlib/System.Reflection.Emit/OpCode.cs
new file mode 100644
index 00000000000..239091fbaa2
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/OpCode.cs
@@ -0,0 +1,129 @@
+//
+// System.Reflection.Emit.OpCode
+//
+// Author:
+// Sergey Chaban (serge@wildwestsoftware.com)
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+
+namespace System.Reflection.Emit {
+
+ public struct OpCode {
+
+ internal string name;
+ internal int size;
+ internal OpCodeType type;
+ internal OperandType operandType;
+ internal StackBehaviour pop;
+ internal StackBehaviour push;
+ internal FlowControl flowCtrl;
+ internal byte op1;
+ internal byte op2;
+
+ internal OpCode (string name, int size,
+ OpCodeType opcodeType,
+ OperandType operandType,
+ StackBehaviour pop,
+ StackBehaviour push,
+ FlowControl flowCtrl,
+ byte op1, byte op2)
+ {
+ this.name = name;
+ this.size = size;
+ this.type = opcodeType;
+ this.operandType = operandType;
+ this.pop = pop;
+ this.push = push;
+ this.flowCtrl = flowCtrl;
+ this.op1 = op1;
+ this.op2 = op2;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
+ /// <summary>
+ /// </summary>
+ public int Size {
+ get {
+ return size;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public OpCodeType OpCodeType {
+ get {
+ return type;
+ }
+ }
+
+ /// <summary>
+ /// </summary>
+ public OperandType OperandType {
+ get {
+ return operandType;
+ }
+ }
+
+ /// <summary>
+ /// </summary>
+ public FlowControl FlowControl {
+ get {
+ return flowCtrl;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public StackBehaviour StackBehaviourPop {
+ get {
+ return pop;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public StackBehaviour StackBehaviourPush {
+ get {
+ return push;
+ }
+ }
+
+
+ /// <summary>
+ /// </summary>
+ public short Value {
+ get {
+ if (size == 1) {
+ return op2;
+ } else {
+ // two byte instruction - combine
+ // give the same values as the mscorlib impl
+ // this makes the Value property useless
+ return (short) ((op1 << 2) | op2);
+ }
+ }
+ }
+
+ public override string ToString()
+ {
+ return Name;
+ }
+ } // OpCode
+
+} // System.Reflection.Emit
diff --git a/mcs/class/corlib/System.Reflection.Emit/OpCodeType.cs b/mcs/class/corlib/System.Reflection.Emit/OpCodeType.cs
new file mode 100644
index 00000000000..2733369ecbe
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/OpCodeType.cs
@@ -0,0 +1,49 @@
+// OpCodeType.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+ /// <summary>
+ /// Describes the types of MSIL instructions.
+ /// </summary>
+ public enum OpCodeType {
+
+ /// <summary>
+ /// "Ignorable" instruction.
+ /// Such instruction are used to supply
+ /// additional information to particular
+ /// MSIL processor.
+ /// </summary>
+ Annotation = 0,
+
+ /// <summary>
+ /// Denotes "shorthand" instruction.
+ /// Such instructions take less space
+ /// than their full-size equivalents
+ /// (ex. ldarg.0 vs. ldarg 0).
+ /// </summary>
+ Macro = 1,
+
+ /// <summary>
+ /// Denotes instruction reserved for internal use.
+ /// </summary>
+ Nternal = 2,
+
+ /// <summary>
+ /// Denotes instruction to deal with objects.
+ /// (ex. ldobj).
+ /// </summary>
+ Objmodel = 3,
+
+ /// <summary>
+ /// </summary>
+ Prefix = 4,
+
+ /// <summary>
+ /// </summary>
+ Primitive = 5
+ }
+
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/OpCodes.cs b/mcs/class/corlib/System.Reflection.Emit/OpCodes.cs
new file mode 100644
index 00000000000..1626d3f4ddb
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/OpCodes.cs
@@ -0,0 +1,486 @@
+// OpCodes.cs
+// Mechanically generated - DO NOT EDIT!
+//
+// (C) Sergey Chaban (serge@wildwestsoftware.com)
+
+using System;
+using System.Reflection.Emit;
+
+namespace System.Reflection.Emit {
+
+
+ public class OpCodes {
+ public static readonly OpCode Add;
+ public static readonly OpCode Add_Ovf;
+ public static readonly OpCode Add_Ovf_Un;
+ public static readonly OpCode And;
+ public static readonly OpCode Arglist;
+ public static readonly OpCode Beq;
+ public static readonly OpCode Beq_S;
+ public static readonly OpCode Bge;
+ public static readonly OpCode Bge_S;
+ public static readonly OpCode Bge_Un;
+ public static readonly OpCode Bge_Un_S;
+ public static readonly OpCode Bgt;
+ public static readonly OpCode Bgt_S;
+ public static readonly OpCode Bgt_Un;
+ public static readonly OpCode Bgt_Un_S;
+ public static readonly OpCode Ble;
+ public static readonly OpCode Ble_S;
+ public static readonly OpCode Ble_Un;
+ public static readonly OpCode Ble_Un_S;
+ public static readonly OpCode Blt;
+ public static readonly OpCode Blt_S;
+ public static readonly OpCode Blt_Un;
+ public static readonly OpCode Blt_Un_S;
+ public static readonly OpCode Bne_Un;
+ public static readonly OpCode Bne_Un_S;
+ public static readonly OpCode Box;
+ public static readonly OpCode Boxval;
+ public static readonly OpCode Br;
+ public static readonly OpCode Br_S;
+ public static readonly OpCode Break;
+ public static readonly OpCode Brfalse;
+ public static readonly OpCode Brfalse_S;
+ public static readonly OpCode Brtrue;
+ public static readonly OpCode Brtrue_S;
+ public static readonly OpCode Call;
+ public static readonly OpCode Calli;
+ public static readonly OpCode Callvirt;
+ public static readonly OpCode Castclass;
+ public static readonly OpCode Ceq;
+ public static readonly OpCode Cgt;
+ public static readonly OpCode Cgt_Un;
+ public static readonly OpCode Ckfinite;
+ public static readonly OpCode Clt;
+ public static readonly OpCode Clt_Un;
+ public static readonly OpCode Conv_I;
+ public static readonly OpCode Conv_I1;
+ public static readonly OpCode Conv_I2;
+ public static readonly OpCode Conv_I4;
+ public static readonly OpCode Conv_I8;
+ public static readonly OpCode Conv_Ovf_I;
+ public static readonly OpCode Conv_Ovf_I_Un;
+ public static readonly OpCode Conv_Ovf_I1;
+ public static readonly OpCode Conv_Ovf_I1_Un;
+ public static readonly OpCode Conv_Ovf_I2;
+ public static readonly OpCode Conv_Ovf_I2_Un;
+ public static readonly OpCode Conv_Ovf_I4;
+ public static readonly OpCode Conv_Ovf_I4_Un;
+ public static readonly OpCode Conv_Ovf_I8;
+ public static readonly OpCode Conv_Ovf_I8_Un;
+ public static readonly OpCode Conv_Ovf_U;
+ public static readonly OpCode Conv_Ovf_U_Un;
+ public static readonly OpCode Conv_Ovf_U1;
+ public static readonly OpCode Conv_Ovf_U1_Un;
+ public static readonly OpCode Conv_Ovf_U2;
+ public static readonly OpCode Conv_Ovf_U2_Un;
+ public static readonly OpCode Conv_Ovf_U4;
+ public static readonly OpCode Conv_Ovf_U4_Un;
+ public static readonly OpCode Conv_Ovf_U8;
+ public static readonly OpCode Conv_Ovf_U8_Un;
+ public static readonly OpCode Conv_R_Un;
+ public static readonly OpCode Conv_R4;
+ public static readonly OpCode Conv_R8;
+ public static readonly OpCode Conv_U;
+ public static readonly OpCode Conv_U1;
+ public static readonly OpCode Conv_U2;
+ public static readonly OpCode Conv_U4;
+ public static readonly OpCode Conv_U8;
+ public static readonly OpCode Cpblk;
+ public static readonly OpCode Cpobj;
+ public static readonly OpCode Div;
+ public static readonly OpCode Div_Un;
+ public static readonly OpCode Dup;
+ public static readonly OpCode Endfilter;
+ public static readonly OpCode Endfinally;
+ public static readonly OpCode Initblk;
+ public static readonly OpCode Initobj;
+ public static readonly OpCode Isinst;
+ public static readonly OpCode Jmp;
+ public static readonly OpCode Ldarg;
+ public static readonly OpCode Ldarg_0;
+ public static readonly OpCode Ldarg_1;
+ public static readonly OpCode Ldarg_2;
+ public static readonly OpCode Ldarg_3;
+ public static readonly OpCode Ldarg_S;
+ public static readonly OpCode Ldarga;
+ public static readonly OpCode Ldarga_S;
+ public static readonly OpCode Ldc_I4;
+ public static readonly OpCode Ldc_I4_0;
+ public static readonly OpCode Ldc_I4_1;
+ public static readonly OpCode Ldc_I4_2;
+ public static readonly OpCode Ldc_I4_3;
+ public static readonly OpCode Ldc_I4_4;
+ public static readonly OpCode Ldc_I4_5;
+ public static readonly OpCode Ldc_I4_6;
+ public static readonly OpCode Ldc_I4_7;
+ public static readonly OpCode Ldc_I4_8;
+ public static readonly OpCode Ldc_I4_M1;
+ public static readonly OpCode Ldc_I4_S;
+ public static readonly OpCode Ldc_I8;
+ public static readonly OpCode Ldc_R4;
+ public static readonly OpCode Ldc_R8;
+ public static readonly OpCode Ldelem_I;
+ public static readonly OpCode Ldelem_I1;
+ public static readonly OpCode Ldelem_I2;
+ public static readonly OpCode Ldelem_I4;
+ public static readonly OpCode Ldelem_I8;
+ public static readonly OpCode Ldelem_R4;
+ public static readonly OpCode Ldelem_R8;
+ public static readonly OpCode Ldelem_Ref;
+ public static readonly OpCode Ldelem_U1;
+ public static readonly OpCode Ldelem_U2;
+ public static readonly OpCode Ldelem_U4;
+ public static readonly OpCode Ldelema;
+ public static readonly OpCode Ldfld;
+ public static readonly OpCode Ldflda;
+ public static readonly OpCode Ldftn;
+ public static readonly OpCode Ldind_I;
+ public static readonly OpCode Ldind_I1;
+ public static readonly OpCode Ldind_I2;
+ public static readonly OpCode Ldind_I4;
+ public static readonly OpCode Ldind_I8;
+ public static readonly OpCode Ldind_R4;
+ public static readonly OpCode Ldind_R8;
+ public static readonly OpCode Ldind_Ref;
+ public static readonly OpCode Ldind_U1;
+ public static readonly OpCode Ldind_U2;
+ public static readonly OpCode Ldind_U4;
+ public static readonly OpCode Ldlen;
+ public static readonly OpCode Ldloc;
+ public static readonly OpCode Ldloc_0;
+ public static readonly OpCode Ldloc_1;
+ public static readonly OpCode Ldloc_2;
+ public static readonly OpCode Ldloc_3;
+ public static readonly OpCode Ldloc_S;
+ public static readonly OpCode Ldloca;
+ public static readonly OpCode Ldloca_S;
+ public static readonly OpCode Ldnull;
+ public static readonly OpCode Ldobj;
+ public static readonly OpCode Ldsfld;
+ public static readonly OpCode Ldsflda;
+ public static readonly OpCode Ldstr;
+ public static readonly OpCode Ldtoken;
+ public static readonly OpCode Ldvirtftn;
+ public static readonly OpCode Leave;
+ public static readonly OpCode Leave_S;
+ public static readonly OpCode Localloc;
+ public static readonly OpCode Mkrefany;
+ public static readonly OpCode Mul;
+ public static readonly OpCode Mul_Ovf;
+ public static readonly OpCode Mul_Ovf_Un;
+ public static readonly OpCode Neg;
+ public static readonly OpCode Newarr;
+ public static readonly OpCode Newobj;
+ public static readonly OpCode Nop;
+ public static readonly OpCode Not;
+ public static readonly OpCode Or;
+ public static readonly OpCode Pop;
+ public static readonly OpCode Prefix1;
+ public static readonly OpCode Prefix2;
+ public static readonly OpCode Prefix3;
+ public static readonly OpCode Prefix4;
+ public static readonly OpCode Prefix5;
+ public static readonly OpCode Prefix6;
+ public static readonly OpCode Prefix7;
+ public static readonly OpCode Prefixref;
+ public static readonly OpCode Refanytype;
+ public static readonly OpCode Refanyval;
+ public static readonly OpCode Rem;
+ public static readonly OpCode Rem_Un;
+ public static readonly OpCode Ret;
+ public static readonly OpCode Rethrow;
+ public static readonly OpCode Shl;
+ public static readonly OpCode Shr;
+ public static readonly OpCode Shr_Un;
+ public static readonly OpCode Sizeof;
+ public static readonly OpCode Starg;
+ public static readonly OpCode Starg_S;
+ public static readonly OpCode Stelem_I;
+ public static readonly OpCode Stelem_I1;
+ public static readonly OpCode Stelem_I2;
+ public static readonly OpCode Stelem_I4;
+ public static readonly OpCode Stelem_I8;
+ public static readonly OpCode Stelem_R4;
+ public static readonly OpCode Stelem_R8;
+ public static readonly OpCode Stelem_Ref;
+ public static readonly OpCode Stfld;
+ public static readonly OpCode Stind_I;
+ public static readonly OpCode Stind_I1;
+ public static readonly OpCode Stind_I2;
+ public static readonly OpCode Stind_I4;
+ public static readonly OpCode Stind_I8;
+ public static readonly OpCode Stind_R4;
+ public static readonly OpCode Stind_R8;
+ public static readonly OpCode Stind_Ref;
+ public static readonly OpCode Stloc;
+ public static readonly OpCode Stloc_0;
+ public static readonly OpCode Stloc_1;
+ public static readonly OpCode Stloc_2;
+ public static readonly OpCode Stloc_3;
+ public static readonly OpCode Stloc_S;
+ public static readonly OpCode Stobj;
+ public static readonly OpCode Stsfld;
+ public static readonly OpCode Sub;
+ public static readonly OpCode Sub_Ovf;
+ public static readonly OpCode Sub_Ovf_Un;
+ public static readonly OpCode Switch;
+ public static readonly OpCode Tailcall;
+ public static readonly OpCode Throw;
+ public static readonly OpCode Unaligned;
+ public static readonly OpCode Unbox;
+ public static readonly OpCode Volatile;
+ public static readonly OpCode Xor;
+
+
+ private OpCodes () {}
+
+ static OpCodes ()
+ {
+
+ Nop = new OpCode("nop", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x0);
+ Arglist = new OpCode("arglist", 2, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0x0);
+ Break = new OpCode("break", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Break, 0xFF, 0x1);
+ Ceq = new OpCode("ceq", 2, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0x1);
+ Starg_S = new OpCode("starg.s", 1, OpCodeType.Macro, OperandType.ShortInlineVar, StackBehaviour.Pop1, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x10);
+ Ldloc_S = new OpCode("ldloc.s", 1, OpCodeType.Macro, OperandType.ShortInlineVar, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x11);
+ Endfilter = new OpCode("endfilter", 2, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Push0, FlowControl.Return, 0xFE, 0x11);
+ Ldloca_S = new OpCode("ldloca.s", 1, OpCodeType.Macro, OperandType.ShortInlineVar, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x12);
+ Unaligned = new OpCode("unaligned.", 2, OpCodeType.Prefix, OperandType.ShortInlineI, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Meta, 0xFE, 0x12);
+ Stloc_S = new OpCode("stloc.s", 1, OpCodeType.Macro, OperandType.ShortInlineVar, StackBehaviour.Pop1, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x13);
+ Volatile = new OpCode("volatile.", 2, OpCodeType.Prefix, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Meta, 0xFE, 0x13);
+ Ldnull = new OpCode("ldnull", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x14);
+ Tailcall = new OpCode("tail.", 2, OpCodeType.Prefix, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Meta, 0xFE, 0x14);
+ Ldc_I4_M1 = new OpCode("ldc.i4.m1", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x15);
+ Initobj = new OpCode("initobj", 2, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popi, StackBehaviour.Push0, FlowControl.Next, 0xFE, 0x15);
+ Ldc_I4_0 = new OpCode("ldc.i4.0", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x16);
+ Ldc_I4_1 = new OpCode("ldc.i4.1", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x17);
+ Cpblk = new OpCode("cpblk", 2, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi_popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFE, 0x17);
+ Ldc_I4_2 = new OpCode("ldc.i4.2", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x18);
+ Initblk = new OpCode("initblk", 2, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi_popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFE, 0x18);
+ Ldc_I4_3 = new OpCode("ldc.i4.3", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x19);
+ Ldc_I4_4 = new OpCode("ldc.i4.4", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x1A);
+ Rethrow = new OpCode("rethrow", 2, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Throw, 0xFE, 0x1A);
+ Ldc_I4_5 = new OpCode("ldc.i4.5", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x1B);
+ Ldc_I4_6 = new OpCode("ldc.i4.6", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x1C);
+ Sizeof = new OpCode("sizeof", 2, OpCodeType.Primitive, OperandType.InlineType, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0x1C);
+ Ldc_I4_7 = new OpCode("ldc.i4.7", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x1D);
+ Refanytype = new OpCode("refanytype", 2, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0x1D);
+ Ldc_I4_8 = new OpCode("ldc.i4.8", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x1E);
+ Ldc_I4_S = new OpCode("ldc.i4.s", 1, OpCodeType.Macro, OperandType.ShortInlineI, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x1F);
+ Ldarg_0 = new OpCode("ldarg.0", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x2);
+ Cgt = new OpCode("cgt", 2, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0x2);
+ Ldc_I4 = new OpCode("ldc.i4", 1, OpCodeType.Primitive, OperandType.InlineI, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x20);
+ Ldc_I8 = new OpCode("ldc.i8", 1, OpCodeType.Primitive, OperandType.InlineI8, StackBehaviour.Pop0, StackBehaviour.Pushi8, FlowControl.Next, 0xFF, 0x21);
+ Ldc_R4 = new OpCode("ldc.r4", 1, OpCodeType.Primitive, OperandType.ShortInlineR, StackBehaviour.Pop0, StackBehaviour.Pushr4, FlowControl.Next, 0xFF, 0x22);
+ Ldc_R8 = new OpCode("ldc.r8", 1, OpCodeType.Primitive, OperandType.InlineR, StackBehaviour.Pop0, StackBehaviour.Pushr8, FlowControl.Next, 0xFF, 0x23);
+ Dup = new OpCode("dup", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Push1_push1, FlowControl.Next, 0xFF, 0x25);
+ Pop = new OpCode("pop", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x26);
+ Jmp = new OpCode("jmp", 1, OpCodeType.Primitive, OperandType.InlineMethod, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Call, 0xFF, 0x27);
+ Call = new OpCode("call", 1, OpCodeType.Primitive, OperandType.InlineMethod, StackBehaviour.Varpop, StackBehaviour.Varpush, FlowControl.Call, 0xFF, 0x28);
+ Calli = new OpCode("calli", 1, OpCodeType.Primitive, OperandType.InlineSig, StackBehaviour.Varpop, StackBehaviour.Varpush, FlowControl.Call, 0xFF, 0x29);
+ Ret = new OpCode("ret", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Varpop, StackBehaviour.Push0, FlowControl.Return, 0xFF, 0x2A);
+ Br_S = new OpCode("br.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Branch, 0xFF, 0x2B);
+ Brfalse_S = new OpCode("brfalse.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Popi, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x2C);
+ Brtrue_S = new OpCode("brtrue.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Popi, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x2D);
+ Beq_S = new OpCode("beq.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x2E);
+ Bge_S = new OpCode("bge.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x2F);
+ Ldarg_1 = new OpCode("ldarg.1", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x3);
+ Cgt_Un = new OpCode("cgt.un", 2, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0x3);
+ Bgt_S = new OpCode("bgt.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x30);
+ Ble_S = new OpCode("ble.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x31);
+ Blt_S = new OpCode("blt.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x32);
+ Bne_Un_S = new OpCode("bne.un.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x33);
+ Bge_Un_S = new OpCode("bge.un.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x34);
+ Bgt_Un_S = new OpCode("bgt.un.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x35);
+ Ble_Un_S = new OpCode("ble.un.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x36);
+ Blt_Un_S = new OpCode("blt.un.s", 1, OpCodeType.Macro, OperandType.ShortInlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x37);
+ Br = new OpCode("br", 1, OpCodeType.Primitive, OperandType.InlineBrTarget, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Branch, 0xFF, 0x38);
+ Brfalse = new OpCode("brfalse", 1, OpCodeType.Primitive, OperandType.InlineBrTarget, StackBehaviour.Popi, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x39);
+ Brtrue = new OpCode("brtrue", 1, OpCodeType.Primitive, OperandType.InlineBrTarget, StackBehaviour.Popi, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x3A);
+ Beq = new OpCode("beq", 1, OpCodeType.Macro, OperandType.InlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x3B);
+ Bge = new OpCode("bge", 1, OpCodeType.Macro, OperandType.InlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x3C);
+ Bgt = new OpCode("bgt", 1, OpCodeType.Macro, OperandType.InlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x3D);
+ Ble = new OpCode("ble", 1, OpCodeType.Macro, OperandType.InlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x3E);
+ Blt = new OpCode("blt", 1, OpCodeType.Macro, OperandType.InlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x3F);
+ Ldarg_2 = new OpCode("ldarg.2", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x4);
+ Clt = new OpCode("clt", 2, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0x4);
+ Bne_Un = new OpCode("bne.un", 1, OpCodeType.Macro, OperandType.InlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x40);
+ Bge_Un = new OpCode("bge.un", 1, OpCodeType.Macro, OperandType.InlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x41);
+ Bgt_Un = new OpCode("bgt.un", 1, OpCodeType.Macro, OperandType.InlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x42);
+ Ble_Un = new OpCode("ble.un", 1, OpCodeType.Macro, OperandType.InlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x43);
+ Blt_Un = new OpCode("blt.un", 1, OpCodeType.Macro, OperandType.InlineBrTarget, StackBehaviour.Pop1_pop1, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x44);
+ Switch = new OpCode("switch", 1, OpCodeType.Primitive, OperandType.InlineSwitch, StackBehaviour.Popi, StackBehaviour.Push0, FlowControl.Cond_Branch, 0xFF, 0x45);
+ Ldind_I1 = new OpCode("ldind.i1", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x46);
+ Ldind_U1 = new OpCode("ldind.u1", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x47);
+ Ldind_I2 = new OpCode("ldind.i2", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x48);
+ Ldind_U2 = new OpCode("ldind.u2", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x49);
+ Ldind_I4 = new OpCode("ldind.i4", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x4A);
+ Ldind_U4 = new OpCode("ldind.u4", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x4B);
+ Ldind_I8 = new OpCode("ldind.i8", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushi8, FlowControl.Next, 0xFF, 0x4C);
+ Ldind_I = new OpCode("ldind.i", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x4D);
+ Ldind_R4 = new OpCode("ldind.r4", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushr4, FlowControl.Next, 0xFF, 0x4E);
+ Ldind_R8 = new OpCode("ldind.r8", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushr8, FlowControl.Next, 0xFF, 0x4F);
+ Ldarg_3 = new OpCode("ldarg.3", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x5);
+ Clt_Un = new OpCode("clt.un", 2, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0x5);
+ Ldind_Ref = new OpCode("ldind.ref", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x50);
+ Stind_Ref = new OpCode("stind.ref", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x51);
+ Stind_I1 = new OpCode("stind.i1", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x52);
+ Stind_I2 = new OpCode("stind.i2", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x53);
+ Stind_I4 = new OpCode("stind.i4", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x54);
+ Stind_I8 = new OpCode("stind.i8", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi_popi8, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x55);
+ Stind_R4 = new OpCode("stind.r4", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi_popr4, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x56);
+ Stind_R8 = new OpCode("stind.r8", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi_popr8, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x57);
+ Add = new OpCode("add", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x58);
+ Sub = new OpCode("sub", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x59);
+ Mul = new OpCode("mul", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x5A);
+ Div = new OpCode("div", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x5B);
+ Div_Un = new OpCode("div.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x5C);
+ Rem = new OpCode("rem", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x5D);
+ Rem_Un = new OpCode("rem.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x5E);
+ And = new OpCode("and", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x5F);
+ Ldloc_0 = new OpCode("ldloc.0", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x6);
+ Ldftn = new OpCode("ldftn", 2, OpCodeType.Primitive, OperandType.InlineMethod, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0x6);
+ Or = new OpCode("or", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x60);
+ Xor = new OpCode("xor", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x61);
+ Shl = new OpCode("shl", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x62);
+ Shr = new OpCode("shr", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x63);
+ Shr_Un = new OpCode("shr.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x64);
+ Neg = new OpCode("neg", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x65);
+ Not = new OpCode("not", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x66);
+ Conv_I1 = new OpCode("conv.i1", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x67);
+ Conv_I2 = new OpCode("conv.i2", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x68);
+ Conv_I4 = new OpCode("conv.i4", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x69);
+ Conv_I8 = new OpCode("conv.i8", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi8, FlowControl.Next, 0xFF, 0x6A);
+ Conv_R4 = new OpCode("conv.r4", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushr4, FlowControl.Next, 0xFF, 0x6B);
+ Conv_R8 = new OpCode("conv.r8", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushr8, FlowControl.Next, 0xFF, 0x6C);
+ Conv_U4 = new OpCode("conv.u4", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x6D);
+ Conv_U8 = new OpCode("conv.u8", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi8, FlowControl.Next, 0xFF, 0x6E);
+ Callvirt = new OpCode("callvirt", 1, OpCodeType.Objmodel, OperandType.InlineMethod, StackBehaviour.Varpop, StackBehaviour.Varpush, FlowControl.Call, 0xFF, 0x6F);
+ Ldloc_1 = new OpCode("ldloc.1", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x7);
+ Ldvirtftn = new OpCode("ldvirtftn", 2, OpCodeType.Primitive, OperandType.InlineMethod, StackBehaviour.Popref, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0x7);
+ Cpobj = new OpCode("cpobj", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x70);
+ Ldobj = new OpCode("ldobj", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popi, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x71);
+ Ldstr = new OpCode("ldstr", 1, OpCodeType.Objmodel, OperandType.InlineString, StackBehaviour.Pop0, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x72);
+ Newobj = new OpCode("newobj", 1, OpCodeType.Objmodel, OperandType.InlineMethod, StackBehaviour.Varpop, StackBehaviour.Pushref, FlowControl.Call, 0xFF, 0x73);
+ Castclass = new OpCode("castclass", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popref, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x74);
+ Isinst = new OpCode("isinst", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popref, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x75);
+ Conv_R_Un = new OpCode("conv.r.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushr8, FlowControl.Next, 0xFF, 0x76);
+ Unbox = new OpCode("unbox", 1, OpCodeType.Primitive, OperandType.InlineType, StackBehaviour.Popref, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x79);
+ Throw = new OpCode("throw", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref, StackBehaviour.Push0, FlowControl.Throw, 0xFF, 0x7A);
+ Ldfld = new OpCode("ldfld", 1, OpCodeType.Objmodel, OperandType.InlineField, StackBehaviour.Popref, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x7B);
+ Ldflda = new OpCode("ldflda", 1, OpCodeType.Objmodel, OperandType.InlineField, StackBehaviour.Popref, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x7C);
+ Stfld = new OpCode("stfld", 1, OpCodeType.Objmodel, OperandType.InlineField, StackBehaviour.Popref_pop1, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x7D);
+ Ldsfld = new OpCode("ldsfld", 1, OpCodeType.Objmodel, OperandType.InlineField, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x7E);
+ Ldsflda = new OpCode("ldsflda", 1, OpCodeType.Objmodel, OperandType.InlineField, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x7F);
+ Ldloc_2 = new OpCode("ldloc.2", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x8);
+ Stsfld = new OpCode("stsfld", 1, OpCodeType.Objmodel, OperandType.InlineField, StackBehaviour.Pop1, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x80);
+ Stobj = new OpCode("stobj", 1, OpCodeType.Primitive, OperandType.InlineType, StackBehaviour.Popi_pop1, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x81);
+ Conv_Ovf_I1_Un = new OpCode("conv.ovf.i1.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x82);
+ Conv_Ovf_I2_Un = new OpCode("conv.ovf.i2.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x83);
+ Conv_Ovf_I4_Un = new OpCode("conv.ovf.i4.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x84);
+ Conv_Ovf_I8_Un = new OpCode("conv.ovf.i8.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi8, FlowControl.Next, 0xFF, 0x85);
+ Conv_Ovf_U1_Un = new OpCode("conv.ovf.u1.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x86);
+ Conv_Ovf_U2_Un = new OpCode("conv.ovf.u2.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x87);
+ Conv_Ovf_U4_Un = new OpCode("conv.ovf.u4.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x88);
+ Conv_Ovf_U8_Un = new OpCode("conv.ovf.u8.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi8, FlowControl.Next, 0xFF, 0x89);
+ Conv_Ovf_I_Un = new OpCode("conv.ovf.i.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x8A);
+ Conv_Ovf_U_Un = new OpCode("conv.ovf.u.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x8B);
+ Boxval = new OpCode("boxval", 1, OpCodeType.Primitive, OperandType.InlineType, StackBehaviour.Pop1, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x8C);
+ Box = new OpCode("box", 1, OpCodeType.Primitive, OperandType.InlineType, StackBehaviour.Pop1, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x8C);
+ Newarr = new OpCode("newarr", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popi, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x8D);
+ Ldlen = new OpCode("ldlen", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x8E);
+ Ldelema = new OpCode("ldelema", 1, OpCodeType.Objmodel, OperandType.InlineType, StackBehaviour.Popref_popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x8F);
+ Ldloc_3 = new OpCode("ldloc.3", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0x9);
+ Ldarg = new OpCode("ldarg", 2, OpCodeType.Primitive, OperandType.InlineVar, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFE, 0x9);
+ Ldelem_I1 = new OpCode("ldelem.i1", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x90);
+ Ldelem_U1 = new OpCode("ldelem.u1", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x91);
+ Ldelem_I2 = new OpCode("ldelem.i2", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x92);
+ Ldelem_U2 = new OpCode("ldelem.u2", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x93);
+ Ldelem_I4 = new OpCode("ldelem.i4", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x94);
+ Ldelem_U4 = new OpCode("ldelem.u4", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x95);
+ Ldelem_I8 = new OpCode("ldelem.i8", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi, StackBehaviour.Pushi8, FlowControl.Next, 0xFF, 0x96);
+ Ldelem_I = new OpCode("ldelem.i", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0x97);
+ Ldelem_R4 = new OpCode("ldelem.r4", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi, StackBehaviour.Pushr4, FlowControl.Next, 0xFF, 0x98);
+ Ldelem_R8 = new OpCode("ldelem.r8", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi, StackBehaviour.Pushr8, FlowControl.Next, 0xFF, 0x99);
+ Ldelem_Ref = new OpCode("ldelem.ref", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi, StackBehaviour.Pushref, FlowControl.Next, 0xFF, 0x9A);
+ Stelem_I = new OpCode("stelem.i", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x9B);
+ Stelem_I1 = new OpCode("stelem.i1", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x9C);
+ Stelem_I2 = new OpCode("stelem.i2", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x9D);
+ Stelem_I4 = new OpCode("stelem.i4", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x9E);
+ Stelem_I8 = new OpCode("stelem.i8", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi_popi8, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0x9F);
+ Stloc_0 = new OpCode("stloc.0", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xA);
+ Ldarga = new OpCode("ldarga", 2, OpCodeType.Primitive, OperandType.InlineVar, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0xA);
+ Stelem_R4 = new OpCode("stelem.r4", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi_popr4, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xA0);
+ Stelem_R8 = new OpCode("stelem.r8", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi_popr8, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xA1);
+ Stelem_Ref = new OpCode("stelem.ref", 1, OpCodeType.Objmodel, OperandType.InlineNone, StackBehaviour.Popref_popi_popref, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xA2);
+ Stloc_1 = new OpCode("stloc.1", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xB);
+ Starg = new OpCode("starg", 2, OpCodeType.Primitive, OperandType.InlineVar, StackBehaviour.Pop1, StackBehaviour.Push0, FlowControl.Next, 0xFE, 0xB);
+ Conv_Ovf_I1 = new OpCode("conv.ovf.i1", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xB3);
+ Conv_Ovf_U1 = new OpCode("conv.ovf.u1", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xB4);
+ Conv_Ovf_I2 = new OpCode("conv.ovf.i2", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xB5);
+ Conv_Ovf_U2 = new OpCode("conv.ovf.u2", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xB6);
+ Conv_Ovf_I4 = new OpCode("conv.ovf.i4", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xB7);
+ Conv_Ovf_U4 = new OpCode("conv.ovf.u4", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xB8);
+ Conv_Ovf_I8 = new OpCode("conv.ovf.i8", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi8, FlowControl.Next, 0xFF, 0xB9);
+ Conv_Ovf_U8 = new OpCode("conv.ovf.u8", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi8, FlowControl.Next, 0xFF, 0xBA);
+ Stloc_2 = new OpCode("stloc.2", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xC);
+ Ldloc = new OpCode("ldloc", 2, OpCodeType.Primitive, OperandType.InlineVar, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFE, 0xC);
+ Refanyval = new OpCode("refanyval", 1, OpCodeType.Primitive, OperandType.InlineType, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xC2);
+ Ckfinite = new OpCode("ckfinite", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushr8, FlowControl.Next, 0xFF, 0xC3);
+ Mkrefany = new OpCode("mkrefany", 1, OpCodeType.Primitive, OperandType.InlineType, StackBehaviour.Popi, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0xC6);
+ Stloc_3 = new OpCode("stloc.3", 1, OpCodeType.Macro, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xD);
+ Ldloca = new OpCode("ldloca", 2, OpCodeType.Primitive, OperandType.InlineVar, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0xD);
+ Ldtoken = new OpCode("ldtoken", 1, OpCodeType.Primitive, OperandType.InlineTok, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xD0);
+ Conv_U2 = new OpCode("conv.u2", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xD1);
+ Conv_U1 = new OpCode("conv.u1", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xD2);
+ Conv_I = new OpCode("conv.i", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xD3);
+ Conv_Ovf_I = new OpCode("conv.ovf.i", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xD4);
+ Conv_Ovf_U = new OpCode("conv.ovf.u", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xD5);
+ Add_Ovf = new OpCode("add.ovf", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0xD6);
+ Add_Ovf_Un = new OpCode("add.ovf.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0xD7);
+ Mul_Ovf = new OpCode("mul.ovf", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0xD8);
+ Mul_Ovf_Un = new OpCode("mul.ovf.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0xD9);
+ Sub_Ovf = new OpCode("sub.ovf", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0xDA);
+ Sub_Ovf_Un = new OpCode("sub.ovf.un", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1_pop1, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0xDB);
+ Endfinally = new OpCode("endfinally", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Return, 0xFF, 0xDC);
+ Leave = new OpCode("leave", 1, OpCodeType.Primitive, OperandType.InlineBrTarget, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Branch, 0xFF, 0xDD);
+ Leave_S = new OpCode("leave.s", 1, OpCodeType.Primitive, OperandType.ShortInlineBrTarget, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Branch, 0xFF, 0xDE);
+ Stind_I = new OpCode("stind.i", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi_popi, StackBehaviour.Push0, FlowControl.Next, 0xFF, 0xDF);
+ Ldarg_S = new OpCode("ldarg.s", 1, OpCodeType.Macro, OperandType.ShortInlineVar, StackBehaviour.Pop0, StackBehaviour.Push1, FlowControl.Next, 0xFF, 0xE);
+ Stloc = new OpCode("stloc", 2, OpCodeType.Primitive, OperandType.InlineVar, StackBehaviour.Pop1, StackBehaviour.Push0, FlowControl.Next, 0xFE, 0xE);
+ Conv_U = new OpCode("conv.u", 1, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Pop1, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xE0);
+ Ldarga_S = new OpCode("ldarga.s", 1, OpCodeType.Macro, OperandType.ShortInlineVar, StackBehaviour.Pop0, StackBehaviour.Pushi, FlowControl.Next, 0xFF, 0xF);
+ Localloc = new OpCode("localloc", 2, OpCodeType.Primitive, OperandType.InlineNone, StackBehaviour.Popi, StackBehaviour.Pushi, FlowControl.Next, 0xFE, 0xF);
+ Prefix7 = new OpCode("prefix7", 1, OpCodeType.Nternal, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Meta, 0xFF, 0xF8);
+ Prefix6 = new OpCode("prefix6", 1, OpCodeType.Nternal, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Meta, 0xFF, 0xF9);
+ Prefix5 = new OpCode("prefix5", 1, OpCodeType.Nternal, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Meta, 0xFF, 0xFA);
+ Prefix4 = new OpCode("prefix4", 1, OpCodeType.Nternal, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Meta, 0xFF, 0xFB);
+ Prefix3 = new OpCode("prefix3", 1, OpCodeType.Nternal, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Meta, 0xFF, 0xFC);
+ Prefix2 = new OpCode("prefix2", 1, OpCodeType.Nternal, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Meta, 0xFF, 0xFD);
+ Prefix1 = new OpCode("prefix1", 1, OpCodeType.Nternal, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Meta, 0xFF, 0xFE);
+ Prefixref = new OpCode("prefixref", 1, OpCodeType.Nternal, OperandType.InlineNone, StackBehaviour.Pop0, StackBehaviour.Push0, FlowControl.Meta, 0xFF, 0xFF);
+
+
+ }
+
+ public static bool TakesSingleByteArgument (OpCode inst)
+ {
+ OperandType t = inst.OperandType;
+
+ // check for short-inline instructions
+ return ( t == OperandType.ShortInlineBrTarget
+ || t == OperandType.ShortInlineI
+ || t == OperandType.ShortInlineR
+ || t == OperandType.ShortInlineVar
+ );
+ }
+ }
+
+
+
+
+
+
+} // namespace System.Reflection.Emit
diff --git a/mcs/class/corlib/System.Reflection.Emit/OperandType.cs b/mcs/class/corlib/System.Reflection.Emit/OperandType.cs
new file mode 100644
index 00000000000..669ca53277e
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/OperandType.cs
@@ -0,0 +1,87 @@
+// OperandType.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+ /// <summary>
+ /// Describes the operand types of MSIL instructions.
+ /// </summary>
+ public enum OperandType {
+
+ /// <summary>
+ /// </summary>
+ InlineBrTarget = 0,
+
+ /// <summary>
+ /// </summary>
+ InlineField = 1,
+
+ /// <summary>
+ /// </summary>
+ InlineI = 2,
+
+ /// <summary>
+ /// </summary>
+ InlineI8 = 3,
+
+ /// <summary>
+ /// </summary>
+ InlineMethod = 4,
+
+ /// <summary>
+ /// </summary>
+ InlineNone = 5,
+
+ /// <summary>
+ /// </summary>
+ InlinePhi = 6,
+
+ /// <summary>
+ /// </summary>
+ InlineR = 7,
+
+ /// <summary>
+ /// </summary>
+ InlineSig = 9,
+
+ /// <summary>
+ /// </summary>
+ InlineString = 0x0A,
+
+ /// <summary>
+ /// </summary>
+ InlineSwitch = 0x0B,
+
+ /// <summary>
+ /// </summary>
+ InlineTok = 0x0C,
+
+ /// <summary>
+ /// </summary>
+ InlineType = 0x0D,
+
+ /// <summary>
+ /// </summary>
+ InlineVar = 0x0E,
+
+ /// <summary>
+ /// </summary>
+ ShortInlineBrTarget = 0x0F,
+
+ /// <summary>
+ /// </summary>
+ ShortInlineI = 0x10,
+
+ /// <summary>
+ /// </summary>
+ ShortInlineR = 0x11,
+
+ /// <summary>
+ /// </summary>
+ ShortInlineVar = 0x12
+ }
+
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/PEFileKinds.cs b/mcs/class/corlib/System.Reflection.Emit/PEFileKinds.cs
new file mode 100644
index 00000000000..0677897bc82
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/PEFileKinds.cs
@@ -0,0 +1,8 @@
+namespace System.Reflection.Emit {
+ public enum PEFileKinds {
+ Dll = 1,
+ ConsoleApplication = 2,
+ WindowApplication = 3
+ }
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/PackingSize.cs b/mcs/class/corlib/System.Reflection.Emit/PackingSize.cs
new file mode 100644
index 00000000000..82c74276386
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/PackingSize.cs
@@ -0,0 +1,41 @@
+// PackingSize.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+ /// <summary>
+ /// Specifies the packing size (data alignment) of a type.
+ /// </summary>
+ public enum PackingSize {
+
+ /// <summary>
+ /// The packing size is unspecified.
+ /// </summary>
+ Unspecified = 0,
+
+ /// <summary>
+ /// </summary>
+ Size1 = 1,
+
+ /// <summary>
+ /// </summary>
+ Size2 = 2,
+
+ /// <summary>
+ /// </summary>
+ Size4 = 4,
+
+ /// <summary>
+ /// </summary>
+ Size8 = 8,
+
+ /// <summary>
+ /// </summary>
+ Size16 = 16
+ }
+
+}
+
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/ParameterBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/ParameterBuilder.cs
new file mode 100755
index 00000000000..02ba64986cd
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/ParameterBuilder.cs
@@ -0,0 +1,102 @@
+
+
+//
+// System.Reflection.Emit/ParameterBuilder.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System.Reflection.Emit {
+ public class ParameterBuilder {
+ private MethodBase methodb; /* MethodBuilder or ConstructorBuilder */
+ private string name;
+ private CustomAttributeBuilder[] cattrs;
+ private UnmanagedMarshal marshal_info;
+ private ParameterAttributes attrs;
+ private int position;
+ private int table_idx;
+
+ internal ParameterBuilder (MethodBase mb, int pos, ParameterAttributes attributes, string strParamName) {
+ name = strParamName;
+ position = pos;
+ attrs = attributes;
+ methodb = mb;
+ table_idx = mb.get_next_table_index (this, 0x08, true);
+ }
+
+ public virtual int Attributes {
+ get {return (int)attrs;}
+ }
+ public bool IsIn {
+ get {return ((int)attrs & (int)ParameterAttributes.In) != 0;}
+ }
+ public bool IsOut {
+ get {return ((int)attrs & (int)ParameterAttributes.Out) != 0;}
+ }
+ public bool IsOptional {
+ get {return ((int)attrs & (int)ParameterAttributes.Optional) != 0;}
+ }
+ public virtual string Name {
+ get {return name;}
+ }
+ public virtual int Position {
+ get {return position;}
+ }
+
+ public virtual ParameterToken GetToken() {
+ return new ParameterToken (0x08 | table_idx);
+ }
+
+ [MonoTODO]
+ public virtual void SetConstant( object defaultValue) {
+ /* FIXME */
+ }
+
+ public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
+ string attrname = customBuilder.Ctor.ReflectedType.FullName;
+ if (attrname == "System.Runtime.InteropServices.InAttribute") {
+ attrs |= ParameterAttributes.In;
+ return;
+ } else if (attrname == "System.Runtime.InteropServices.OutAttribute") {
+ attrs |= ParameterAttributes.Out;
+ return;
+ } else if (attrname == "System.Runtime.InteropServices.OptionalAttribute") {
+ attrs |= ParameterAttributes.Optional;
+ return;
+ } else if (attrname == "System.Runtime.InteropServices.MarshalAsAttribute") {
+ marshal_info = CustomAttributeBuilder.get_umarshal (customBuilder, true);
+ /* FIXME: check for errors */
+ return;
+ }
+ if (cattrs != null) {
+ CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
+ cattrs.CopyTo (new_array, 0);
+ new_array [cattrs.Length] = customBuilder;
+ cattrs = new_array;
+ } else {
+ cattrs = new CustomAttributeBuilder [1];
+ cattrs [0] = customBuilder;
+ }
+ }
+ public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
+ SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
+ }
+
+ public virtual void SetMarshal( UnmanagedMarshal unmanagedMarshal) {
+ marshal_info = unmanagedMarshal;
+ attrs |= ParameterAttributes.HasFieldMarshal;
+ }
+
+ }
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/ParameterToken.cs b/mcs/class/corlib/System.Reflection.Emit/ParameterToken.cs
new file mode 100644
index 00000000000..21d1895747d
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/ParameterToken.cs
@@ -0,0 +1,70 @@
+// ParameterToken.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+
+ /// <summary>
+ /// Represents the Token returned by the metadata to represent a Parameter.
+ /// </summary>
+ [Serializable]
+ public struct ParameterToken {
+
+ internal int tokValue;
+
+ public static readonly ParameterToken Empty;
+
+
+ static ParameterToken ()
+ {
+ Empty = new ParameterToken ();
+ }
+
+
+ internal ParameterToken (int val)
+ {
+ tokValue = val;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public override bool Equals (object obj)
+ {
+ bool res = obj is ParameterToken;
+
+ if (res) {
+ ParameterToken that = (ParameterToken) obj;
+ res = (this.tokValue == that.tokValue);
+ }
+
+ return res;
+ }
+
+
+ /// <summary>
+ /// Tests whether the given object is an instance of
+ /// ParameterToken and has the same token value.
+ /// </summary>
+ public override int GetHashCode ()
+ {
+ return tokValue;
+ }
+
+
+ /// <summary>
+ /// Returns the metadata token for this Parameter.
+ /// </summary>
+ public int Token {
+ get {
+ return tokValue;
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/PropertyBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/PropertyBuilder.cs
new file mode 100755
index 00000000000..d006a4ac142
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/PropertyBuilder.cs
@@ -0,0 +1,124 @@
+
+//
+// System.Reflection.Emit/PropertyBuilder.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+
+namespace System.Reflection.Emit {
+ public sealed class PropertyBuilder : PropertyInfo {
+ private PropertyAttributes attrs;
+ private string name;
+ private Type type;
+ private Type[] parameters;
+ private CustomAttributeBuilder[] cattrs;
+ private object def_value;
+ private MethodBuilder set_method;
+ private MethodBuilder get_method;
+ private int table_idx = 0;
+ internal TypeBuilder typeb;
+
+ internal PropertyBuilder (TypeBuilder tb, string name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes) {
+ this.name = name;
+ this.attrs = attributes;
+ this.type = returnType;
+ if (parameterTypes != null) {
+ this.parameters = new Type [parameterTypes.Length];
+ System.Array.Copy (parameterTypes, this.parameters, this.parameters.Length);
+ }
+ typeb = tb;
+ table_idx = tb.get_next_table_index (this, 0x17, true);
+ }
+
+ public override PropertyAttributes Attributes {
+ get {return attrs;}
+ }
+ public override bool CanRead {
+ get {return get_method != null;}
+ }
+ public override bool CanWrite {
+ get {return set_method != null;}
+ }
+ public override Type DeclaringType {
+ get {return typeb;}
+ }
+ public override string Name {
+ get {return name;}
+ }
+ public PropertyToken PropertyToken {
+ get {return new PropertyToken ();}
+ }
+ public override Type PropertyType {
+ get {return type;}
+ }
+ public override Type ReflectedType {
+ get {return typeb;}
+ }
+ public void AddOtherMethod( MethodBuilder mdBuilder) {
+ }
+ public override MethodInfo[] GetAccessors( bool nonPublic) {
+ return null;
+ }
+ public override object[] GetCustomAttributes(bool inherit) {
+ return null;
+ }
+ public override object[] GetCustomAttributes(Type attributeType, bool inherit) {
+ return null;
+ }
+ public override MethodInfo GetGetMethod( bool nonPublic) {
+ return get_method;
+ }
+ public override ParameterInfo[] GetIndexParameters() {
+ return null;
+ }
+ public override MethodInfo GetSetMethod( bool nonPublic) {
+ return set_method;
+ }
+ public override object GetValue(object obj, object[] index) {
+ return null;
+ }
+ public override object GetValue( object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) {
+ return null;
+ }
+ public override bool IsDefined( Type attributeType, bool inherit) {
+ return false;
+ }
+ public void SetConstant( object defaultValue) {
+ def_value = defaultValue;
+ }
+ public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
+ if (cattrs != null) {
+ CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
+ cattrs.CopyTo (new_array, 0);
+ new_array [cattrs.Length] = customBuilder;
+ cattrs = new_array;
+ } else {
+ cattrs = new CustomAttributeBuilder [1];
+ cattrs [0] = customBuilder;
+ }
+ }
+ public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
+ SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
+ }
+ public void SetGetMethod( MethodBuilder mdBuilder) {
+ get_method = mdBuilder;
+ }
+ public void SetSetMethod( MethodBuilder mdBuilder) {
+ set_method = mdBuilder;
+ }
+ public override void SetValue( object obj, object value, object[] index) {
+ }
+ public override void SetValue( object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) {
+ }
+ }
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/PropertyToken.cs b/mcs/class/corlib/System.Reflection.Emit/PropertyToken.cs
new file mode 100644
index 00000000000..38216a23996
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/PropertyToken.cs
@@ -0,0 +1,70 @@
+// PropertyToken.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+
+ /// <summary>
+ /// Represents the Token returned by the metadata to represent a Property.
+ /// </summary>
+ [Serializable]
+ public struct PropertyToken {
+
+ internal int tokValue;
+
+ public static readonly PropertyToken Empty;
+
+
+ static PropertyToken ()
+ {
+ Empty = new PropertyToken ();
+ }
+
+
+ internal PropertyToken (int val)
+ {
+ tokValue = val;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public override bool Equals (object obj)
+ {
+ bool res = obj is PropertyToken;
+
+ if (res) {
+ PropertyToken that = (PropertyToken) obj;
+ res = (this.tokValue == that.tokValue);
+ }
+
+ return res;
+ }
+
+
+ /// <summary>
+ /// Tests whether the given object is an instance of
+ /// PropertyToken and has the same token value.
+ /// </summary>
+ public override int GetHashCode ()
+ {
+ return tokValue;
+ }
+
+
+ /// <summary>
+ /// Returns the metadata token for this Property.
+ /// </summary>
+ public int Token {
+ get {
+ return tokValue;
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/SignatureHelper.cs b/mcs/class/corlib/System.Reflection.Emit/SignatureHelper.cs
new file mode 100755
index 00000000000..40e3b566a22
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/SignatureHelper.cs
@@ -0,0 +1,121 @@
+
+//
+// System.Reflection.Emit/SignatureHelper.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace System.Reflection.Emit {
+ [Serializable]
+ public sealed class SignatureHelper {
+ internal enum SignatureHelperType {
+ HELPER_FIELD,
+ HELPER_LOCAL,
+ HELPER_METHOD,
+ HELPER_PROPERTY
+ }
+
+ private ModuleBuilder module;
+ private Type[] arguments;
+ private SignatureHelperType type;
+
+ internal SignatureHelper (ModuleBuilder module, SignatureHelperType type)
+ {
+ this.type = type;
+ this.module = module;
+ }
+
+ public static SignatureHelper GetFieldSigHelper (Module mod)
+ {
+ if (!(mod is ModuleBuilder))
+ throw new NotImplementedException ();
+
+ return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_FIELD);
+ }
+ public static SignatureHelper GetLocalVarSigHelper (Module mod)
+ {
+ if (!(mod is ModuleBuilder))
+ throw new NotImplementedException ();
+
+ return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_LOCAL);
+ }
+ [MonoTODO]
+ public static SignatureHelper GetMethodSigHelper( Module mod, CallingConventions callingConvention, Type returnType)
+ {
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ public static SignatureHelper GetMethodSigHelper( Module mod, Type returnType, Type[] parameterTypes)
+ {
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ public static SignatureHelper GetPropertySigHelper( Module mod, Type returnType, Type[] parameterTypes)
+ {
+ throw new NotImplementedException ();
+ }
+ public void AddArgument (Type clsArgument)
+ {
+ if (arguments != null) {
+ Type[] new_a = new Type [arguments.Length + 1];
+ System.Array.Copy (arguments, new_a, arguments.Length);
+ new_a [arguments.Length] = clsArgument;
+ arguments = new_a;
+ } else {
+ arguments = new Type [1];
+ arguments [0] = clsArgument;
+ }
+ }
+ [MonoTODO]
+ public void AddSentinel ()
+ {
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ public override bool Equals (object obj)
+ {
+ throw new NotImplementedException ();
+ }
+ [MonoTODO]
+ public override int GetHashCode ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ internal extern byte[] get_signature_local ();
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ internal extern byte[] get_signature_field ();
+
+ public byte[] GetSignature ()
+ {
+ switch (type) {
+ case SignatureHelperType.HELPER_LOCAL:
+ return get_signature_local ();
+ case SignatureHelperType.HELPER_FIELD:
+ return get_signature_field ();
+ default:
+ throw new NotImplementedException ();
+ }
+ }
+
+ public override string ToString() {
+ return "SignatureHelper";
+ }
+
+
+
+ }
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/SignatureToken.cs b/mcs/class/corlib/System.Reflection.Emit/SignatureToken.cs
new file mode 100644
index 00000000000..b8e7aa67bb5
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/SignatureToken.cs
@@ -0,0 +1,70 @@
+// SignatureToken.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+
+ /// <summary>
+ /// Represents the Token returned by the metadata to represent a Signature.
+ /// </summary>
+ [Serializable]
+ public struct SignatureToken {
+
+ internal int tokValue;
+
+ public static readonly SignatureToken Empty;
+
+
+ static SignatureToken ()
+ {
+ Empty = new SignatureToken ();
+ }
+
+
+ internal SignatureToken (int val)
+ {
+ tokValue = val;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public override bool Equals (object obj)
+ {
+ bool res = obj is SignatureToken;
+
+ if (res) {
+ SignatureToken that = (SignatureToken) obj;
+ res = (this.tokValue == that.tokValue);
+ }
+
+ return res;
+ }
+
+
+ /// <summary>
+ /// Tests whether the given object is an instance of
+ /// SignatureToken and has the same token value.
+ /// </summary>
+ public override int GetHashCode ()
+ {
+ return tokValue;
+ }
+
+
+ /// <summary>
+ /// Returns the metadata token for this Signature.
+ /// </summary>
+ public int Token {
+ get {
+ return tokValue;
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/StackBehaviour.cs b/mcs/class/corlib/System.Reflection.Emit/StackBehaviour.cs
new file mode 100644
index 00000000000..78cb915e7a6
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/StackBehaviour.cs
@@ -0,0 +1,126 @@
+// StackBehaviour.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+ /// <summary>
+ /// Describes how values are pushed onto or popped off a stack.
+ /// </summary>
+ public enum StackBehaviour {
+
+ /// <summary>
+ /// </summary>
+ Pop0 = 0,
+
+ /// <summary>
+ /// </summary>
+ Pop1 = 1,
+
+ /// <summary>
+ /// </summary>
+ Pop1_pop1 = 2,
+
+ /// <summary>
+ /// </summary>
+ Popi = 3,
+
+ /// <summary>
+ /// </summary>
+ Popi_pop1 = 4,
+
+ /// <summary>
+ /// </summary>
+ Popi_popi = 5,
+
+ /// <summary>
+ /// </summary>
+ Popi_popi8 = 6,
+
+ /// <summary>
+ /// </summary>
+ Popi_popi_popi = 7,
+
+ /// <summary>
+ /// </summary>
+ Popi_popr4 = 8,
+
+ /// <summary>
+ /// </summary>
+ Popi_popr8 = 9,
+
+ /// <summary>
+ /// </summary>
+ Popref = 0x0A,
+
+ /// <summary>
+ /// </summary>
+ Popref_pop1 = 0x0B,
+
+ /// <summary>
+ /// </summary>
+ Popref_popi = 0x0C,
+
+ /// <summary>
+ /// </summary>
+ Popref_popi_popi = 0x0D,
+
+ /// <summary>
+ /// </summary>
+ Popref_popi_popi8 = 0x0E,
+
+ /// <summary>
+ /// </summary>
+ Popref_popi_popr4 = 0x0F,
+
+ /// <summary>
+ /// </summary>
+ Popref_popi_popr8 = 0x10,
+
+ /// <summary>
+ /// </summary>
+ Popref_popi_popref = 0x11,
+
+ /// <summary>
+ /// </summary>
+ Push0 = 0x12,
+
+ /// <summary>
+ /// </summary>
+ Push1 = 0x13,
+
+ /// <summary>
+ /// </summary>
+ Push1_push1 = 0x14,
+
+ /// <summary>
+ /// </summary>
+ Pushi = 0x15,
+
+ /// <summary>
+ /// </summary>
+ Pushi8 = 0x16,
+
+ /// <summary>
+ /// </summary>
+ Pushr4 = 0x17,
+
+ /// <summary>
+ /// </summary>
+ Pushr8 = 0x18,
+
+ /// <summary>
+ /// </summary>
+ Pushref = 0x19,
+
+ /// <summary>
+ /// </summary>
+ Varpop = 0x1A,
+
+ /// <summary>
+ /// </summary>
+ Varpush = 0x1B
+ }
+
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/StringToken.cs b/mcs/class/corlib/System.Reflection.Emit/StringToken.cs
new file mode 100644
index 00000000000..a872b8967bd
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/StringToken.cs
@@ -0,0 +1,70 @@
+// StringToken.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+
+ /// <summary>
+ /// Represents the Token returned by the metadata to represent a String.
+ /// </summary>
+ [Serializable]
+ public struct StringToken {
+
+ internal int tokValue;
+
+ public static readonly StringToken Empty;
+
+
+ static StringToken ()
+ {
+ Empty = new StringToken ();
+ }
+
+
+ internal StringToken (int val)
+ {
+ tokValue = val;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public override bool Equals (object obj)
+ {
+ bool res = obj is StringToken;
+
+ if (res) {
+ StringToken that = (StringToken) obj;
+ res = (this.tokValue == that.tokValue);
+ }
+
+ return res;
+ }
+
+
+ /// <summary>
+ /// Tests whether the given object is an instance of
+ /// StringToken and has the same token value.
+ /// </summary>
+ public override int GetHashCode ()
+ {
+ return tokValue;
+ }
+
+
+ /// <summary>
+ /// Returns the metadata token for this String.
+ /// </summary>
+ public int Token {
+ get {
+ return tokValue;
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
new file mode 100644
index 00000000000..75d231ee448
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
@@ -0,0 +1,748 @@
+//
+// System.Reflection.Emit/TypeBuilder.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Globalization;
+using System.Collections;
+using System.Security;
+using System.Security.Permissions;
+
+namespace System.Reflection.Emit {
+ public sealed class TypeBuilder : Type {
+ private string tname;
+ private string nspace;
+ private Type parent;
+ private Type nesting_type;
+ private Type[] interfaces;
+ private MethodBuilder[] methods;
+ private ConstructorBuilder[] ctors;
+ private PropertyBuilder[] properties;
+ private FieldBuilder[] fields;
+ private EventBuilder[] events;
+ private CustomAttributeBuilder[] cattrs;
+ internal TypeBuilder[] subtypes;
+ private TypeAttributes attrs;
+ private int table_idx;
+ private ModuleBuilder pmodule;
+ private int class_size;
+ private PackingSize packing_size;
+ private Type created;
+ string fullname;
+
+ public const int UnspecifiedTypeSize = 0;
+
+ protected override TypeAttributes GetAttributeFlagsImpl () {
+ return attrs;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private extern void setup_internal_class (TypeBuilder tb);
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private extern void create_internal_class (TypeBuilder tb);
+
+ internal TypeBuilder (ModuleBuilder mb, TypeAttributes attr) {
+ this.parent = null;
+ this.attrs = attr;
+ this.class_size = -1;
+ fullname = this.tname = "<Module>";
+ this.nspace = "";
+ pmodule = mb;
+ setup_internal_class (this);
+ }
+
+ internal TypeBuilder (ModuleBuilder mb, string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packing_size, int type_size) {
+ int sep_index;
+ this.parent = parent;
+ this.attrs = attr;
+ this.class_size = type_size;
+ this.packing_size = packing_size;
+ sep_index = name.LastIndexOf('.');
+ if (sep_index != -1) {
+ this.tname = name.Substring (sep_index + 1);
+ this.nspace = name.Substring (0, sep_index);
+ } else {
+ this.tname = name;
+ this.nspace = "";
+ }
+ if (interfaces != null) {
+ this.interfaces = new Type[interfaces.Length];
+ System.Array.Copy (interfaces, this.interfaces, interfaces.Length);
+ }
+ pmodule = mb;
+ // skip .<Module> ?
+ table_idx = mb.get_next_table_index (this, 0x02, true);
+ setup_internal_class (this);
+ fullname = GetFullName ();
+ }
+
+ public override Assembly Assembly {
+ get {return pmodule.Assembly;}
+ }
+ public override string AssemblyQualifiedName {
+ get {
+ return fullname + ", " + Assembly.ToString();
+ }
+ }
+ public override Type BaseType {
+ get {
+ return parent;
+ }
+ }
+ public override Type DeclaringType {get {return nesting_type;}}
+ public override Type UnderlyingSystemType {
+ get {
+ if (fields != null) {
+ foreach (FieldBuilder f in fields) {
+ if ((f.Attributes & FieldAttributes.Static) == 0)
+ return f.FieldType;
+ }
+ }
+ throw new InvalidOperationException (String.Format ("typebuilder: {0}", this));
+ }
+ }
+
+ string GetFullName () {
+ if (nesting_type != null)
+ return String.Concat (nesting_type.FullName, "+", tname);
+ if ((nspace != null) && (nspace.Length > 0))
+ return String.Concat (nspace, ".", tname);
+ return tname;
+ }
+
+ public override string FullName {
+ get {
+ return fullname;
+ }
+ }
+
+ public override Guid GUID {
+ get {return Guid.Empty;}
+ }
+
+ public override Module Module {
+ get {return pmodule;}
+ }
+ public override string Name {
+ get {return tname;}
+ }
+ public override string Namespace {
+ get {return nspace;}
+ }
+ public PackingSize PackingSize {
+ get {return packing_size;}
+ }
+ public override Type ReflectedType {get {return nesting_type;}}
+ public override MemberTypes MemberType {
+ get {return MemberTypes.TypeInfo;}
+ }
+
+ [MonoTODO]
+ public void AddDeclarativeSecurity( SecurityAction action, PermissionSet pset) {
+ throw new NotImplementedException ();
+ }
+
+ public void AddInterfaceImplementation( Type interfaceType) {
+ if (interfaces != null) {
+ Type[] ifnew = new Type [interfaces.Length + 1];
+ interfaces.CopyTo (ifnew, 0);
+ ifnew [interfaces.Length] = interfaceType;
+ interfaces = ifnew;
+ } else {
+ interfaces = new Type [1];
+ interfaces [0] = interfaceType;
+ }
+ }
+
+ [MonoTODO]
+ protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) {
+ throw new NotImplementedException ();
+ }
+
+ public override bool IsDefined( Type attributeType, bool inherit) {
+ return false;
+ }
+ public override object[] GetCustomAttributes(bool inherit) {
+ return null;
+ }
+ public override object[] GetCustomAttributes(Type attributeType, bool inherit) {
+ return null;
+ }
+
+ [MonoTODO]
+ public TypeBuilder DefineNestedType (string name) {
+ // FIXME: LAMESPEC: what other attributes should we use here as default?
+ return DefineNestedType (name, TypeAttributes.Public, pmodule.assemblyb.corlib_object_type, null);
+ }
+
+ public TypeBuilder DefineNestedType (string name, TypeAttributes attr) {
+ return DefineNestedType (name, attr, pmodule.assemblyb.corlib_object_type, null);
+ }
+
+ public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent) {
+ return DefineNestedType (name, attr, parent, null);
+ }
+
+ private TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packsize, int typesize) {
+ TypeBuilder res = new TypeBuilder (pmodule, name, attr, parent, interfaces, packsize, typesize);
+ res.nesting_type = this;
+ res.fullname = res.GetFullName ();
+ pmodule.RegisterTypeName (res, res.fullname);
+ if (subtypes != null) {
+ TypeBuilder[] new_types = new TypeBuilder [subtypes.Length + 1];
+ System.Array.Copy (subtypes, new_types, subtypes.Length);
+ new_types [subtypes.Length] = res;
+ subtypes = new_types;
+ } else {
+ subtypes = new TypeBuilder [1];
+ subtypes [0] = res;
+ }
+ return res;
+ }
+
+ public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, Type[] interfaces) {
+ return DefineNestedType (name, attr, parent, interfaces, PackingSize.Unspecified, UnspecifiedTypeSize);
+ }
+
+ public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, int typesize) {
+ return DefineNestedType (name, attr, parent, null, PackingSize.Unspecified, typesize);
+ }
+
+ public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, PackingSize packsize) {
+ return DefineNestedType (name, attr, parent, null, packsize, UnspecifiedTypeSize);
+ }
+
+ public ConstructorBuilder DefineConstructor( MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes) {
+ ConstructorBuilder cb = new ConstructorBuilder (this, attributes, callingConvention, parameterTypes);
+ if (ctors != null) {
+ ConstructorBuilder[] new_ctors = new ConstructorBuilder [ctors.Length+1];
+ System.Array.Copy (ctors, new_ctors, ctors.Length);
+ new_ctors [ctors.Length] = cb;
+ ctors = new_ctors;
+ } else {
+ ctors = new ConstructorBuilder [1];
+ ctors [0] = cb;
+ }
+ return cb;
+ }
+
+ public ConstructorBuilder DefineDefaultConstructor( MethodAttributes attributes) {
+ return DefineConstructor (attributes, CallingConventions.Standard, null);
+ }
+
+ public MethodBuilder DefineMethod( string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) {
+ return DefineMethod (name, attributes, CallingConventions.Standard, returnType, parameterTypes);
+ }
+
+ private void append_method (MethodBuilder mb) {
+ if (methods != null) {
+ MethodBuilder[] new_methods = new MethodBuilder [methods.Length+1];
+ System.Array.Copy (methods, new_methods, methods.Length);
+ new_methods [methods.Length] = mb;
+ methods = new_methods;
+ } else {
+ methods = new MethodBuilder [1];
+ methods [0] = mb;
+ }
+ }
+
+ public MethodBuilder DefineMethod( string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
+ MethodBuilder res = new MethodBuilder (this, name, attributes, callingConvention, returnType, parameterTypes);
+ append_method (res);
+ return res;
+ }
+
+ public MethodBuilder DefinePInvokeMethod (string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet) {
+ MethodBuilder res = new MethodBuilder (this, name, attributes, callingConvention, returnType, parameterTypes,
+ dllName, entryName, nativeCallConv, nativeCharSet);
+ append_method (res);
+ return res;
+ }
+
+ public MethodBuilder DefinePInvokeMethod (string name, string dllName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet) {
+ return DefinePInvokeMethod (name, dllName, name, attributes, callingConvention, returnType, parameterTypes,
+ nativeCallConv, nativeCharSet);
+ }
+
+ public void DefineMethodOverride( MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration) {
+ if (methodInfoBody is MethodBuilder) {
+ MethodBuilder mb = (MethodBuilder)methodInfoBody;
+ mb.set_override (methodInfoDeclaration);
+ }
+ }
+
+ public FieldBuilder DefineField( string fieldName, Type type, FieldAttributes attributes) {
+ FieldBuilder res = new FieldBuilder (this, fieldName, type, attributes);
+ if (fields != null) {
+ FieldBuilder[] new_fields = new FieldBuilder [fields.Length+1];
+ System.Array.Copy (fields, new_fields, fields.Length);
+ new_fields [fields.Length] = res;
+ fields = new_fields;
+ } else {
+ fields = new FieldBuilder [1];
+ fields [0] = res;
+ create_internal_class (this);
+ }
+ return res;
+ }
+
+ public PropertyBuilder DefineProperty( string name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes) {
+ PropertyBuilder res = new PropertyBuilder (this, name, attributes, returnType, parameterTypes);
+
+ if (properties != null) {
+ PropertyBuilder[] new_properties = new PropertyBuilder [properties.Length+1];
+ System.Array.Copy (properties, new_properties, properties.Length);
+ new_properties [properties.Length] = res;
+ properties = new_properties;
+ } else {
+ properties = new PropertyBuilder [1];
+ properties [0] = res;
+ }
+ return res;
+ }
+
+ [MonoTODO]
+ public ConstructorBuilder DefineTypeInitializer() {
+ throw new NotImplementedException ();
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private extern Type create_runtime_class (TypeBuilder tb);
+
+ public Type CreateType() {
+ /* handle nesting_type */
+ if (created != null) {
+ string err="type already created: " + created.ToString();
+ throw new InvalidOperationException (err);
+ }
+ if (methods != null) {
+ foreach (MethodBuilder method in methods) {
+ method.fixup ();
+ }
+ }
+ if (ctors != null) {
+ foreach (ConstructorBuilder ctor in ctors) {
+ ctor.fixup ();
+ }
+ }
+ created = create_runtime_class (this);
+ if (created != null)
+ return created;
+ return this;
+ }
+
+ public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr) {
+ if (ctors == null)
+ return new ConstructorInfo [0];
+ ArrayList l = new ArrayList ();
+ bool match;
+ MethodAttributes mattrs;
+
+ foreach (ConstructorBuilder c in ctors) {
+ match = false;
+ mattrs = c.Attributes;
+ if ((mattrs & MethodAttributes.MemberAccessMask) == MethodAttributes.Public) {
+ if ((bindingAttr & BindingFlags.Public) != 0)
+ match = true;
+ } else {
+ if ((bindingAttr & BindingFlags.NonPublic) != 0)
+ match = true;
+ }
+ if (!match)
+ continue;
+ match = false;
+ if ((mattrs & MethodAttributes.Static) != 0) {
+ if ((bindingAttr & BindingFlags.Static) != 0)
+ match = true;
+ } else {
+ if ((bindingAttr & BindingFlags.Instance) != 0)
+ match = true;
+ }
+ if (!match)
+ continue;
+ l.Add (c);
+ }
+ ConstructorInfo[] result = new ConstructorInfo [l.Count];
+ l.CopyTo (result);
+ return result;
+ }
+
+ public override Type GetElementType () { return null; }
+
+ [MonoTODO]
+ public override EventInfo GetEvent (string name, BindingFlags bindingAttr) {
+ throw new NotImplementedException ();
+ }
+
+ public override EventInfo[] GetEvents (BindingFlags bindingAttr) {
+ return new EventInfo [0];
+ }
+
+ [MonoTODO]
+ public override FieldInfo GetField( string name, BindingFlags bindingAttr) {
+ //FIXME
+ throw new NotImplementedException ();
+ }
+
+ public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
+ if (fields == null)
+ return new FieldInfo [0];
+ ArrayList l = new ArrayList ();
+ bool match;
+ FieldAttributes mattrs;
+
+ foreach (FieldInfo c in fields) {
+ match = false;
+ mattrs = c.Attributes;
+ if ((mattrs & FieldAttributes.FieldAccessMask) == FieldAttributes.Public) {
+ if ((bindingAttr & BindingFlags.Public) != 0)
+ match = true;
+ } else {
+ if ((bindingAttr & BindingFlags.NonPublic) != 0)
+ match = true;
+ }
+ if (!match)
+ continue;
+ match = false;
+ if ((mattrs & FieldAttributes.Static) != 0) {
+ if ((bindingAttr & BindingFlags.Static) != 0)
+ match = true;
+ } else {
+ if ((bindingAttr & BindingFlags.Instance) != 0)
+ match = true;
+ }
+ if (!match)
+ continue;
+ l.Add (c);
+ }
+ FieldInfo[] result = new FieldInfo [l.Count];
+ l.CopyTo (result);
+ return result;
+ }
+
+ [MonoTODO]
+ public override Type GetInterface (string name, bool ignoreCase) {
+ throw new NotImplementedException ();
+ }
+
+ public override Type[] GetInterfaces () {
+ if (interfaces != null) {
+ Type[] ret = new Type [interfaces.Length];
+ interfaces.CopyTo (ret, 0);
+ return ret;
+ } else {
+ return Type.EmptyTypes;
+ }
+ }
+
+ [MonoTODO]
+ public override MemberInfo[] GetMembers( BindingFlags bindingAttr) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ public override MethodInfo[] GetMethods (BindingFlags bindingAttr) {
+ if (methods == null)
+ return new MethodInfo [0];
+ ArrayList l = new ArrayList ();
+ bool match;
+ MethodAttributes mattrs;
+
+ foreach (MethodInfo c in methods) {
+ match = false;
+ mattrs = c.Attributes;
+ if ((mattrs & MethodAttributes.MemberAccessMask) == MethodAttributes.Public) {
+ if ((bindingAttr & BindingFlags.Public) != 0)
+ match = true;
+ } else {
+ if ((bindingAttr & BindingFlags.NonPublic) != 0)
+ match = true;
+ }
+ if (!match)
+ continue;
+ match = false;
+ if ((mattrs & MethodAttributes.Static) != 0) {
+ if ((bindingAttr & BindingFlags.Static) != 0)
+ match = true;
+ } else {
+ if ((bindingAttr & BindingFlags.Instance) != 0)
+ match = true;
+ }
+ if (!match)
+ continue;
+ l.Add (c);
+ }
+ MethodInfo[] result = new MethodInfo [l.Count];
+ l.CopyTo (result);
+ return result;
+ }
+
+ [MonoTODO]
+ protected override MethodInfo GetMethodImpl( string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override Type GetNestedType( string name, BindingFlags bindingAttr) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ public override Type[] GetNestedTypes (BindingFlags bindingAttr) {
+ bool match;
+ ArrayList result = new ArrayList ();
+
+ if (subtypes == null)
+ return Type.EmptyTypes;
+ foreach (TypeBuilder t in subtypes) {
+ match = false;
+ if ((t.attrs & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPublic) {
+ if ((bindingAttr & BindingFlags.Public) != 0)
+ match = true;
+ } else {
+ if ((bindingAttr & BindingFlags.NonPublic) != 0)
+ match = true;
+ }
+ if (!match)
+ continue;
+ result.Add (t);
+ }
+ Type[] r = new Type [result.Count];
+ result.CopyTo (r);
+ return r;
+ }
+
+ public override PropertyInfo[] GetProperties( BindingFlags bindingAttr) {
+ if (properties == null)
+ return new PropertyInfo [0];
+ ArrayList l = new ArrayList ();
+ bool match;
+ MethodAttributes mattrs;
+ MethodInfo accessor;
+
+ foreach (PropertyInfo c in properties) {
+ match = false;
+ accessor = c.GetGetMethod (true);
+ if (accessor == null)
+ accessor = c.GetSetMethod (true);
+ if (accessor == null)
+ continue;
+ mattrs = accessor.Attributes;
+ if ((mattrs & MethodAttributes.MemberAccessMask) == MethodAttributes.Public) {
+ if ((bindingAttr & BindingFlags.Public) != 0)
+ match = true;
+ } else {
+ if ((bindingAttr & BindingFlags.NonPublic) != 0)
+ match = true;
+ }
+ if (!match)
+ continue;
+ match = false;
+ if ((mattrs & MethodAttributes.Static) != 0) {
+ if ((bindingAttr & BindingFlags.Static) != 0)
+ match = true;
+ } else {
+ if ((bindingAttr & BindingFlags.Instance) != 0)
+ match = true;
+ }
+ if (!match)
+ continue;
+ l.Add (c);
+ }
+ PropertyInfo[] result = new PropertyInfo [l.Count];
+ l.CopyTo (result);
+ return result;
+ }
+
+ [MonoTODO]
+ protected override PropertyInfo GetPropertyImpl( string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ protected override bool HasElementTypeImpl () {
+ return IsArrayImpl() || IsByRefImpl() || IsPointerImpl ();
+ }
+
+ [MonoTODO]
+ public override object InvokeMember( string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) {
+ // FIXME
+ throw new NotImplementedException ();
+ }
+
+ protected override bool IsArrayImpl () {
+ return type_is_subtype_of (this, typeof (System.Array), false);
+ }
+ protected override bool IsByRefImpl () {
+ // FIXME
+ return false;
+ }
+ protected override bool IsCOMObjectImpl () {
+ return false;
+ }
+ protected override bool IsPointerImpl () {
+ // FIXME
+ return false;
+ }
+ protected override bool IsPrimitiveImpl () {
+ // FIXME
+ return false;
+ }
+ protected override bool IsValueTypeImpl () {
+ return ((type_is_subtype_of (this, pmodule.assemblyb.corlib_value_type, false) || type_is_subtype_of (this, typeof(System.ValueType), false)) &&
+ this != pmodule.assemblyb.corlib_value_type &&
+ this != pmodule.assemblyb.corlib_enum_type);
+ }
+
+ public override RuntimeTypeHandle TypeHandle { get { return _impl; } }
+
+ public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
+ string attrname = customBuilder.Ctor.ReflectedType.FullName;
+ if (attrname == "System.Runtime.InteropServices.StructLayoutAttribute") {
+ byte[] data = customBuilder.Data;
+ int layout_kind; /* the (stupid) ctor takes a short or an int ... */
+ layout_kind = (int)data [2];
+ layout_kind |= ((int)data [3]) << 8;
+ attrs &= ~TypeAttributes.LayoutMask;
+ switch ((LayoutKind)layout_kind) {
+ case LayoutKind.Auto:
+ attrs |= TypeAttributes.AutoLayout;
+ break;
+ case LayoutKind.Explicit:
+ attrs |= TypeAttributes.ExplicitLayout;
+ break;
+ case LayoutKind.Sequential:
+ attrs |= TypeAttributes.SequentialLayout;
+ break;
+ default:
+ // we should ignore it since it can be any value anyway...
+ throw new Exception ("Error in customattr");
+ }
+ string first_type_name = customBuilder.Ctor.GetParameters()[0].ParameterType.FullName;
+ int pos = 6;
+ if (first_type_name == "System.Int16")
+ pos = 4;
+ int nnamed = (int)data [pos++];
+ nnamed |= ((int)data [pos++]) << 8;
+ for (int i = 0; i < nnamed; ++i) {
+ byte named_type = data [pos++];
+ byte type = data [pos++];
+ int len = CustomAttributeBuilder.decode_len (data, pos, out pos);
+ string named_name = CustomAttributeBuilder.string_from_bytes (data, pos, len);
+ pos += len;
+ /* all the fields are integers in StructLayout */
+ int value = (int)data [pos++];
+ value |= ((int)data [pos++]) << 8;
+ value |= ((int)data [pos++]) << 16;
+ value |= ((int)data [pos++]) << 24;
+ switch (named_name) {
+ case "CharSet":
+ switch ((CharSet)value) {
+ case CharSet.None:
+ case CharSet.Ansi:
+ break;
+ case CharSet.Unicode:
+ attrs |= TypeAttributes.UnicodeClass;
+ break;
+ case CharSet.Auto:
+ attrs |= TypeAttributes.AutoClass;
+ break;
+ default:
+ break; // error out...
+ }
+ break;
+ case "Pack":
+ packing_size = (PackingSize)value;
+ break;
+ case "Size":
+ class_size = value;
+ break;
+ default:
+ break; // error out...
+ }
+ }
+ return;
+ } else if (attrname == "System.SerializableAttribute") {
+ attrs |= TypeAttributes.Serializable;
+ return;
+ }
+ if (cattrs != null) {
+ CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
+ cattrs.CopyTo (new_array, 0);
+ new_array [cattrs.Length] = customBuilder;
+ cattrs = new_array;
+ } else {
+ cattrs = new CustomAttributeBuilder [1];
+ cattrs [0] = customBuilder;
+ }
+ }
+ public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
+ SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
+ }
+
+ public EventBuilder DefineEvent( string name, EventAttributes attributes, Type eventtype) {
+ EventBuilder res = new EventBuilder (this, name, attributes, eventtype);
+ if (events != null) {
+ EventBuilder[] new_events = new EventBuilder [events.Length+1];
+ System.Array.Copy (events, new_events, events.Length);
+ new_events [events.Length] = res;
+ events = new_events;
+ } else {
+ events = new EventBuilder [1];
+ events [0] = res;
+ }
+ return res;
+ }
+
+ static int InitializedDataCount = 0;
+
+ public FieldBuilder DefineInitializedData( string name, byte[] data, FieldAttributes attributes) {
+ TypeBuilder datablobtype = DefineNestedType ("$ArrayType$"+InitializedDataCount.ToString(),
+ TypeAttributes.NestedPrivate|TypeAttributes.ExplicitLayout|TypeAttributes.Sealed,
+ pmodule.assemblyb.corlib_value_type, null, PackingSize.Size1, data.Length);
+ datablobtype.packing_size = PackingSize.Size1;
+ datablobtype.class_size = data.Length;
+ datablobtype.CreateType ();
+ FieldBuilder res = DefineField (name, datablobtype, attributes|FieldAttributes.Assembly|FieldAttributes.Static|FieldAttributes.HasFieldRVA);
+ res.SetRVAData (data);
+ InitializedDataCount++;
+ return res;
+ }
+
+ [MonoTODO]
+ public FieldBuilder DefineUninitializedData( string name, int size, FieldAttributes attributes) {
+ throw new NotImplementedException ();
+ }
+
+ public TypeToken TypeToken {
+ get {
+ return new TypeToken (0x02000000 | table_idx);
+ }
+ }
+ public void SetParent (Type parentType) {
+ parent = parentType;
+ }
+ internal int get_next_table_index (object obj, int table, bool inc) {
+ return pmodule.get_next_table_index (obj, table, inc);
+ }
+
+ public override InterfaceMapping GetInterfaceMap (Type interfaceType)
+ {
+ if (created == null)
+ throw new NotSupportedException ("This method is not implemented for incomplete types.");
+
+ return created.GetInterfaceMap (interfaceType);
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/TypeToken.cs b/mcs/class/corlib/System.Reflection.Emit/TypeToken.cs
new file mode 100644
index 00000000000..8fd6ae493b3
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/TypeToken.cs
@@ -0,0 +1,70 @@
+// TypeToken.cs
+//
+// (C) 2001 Ximian, Inc. http://www.ximian.com
+
+
+namespace System.Reflection.Emit {
+
+
+ /// <summary>
+ /// Represents the Token returned by the metadata to represent a Type.
+ /// </summary>
+ [Serializable]
+ public struct TypeToken {
+
+ internal int tokValue;
+
+ public static readonly TypeToken Empty;
+
+
+ static TypeToken ()
+ {
+ Empty = new TypeToken ();
+ }
+
+
+ internal TypeToken (int val)
+ {
+ tokValue = val;
+ }
+
+
+
+ /// <summary>
+ /// </summary>
+ public override bool Equals (object obj)
+ {
+ bool res = obj is TypeToken;
+
+ if (res) {
+ TypeToken that = (TypeToken) obj;
+ res = (this.tokValue == that.tokValue);
+ }
+
+ return res;
+ }
+
+
+ /// <summary>
+ /// Tests whether the given object is an instance of
+ /// TypeToken and has the same token value.
+ /// </summary>
+ public override int GetHashCode ()
+ {
+ return tokValue;
+ }
+
+
+ /// <summary>
+ /// Returns the metadata token for this Type.
+ /// </summary>
+ public int Token {
+ get {
+ return tokValue;
+ }
+ }
+
+ }
+
+}
+
diff --git a/mcs/class/corlib/System.Reflection.Emit/UnmanagedMarshal.cs b/mcs/class/corlib/System.Reflection.Emit/UnmanagedMarshal.cs
new file mode 100755
index 00000000000..1c0d8bf5280
--- /dev/null
+++ b/mcs/class/corlib/System.Reflection.Emit/UnmanagedMarshal.cs
@@ -0,0 +1,75 @@
+
+//
+// System.Reflection.Emit/UnmanagedMarshal.cs
+//
+// Author:
+// Paolo Molaro (lupus@ximian.com)
+//
+// (C) 2001-2002 Ximian, Inc. http://www.ximian.com
+//
+
+using System.Reflection.Emit;
+using System.Runtime.InteropServices;
+using System;
+
+namespace System.Reflection.Emit {
+
+ [Serializable]
+ public sealed class UnmanagedMarshal {
+ private int count;
+ private UnmanagedType t;
+ private UnmanagedType tbase;
+
+ private UnmanagedMarshal (UnmanagedType maint, int cnt) {
+ count = cnt;
+ t = maint;
+ tbase = maint;
+ }
+ private UnmanagedMarshal (UnmanagedType maint, UnmanagedType elemt) {
+ count = 0;
+ t = maint;
+ tbase = elemt;
+ }
+
+ public UnmanagedType BaseType {
+ get {
+ if (t == UnmanagedType.LPArray || t == UnmanagedType.SafeArray)
+ throw new ArgumentException ();
+ return tbase;
+ }
+ }
+
+ public int ElementCount {
+ get {return count;}
+ }
+
+ public UnmanagedType GetUnmanagedType {
+ get {return t;}
+ }
+
+ public Guid IIDGuid {
+ get {return Guid.Empty;}
+ }
+
+ public static UnmanagedMarshal DefineByValArray( int elemCount) {
+ return new UnmanagedMarshal (UnmanagedType.ByValArray, elemCount);
+ }
+
+ public static UnmanagedMarshal DefineByValTStr( int elemCount) {
+ return new UnmanagedMarshal (UnmanagedType.ByValTStr, elemCount);
+ }
+
+ public static UnmanagedMarshal DefineLPArray( UnmanagedType elemType) {
+ return new UnmanagedMarshal (UnmanagedType.LPArray, elemType);
+ }
+
+ public static UnmanagedMarshal DefineSafeArray( UnmanagedType elemType) {
+ return new UnmanagedMarshal (UnmanagedType.SafeArray, elemType);
+ }
+
+ public static UnmanagedMarshal DefineUnmanagedMarshal( UnmanagedType unmanagedType) {
+ return new UnmanagedMarshal (unmanagedType, unmanagedType);
+ }
+
+ }
+}