//
using System;
-using System.Collections;
+using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
protected Assembly assembly;
public ModuleContainer (Assembly assembly)
- : base (null, null, MemberName.Null, null, Kind.Root)
+ : base (null, null, MemberName.Null, null, 0)
{
this.assembly = assembly;
}
- public Assembly Assembly {
+ public override Assembly Assembly {
get { return assembly; }
}
//
public class ModuleCompiled : ModuleContainer
{
- // TODO: It'd be so nice to have generics
- Hashtable anonymous_types;
+ Dictionary<int, List<AnonymousTypeClass>> anonymous_types;
readonly bool is_unsafe;
readonly CompilerContext context;
this.is_unsafe = isUnsafe;
this.context = context;
- types = new ArrayList ();
- anonymous_types = new Hashtable ();
+ types = new List<TypeContainer> ();
+ anonymous_types = new Dictionary<int, List<AnonymousTypeClass>> ();
}
public override AttributeTargets AttributeTargets {
public void AddAnonymousType (AnonymousTypeClass type)
{
- ArrayList existing = (ArrayList)anonymous_types [type.Parameters.Count];
+ List<AnonymousTypeClass> existing;
+ if (!anonymous_types.TryGetValue (type.Parameters.Count, out existing))
if (existing == null) {
- existing = new ArrayList ();
+ existing = new List<AnonymousTypeClass> ();
anonymous_types.Add (type.Parameters.Count, existing);
}
+
existing.Add (type);
}
- public void AddAttributes (ArrayList attrs)
+ public void AddAttributes (List<Attribute> attrs)
{
foreach (Attribute a in attrs)
a.AttachTo (this, CodeGen.Assembly);
return AddPartial (nextPart, nextPart.Name);
}
- public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
+ public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Type == pa.CLSCompliant) {
if (CodeGen.Assembly.ClsCompliantAttribute == null) {
}
}
- builder.SetCustomAttribute (cb);
+ builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), cdata);
}
public ModuleBuilder Builder {
OptAttributes.Emit ();
if (is_unsafe) {
- Type t = TypeManager.CoreLookupType (context, "System.Security", "UnverifiableCodeAttribute", Kind.Class, true);
+ TypeSpec t = TypeManager.CoreLookupType (context, "System.Security", "UnverifiableCodeAttribute", MemberKind.Class, true);
if (t != null) {
- ConstructorInfo unverifiable_code_ctor = TypeManager.GetPredefinedConstructor (t, Location.Null, Type.EmptyTypes);
+ var unverifiable_code_ctor = TypeManager.GetPredefinedConstructor (t, Location.Null, TypeSpec.EmptyTypes);
if (unverifiable_code_ctor != null)
- builder.SetCustomAttribute (new CustomAttributeBuilder (unverifiable_code_ctor, new object [0]));
+ builder.SetCustomAttribute (new CustomAttributeBuilder ((ConstructorInfo) unverifiable_code_ctor.GetMetaInfo (), new object[0]));
}
}
}
- public AnonymousTypeClass GetAnonymousType (ArrayList parameters)
+ public AnonymousTypeClass GetAnonymousType (IList<AnonymousTypeParameter> parameters)
{
- ArrayList candidates = (ArrayList) anonymous_types [parameters.Count];
- if (candidates == null)
+ List<AnonymousTypeClass> candidates;
+ if (!anonymous_types.TryGetValue (parameters.Count, out candidates))
return null;
int i;
return null;
}
- public override bool GetClsCompliantAttributeValue ()
- {
- return CodeGen.Assembly.IsClsCompliant;
- }
-
public bool HasDefaultCharSet {
get {
return has_default_charset;
public override bool IsClsComplianceRequired ()
{
- return true;
+ return CodeGen.Assembly.IsClsCompliant;
}
- protected override bool AddMemberType (DeclSpace ds)
+ protected override bool AddMemberType (TypeContainer ds)
{
if (!AddToContainer (ds, ds.Name))
return false;
- ds.NamespaceEntry.NS.AddDeclSpace (ds.Basename, ds);
+ ds.NamespaceEntry.NS.AddType (ds.Definition);
return true;
}
}
}
- class RootDeclSpace : DeclSpace {
+ class RootDeclSpace : TypeContainer {
public RootDeclSpace (NamespaceEntry ns)
- : base (ns, null, MemberName.Null, null)
+ : base (ns, null, MemberName.Null, null, 0)
{
PartialContainer = RootContext.ToplevelTypes;
}
get { throw new InternalErrorException ("should not be called"); }
}
- public override bool Define ()
- {
- throw new InternalErrorException ("should not be called");
- }
+ //public override bool Define ()
+ //{
+ // throw new InternalErrorException ("should not be called");
+ //}
public override TypeBuilder DefineType ()
{
throw new InternalErrorException ("should not be called");
}
- public override MemberCache MemberCache {
- get { return PartialContainer.MemberCache; }
- }
-
public override ModuleContainer Module {
get {
return PartialContainer.Module;
}
}
- public override bool GetClsCompliantAttributeValue ()
- {
- return PartialContainer.GetClsCompliantAttributeValue ();
- }
-
public override bool IsClsComplianceRequired ()
{
return PartialContainer.IsClsComplianceRequired ();