+2003-04-17 Jackson Harper <jackson@latitudegeo.com>
+
+ * ExternTypeRef.cs: New file - Represents a reference to a type in
+ an external assembly
+ * FieldDef.cs: New file - Represents a field definition
+ * IClassRef.cs: New file - Interface that classrefs must
+ implement. This needs some more thought though because once a
+ classref has been modified it is no longer a classref.
+ * ITypeRef.cs: New file - Interface that references to types must
+ implement
+ * TypeDef.cs: New file - Represents the a class definition, and
+ will hold all of the classes members.
+
2003-04-07 Jackson Harper <jackson@latitudegeo.com>
* TypeRef.cs: Return FieldDef when adding a field def to a class
--- /dev/null
+//
+// Mono.ILASM.ExternTypeRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ /// <summary>
+ /// A reference to a type in another assembly
+ /// </summary>
+ public class ExternTypeRef : PeapiTypeRef {
+
+ public ExternTypeRef (PEAPI.ClassRef extern_type,
+ string full_name) : base (extern_type, full_name)
+ {
+
+ }
+ }
+
+}
+
--- /dev/null
+//
+// Mono.ILASM.FieldDef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+
+namespace Mono.ILASM {
+
+ public class FieldDef {
+
+ private string name;
+ private ITypeRef type;
+ private PEAPI.FieldAttr attr;
+ private PEAPI.FieldDef field_def;
+
+ private bool offset_set;
+ private bool datavalue_set;
+ private bool value_set;
+
+ private uint offset;
+
+ public FieldDef (PEAPI.FieldAttr attr, string name,
+ ITypeRef type)
+ {
+ this.attr = attr;
+ this.name = name;
+ this.type = type;
+
+ offset_set = false;
+ datavalue_set = false;
+ value_set = false;
+ }
+
+ public string Name {
+ get { return name; }
+ }
+
+ public PEAPI.FieldDef FieldDef {
+ get { return field_def; }
+ }
+
+ public void SetOffset (uint val) {
+ offset_set = true;
+ offset = val;
+ }
+
+ /// <summary>
+ /// Define a global field
+ /// </summary>
+ public void Define (CodeGen code_gen)
+ {
+ type.Resolve (code_gen);
+
+ field_def = code_gen.PEFile.AddField (attr, name, type.PeapiType);
+
+ if (offset_set) {
+ field_def.SetOffset (offset);
+
+ }
+ }
+
+ /// <summary>
+ /// Define a field member of the specified class
+ /// </summary>
+ public void Define (CodeGen code_gen, PEAPI.ClassDef class_def)
+ {
+ type.Resolve (code_gen);
+
+ class_def.AddField (attr, name, type.PeapiType);
+ }
+ }
+
+}
+
+
+
--- /dev/null
+//
+// Mono.ILASM.IClassRef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+using System;
+
+namespace Mono.ILASM {
+
+ public interface IClassRef : ITypeRef {
+
+ PEAPI.Class PeapiClass { get; }
+
+ }
+
+}
+
--- /dev/null
+//
+// Mono.ILASM.ITypeRef
+//
+// Interface that all Type references must implement
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public interface ITypeRef {
+
+ /// <summary>
+ /// The full name of the type, <namespace>.<name>
+ /// ie System.Collections.ArrayList
+ /// </summary>
+ string FullName { get; }
+
+ bool IsPinned { get; }
+
+ /// <summary>
+ /// The PEAPI.Type of this typeref, this is not guaranteed
+ /// to be correct untill after this is resolved.
+ /// </summary>
+ PEAPI.Type PeapiType { get; }
+
+ /// <summary>
+ /// Convert this typeref into a zero based array
+ /// </summary>
+ void MakeArray ();
+
+ /// <summary>
+ /// Convert this typeref into a bound array. The ArrayList
+ /// should be in the format Entry (lower_bound, upper_bound) with
+ /// null being used for unset bounds.
+ /// </summary>
+ void MakeBoundArray (ArrayList bounds);
+
+ /// <summary>
+ /// Convert this typeref into a reference
+ /// </summary>
+ void MakeManagedPointer ();
+
+ /// <summary>
+ /// Convert this typeref into an unmanaged pointer
+ /// </summary>
+ void MakeUnmanagedPointer ();
+
+ /// <summary>
+ /// Convert this typeref into a CustomModifiedType
+ /// </summary>
+ void MakeCustomModified (PEAPI.CustomModifier modifier);
+
+ /// <summary>
+ /// Make this typeref pinned.
+ /// </summary>
+ void MakePinned ();
+
+ void Resolve (CodeGen code_gen);
+
+ }
+
+}
+
--- /dev/null
+//
+// Mono.ILASM.TypeDef
+//
+// Author(s):
+// Jackson Harper (Jackson@LatitudeGeo.com)
+//
+// (C) 2003 Jackson Harper, All rights reserved
+//
+
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class TypeDef {
+
+ private PEAPI.TypeAttr attr;
+ private string name_space;
+ private string name;
+ private bool is_resolved;
+ private bool is_intransit;
+ private IClassRef parent;
+ private ArrayList impl_list;
+ private PEAPI.ClassDef classdef;
+ private ArrayList field_list;
+
+ public TypeDef (PEAPI.TypeAttr attr, string name_space, string name,
+ IClassRef parent, ArrayList impl_list, Location location)
+ {
+ this.attr = attr;
+ this.name_space = name_space;
+ this.name = name;
+ this.parent = parent;
+ this.impl_list = impl_list;
+ field_list = new ArrayList ();
+ }
+
+ public string FullName {
+ get { return MakeFullName (); }
+ }
+
+ public PEAPI.ClassDef PeapiType {
+ get { return classdef; }
+ }
+
+ public PEAPI.ClassDef ClassDef {
+ get { return classdef; }
+ }
+
+ public bool IsResolved {
+ get { return is_resolved; }
+ }
+
+ public void AddFieldDef (FieldDef fielddef)
+ {
+ field_list.Add (fielddef);
+ }
+
+ public void Define (CodeGen code_gen)
+ {
+ if (is_resolved)
+ return;
+
+ if (is_intransit) {
+ // Circular definition
+ throw new Exception ("Circular definition of class: " + this);
+ }
+
+ is_intransit = true;
+
+ if (parent != null) {
+ parent.Resolve (code_gen);
+ if (parent.PeapiClass == null) {
+ throw new Exception ("this type can not be a base type: "
+ + parent);
+ }
+ classdef = code_gen.PEFile.AddClass (attr,
+ name_space, name, parent.PeapiClass);
+ } else {
+ classdef = code_gen.PEFile.AddClass (attr,
+ name_space, name);
+ }
+
+ foreach (FieldDef fielddef in field_list) {
+ fielddef.Define (code_gen, classdef);
+ }
+
+ is_intransit = false;
+ }
+
+ private string MakeFullName ()
+ {
+ if (name_space == null || name_space == String.Empty)
+ return name;
+
+ return name_space + "." + name;
+ }
+ }
+
+}
+