//------------------------------------------------------------------
public ArrayList AddedModules = new ArrayList();
- [Option("[NOT IMPLEMENTED YET]References metadata from specified {module}", "addmodule")]
+ [Option("References metadata from specified {module}", "addmodule")]
public string AddedModule { set { AddedModules.Add(value); } }
[Option("[NOT IMPLEMENTED YET]Include all files in the current directory and subdirectories according to the {wildcard}", "recurse")]
return 0;
}
+ public void LoadModule (MethodInfo adder_method, string module)
+ {
+ System.Reflection.Module m;
+ string total_log = "";
+
+ try {
+ try {
+ m = (System.Reflection.Module)adder_method.Invoke (CodeGen.AssemblyBuilder, new object [] { module });
+ }
+ catch (TargetInvocationException ex) {
+ throw ex.InnerException;
+ }
+ TypeManager.AddModule (m);
+
+ }
+ catch (FileNotFoundException) {
+ foreach (string dir in libpath) {
+ string full_path = Path.Combine (dir, module);
+ if (!module.EndsWith (".netmodule"))
+ full_path += ".netmodule";
+
+ try {
+ try {
+ m = (System.Reflection.Module) adder_method.Invoke (CodeGen.AssemblyBuilder, new object [] { full_path });
+ }
+ catch (TargetInvocationException ex) {
+ throw ex.InnerException;
+ }
+ TypeManager.AddModule (m);
+ return;
+ }
+ catch (FileNotFoundException ff) {
+ total_log += ff.FusionLog;
+ continue;
+ }
+ }
+ Report.Error (6, "Cannot find module `" + module + "'" );
+ Console.WriteLine ("Log: \n" + total_log);
+ }
+ catch (BadImageFormatException f) {
+ Report.Error(6, "Cannot load module (bad file format)" + f.FusionLog);
+ }
+ catch (FileLoadException f) {
+ Report.Error(6, "Cannot load module " + f.FusionLog);
+ }
+ catch (ArgumentNullException) {
+ Report.Error(6, "Cannot load module (null argument)");
+ }
+ }
+
void Error(string message)
{
Console.WriteLine(message);
bool ParseAll() // Phase 1
{
- if (first_source == null)
- {
+ if (first_source == null) {
Report.Error(2008, "No files to compile were specified");
return false;
}
TypeManager.AddModule (CodeGen.ModuleBuilder);
}
-
+ if (AddedModules.Count > 0) {
+ MethodInfo adder_method = typeof (AssemblyBuilder).GetMethod ("AddModule", BindingFlags.Instance|BindingFlags.NonPublic);
+ if (adder_method == null) {
+ Report.Error (0, new Location (-1, -1), "Cannot use /addmodule on this runtime: Try the Mono runtime instead.");
+ Environment.Exit (1);
+ }
+
+ foreach (string module in AddedModules)
+ LoadModule (adder_method, module);
+ }
+
//
// Before emitting, we need to get the core
// Keeps a list of module builders. We used this to do lookups
// on the modulebuilder using GetType -- needed for arrays
// </remarks>
- static ModuleBuilder [] modules;
+
+ // This is changed from list of ModuleBuilders
+ // to list of Modules for getting addmodule
+ // compiler option working
+ // Anirban - 13.07.2004
+
+ static System.Reflection.Module [] modules;
// <remarks>
// This is the type_cache from the assemblies to avoid
/// <summary>
/// Registers a module builder to lookup types from
/// </summary>
- public static void AddModule (ModuleBuilder mb)
+ public static void AddModule (System.Reflection.Module mb)
{
int top = modules != null ? modules.Length : 0;
- ModuleBuilder [] n = new ModuleBuilder [top + 1];
+ System.Reflection.Module [] n = new System.Reflection.Module [top + 1];
if (modules != null)
modules.CopyTo (n, 0);
modules = n;
}
-
private class StandardModule {
public readonly string Namespace;
public readonly string Name;
return t;
}
- foreach (ModuleBuilder mb in modules) {
+ foreach (System.Reflection.Module mb in modules) {
t = mb.GetType (name, false, true);
if (t != null){
return t;
}
}
- foreach (ModuleBuilder mb in modules) {
+ foreach (System.Reflection.Module mb in modules) {
foreach (Type t in mb.GetTypes ()) {
string ns = t.Namespace;