//
static Tree tree;
- static public bool Optimize;
+ //
+ // This hashtable contains all of the #definitions across the source code
+ // it is used by the ConditionalAttribute handler.
+ //
+ public static Hashtable AllDefines = new Hashtable ();
//
// The list of global attributes (those that target the assembly)
// These are classes that depends on the core interfaces
//
string [] classes_second_stage = {
- "System.String", "System.Enum",
- "System.Array", "System.MulticastDelegate",
- "System.Delegate",
-
"System.Reflection.MemberInfo",
"System.Type",
+ "System.Exception",
//
// These are not really important in the order, but they
"System.Runtime.InteropServices.DllImportAttribute",
"System.Runtime.CompilerServices.MethodImplAttribute",
"System.Runtime.InteropServices.MarshalAsAttribute",
+ "System.Diagnostics.ConditionalAttribute",
+ "System.ObsoleteAttribute",
"System.ParamArrayAttribute",
"System.Security.UnverifiableCodeAttribute",
+ "System.Runtime.CompilerServices.IndexerNameAttribute",
};
+
+ // We must store them here before calling BootstrapCorlib_ResolveDelegate.
+ TypeManager.string_type = BootstrapCorlib_ResolveClass (root, "System.String");
+ TypeManager.enum_type = BootstrapCorlib_ResolveClass (root, "System.Enum");
+ TypeManager.array_type = BootstrapCorlib_ResolveClass (root, "System.Array");
+ TypeManager.multicast_delegate_type = BootstrapCorlib_ResolveClass (root, "System.MulticastDelegate");
+ TypeManager.delegate_type = BootstrapCorlib_ResolveClass (root, "System.Delegate");
foreach (string cname in classes_second_stage)
BootstrapCorlib_ResolveClass (root, cname);
{
DeclSpace ds = (DeclSpace) root.GetDefinition (name);
+ ds.DefineMembers (root);
ds.Define (root);
}
if (attribute_types != null)
foreach (TypeContainer tc in attribute_types)
- tc.Define (root);
+ tc.DefineMembers (root);
if (interface_resolve_order != null){
foreach (Interface iface in interface_resolve_order)
if ((iface.ModFlags & Modifiers.NEW) == 0)
- iface.Define (root);
+ iface.DefineMembers (root);
else
Report1530 (iface.Location);
}
if (type_container_resolve_order != null){
- foreach (TypeContainer tc in type_container_resolve_order)
+ foreach (TypeContainer tc in type_container_resolve_order) {
+ // When compiling corlib, these types have already been
+ // populated from BootCorlib_PopulateCoreTypes ().
+ if (!RootContext.StdLib &&
+ ((tc.Name == "System.Object") ||
+ (tc.Name == "System.Attribute") ||
+ (tc.Name == "System.ValueType")))
+ continue;
+
if ((tc.ModFlags & Modifiers.NEW) == 0)
- tc.Define (root);
+ tc.DefineMembers (root);
else
Report1530 (tc.Location);
+ }
}
ArrayList delegates = root.Delegates;
if (delegates != null){
foreach (Delegate d in delegates)
if ((d.ModFlags & Modifiers.NEW) == 0)
- d.Define (root);
+ d.DefineMembers (root);
else
Report1530 (d.Location);
}
if (enums != null){
foreach (Enum en in enums)
if ((en.ModFlags & Modifiers.NEW) == 0)
- en.Define (root);
+ en.DefineMembers (root);
else
Report1530 (en.Location);
}
}
+ static public void DefineTypes ()
+ {
+ TypeContainer root = Tree.Types;
+
+ if (attribute_types != null)
+ foreach (TypeContainer tc in attribute_types)
+ tc.Define (root);
+
+ if (interface_resolve_order != null){
+ foreach (Interface iface in interface_resolve_order)
+ if ((iface.ModFlags & Modifiers.NEW) == 0)
+ iface.Define (root);
+ }
+
+
+ if (type_container_resolve_order != null){
+ foreach (TypeContainer tc in type_container_resolve_order) {
+ // When compiling corlib, these types have already been
+ // populated from BootCorlib_PopulateCoreTypes ().
+ if (!RootContext.StdLib &&
+ ((tc.Name == "System.Object") ||
+ (tc.Name == "System.Attribute") ||
+ (tc.Name == "System.ValueType")))
+ continue;
+
+ if ((tc.ModFlags & Modifiers.NEW) == 0)
+ tc.Define (root);
+ }
+ }
+
+ ArrayList delegates = root.Delegates;
+ if (delegates != null){
+ foreach (Delegate d in delegates)
+ if ((d.ModFlags & Modifiers.NEW) == 0)
+ d.Define (root);
+ }
+
+ ArrayList enums = root.Enums;
+ if (enums != null){
+ foreach (Enum en in enums)
+ if ((en.ModFlags & Modifiers.NEW) == 0)
+ en.Define (root);
+ }
+ }
+
static public void EmitCode ()
{
//
Attribute.ApplyAttributes (temp_ec, ab, ab, attrs, attrs.Location);
}
}
-
+
if (attribute_types != null)
foreach (TypeContainer tc in attribute_types)
tc.Emit ();
}
if (Unsafe) {
- ConstructorInfo ci = TypeManager.unverifiable_code_type.GetConstructor (new Type [0]);
-
- if (ci == null) {
- Console.WriteLine ("Internal error !");
+ if (TypeManager.unverifiable_code_ctor == null) {
+ Console.WriteLine ("Internal error ! Cannot set unverifiable code attribute.");
return;
}
- CustomAttributeBuilder cb = new CustomAttributeBuilder (ci, new object [0]);
+ CustomAttributeBuilder cb = new CustomAttributeBuilder (TypeManager.unverifiable_code_ctor, new object [0]);
CodeGen.ModuleBuilder.SetCustomAttribute (cb);
}
}
if (impl_details_class == null)
impl_details_class = CodeGen.ModuleBuilder.DefineType (
- "<PrivateImplementationDetails>", TypeAttributes.NotPublic);
+ "<PrivateImplementationDetails>", TypeAttributes.NotPublic, TypeManager.object_type);
fb = impl_details_class.DefineInitializedData (
"$$field-" + (field_count++), data,