public readonly BuildinTypeSpec RuntimeTypeHandle;
public readonly BuildinTypeSpec Exception;
+ //
+ // These are internal buil-in types which depend on other
+ // build-in type (mostly object)
+ //
+ public readonly BuildinTypeSpec Dynamic;
+ public readonly BuildinTypeSpec Null;
+
readonly BuildinTypeSpec[] types;
public BuildinTypes ()
RuntimeFieldHandle = new BuildinTypeSpec (MemberKind.Struct, "System", "RuntimeFieldHandle", BuildinTypeSpec.Type.RuntimeFieldHandle);
RuntimeTypeHandle = new BuildinTypeSpec (MemberKind.Struct, "System", "RuntimeTypeHandle", BuildinTypeSpec.Type.RuntimeTypeHandle);
+ Dynamic = new BuildinTypeSpec ("dynamic", BuildinTypeSpec.Type.Dynamic);
+ Null = new BuildinTypeSpec ("null", BuildinTypeSpec.Type.Null);
+ Null.MemberCache = MemberCache.Empty;
+
types = new BuildinTypeSpec[] {
Object, ValueType, Attribute,
Int, UInt, Long, ULong, Float, Double, Char, Short, Decimal, Bool, SByte, Byte, UShort, String,
TypeManager.runtime_field_handle_type = RuntimeFieldHandle;
TypeManager.attribute_type = Attribute;
TypeManager.exception_type = Exception;
- }
- #region Properties
+ InternalType.Dynamic = Dynamic;
+ InternalType.Null = Null;
+ }
- public BuildinTypeSpec[] Types {
- get {
- return types;
+ public bool CheckDefinitions (ModuleContainer module)
+ {
+ var ctx = module.Compiler;
+ foreach (var p in types) {
+ var found = PredefinedType.Resolve (module, p.Kind, p.Namespace, p.Name, p.Arity, Location.Null);
+ if (found == null || found == p)
+ continue;
+
+ if (!RootContext.StdLib) {
+ var ns = module.GlobalRootNamespace.GetNamespace (p.Namespace, false);
+ ns.ReplaceTypeWithPredefined (found, p);
+
+ var tc = found.MemberDefinition as TypeContainer;
+ tc.SetPredefinedSpec (p);
+ p.SetDefinition (found);
+ }
}
- }
- #endregion
+ if (ctx.Report.Errors != 0)
+ return false;
+
+ // Set internal build-in types
+ Dynamic.SetDefinition (Object);
+ Null.SetDefinition (Object);
+
+ return true;
+ }
}
//
return GetPredefinedMember (t, MemberFilter.Property (name, type), false, loc) as PropertySpec;
}
- /// <remarks>
- /// The types have to be initialized after the initial
- /// population of the type has happened (for example, to
- /// bootstrap the corlib.dll
- /// </remarks>
- public static bool InitCoreTypes (ModuleContainer module, BuildinTypes buildin)
- {
- var ctx = module.Compiler;
- foreach (var p in buildin.Types) {
- var found = PredefinedType.Resolve (module, p.Kind, p.Namespace, p.Name, p.Arity, Location.Null);
- if (found == null || found == p)
- continue;
-
- if (!RootContext.StdLib) {
- var ns = module.GlobalRootNamespace.GetNamespace (p.Namespace, false);
- ns.ReplaceTypeWithPredefined (found, p);
-
- var tc = found.MemberDefinition as TypeContainer;
- tc.SetPredefinedSpec (p);
- p.SetDefinition (found);
- }
- }
-
- if (InternalType.Dynamic.GetMetaInfo () == null) {
- InternalType.Dynamic.SetMetaInfo (object_type.GetMetaInfo ());
-
- if (object_type.MemberDefinition.IsImported)
- InternalType.Dynamic.MemberCache = object_type.MemberCache;
-
- InternalType.Null.SetMetaInfo (object_type.GetMetaInfo ());
- }
-
- return ctx.Report.Errors == 0;
- }
-
public static bool IsBuiltinType (TypeSpec t)
{
if (t == object_type || t == string_type || t == int32_type || t == uint32_type ||
UIntPtr,
RuntimeFieldHandle,
RuntimeTypeHandle,
- Exception
+ Exception,
+
+ Null,
+ Dynamic
}
readonly Type type;
this.name = name;
}
+ public BuildinTypeSpec (string name, Type buildinKind)
+ : this (MemberKind.InternalCompilerType, "", name, buildinKind)
+ {
+ // Make all internal types CLS-compliant, non-obsolete
+ state = (state & ~(StateFlags.CLSCompliant_Undetected | StateFlags.Obsolete_Undetected)) | StateFlags.CLSCompliant;
+ }
+
#region Properties
public override int Arity {
case "SByte": return "sbyte";
}
+ if (ns.Length == 0)
+ return name;
+
return ns + "." + name;
}
{
public static readonly InternalType AnonymousMethod = new InternalType ("anonymous method");
public static readonly InternalType Arglist = new InternalType ("__arglist");
- public static readonly InternalType Dynamic = new InternalType ("dynamic", null);
+ public static BuildinTypeSpec Dynamic;
public static readonly InternalType MethodGroup = new InternalType ("method group");
- public static readonly InternalType Null = new InternalType ("null");
+ public static BuildinTypeSpec Null;
public static readonly InternalType FakeInternalType = new InternalType ("<fake$type>");
readonly string name;