public TypeInfo[] SubStructInfo;
readonly StructInfo struct_info;
- private static Dictionary<TypeSpec, TypeInfo> type_hash;
static readonly TypeInfo simple_type = new TypeInfo (1);
-
+
static TypeInfo ()
{
Reset ();
public static void Reset ()
{
- type_hash = new Dictionary<TypeSpec, TypeInfo> ();
StructInfo.field_type_hash = new Dictionary<TypeSpec, StructInfo> ();
}
return simple_type;
TypeInfo info;
- if (type_hash.TryGetValue (type, out info))
- return info;
+ Dictionary<TypeSpec, TypeInfo> type_hash;
+ if (type.BuiltinType > 0) {
+ // Don't cache built-in types, they are null in most cases except for
+ // corlib compilation when we need to distinguish between declaration
+ // and referencing
+ type_hash = null;
+ } else {
+ type_hash = context.Module.TypeInfoCache;
+ if (type_hash.TryGetValue (type, out info))
+ return info;
+ }
var struct_info = StructInfo.GetStructInfo (type, context);
if (struct_info != null) {
info = simple_type;
}
- type_hash.Add (type, info);
+ if (type_hash != null)
+ type_hash.Add (type, info);
+
return info;
}
public static StructInfo GetStructInfo (TypeSpec type, IMemberContext context)
{
- if (type.BuiltinType > 0)
+ if (type.BuiltinType > 0 && type != context.CurrentType)
return null;
StructInfo info;
readonly Dictionary<TypeSpec, ReferenceContainer> reference_types;
readonly Dictionary<TypeSpec, MethodSpec> attrs_cache;
readonly Dictionary<TypeSpec, AwaiterDefinition> awaiters;
+ readonly Dictionary<TypeSpec, TypeInfo> type_info_cache;
AssemblyDefinition assembly;
readonly CompilerContext context;
reference_types = new Dictionary<TypeSpec, ReferenceContainer> ();
attrs_cache = new Dictionary<TypeSpec, MethodSpec> ();
awaiters = new Dictionary<TypeSpec, AwaiterDefinition> ();
+ type_info_cache = new Dictionary<TypeSpec, TypeInfo> ();
}
#region Properties
}
}
+ internal Dictionary<TypeSpec, TypeInfo> TypeInfoCache {
+ get {
+ return type_info_cache;
+ }
+ }
+
public override string[] ValidAttributeTargets {
get {
return attribute_targets;
public struct UInt64 {}
public struct IntPtr {}
public struct UIntPtr {}
- public struct Decimal { }
public class String { }
public class Delegate {}
public class MulticastDelegate {}
public interface IDisposable {}
+ public struct Decimal {
+
+ private int flags;
+
+ public Decimal(int[] bits) {
+ flags = 0;
+ SetBits(bits);
+ }
+
+ public Decimal (int i)
+ {
+ flags = 0;
+ }
+
+ private void SetBits(int[] bits) {
+ }
+ }
+
partial class Type
{
public static bool operator == (Type left, Type right)
{
return true;
}
+
+ void Foo ()
+ {
+ Decimal d = 0;
+ var d2 = d;
+ }
}
}
{
public class DefaultMemberAttribute {}
}
-