* 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).
svn path=/trunk/mcs/; revision=2968
public void Save (string assemblyFileName)
{
- byte[] buf = new byte [65536];
+ byte[] buf = new byte [1024000];
FileStream file;
int count;
count = getDataChunk (this, 0, buf);
if (count != 0) {
file.Write (buf, 0, count);
- count = getDataChunk (this, 1, buf); /* may be a too small buffer */
- file.Write (buf, 0, count);
+ int offset = 1;
+ while ((count = getDataChunk (this, offset, buf)) != 0) {
+ file.Write (buf, 0, count);
+ offset += count;
+ }
}
file.Close ();
+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.
}
}
+ internal struct ILTokenInfo {
+ public MemberInfo member;
+ public int code_pos;
+ }
+
public class ILGenerator: Object {
private struct LabelFixup {
public int size;
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;
num_fixups = num_labels = 0;
label_to_addr = new int [16];
fixups = new LabelFixup [16];
+ token_fixups = new ILTokenInfo [16];
+ num_token_fixups = 0;
if (mb is MethodBuilder) {
abuilder = (AssemblyBuilder)((MethodBuilder)mb).TypeBuilder.Module.Assembly;
} else if (mb is ConstructorBuilder) {
}
}
+ 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;
int token = abuilder.GetToken (constructor);
make_room (6);
ll_emit (opcode);
+ if (constructor is ConstructorBuilder)
+ add_token_fixup (constructor);
emit_int (token);
}
public virtual void Emit (OpCode opcode, Double val) {
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) {
int token = abuilder.GetToken (method);
make_room (6);
ll_emit (opcode);
+ if (method is MethodBuilder)
+ add_token_fixup (method);
emit_int (token);
}
[CLSCompliant(false)]
using System;
using System.Reflection;
+using System.Collections;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
private CustomAttributeBuilder[] cattrs;
private int table_idx;
private AssemblyBuilder assemblyb;
+ Hashtable name_cache;
internal ModuleBuilder (AssemblyBuilder assb, string name, string fullyqname) {
this.name = this.scopename = name;
this.fqname = fullyqname;
this.assembly = this.assemblyb = assb;
table_idx = get_next_table_index (0x00, true);
+ name_cache = new Hashtable ();
}
public override string FullyQualifiedName {get { return fqname;}}
types = new TypeBuilder [1];
types [0] = res;
}
+ name_cache.Add (name, res);
return res;
}
private TypeBuilder search_in_array (TypeBuilder[] arr, string className, bool ignoreCase) {
int i;
+ if (arr == types && !ignoreCase)
+ return (TypeBuilder)name_cache [className];
for (i = 0; i < arr.Length; ++i) {
if (String.Compare (className, arr [i].FullName, ignoreCase) == 0) {
return arr [i];
public override Type[] GetInterfaces () {
if (interfaces != null) {
- Type [] pi;
- if (parent != null)
- pi = parent.GetInterfaces ();
- else
- pi = Type.EmptyTypes;
- Type[] ret = new Type [interfaces.Length + pi.Length];
+ Type[] ret = new Type [interfaces.Length];
interfaces.CopyTo (ret, 0);
- pi.CopyTo (ret, interfaces.Length);
return ret;
} else {
- if (parent != null)
- return parent.GetInterfaces ();
- else
- return Type.EmptyTypes;
+ return Type.EmptyTypes;
}
}