2 // rootcontext.cs: keeps track of our tree representation, and assemblies loaded.
4 // Author: Miguel de Icaza (miguel@ximian.com)
5 // Ravi Pratap (ravi@ximian.com)
6 // Marek Safar (marek.safar@gmail.com)
9 // Dual licensed under the terms of the MIT X11 or GNU GPL
11 // Copyright 2001 Ximian, Inc (http://www.ximian.com)
12 // Copyright 2004-2008 Novell, Inc
14 using System.Collections.Generic;
18 namespace Mono.CSharp {
20 public enum LanguageVersion
28 Default = LanguageVersion.V_4,
31 public enum RuntimeVersion
38 public enum SdkVersion
46 Library, Exe, Module, WinExe
51 AnyCPU, X86, X64, IA64
54 public class RootContext {
57 // COMPILER OPTIONS CLASS
59 public static Target Target;
60 public static Platform Platform;
61 public static string TargetExt;
62 public static bool VerifyClsCompliance;
63 public static bool Optimize;
64 public static LanguageVersion Version;
65 public static bool EnhancedWarnings;
66 public static bool LoadDefaultReferences;
67 public static SdkVersion SdkVersion;
70 // We keep strongname related info here because
71 // it's also used as complier options from CSC 8.x
73 public static string StrongNameKeyFile;
74 public static string StrongNameKeyContainer;
75 public static bool StrongNameDelaySign;
78 // Assemblies references to be loaded
80 public static List<string> AssemblyReferences;
83 // External aliases for assemblies
85 public static List<Tuple<string, string>> AssemblyReferencesAliases;
88 // Modules to be embedded
90 public static List<string> Modules;
93 // Lookup paths for referenced assemblies
95 public static List<string> ReferencesLookupPaths;
100 public static Encoding Encoding;
103 // If set, enable XML documentation generation
105 public static Documentation Documentation;
107 static public string MainClass;
112 static string output_file;
113 public static string OutputFile {
124 // The default compiler checked state
126 static public bool Checked;
129 // If true, it means that the compiler is executing as
130 // in eval mode so unresolved variables are resolved in
131 // static classes maintained by the eval engine.
133 static public bool EvalMode;
136 // If true, the compiler is operating in statement mode,
137 // this currently turns local variable declaration into
138 // static variables of a class
140 static public bool StatementMode;
143 // Whether to allow Unsafe code
145 static public bool Unsafe;
147 static public string Win32ResourceFile;
148 static public string Win32IconFile;
151 // A list of resource files for embedding
153 static public List<AssemblyResource> Resources;
155 static public bool GenerateDebugInfo;
157 // Compiler debug flags only
158 public static bool ParseOnly, TokenizeOnly;
161 // Whether we are being linked against the standard libraries.
162 // This is only used to tell whether `System.Object' should
163 // have a base class or not.
165 public static bool StdLib;
167 public static RuntimeVersion StdLibRuntimeVersion;
169 public static bool NeedsEntryPoint {
170 get { return Target == Target.Exe || Target == Target.WinExe; }
174 // COMPILER OPTIONS CLASS END
178 // Contains the parsed tree
180 static ModuleContainer root;
183 // This hashtable contains all of the #definitions across the source code
184 // it is used by the ConditionalAttribute handler.
186 static List<string> AllDefines;
191 static RootContext ()
196 public static void PartialReset ()
201 public static void Reset (bool full)
209 StrongNameKeyFile = null;
210 StrongNameKeyContainer = null;
211 StrongNameDelaySign = false;
215 SdkVersion = SdkVersion.v2;
217 Platform = Platform.AnyCPU;
218 Version = LanguageVersion.Default;
219 VerifyClsCompliance = true;
221 Encoding = Encoding.Default;
222 Documentation = null;
223 GenerateDebugInfo = false;
225 TokenizeOnly = false;
226 Win32IconFile = null;
227 Win32ResourceFile = null;
229 LoadDefaultReferences = true;
230 AssemblyReferences = new List<string> ();
231 AssemblyReferencesAliases = new List<Tuple<string, string>> ();
232 Modules = new List<string> ();
233 ReferencesLookupPaths = new List<string> ();
234 StdLibRuntimeVersion = RuntimeVersion.v2;
237 // Setup default defines
239 AllDefines = new List<string> ();
240 AddConditional ("__MonoCS__");
243 public static void AddConditional (string p)
245 if (AllDefines.Contains (p))
250 public static bool IsConditionalDefined (string value)
252 return AllDefines.Contains (value);
255 static public ModuleContainer ToplevelTypes {
257 set { root = value; }