+2003-06-08 Jackson Harper <jackson@latitudegeo.com>
+
+ * EventDef.cs: New file - An event definition.
+ * FeatureAttr.cs: New file - Attributes for features (events and
+ properties)
+ * MethodRef.cs: Only resolve methods once.
+ * TypeDef.cs: Allow Events to be added to types. Also add
+ functionality to add generic type parameters to types. The
+ actually emission of these type parameters is commented out untill
+ I commit my patches to PEAPI and work out the syntax of constraints.
+
2003-05-31 Jackson Harper <jackson@latitudegeo.com>
* CodeGen.cs: Allow this assembly name to be set.
--- /dev/null
+//
+// Mono.ILASM.EventDef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All right reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class EventDef {
+
+ private FeatureAttr attr;
+ private string name;
+ private ITypeRef type;
+ private PEAPI.Event event_def;
+ private bool is_resolved;
+
+ private ArrayList addon_list;
+ private ArrayList fire_list;
+ private ArrayList other_list;
+ private ArrayList removeon_list;
+
+ public EventDef (FeatureAttr attr, ITypeRef type, string name)
+ {
+ this.attr = attr;
+ this.name = name;
+ this.type = type;
+ is_resolved = false;
+ }
+
+ public PEAPI.Event Resolve (CodeGen code_gen, PEAPI.ClassDef classdef)
+ {
+ if (is_resolved)
+ return event_def;
+
+ type.Resolve (code_gen);
+ event_def = classdef.AddEvent (name, type.PeapiType);
+
+ if ((attr & FeatureAttr.Rtspecialname) != 0)
+ event_def.SetRTSpecialName ();
+
+ if ((attr & FeatureAttr.Specialname) != 0)
+ event_def.SetSpecialName ();
+
+ is_resolved = true;
+
+ return event_def;
+ }
+
+ public void Define (CodeGen code_gen, PEAPI.ClassDef classdef)
+ {
+ if (!is_resolved)
+ Resolve (code_gen, classdef);
+
+ if (addon_list != null) {
+ foreach (MethodRef methodref in addon_list) {
+ methodref.Resolve (code_gen);
+ event_def.AddAddon ((PEAPI.MethodDef) methodref.PeapiMethod);
+ }
+ }
+
+ if (fire_list != null) {
+ foreach (MethodRef methodref in fire_list) {
+ methodref.Resolve (code_gen);
+ event_def.AddFire ((PEAPI.MethodDef) methodref.PeapiMethod);
+ }
+ }
+
+ if (other_list != null) {
+ foreach (MethodRef methodref in other_list) {
+ methodref.Resolve (code_gen);
+ event_def.AddOther ((PEAPI.MethodDef) methodref.PeapiMethod);
+ }
+ }
+
+ if (removeon_list != null) {
+ foreach (MethodRef methodref in removeon_list) {
+ methodref.Resolve (code_gen);
+ event_def.AddRemoveOn ((PEAPI.MethodDef) methodref.PeapiMethod);
+ }
+ }
+ }
+
+ public void AddAddon (MethodRef method_ref)
+ {
+ if (addon_list == null)
+ addon_list = new ArrayList ();
+
+ addon_list.Add (method_ref);
+ }
+
+ public void AddFire (MethodRef method_ref)
+ {
+ if (fire_list == null)
+ fire_list = new ArrayList ();
+
+ fire_list.Add (method_ref);
+ }
+
+ public void AddOther (MethodRef method_ref)
+ {
+ if (other_list == null)
+ other_list = new ArrayList ();
+
+ other_list.Add (method_ref);
+ }
+
+ public void AddRemoveon (MethodRef method_ref)
+ {
+ if (removeon_list == null)
+ removeon_list = new ArrayList ();
+
+ removeon_list.Add (method_ref);
+ }
+
+ }
+
+}
+
--- /dev/null
+//
+// Mono.ILASM.FeatureAttr
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public enum FeatureAttr {
+ Rtspecialname,
+ Specialname
+ }
+
+}
+
private ITypeRef[] param;
private PEAPI.Method peapi_method;
+ private bool is_resolved;
public MethodRef (TypeRef owner, PEAPI.CallConv call_conv,
ITypeRef ret_type, string name, ITypeRef[] param)
this.ret_type = ret_type;
this.name = name;
this.param = param;
+ is_resolved = false;
}
public PEAPI.Method PeapiMethod {
public void Resolve (CodeGen code_gen)
{
+ if (is_resolved)
+ return;
+
TypeDef owner_def = code_gen.TypeManager[owner.FullName];
string write_name;
(PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)));
}
+ is_resolved = true;
+
}
}
private Hashtable method_table;
private ArrayList data_list;
private ArrayList customattr_list;
+ private ArrayList event_list;
+ private ArrayList typar_list;
private TypeDef outer;
+ private EventDef current_event;
+
private int size;
private int pack;
get { return classdef; }
}
+ public bool IsGenericType {
+ get { return (typar_list == null); }
+ }
+
public bool IsDefined {
get { return is_defined; }
}
+ public EventDef CurrentEvent {
+ get { return current_event; }
+ }
+
public void SetSize (int size)
{
this.size = size;
method_table.Add (methoddef.Signature, methoddef);
}
+ public void BeginEventDef (EventDef event_def)
+ {
+ if (current_event != null)
+ throw new Exception ("An event definition was not closed.");
+
+ current_event = event_def;
+ }
+
+ public void EndEventDef ()
+ {
+ if (event_list == null)
+ event_list = new ArrayList ();
+
+ event_list.Add (current_event);
+ current_event = null;
+ }
+
public void AddCustomAttribute (CustomAttr customattr)
{
if (customattr_list == null)
customattr_list.Add (customattr);
}
+ // Lamespec: Is id just for debugging? I don't see a spot for it
+ // in the metadata, unless it overrides name.
+ public void AddGenericParam (string name, string id)
+ {
+ AddGenericParam (name, id, null);
+ }
+
+ public void AddGenericParam (string name, string id, ITypeRef constraint)
+ {
+ if (typar_list == null)
+ typar_list = new ArrayList ();
+
+ typar_list.Add (new DictionaryEntry (name, constraint));
+ }
+
public void Define (CodeGen code_gen)
{
if (is_defined)
if (size != -1)
classdef.AddLayoutInfo (pack, size);
+ /*
+ ///
+ /// Commented out until I checkin PEAPI generics fixes
+ ///
+ if (typar_list != null) {
+ short index = 0;
+ foreach (DictionaryEntry typar in typar_list) {
+ if (typar.Value == null) {
+ classdef.AddGenericParameter (index++, (string) typar.Key);
+ } else {
+ ITypeRef constraint = (ITypeRef) typar.Value;
+ constraint.Resolve (code_gen);
+ classdef.AddGenericParameter (index++, (string) typar.Key,
+ constraint.PeapiType);
+ }
+ }
+ }
+ */
is_intransit = false;
is_defined = true;
methoddef.Define (code_gen, classdef);
}
+ foreach (EventDef eventdef in event_list) {
+ eventdef.Define (code_gen, classdef);
+ }
+
if (customattr_list != null) {
foreach (CustomAttr customattr in customattr_list)
customattr.AddTo (code_gen, classdef);
}
}
- public PEAPI.Method ResolveMethod (string signature, CodeGen code_gen)
+ public PEAPI.MethodDef ResolveMethod (string signature, CodeGen code_gen)
{
MethodDef methoddef = (MethodDef) method_table[signature];