[svn] r5810: nemerle/trunk/ncc: CompilationOptions.n
external/LibrariesLoader.n passes.n
nazgul
svnadmin at nemerle.org
Mon Oct 10 20:11:46 CEST 2005
Log:
Add -macros switch to just load macros without other types in library. Cleanup macro registration a little bit
Author: nazgul
Date: Mon Oct 10 20:11:22 2005
New Revision: 5810
Modified:
nemerle/trunk/ncc/CompilationOptions.n
nemerle/trunk/ncc/external/LibrariesLoader.n
nemerle/trunk/ncc/passes.n
Modified: nemerle/trunk/ncc/CompilationOptions.n
==============================================================================
--- nemerle/trunk/ncc/CompilationOptions.n (original)
+++ nemerle/trunk/ncc/CompilationOptions.n Mon Oct 10 20:11:22 2005
@@ -59,6 +59,7 @@
public mutable LinkedResources : list [string];
public mutable EmbeddedResources : list [string];
public mutable ReferencedLibraries : list [string];
+ public mutable MacrosToLoad : list [string];
public mutable Sources : list [string];
private disabled_keywords : Hashtable [string, list [NamespaceTree.Node]] = Hashtable ();
@@ -100,6 +101,7 @@
LinkedResources = [];
EmbeddedResources = [];
ReferencedLibraries = [];
+ MacrosToLoad = [];
Sources = [];
disabled_keywords.Clear ();
}
@@ -337,6 +339,12 @@
help = "Read command line options from given file",
substitute = execute_fromfile),
+ Getopt.CliOption.String (name = "-macros",
+ aliases = ["-m"],
+ help = "Load macros from given library (without loading"
+ " types from library into the scope)",
+ handler = fun (x) { Options.MacrosToLoad ::= x; }),
+
Getopt.CliOption.String (name = "-warn",
aliases = ["-W"],
help = "Specify warning level",
Modified: nemerle/trunk/ncc/external/LibrariesLoader.n
==============================================================================
--- nemerle/trunk/ncc/external/LibrariesLoader.n (original)
+++ nemerle/trunk/ncc/external/LibrariesLoader.n Mon Oct 10 20:11:22 2005
@@ -229,29 +229,21 @@
"' from assembly " + lib.FullName);
}
else {
- def macro_object = ctor.Invoke (null);
- if (macro_object == null) {
+ match (ctor.Invoke (null)) {
+ | null =>
Message.Warning ("failed to construct instance of macro `" + macro_name +
"' from assembly " + lib.FullName);
- }
- else {
- def casted_macro =
- try {
- (macro_object :> IMacro)
- } catch {
- | _ is System.InvalidCastException =>
- Message.Warning ("instance of macro `" + macro_name +
- "' from assembly " + lib.FullName +
- " does not implement IMacro interface");
- null
- };
- when (casted_macro != null) {
+ | casted_macro is IMacro =>
def ns = casted_macro.GetNamespace ();
when (namespace_nodes.Get (ns).IsNone)
_ = cache_namespace_node (ns);
MacroRegistry.register_macro (casted_macro);
- }
+
+ | _ =>
+ Message.Warning ("instance of macro `" + macro_name +
+ "' from assembly " + lib.FullName +
+ " does not implement IMacro interface");
}
}
}
Modified: nemerle/trunk/ncc/passes.n
==============================================================================
--- nemerle/trunk/ncc/passes.n (original)
+++ nemerle/trunk/ncc/passes.n Mon Oct 10 20:11:22 2005
@@ -148,6 +148,9 @@
List.Iter (List.Rev (Options.ReferencedLibraries),
LibraryReferenceManager.AddLibrary);
+ foreach (file in Options.MacrosToLoad.Reverse())
+ LibraryReferenceManager.LoadMacrosFrom (file);
+
when (! Options.PersistentLibraries || InternalType.Void == null) {
SystemType.Init ();
InternalType.InitSystemTypes ();
More information about the svn
mailing list