2 // typespec.cs: Type specification
4 // Authors: Marek Safar (marek.safar@gmail.com)
6 // Dual licensed under the terms of the MIT X11 or GNU GPL
8 // Copyright 2010 Novell, Inc
12 using System.Collections.Generic;
18 public class TypeSpec : MemberSpec
21 protected MemberCache cache;
22 protected IList<TypeSpec> ifaces;
25 Dictionary<TypeSpec[], InflatedTypeSpec> inflated_instances;
27 public static readonly TypeSpec[] EmptyTypes = new TypeSpec[0];
29 // Reflection Emit hacking
30 static Type TypeBuilder;
31 static Type GenericTypeBuilder;
35 var assembly = typeof (object).Assembly;
36 TypeBuilder = assembly.GetType ("System.Reflection.Emit.TypeBuilder");
37 GenericTypeBuilder = assembly.GetType ("System.Reflection.MonoGenericClass");
38 if (GenericTypeBuilder == null)
39 GenericTypeBuilder = assembly.GetType ("System.Reflection.Emit.TypeBuilderInstantiation");
42 public TypeSpec (MemberKind kind, TypeSpec declaringType, ITypeDefinition definition, Type info, Modifiers modifiers)
43 : base (kind, declaringType, definition, modifiers)
45 this.declaringType = declaringType;
48 if (definition != null && definition.TypeParametersCount > 0)
49 state |= StateFlags.IsGeneric;
54 public override int Arity {
56 return MemberDefinition.TypeParametersCount;
60 public virtual TypeSpec BaseType {
69 public virtual IList<TypeSpec> Interfaces {
80 return Kind == MemberKind.ArrayType;
84 public bool IsAttribute {
94 if (type == TypeManager.attribute_type)
97 type = type.base_type;
98 } while (type != null);
104 public bool IsInterface {
106 return Kind == MemberKind.Interface;
110 public bool IsClass {
112 return Kind == MemberKind.Class;
116 public bool IsConstantCompatible {
118 if ((Kind & (MemberKind.Enum | MemberKind.Class | MemberKind.Interface | MemberKind.Delegate | MemberKind.ArrayType)) != 0)
121 return TypeManager.IsPrimitiveType (this) || this == TypeManager.decimal_type || this == InternalType.Dynamic;
125 public bool IsDelegate {
127 return Kind == MemberKind.Delegate;
132 get { return Kind == MemberKind.Enum; }
135 // TODO: Should probably do
136 // IsGenericType -- recursive
137 // HasTypeParameter -- non-recursive
138 public bool IsGenericOrParentIsGeneric {
144 ts = ts.declaringType;
145 } while (ts != null);
151 public bool IsGenericParameter {
152 get { return Kind == MemberKind.TypeParameter; }
155 public bool IsNested {
156 get { return declaringType != null && Kind != MemberKind.TypeParameter; }
159 public bool IsPointer {
161 return Kind == MemberKind.PointerType;
165 public bool IsSealed {
166 get { return (Modifiers & Modifiers.SEALED) != 0; }
169 public bool IsStruct {
171 return Kind == MemberKind.Struct;
175 public bool IsTypeBuilder {
177 var meta = GetMetaInfo().GetType ();
178 return meta == TypeBuilder || meta == GenericTypeBuilder;
182 public MemberCache MemberCache {
184 if (cache == null || (state & StateFlags.PendingMemberCacheMembers) != 0)
185 InitializeMemberCache (false);
191 throw new InternalErrorException ("Membercache reset");
197 public virtual MemberCache MemberCacheTypes {
203 public new ITypeDefinition MemberDefinition {
205 return (ITypeDefinition) definition;
209 // TODO: Wouldn't be better to rely on cast to InflatedTypeSpec and
210 // remove the property, YES IT WOULD !!!
211 public virtual TypeSpec[] TypeArguments {
212 get { return TypeSpec.EmptyTypes; }
217 public bool AddInterface (TypeSpec iface)
219 if ((state & StateFlags.InterfacesExpanded) != 0)
220 throw new InternalErrorException ("Modifying expanded interface list");
222 if (ifaces == null) {
223 ifaces = new List<TypeSpec> () { iface };
227 if (!ifaces.Contains (iface)) {
235 public AttributeUsageAttribute GetAttributeUsage (PredefinedAttribute pa)
237 if (Kind != MemberKind.Class)
238 throw new InternalErrorException ();
241 return Attribute.DefaultUsageAttribute;
243 AttributeUsageAttribute aua = null;
245 while (type != null) {
246 aua = type.MemberDefinition.GetAttributeUsage (pa);
250 type = type.BaseType;
256 public virtual Type GetMetaInfo ()
261 public virtual TypeSpec GetDefinition ()
266 public override string GetSignatureForError ()
271 s = DeclaringType.GetSignatureForError ();
272 } else if (MemberDefinition is AnonymousTypeClass) {
273 return ((AnonymousTypeClass) MemberDefinition).GetSignatureForError ();
275 s = MemberDefinition.Namespace;
278 if (!string.IsNullOrEmpty (s))
281 return s + Name + GetTypeNameSignature ();
284 protected virtual string GetTypeNameSignature ()
289 return "<" + TypeManager.CSharpName (MemberDefinition.TypeParameters) + ">";
292 public bool ImplementsInterface (TypeSpec iface)
296 if (t.Interfaces != null) { // TODO: Try t.iface
297 foreach (TypeSpec i in t.Interfaces) {
298 if (i == iface || TypeSpecComparer.Variant.IsEqual (i, iface) || TypeSpecComparer.IsEqual (i, iface))
309 protected virtual void InitializeMemberCache (bool onlyTypes)
312 // Not interested in members of nested private types
315 cache = new MemberCache (0);
317 cache = MemberDefinition.LoadMembers (this);
322 // Is @baseClass base implementation of @type. With enabled @dynamicIsEqual the slower
323 // comparison is used to hide differences between `object' and `dynamic' for generic
324 // types. Should not be used for comparisons where G<object> != G<dynamic>
326 public static bool IsBaseClass (TypeSpec type, TypeSpec baseClass, bool dynamicIsObject)
328 if (dynamicIsObject && baseClass.IsGeneric) {
330 // Returns true for a hierarchies like this when passing baseClass of A<dynamic>
332 // class B : A<object> {}
334 while (type != null) {
335 type = type.BaseType;
336 if (TypeSpecComparer.IsEqual (type, baseClass))
343 while (type != null) {
344 type = type.BaseType;
345 if (type == baseClass)
352 public override MemberSpec InflateMember (TypeParameterInflator inflator)
354 var targs = IsGeneric ? MemberDefinition.TypeParameters : TypeSpec.EmptyTypes;
357 // When inflating nested type from inside the type instance will be same
358 // because type parameters are same for all nested types
360 if (DeclaringType == inflator.TypeInstance)
361 return MakeGenericType (targs);
363 return new InflatedTypeSpec (this, inflator.TypeInstance, targs);
366 public InflatedTypeSpec MakeGenericType (TypeSpec[] targs)
368 if (targs.Length == 0 && !IsNested)
369 throw new ArgumentException ("Empty type arguments");
371 InflatedTypeSpec instance;
373 if (inflated_instances == null)
374 inflated_instances = new Dictionary<TypeSpec[], InflatedTypeSpec> (TypeSpecComparer.Default);
376 if (!inflated_instances.TryGetValue (targs, out instance)) {
377 if (GetDefinition () != this && !IsNested)
378 throw new InternalErrorException ("Only type definition or nested non-inflated types can be used to call MakeGenericType");
380 instance = new InflatedTypeSpec (this, declaringType, targs);
381 inflated_instances.Add (targs, instance);
387 public virtual TypeSpec Mutate (TypeParameterMutator mutator)
392 public void SetMetaInfo (Type info)
394 if (this.info != null)
395 throw new InternalErrorException ("MetaInfo reset");
400 public void SetExtensionMethodContainer ()
402 modifiers |= Modifiers.METHOD_EXTENSION;
406 public class PredefinedTypeSpec : TypeSpec
411 public PredefinedTypeSpec (MemberKind kind, string ns, string name)
412 : base (kind, null, null, null, Modifiers.PUBLIC)
420 public override int Arity {
426 public override string Name {
432 public string Namespace {
440 public override string GetSignatureForError ()
443 case "Int32": return "int";
444 case "Int64": return "long";
445 case "String": return "string";
446 case "Boolean": return "bool";
447 case "Void": return "void";
448 case "Object": return "object";
449 case "UInt32": return "uint";
450 case "Int16": return "short";
451 case "UInt16": return "ushort";
452 case "UInt64": return "ulong";
453 case "Single": return "float";
454 case "Double": return "double";
455 case "Decimal": return "decimal";
456 case "Char": return "char";
457 case "Byte": return "byte";
458 case "SByte": return "sbyte";
461 return ns + "." + name;
464 public void SetDefinition (ITypeDefinition td, Type type)
466 this.definition = td;
470 public void SetDefinition (TypeSpec ts)
472 this.definition = ts.MemberDefinition;
473 this.info = ts.GetMetaInfo ();
474 this.BaseType = ts.BaseType;
475 this.Interfaces = ts.Interfaces;
479 static class TypeSpecComparer
482 // Does strict reference comparion only
484 public static readonly DefaultImpl Default = new DefaultImpl ();
486 public class DefaultImpl : IEqualityComparer<TypeSpec[]>
488 #region IEqualityComparer<TypeSpec[]> Members
490 bool IEqualityComparer<TypeSpec[]>.Equals (TypeSpec[] x, TypeSpec[] y)
495 if (x.Length != y.Length)
498 for (int i = 0; i < x.Length; ++i)
505 int IEqualityComparer<TypeSpec[]>.GetHashCode (TypeSpec[] obj)
508 for (int i = 0; i < obj.Length; ++i)
509 hash = (hash << 5) - hash + obj[i].GetHashCode ();
518 // When comparing type signature of overrides or overloads
519 // this version tolerates different MVARs at same position
521 public static class Override
523 public static bool IsEqual (TypeSpec a, TypeSpec b)
529 // Consider the following example:
531 // public abstract class A
533 // public abstract T Foo<T>();
536 // public class B : A
538 // public override U Foo<T>() { return default (U); }
541 // Here, `T' and `U' are method type parameters from different methods
542 // (A.Foo and B.Foo), so both `==' and Equals() will fail.
544 // However, since we're determining whether B.Foo() overrides A.Foo(),
545 // we need to do a signature based comparision and consider them equal.
548 var tp_a = a as TypeParameterSpec;
550 var tp_b = b as TypeParameterSpec;
551 return tp_b != null && tp_a.IsMethodOwned == tp_b.IsMethodOwned && tp_a.DeclaredPosition == tp_b.DeclaredPosition;
554 if (a.TypeArguments.Length != b.TypeArguments.Length)
557 if (a.TypeArguments.Length != 0) {
558 if (a.MemberDefinition != b.MemberDefinition)
561 for (int i = 0; i < a.TypeArguments.Length; ++i) {
562 if (!IsEqual (a.TypeArguments[i], b.TypeArguments[i]))
569 var ac_a = a as ArrayContainer;
571 var ac_b = b as ArrayContainer;
572 return ac_b != null && ac_a.Rank == ac_b.Rank && IsEqual (ac_a.Element, ac_b.Element);
575 if (a == InternalType.Dynamic || b == InternalType.Dynamic)
576 return b == TypeManager.object_type || a == TypeManager.object_type;
582 // Compares unordered arrays
584 public static bool IsSame (TypeSpec[] a, TypeSpec[] b)
589 if (a == null || b == null || a.Length != b.Length)
592 for (int ai = 0; ai < a.Length; ++ai) {
594 for (int bi = 0; bi < b.Length; ++bi) {
595 if (IsEqual (a[ai], b[bi])) {
608 public static bool IsEqual (AParametersCollection a, AParametersCollection b)
613 if (a.Count != b.Count)
616 for (int i = 0; i < a.Count; ++i) {
617 if (!IsEqual (a.Types[i], b.Types[i]))
620 const Parameter.Modifier ref_out = Parameter.Modifier.REF | Parameter.Modifier.OUT;
621 if ((a.FixedParameters[i].ModFlags & ref_out) != (b.FixedParameters[i].ModFlags & ref_out))
630 // Type variance equality comparison
632 public static class Variant
634 public static bool IsEqual (TypeSpec type1, TypeSpec type2)
636 if (!type1.IsGeneric || !type2.IsGeneric)
639 var target_type_def = type2.MemberDefinition;
640 if (type1.MemberDefinition != target_type_def)
643 var t1_targs = type1.TypeArguments;
644 var t2_targs = type2.TypeArguments;
645 var targs_definition = target_type_def.TypeParameters;
647 if (!type1.IsInterface && !type1.IsDelegate) {
648 return TypeSpecComparer.Equals (t1_targs, t2_targs);
651 for (int i = 0; i < targs_definition.Length; ++i) {
652 Variance v = targs_definition[i].Variance;
653 if (v == Variance.None) {
654 if (t1_targs[i] == t2_targs[i])
659 if (v == Variance.Covariant) {
660 if (!Convert.ImplicitReferenceConversionExists (new EmptyExpression (t1_targs[i]), t2_targs[i]))
662 } else if (!Convert.ImplicitReferenceConversionExists (new EmptyExpression (t2_targs[i]), t1_targs[i])) {
672 // Checks whether two generic instances may become equal for some
673 // particular instantiation (26.3.1).
675 public static class Unify
678 // Either @a or @b must be generic type
680 public static bool IsEqual (TypeSpec a, TypeSpec b)
682 if (a.MemberDefinition != b.MemberDefinition)
685 var ta = a.TypeArguments;
686 var tb = b.TypeArguments;
687 for (int i = 0; i < ta.Length; i++) {
688 if (!MayBecomeEqualGenericTypes (ta[i], tb[i]))
695 static bool ContainsTypeParameter (TypeSpec tparam, TypeSpec type)
697 TypeSpec[] targs = type.TypeArguments;
698 for (int i = 0; i < targs.Length; i++) {
699 if (tparam == targs[i])
702 if (ContainsTypeParameter (tparam, targs[i]))
710 /// Check whether `a' and `b' may become equal generic types.
711 /// The algorithm to do that is a little bit complicated.
713 static bool MayBecomeEqualGenericTypes (TypeSpec a, TypeSpec b)
715 if (a.IsGenericParameter) {
717 // If a is an array of a's type, they may never
724 // If b is a generic parameter or an actual type,
725 // they may become equal:
727 // class X<T,U> : I<T>, I<U>
728 // class X<T> : I<T>, I<float>
730 if (b.IsGenericParameter)
731 return a.DeclaringType == b.DeclaringType;
734 // We're now comparing a type parameter with a
735 // generic instance. They may become equal unless
736 // the type parameter appears anywhere in the
739 // class X<T,U> : I<T>, I<X<U>>
740 // -> error because you could instanciate it as
743 // class X<T> : I<T>, I<X<T>> -> ok
746 return !ContainsTypeParameter (a, b);
749 if (b.IsGenericParameter)
750 return MayBecomeEqualGenericTypes (b, a);
753 // At this point, neither a nor b are a type parameter.
755 // If one of them is a generic instance, compare them (if the
756 // other one is not a generic instance, they can never
759 if (TypeManager.IsGenericType (a) || TypeManager.IsGenericType (b))
760 return IsEqual (a, b);
763 // If both of them are arrays.
765 var a_ac = a as ArrayContainer;
767 var b_ac = b as ArrayContainer;
768 if (b_ac == null || a_ac.Rank != b_ac.Rank)
771 return MayBecomeEqualGenericTypes (a_ac.Element, b_ac.Element);
775 // Ok, two ordinary types.
781 public static bool Equals (TypeSpec[] x, TypeSpec[] y)
786 if (x.Length != y.Length)
789 for (int i = 0; i < x.Length; ++i)
790 if (!IsEqual (x[i], y[i]))
797 // Identity type conversion
799 // Default reference comparison, it has to be used when comparing
800 // two possible dynamic/internal types
802 public static bool IsEqual (TypeSpec a, TypeSpec b)
805 // This also rejects dynamic == dynamic
806 return a.Kind != MemberKind.InternalCompilerType;
810 // object and dynamic are considered equivalent there is an identity conversion
811 // between object and dynamic, and between constructed types that are the same
812 // when replacing all occurences of dynamic with object.
814 if (a == InternalType.Dynamic || b == InternalType.Dynamic)
815 return b == TypeManager.object_type || a == TypeManager.object_type;
817 if (a == null || !a.IsGeneric || b == null || !b.IsGeneric)
820 if (a.MemberDefinition != b.MemberDefinition)
823 return Equals (a.TypeArguments, b.TypeArguments);
827 public interface ITypeDefinition : IMemberDefinition
829 string Namespace { get; }
830 int TypeParametersCount { get; }
831 TypeParameterSpec[] TypeParameters { get; }
833 TypeSpec GetAttributeCoClass ();
834 string GetAttributeDefaultMember ();
835 AttributeUsageAttribute GetAttributeUsage (PredefinedAttribute pa);
836 MemberCache LoadMembers (TypeSpec declaringType);
839 class InternalType : TypeSpec
841 public static readonly InternalType AnonymousMethod = new InternalType ("anonymous method");
842 public static readonly InternalType Arglist = new InternalType ("__arglist");
843 public static readonly InternalType Dynamic = new InternalType ("dynamic", typeof (object));
844 public static readonly InternalType MethodGroup = new InternalType ("method group");
845 public static readonly InternalType Null = new InternalType ("null", typeof (object));
846 public static readonly InternalType FakeInternalType = new InternalType ("<fake$type>");
848 readonly string name;
850 InternalType (string name, Type metaInfo)
856 InternalType (string name)
857 : base (MemberKind.InternalCompilerType, null, null, null, Modifiers.PUBLIC)
860 cache = MemberCache.Empty;
862 // Make all internal types CLS-compliant, non-obsolete
863 state = (state & ~(StateFlags.CLSCompliant_Undetected | StateFlags.Obsolete_Undetected)) | StateFlags.CLSCompliant;
868 public override int Arity {
874 public override string Name {
882 public override string GetSignatureForError ()
888 public abstract class ElementTypeSpec : TypeSpec, ITypeDefinition
890 protected ElementTypeSpec (MemberKind kind, TypeSpec element, Type info)
891 : base (kind, element.DeclaringType, null, info, element.Modifiers)
893 this.Element = element;
895 // Has to use its own type definition instead of just element definition to
896 // correctly identify itself for cases like x.MemberDefininition == predefined.MemberDefinition
897 this.definition = this;
899 cache = MemberCache.Empty;
904 public TypeSpec Element { get; private set; }
906 public override string Name {
908 throw new NotSupportedException ();
914 public override ObsoleteAttribute GetAttributeObsolete ()
916 return Element.GetAttributeObsolete ();
919 protected virtual string GetPostfixSignature ()
924 public override string GetSignatureForError ()
926 return Element.GetSignatureForError () + GetPostfixSignature ();
929 public override TypeSpec Mutate (TypeParameterMutator mutator)
931 var me = Element.Mutate (mutator);
935 var mutated = (ElementTypeSpec) MemberwiseClone ();
936 mutated.Element = me;
941 #region ITypeDefinition Members
943 System.Reflection.Assembly IMemberDefinition.Assembly {
945 return Element.Assembly;
949 public string Namespace {
950 get { throw new NotImplementedException (); }
953 public int TypeParametersCount {
959 public TypeParameterSpec[] TypeParameters {
961 throw new NotSupportedException ();
965 public TypeSpec GetAttributeCoClass ()
967 return Element.MemberDefinition.GetAttributeCoClass ();
970 public string GetAttributeDefaultMember ()
972 return Element.MemberDefinition.GetAttributeDefaultMember ();
975 public MemberCache LoadMembers (TypeSpec declaringType)
977 return Element.MemberDefinition.LoadMembers (declaringType);
980 public bool IsImported {
982 return Element.MemberDefinition.IsImported;
986 public string[] ConditionalConditions ()
988 return Element.MemberDefinition.ConditionalConditions ();
991 bool IMemberDefinition.IsNotCLSCompliant ()
993 return Element.MemberDefinition.IsNotCLSCompliant ();
996 public void SetIsAssigned ()
998 Element.MemberDefinition.SetIsAssigned ();
1001 public void SetIsUsed ()
1003 Element.MemberDefinition.SetIsUsed ();
1009 public class ArrayContainer : ElementTypeSpec
1011 struct TypeRankPair : IEquatable<TypeRankPair>
1016 public TypeRankPair (TypeSpec ts, int rank)
1022 public override int GetHashCode ()
1024 return ts.GetHashCode () ^ rank.GetHashCode ();
1027 #region IEquatable<Tuple<T1,T2>> Members
1029 public bool Equals (TypeRankPair other)
1031 return other.ts == ts && other.rank == rank;
1038 static Dictionary<TypeRankPair, ArrayContainer> instances = new Dictionary<TypeRankPair, ArrayContainer> ();
1040 private ArrayContainer (TypeSpec element, int rank)
1041 : base (MemberKind.ArrayType, element, null)
1052 public System.Reflection.MethodInfo GetConstructor ()
1054 var mb = RootContext.ToplevelTypes.Builder;
1056 var arg_types = new Type[rank];
1057 for (int i = 0; i < rank; i++)
1058 arg_types[i] = TypeManager.int32_type.GetMetaInfo ();
1060 var ctor = mb.GetArrayMethod (
1061 GetMetaInfo (), ".ctor",
1062 System.Reflection.CallingConventions.HasThis,
1068 public System.Reflection.MethodInfo GetAddressMethod ()
1070 var mb = RootContext.ToplevelTypes.Builder;
1072 var arg_types = new Type[rank];
1073 for (int i = 0; i < rank; i++)
1074 arg_types[i] = TypeManager.int32_type.GetMetaInfo ();
1076 var address = mb.GetArrayMethod (
1077 GetMetaInfo (), "Address",
1078 System.Reflection.CallingConventions.HasThis | System.Reflection.CallingConventions.Standard,
1079 ReferenceContainer.MakeType (Element).GetMetaInfo (), arg_types);
1084 public System.Reflection.MethodInfo GetGetMethod ()
1086 var mb = RootContext.ToplevelTypes.Builder;
1088 var arg_types = new Type[rank];
1089 for (int i = 0; i < rank; i++)
1090 arg_types[i] = TypeManager.int32_type.GetMetaInfo ();
1092 var get = mb.GetArrayMethod (
1093 GetMetaInfo (), "Get",
1094 System.Reflection.CallingConventions.HasThis | System.Reflection.CallingConventions.Standard,
1095 Element.GetMetaInfo (), arg_types);
1100 public System.Reflection.MethodInfo GetSetMethod ()
1102 var mb = RootContext.ToplevelTypes.Builder;
1104 var arg_types = new Type[rank + 1];
1105 for (int i = 0; i < rank; i++)
1106 arg_types[i] = TypeManager.int32_type.GetMetaInfo ();
1108 arg_types[rank] = Element.GetMetaInfo ();
1110 var set = mb.GetArrayMethod (
1111 GetMetaInfo (), "Set",
1112 System.Reflection.CallingConventions.HasThis | System.Reflection.CallingConventions.Standard,
1113 TypeManager.void_type.GetMetaInfo (), arg_types);
1118 public override Type GetMetaInfo ()
1122 info = Element.GetMetaInfo ().MakeArrayType ();
1124 info = Element.GetMetaInfo ().MakeArrayType (rank);
1130 protected override string GetPostfixSignature()
1132 return GetPostfixSignature (rank);
1135 public static string GetPostfixSignature (int rank)
1137 StringBuilder sb = new StringBuilder ();
1139 for (int i = 1; i < rank; i++) {
1144 return sb.ToString ();
1147 public static ArrayContainer MakeType (TypeSpec element)
1149 return MakeType (element, 1);
1152 public static ArrayContainer MakeType (TypeSpec element, int rank)
1155 var key = new TypeRankPair (element, rank);
1156 if (!instances.TryGetValue (key, out ac)) {
1157 ac = new ArrayContainer (element, rank) {
1158 BaseType = TypeManager.array_type
1161 instances.Add (key, ac);
1167 public static void Reset ()
1169 instances = new Dictionary<TypeRankPair, ArrayContainer> ();
1173 class ReferenceContainer : ElementTypeSpec
1175 static Dictionary<TypeSpec, ReferenceContainer> instances = new Dictionary<TypeSpec, ReferenceContainer> ();
1177 private ReferenceContainer (TypeSpec element)
1178 : base (MemberKind.Class, element, null) // TODO: Kind.Class is most likely wrong
1182 public override Type GetMetaInfo ()
1185 info = Element.GetMetaInfo ().MakeByRefType ();
1191 public static ReferenceContainer MakeType (TypeSpec element)
1193 ReferenceContainer pc;
1194 if (!instances.TryGetValue (element, out pc)) {
1195 pc = new ReferenceContainer (element);
1196 instances.Add (element, pc);
1202 public static void Reset ()
1204 instances = new Dictionary<TypeSpec, ReferenceContainer> ();
1208 class PointerContainer : ElementTypeSpec
1210 static Dictionary<TypeSpec, PointerContainer> instances = new Dictionary<TypeSpec, PointerContainer> ();
1212 private PointerContainer (TypeSpec element)
1213 : base (MemberKind.PointerType, element, null)
1215 // It's never CLS-Compliant
1216 state &= ~StateFlags.CLSCompliant_Undetected;
1219 public override Type GetMetaInfo ()
1222 info = Element.GetMetaInfo ().MakePointerType ();
1228 protected override string GetPostfixSignature()
1233 public static PointerContainer MakeType (TypeSpec element)
1235 PointerContainer pc;
1236 if (!instances.TryGetValue (element, out pc)) {
1237 pc = new PointerContainer (element);
1238 instances.Add (element, pc);
1244 public static void Reset ()
1246 instances = new Dictionary<TypeSpec, PointerContainer> ();