[svn] r5872: nemerle/trunk: Makefile tools/nemerlish/Makefile tools/nemerlish/eval.n tools/nemerlish/tests...

nazgul svnadmin at nemerle.org
Wed Nov 2 19:45:47 CET 2005


Log:
Some more fixes. Add testcase for evaluation

Author: nazgul
Date: Wed Nov  2 19:45:20 2005
New Revision: 5872

Added:
   nemerle/trunk/tools/nemerlish/tests/
   nemerle/trunk/tools/nemerlish/tests/Makefile   (contents, props changed)
   nemerle/trunk/tools/nemerlish/tests/eval.n   (contents, props changed)
Modified:
   nemerle/trunk/Makefile
   nemerle/trunk/tools/nemerlish/Makefile
   nemerle/trunk/tools/nemerlish/eval.n

Modified: nemerle/trunk/Makefile
==============================================================================
--- nemerle/trunk/Makefile	(original)
+++ nemerle/trunk/Makefile	Wed Nov  2 19:45:20 2005
@@ -148,6 +148,7 @@
 	$(Q)$(MAKE) -C snippets clean
 	$(Q)$(MAKE) -C snippets all
 	$(Q)$(MAKE) -C lib/tests all
+	$(Q)$(MAKE) -C tools/nemerlish check
 	$(Q)$(MAKE) -C ncc/testsuite/frommcs all
 	$(Q)$(MAKE) -C ncc/testsuite/ clean
 

Modified: nemerle/trunk/tools/nemerlish/Makefile
==============================================================================
--- nemerle/trunk/tools/nemerlish/Makefile	(original)
+++ nemerle/trunk/tools/nemerlish/Makefile	Wed Nov  2 19:45:20 2005
@@ -16,12 +16,15 @@
 
 all:	Nemerle.Evaluation.dll nemish.exe
 
-Nemerle.Evaluation.dll: eval.n
+Nemerle.Evaluation.dll: eval.n $(NCC_DIR)/Nemerle.dll $(NCC_DIR)/Nemerle.Compiler.dll $(NCC_DIR)/Nemerle.Macros.dll 
 	$(NCC) -r Nemerle.Compiler.dll -t library -o Nemerle.Evaluation.dll eval.n
 
-nemish.exe: $(NEMISH_SRC)
+nemish.exe: $(NEMISH_SRC) Nemerle.Evaluation.dll
 	$(NCC) -r Nemerle.Evaluation.dll -o nemish.exe $(NEMISH_SRC)
 
+check: all
+	$(MAKE) -C tests all
+
 withdoc: withdoc-dll withdoc-exe
 
 withdoc-dll: eval.n

Modified: nemerle/trunk/tools/nemerlish/eval.n
==============================================================================
--- nemerle/trunk/tools/nemerlish/eval.n	(original)
+++ nemerle/trunk/tools/nemerlish/eval.n	Wed Nov  2 19:45:20 2005
@@ -44,9 +44,13 @@
     public static mutable vals : list [object] = [];
 
     public this () {
+      this (true);
+    }
+    
+    public this (persistent_mode : bool) {
       Message.InitOutput (System.Console.Out);         
 
-      Options.PersistentLibraries = true;
+      Options.PersistentLibraries = persistent_mode;
       Options.CompileToMemory = true;
       Options.IgnoreConfusion = true;
       Options.ProgressBar = false;
@@ -55,9 +59,19 @@
       Passes.ParsingPipeline = fun (_) { [null] };
       Passes.ScanningPipeline = DoTheStuff;
 
+      when (persistent_mode)
       MacroRegistry.register_macro (StagedMacro ());
     }
     
+    public static EvaluateExpression ([Nemerle.Assertions.NotNull] code : string) : object 
+    {
+      def eval = Evaluator (false);
+      match (eval.Eval (code)) {
+        | [] => null
+        | returned => returned.Last [3];
+      }
+    }
+    
     /**
      * Evaluates supplied code in memory and returns computation results.
      * Persistent computation history is maintained between subsequent calls.
@@ -83,6 +97,7 @@
       Evaluator.code = code;
 
       Passes.LexingPipeline = fun (_) { null };
+
 //    Options.DumpTypedTree = true;
 //    Options.AdditionalDebug = true;
       
@@ -224,7 +239,11 @@
       completionList
     }
   
-    internal static DoTheStuff (_tdecl : Parsetree.TopDeclaration) : void {
+    internal static DoTheStuff (_tdecl : Parsetree.TopDeclaration) : void 
+    {
+      unless (Options.PersistentLibraries)
+        MacroRegistry.register_macro (StagedMacro ());
+    
       def n = (None (), ["Nemerle", "Core"]) :: 
               (None (), ["Nemerle", "Core", "option"]) :: Evaluator.ns;
       // Open namespaces and set aliases.

Added: nemerle/trunk/tools/nemerlish/tests/Makefile
==============================================================================
--- (empty file)
+++ nemerle/trunk/tools/nemerlish/tests/Makefile	Wed Nov  2 19:45:20 2005
@@ -0,0 +1,21 @@
+
+TOPDIR = ../../..
+
+############################################################
+# VARIABLES
+############################################################
+
+EXECUTE = $(NET_ENGINE) $(NET_FLAGS)
+THISDIR = $(shell if cygpath --help 2>/dev/null 1>&2; then echo `cygpath -m $(CURDIR)`; else echo $(CURDIR); fi)
+
+
+############################################################
+# TARGETS
+############################################################
+
+all: 
+	cp ../Nemerle.Evaluation.dll $(TOPDIR)/ncc/testsuite/
+	$(Q)$(MAKE) TEST_FILES=$(THISDIR)/*.n -C $(TOPDIR)/ncc/testsuite/ test
+
+clean:
+	rm -f *.exe *.il *.dll 

Added: nemerle/trunk/tools/nemerlish/tests/eval.n
==============================================================================
--- (empty file)
+++ nemerle/trunk/tools/nemerlish/tests/eval.n	Wed Nov  2 19:45:20 2005
@@ -0,0 +1,18 @@
+// REFERENCE: ../../tools/nemerlish/Nemerle.Evaluation.dll
+
+using Nemerle.Evaluation;
+
+def x = "2";
+def y = "2";
+def eval = Evaluator (false);
+def (_, _, _, result, _) = eval.Eval (x + " + " + y).Last;
+System.Console.WriteLine (result);
+
+System.Console.WriteLine (Evaluator.EvaluateExpression ("def x = 2; x + 4"));
+
+/*
+BEGIN-OUTPUT
+4
+6
+END-OUTPUT
+*/
\ No newline at end of file



More information about the svn mailing list