wrap_non_exception_throws = true;
- delay_sign = RootContext.StrongNameDelaySign;
+ delay_sign = Compiler.Settings.StrongNameDelaySign;
//
// Load strong name key early enough for assembly importer to be able to
// use the keys for InternalsVisibleTo
// This should go somewhere close to ReferencesLoading but don't have the place yet
//
- if (RootContext.StrongNameKeyFile != null || RootContext.StrongNameKeyContainer != null) {
- LoadPublicKey (RootContext.StrongNameKeyFile, RootContext.StrongNameKeyContainer);
+ if (Compiler.Settings.HasKeyFileOrContainer) {
+ LoadPublicKey (Compiler.Settings.StrongNameKeyFile, Compiler.Settings.StrongNameKeyContainer);
}
}
if (value == null || value.Length == 0)
return;
- if (RootContext.Target == Target.Exe) {
+ if (Compiler.Settings.Target == Target.Exe) {
a.Error_AttributeEmitError ("The executables cannot be satelite assemblies, remove the attribute or keep it empty");
return;
}
if (value == "neutral")
value = "";
- if (RootContext.Target == Target.Module) {
+ if (Compiler.Settings.Target == Target.Module) {
SetCustomAttribute (ctor, cdata);
} else {
builder_extra.SetCulture (value, a.Location);
return;
}
- if (RootContext.Target == Target.Module) {
+ if (Compiler.Settings.Target == Target.Module) {
SetCustomAttribute (ctor, cdata);
} else {
builder_extra.SetVersion (vinfo, a.Location);
alg |= ((uint) cdata [pos + 2]) << 16;
alg |= ((uint) cdata [pos + 3]) << 24;
- if (RootContext.Target == Target.Module) {
+ if (Compiler.Settings.Target == Target.Module) {
SetCustomAttribute (ctor, cdata);
} else {
builder_extra.SetAlgorithmId (alg, a.Location);
if ((flags & (uint) AssemblyNameFlags.PublicKey) != 0 && public_key == null)
flags &= ~(uint) AssemblyNameFlags.PublicKey;
- if (RootContext.Target == Target.Module) {
+ if (Compiler.Settings.Target == Target.Module) {
SetCustomAttribute (ctor, cdata);
} else {
builder_extra.SetFlags (flags, a.Location);
{
var an = new AssemblyName (name);
- if (public_key != null && RootContext.Target != Target.Module) {
+ if (public_key != null && Compiler.Settings.Target != Target.Module) {
if (delay_sign) {
an.SetPublicKey (public_key);
} else {
public virtual void Emit ()
{
- if (RootContext.Target == Target.Module) {
+ if (Compiler.Settings.Target == Target.Module) {
module_target_attrs = new AssemblyAttributesPlaceholder (module, name);
module_target_attrs.CreateType ();
module_target_attrs.DefineType ();
ReadModulesAssemblyAttributes ();
}
- if (RootContext.GenerateDebugInfo) {
+ if (Compiler.Settings.GenerateDebugInfo) {
symbol_writer = new MonoSymbolWriter (file_name);
// TODO: global variables
// For attribute based KeyFile do additional lookup
// in output assembly path
//
- if (!key_file_exists && RootContext.StrongNameKeyFile == null) {
+ if (!key_file_exists && Compiler.Settings.StrongNameKeyFile == null) {
//
// The key file can be relative to output assembly
//
public void Resolve ()
{
- if (RootContext.Unsafe && module.PredefinedTypes.SecurityAction.Define ()) {
+ if (Compiler.Settings.Unsafe && module.PredefinedTypes.SecurityAction.Define ()) {
//
// Emits [assembly: SecurityPermissionAttribute (SecurityAction.RequestMinimum, SkipVerification = true)]
// when -unsafe option was specified
is_cls_compliant = cls_attribute.GetClsCompliantAttributeValue ();
}
- if (added_modules != null && RootContext.VerifyClsCompliance && is_cls_compliant) {
+ if (added_modules != null && Compiler.Settings.VerifyClsCompliance && is_cls_compliant) {
foreach (var m in added_modules) {
if (!m.IsCLSCompliant) {
Report.Error (3013,
case "AssemblyKeyFile":
case "AssemblyKeyFileAttribute":
case "System.Reflection.AssemblyKeyFileAttribute":
- if (RootContext.StrongNameKeyFile != null) {
+ if (Compiler.Settings.StrongNameKeyFile != null) {
Report.SymbolRelatedToPreviousError (a.Location, a.GetSignatureForError ());
Report.Warning (1616, 1, "Option `{0}' overrides attribute `{1}' given in a source file or added module",
"keyfile", "System.Reflection.AssemblyKeyFileAttribute");
case "AssemblyKeyName":
case "AssemblyKeyNameAttribute":
case "System.Reflection.AssemblyKeyNameAttribute":
- if (RootContext.StrongNameKeyContainer != null) {
+ if (Compiler.Settings.StrongNameKeyContainer != null) {
Report.SymbolRelatedToPreviousError (a.Location, a.GetSignatureForError ());
Report.Warning (1616, 1, "Option `{0}' overrides attribute `{1}' given in a source file or added module",
"keycontainer", "System.Reflection.AssemblyKeyNameAttribute");
//
// Add Win32 resources
//
- if (RootContext.Win32ResourceFile != null) {
- Builder.DefineUnmanagedResource (RootContext.Win32ResourceFile);
+ if (Compiler.Settings.Win32ResourceFile != null) {
+ Builder.DefineUnmanagedResource (Compiler.Settings.Win32ResourceFile);
} else {
Builder.DefineVersionInfoResource ();
}
- if (RootContext.Win32IconFile != null) {
- builder_extra.DefineWin32IconResource (RootContext.Win32IconFile);
+ if (Compiler.Settings.Win32IconFile != null) {
+ builder_extra.DefineWin32IconResource (Compiler.Settings.Win32IconFile);
}
- if (RootContext.Resources != null) {
- if (RootContext.Target == Target.Module) {
+ if (Compiler.Settings.Resources != null) {
+ if (Compiler.Settings.Target == Target.Module) {
Report.Error (1507, "Cannot link resource file when building a module");
} else {
int counter = 0;
- foreach (var res in RootContext.Resources) {
+ foreach (var res in Compiler.Settings.Resources) {
if (!File.Exists (res.FileName)) {
Report.Error (1566, "Error reading resource file `{0}'", res.FileName);
continue;
PortableExecutableKinds pekind;
ImageFileMachine machine;
- switch (RootContext.Platform) {
+ switch (Compiler.Settings.Platform) {
case Platform.X86:
pekind = PortableExecutableKinds.Required32Bit | PortableExecutableKinds.ILOnly;
machine = ImageFileMachine.I386;
Compiler.TimeReporter.Start (TimeReporter.TimerType.OutputSave);
try {
- if (RootContext.Target == Target.Module) {
+ if (Compiler.Settings.Target == Target.Module) {
SaveModule (pekind, machine);
} else {
Builder.Save (module.Builder.ScopeName, pekind, machine);
void SetEntryPoint ()
{
- if (!RootContext.NeedsEntryPoint) {
- if (RootContext.MainClass != null)
+ if (!Compiler.Settings.NeedsEntryPoint) {
+ if (Compiler.Settings.MainClass != null)
Report.Error (2017, "Cannot specify -main if building a module or library");
return;
PEFileKinds file_kind;
- switch (RootContext.Target) {
+ switch (Compiler.Settings.Target) {
case Target.Library:
case Target.Module:
file_kind = PEFileKinds.Dll;
}
if (entry_point == null) {
- if (RootContext.MainClass != null) {
+ if (Compiler.Settings.MainClass != null) {
// TODO: Should use MemberCache
- DeclSpace main_cont = module.GetDefinition (RootContext.MainClass) as DeclSpace;
+ DeclSpace main_cont = module.GetDefinition (Compiler.Settings.MainClass) as DeclSpace;
if (main_cont == null) {
- Report.Error (1555, "Could not find `{0}' specified for Main method", RootContext.MainClass);
+ Report.Error (1555, "Could not find `{0}' specified for Main method", Compiler.Settings.MainClass);
return;
}
if (!(main_cont is ClassOrStruct)) {
- Report.Error (1556, "`{0}' specified for Main method must be a valid class or struct", RootContext.MainClass);
+ Report.Error (1556, "`{0}' specified for Main method must be a valid class or struct", Compiler.Settings.MainClass);
return;
}
protected readonly CompilerContext compiler;
protected readonly List<string> paths;
- readonly string[] default_references;
public AssemblyReferencesLoader (CompilerContext compiler)
{
this.compiler = compiler;
- if (RootContext.LoadDefaultReferences)
- default_references = GetDefaultReferences ();
- else
- default_references = new string[0];
-
paths = new List<string> ();
- paths.AddRange (RootContext.ReferencesLookupPaths);
+ paths.AddRange (compiler.Settings.ReferencesLookupPaths);
paths.Add (Directory.GetCurrentDirectory ());
}
//
// Load mscorlib.dll as the first
//
- if (RootContext.StdLib) {
+ if (module.Compiler.Settings.StdLib) {
corlib_assembly = LoadAssemblyDefault ("mscorlib.dll");
} else {
corlib_assembly = default (T);
}
T a;
- foreach (string r in default_references) {
- a = LoadAssemblyDefault (r);
- if (a != null)
- loaded.Add (Tuple.Create (module.GlobalRootNamespace, a));
- }
-
- foreach (string r in RootContext.AssemblyReferences) {
+ foreach (string r in module.Compiler.Settings.AssemblyReferences) {
a = LoadAssemblyFile (r);
if (a == null || EqualityComparer<T>.Default.Equals (a, corlib_assembly))
continue;
loaded.Add (key);
}
- foreach (var entry in RootContext.AssemblyReferencesAliases) {
+ foreach (var entry in module.Compiler.Settings.AssemblyReferencesAliases) {
a = LoadAssemblyFile (entry.Item2);
if (a == null)
continue;
loaded.Add (key);
}
+ if (compiler.Settings.LoadDefaultReferences) {
+ foreach (string r in GetDefaultReferences ()) {
+ a = LoadAssemblyDefault (r);
+ if (a == null)
+ continue;
+
+ var key = Tuple.Create (module.GlobalRootNamespace, a);
+ if (loaded.Contains (key))
+ continue;
+
+ loaded.Add (key);
+ }
+ }
+
compiler.TimeReporter.Stop (TimeReporter.TimerType.ReferencesLoading);
}
}