public enum LanguageVersion
{
Default = 0,
- ISO_1 = 1
+ ISO_1 = 1,
+ LINQ
}
public class RootContext {
//
// Contains the parsed tree
//
- static Tree tree;
+ static RootTypes root;
//
// This hashtable contains all of the #definitions across the source code
static TypeBuilder impl_details_class;
public static int WarningLevel;
-
+
public static Target Target;
public static string TargetExt;
public static void Reset ()
{
- tree = new Tree ();
+ root = new RootTypes ();
type_container_resolve_order = new ArrayList ();
EntryPoint = null;
WarningLevel = 3;
StrongNameDelaySign = false;
MainClass = null;
Target = Target.Exe;
- TargetExt = ".exe";
+ TargetExt = ".exe";
Version = LanguageVersion.Default;
Documentation = null;
impl_details_class = null;
+ helper_classes = null;
}
-
+
public static bool NeedsEntryPoint {
- get {
- return RootContext.Target == Target.Exe || RootContext.Target == Target.WinExe;
- }
+ get { return RootContext.Target == Target.Exe || RootContext.Target == Target.WinExe; }
}
- static public Tree Tree {
- get {
- return tree;
- }
+ static public RootTypes ToplevelTypes {
+ get { return root; }
}
public static void RegisterOrder (TypeContainer tc)
// a set of interfaces, we need to be able to tell
// them appart by just using the TypeManager.
//
- TypeContainer root = Tree.Types;
-
ArrayList ifaces = root.Interfaces;
if (ifaces != null){
foreach (TypeContainer i in ifaces)
//
// Resolves a single class during the corlib bootstrap process
//
- static TypeBuilder BootstrapCorlib_ResolveClass (TypeContainer root, string name)
+ static Type BootstrapCorlib_ResolveClass (TypeContainer root, string name)
{
object o = root.GetDefinition (name);
if (o == null){
- Report.Error (518, "The predefined type `" + name + "' is not defined");
+ Report.Error (518, "The predefined type `" + name + "' is not defined or imported");
return null;
}
return null;
}
- return ((DeclSpace) o).DefineType ();
+ Type t = ((DeclSpace) o).DefineType ();
+ if (t != null)
+ AttributeTester.RegisterNonObsoleteType (t);
+ return t;
}
//
{
object o = root.GetDefinition (name);
if (o == null){
- Report.Error (518, "The predefined type `" + name + "' is not defined");
+ Report.Error (518, "The predefined type `" + name + "' is not defined or imported");
return;
}
{
object o = root.GetDefinition (name);
if (o == null){
- Report.Error (518, "The predefined type `" + name + "' is not defined");
+ Report.Error (518, "The predefined type `" + name + "' is not defined or imported");
return;
}
return;
}
- ((DeclSpace) o).DefineType ();
+ Type t = ((DeclSpace) o).DefineType ();
+ if (t != null)
+ AttributeTester.RegisterNonObsoleteType (t);
}
//
{
object o = root.GetDefinition (name);
if (o == null){
- Report.Error (518, "The predefined type `" + name + "' is not defined");
+ Report.Error (518, "The predefined type `" + name + "' is not defined or imported");
return;
}
/// </summary>
static public void ResolveCore ()
{
- TypeContainer root = Tree.Types;
-
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.Runtime.Serialization.ISerializable",
"System.Reflection.IReflect",
- "System.Reflection.ICustomAttributeProvider"
+ "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)
"System.Reflection.MemberInfo",
"System.Type",
"System.Exception",
+#if GMCS_SOURCE
+ "System.Activator",
+#endif
//
// These are not really important in the order, but they
"System.Runtime.CompilerServices.RuntimeHelpers",
"System.Reflection.DefaultMemberAttribute",
"System.Threading.Monitor",
+ "System.Threading.Interlocked",
"System.AttributeUsageAttribute",
"System.Runtime.InteropServices.DllImportAttribute",
"System.Runtime.CompilerServices.MethodImplAttribute",
"System.Runtime.InteropServices.MarshalAsAttribute",
+#if GMCS_SOURCE
+ "System.Runtime.CompilerServices.CompilerGeneratedAttribute",
+ "System.Runtime.CompilerServices.FixedBufferAttribute",
+#endif
"System.Diagnostics.ConditionalAttribute",
- "System.ObsoleteAttribute",
"System.ParamArrayAttribute",
"System.CLSCompliantAttribute",
"System.Security.UnverifiableCodeAttribute",
"System.Runtime.InteropServices.OutAttribute",
"System.Runtime.InteropServices.StructLayoutAttribute",
"System.Runtime.InteropServices.FieldOffsetAttribute",
+#if GMCS_SOURCE
+ "System.Runtime.InteropServices.DefaultCharSetAttribute",
+#endif
"System.InvalidOperationException",
"System.NotSupportedException",
"System.MarshalByRefObject",
"System.Security.CodeAccessPermission",
"System.Runtime.CompilerServices.RequiredAttributeAttribute",
- "System.Runtime.InteropServices.GuidAttribute"
+ "System.Runtime.InteropServices.GuidAttribute",
+ "System.Reflection.AssemblyCultureAttribute"
};
foreach (string cname in classes_second_stage)
BootstrapCorlib_ResolveClass (root, cname);
-
+#if GMCS_SOURCE
+ BootstrapCorlib_ResolveStruct (root, "System.Nullable`1");
+#endif
BootstrapCorlib_ResolveDelegate (root, "System.AsyncCallback");
// These will be defined indirectly during the previous ResolveDelegate.
// </remarks>
static public void CloseTypes ()
{
- TypeContainer root = Tree.Types;
-
if (root.Enums != null)
foreach (Enum en in root.Enums)
en.CloseType ();
// make sure that we define the structs in order as well.
//
foreach (TypeContainer tc in type_container_resolve_order){
- if (tc.Kind == Kind.Struct && tc.Parent == tree.Types){
+ if (tc.Kind == Kind.Struct && tc.Parent == root){
tc.CloseType ();
}
}
foreach (TypeContainer tc in type_container_resolve_order){
- if (!(tc.Kind == Kind.Struct && tc.Parent == tree.Types))
+ if (!(tc.Kind == Kind.Struct && tc.Parent == root))
tc.CloseType ();
}
//
if (helper_classes != null){
foreach (TypeBuilder type_builder in helper_classes) {
-#if NET_2_0
+#if GMCS_SOURCE
type_builder.SetCustomAttribute (TypeManager.compiler_generated_attr);
#endif
type_builder.CreateType ();
type_container_resolve_order = null;
helper_classes = null;
- //tree = null;
+ //root = null;
TypeManager.CleanUp ();
}
helper_classes.Add (helper_class);
}
- static void Report1530 (Location loc)
- {
- Report.Error (1530, loc, "Keyword new not allowed for namespace elements");
- }
-
static public void PopulateCoreType (TypeContainer root, string name)
{
DeclSpace ds = (DeclSpace) root.GetDefinition (name);
- ds.DefineMembers (root);
+ ds.DefineMembers ();
ds.Define ();
}
static public void BootCorlib_PopulateCoreTypes ()
{
- TypeContainer root = tree.Types;
-
PopulateCoreType (root, "System.Object");
PopulateCoreType (root, "System.ValueType");
PopulateCoreType (root, "System.Attribute");
// have been defined through `ResolveTree'
static public void PopulateTypes ()
{
- TypeContainer root = Tree.Types;
if (type_container_resolve_order != null){
- if (RootContext.StdLib){
- foreach (TypeContainer tc in type_container_resolve_order)
- tc.DefineMembers (root);
- } else {
- foreach (TypeContainer tc in type_container_resolve_order) {
- // When compiling corlib, these types have already been
- // populated from BootCorlib_PopulateCoreTypes ().
- if (((tc.Name == "System.Object") ||
- (tc.Name == "System.Attribute") ||
- (tc.Name == "System.ValueType") ||
- (tc.Name == "System.Runtime.CompilerServices.IndexerNameAttribute")))
- continue;
-
- tc.DefineMembers (root);
- }
- }
+#if GMCS_SOURCE
+ foreach (TypeContainer tc in type_container_resolve_order)
+ tc.ResolveType ();
+#endif
+ foreach (TypeContainer tc in type_container_resolve_order)
+ tc.DefineMembers ();
}
ArrayList delegates = root.Delegates;
if (delegates != null){
foreach (Delegate d in delegates)
- if ((d.ModFlags & Modifiers.NEW) == 0)
- d.DefineMembers (root);
- else
- Report1530 (d.Location);
+ d.DefineMembers ();
}
ArrayList enums = root.Enums;
if (enums != null){
foreach (Enum en in enums)
- if ((en.ModFlags & Modifiers.NEW) == 0)
- en.DefineMembers (root);
- else
- Report1530 (en.Location);
+ en.DefineMembers ();
}
//
//
static public void DefineTypes ()
{
- TypeContainer root = Tree.Types;
-
ArrayList delegates = root.Delegates;
if (delegates != null){
foreach (Delegate d in delegates)
- if ((d.ModFlags & Modifiers.NEW) == 0)
- d.Define ();
+ d.Define ();
}
if (type_container_resolve_order != null){
(tc.Name == "System.Runtime.CompilerServices.IndexerNameAttribute")))
continue;
- if ((tc.ModFlags & Modifiers.NEW) == 0)
- tc.Define ();
+ tc.Define ();
}
}
ArrayList enums = root.Enums;
if (enums != null){
foreach (Enum en in enums)
- if ((en.ModFlags & Modifiers.NEW) == 0)
- en.Define ();
+ en.Define ();
}
}
static public void EmitCode ()
{
- if (Tree.Types.Enums != null) {
- foreach (Enum e in Tree.Types.Enums)
+ if (root.Enums != null) {
+ foreach (Enum e in root.Enums)
e.Emit ();
}
tc.VerifyMembers ();
}
- if (Tree.Types.Delegates != null) {
- foreach (Delegate d in Tree.Types.Delegates)
+ if (root.Delegates != null) {
+ foreach (Delegate d in root.Delegates)
d.Emit ();
}
//
if (EmitCodeHook != null)
EmitCodeHook ();
- CodeGen.Assembly.Emit (Tree.Types);
- CodeGen.Module.Emit (Tree.Types);
+ CodeGen.Assembly.Emit (root);
+ CodeGen.Module.Emit (root);
}
//
return fb;
}
+
+ public static void CheckUnsafeOption (Location loc)
+ {
+ if (!Unsafe) {
+ Report.Error (227, loc,
+ "Unsafe code requires the `unsafe' command line option to be specified");
+ }
+ }
}
}