- TypeLookupExpression tle = new TypeLookupExpression (name);
- Report.DisableReporting ();
- TypeExpr te = tle.ResolveAsTypeTerminal (root, false);
- Report.EnableReporting ();
- if (te == null) {
- Report.Error (518, "The predefined type `{0}' is not defined or imported", name);
- return null;
- }
-
- Type t = te.Type;
- if (!typeVerifier (t)) {
- MemberCore mc = root.GetDefinition (name);
- Location loc = Location.Null;
- if (mc != null) {
- name = mc.GetSignatureForError ();
- loc = mc.Location;
- }
-
- Report.Error (520, loc, "The predefined type `{0}' is not declared correctly", name);
- return null;
- }
-
- AttributeTester.RegisterNonObsoleteType (t);
- return t;
- }
- //
- // Resolves a single class during the corlib bootstrap process
- //
- static Type BootstrapCorlib_ResolveClass (TypeContainer root, string name)
- {
- return BootstrapCorlib_ResolveType (root, name, IsClass);
- }
-
- static bool IsClass (Type t)
- {
- DeclSpace ds = TypeManager.LookupDeclSpace (t);
- if (ds != null)
- return ds is Class;
- return t.IsClass;
- }
-
- //
- // Resolves a struct during the corlib bootstrap process
- //
- static Type BootstrapCorlib_ResolveStruct (TypeContainer root, string name)
- {
- return BootstrapCorlib_ResolveType (root, name, IsStruct);
- }
-
- static bool IsStruct (Type t)
- {
- DeclSpace ds = TypeManager.LookupDeclSpace (t);
- if (ds != null)
- return ds is Struct;
-
- return TypeManager.IsSubclassOf (t, TypeManager.value_type);
- }
-
- //
- // Resolves an interface during the corlib bootstrap process
- //
- static void BootstrapCorlib_ResolveInterface (TypeContainer root, string name)
- {
- BootstrapCorlib_ResolveType (root, name, IsInterface);
- }
-
- static bool IsInterface (Type t)
- {
- return t.IsInterface;
- }
-
- //
- // Resolves a delegate during the corlib bootstrap process
- //
- static void BootstrapCorlib_ResolveDelegate (TypeContainer root, string name)
- {
- BootstrapCorlib_ResolveType (root, name, IsDelegate);
- }
-
- static bool IsDelegate (Type t)
- {
- return TypeManager.IsDelegateType (t);
- }
-
- /// <summary>
- /// Resolves the core types in the compiler when compiling with --nostdlib
- /// </summary>
- static public void ResolveCore ()
- {
- TypeManager.object_type = BootstrapCorlib_ResolveClass (root, "System.Object");
- TypeManager.system_object_expr.Type = TypeManager.object_type;
- TypeManager.value_type = BootstrapCorlib_ResolveClass (root, "System.ValueType");
- TypeManager.system_valuetype_expr.Type = TypeManager.value_type;
-
- //
- // The core attributes
- //
- BootstrapCorlib_ResolveInterface (root, "System.Runtime.InteropServices._Attribute");
- TypeManager.attribute_type = BootstrapCorlib_ResolveClass (root, "System.Attribute");
- TypeManager.obsolete_attribute_type = BootstrapCorlib_ResolveClass (root, "System.ObsoleteAttribute");
- TypeManager.indexer_name_type = BootstrapCorlib_ResolveClass (root, "System.Runtime.CompilerServices.IndexerNameAttribute");
-
- string [] interfaces_first_stage = {
- "System.IComparable", "System.ICloneable",
- "System.IConvertible",
-
- "System.Collections.IEnumerable",
- "System.Collections.ICollection",
- "System.Collections.IEnumerator",
- "System.Collections.IList",
- "System.IAsyncResult",
- "System.IDisposable",
-
- "System.Runtime.Serialization.ISerializable",
-
- "System.Reflection.IReflect",
- "System.Reflection.ICustomAttributeProvider",
-#if GMCS_SOURCE
- "System.Runtime.InteropServices._Exception",
-
- //
- // Generic types
- //
- "System.Collections.Generic.IEnumerator`1",
- "System.Collections.Generic.IEnumerable`1"
-#endif
- };
-
- foreach (string iname in interfaces_first_stage)
- BootstrapCorlib_ResolveInterface (root, iname);