OSDN Git Service

[UPDATE] (begin) return undefined
authormzp <mzpppp@gmail.com>
Mon, 3 Nov 2008 12:44:11 +0000 (21:44 +0900)
committermzp <mzpppp@gmail.com>
Mon, 3 Nov 2008 12:44:11 +0000 (21:44 +0900)
src/codegen.ml
test/runner.ml [deleted file]
test/test_codegen.ml

index 6cbf187..c2fb99a 100644 (file)
@@ -181,6 +181,7 @@ let rec generate_expr expr env =
     | String str -> [PushString str]
     | Int n when 0 <= n && n <= 0xFF -> [PushByte n]
     | Int n      -> [PushInt n]
+    | Block []   -> [PushUndefined]
     | Block xs   -> List.concat @@ interperse [Pop] @@ (List.map gen xs)
     | New ((ns,name),args) ->
        let qname =
@@ -219,11 +220,10 @@ let rec generate_expr expr env =
     | SlotSet (obj,name,value) ->
        List.concat [
          gen value;
-         [Dup];
          gen obj;
          [Swap;
-          SetProperty (Cpool.make_qname name); ]]
-
+          SetProperty (Cpool.make_qname name); 
+          PushUndefined]]
     | Ast.Call (Var name::args) when is_builtin name args ->
        let inst,_ =
          List.assoc name builtin in
diff --git a/test/runner.ml b/test/runner.ml
deleted file mode 100644 (file)
index 2ce67b9..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-(* CAUTION: this is a generated file.  If you edit it, all changes will be lost! *)
-# 1 "runner.mlp"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 1 "./runner.h" 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# 1 "<command-line>" 2
-# 1 "runner.mlp"
-# 1 "runner.h" 1
-open Test_abc
-open Test_asm
-open Test_ast
-open Test_base
-open Test_bytes
-open Test_clostrans
-open Test_closuretrans
-open Test_codegen
-open Test_cpool
-open Test_hList
-open Test_lexer
-open Test_lisp
-open Test_sexp
-open Testtbl
-open Util
-# 2 "runner.mlp" 2
-
-let _ =
-  Testtbl.run_test ()
index 817d71d..d21d625 100644 (file)
@@ -128,8 +128,9 @@ test letrec =
                 GetScopeObject 1;
                 PushByte 42;
                 SetProperty (qname "x");
+                PushByte 10;
                 PopScope])
-      (compile (LetRec (["x",Int 42],Block [])))
+      (compile (LetRec (["x",Int 42],Block [Int 10])))
 
 test letrec =
     assert_equal
@@ -141,8 +142,10 @@ test letrec =
             GetProperty (qname "x");
 
             SetProperty (qname "x");
+
+            PushByte 42;
             PopScope])
-      (compile (LetRec (["x",Var "x"],Block [])))
+      (compile (LetRec (["x",Var "x"],Block [Int 42])))
 
 test define =
     assert_equal 
@@ -218,10 +221,10 @@ test slotref =
 test slotsef =
   assert_equal
     (expr [PushByte 42; 
-          Dup;
           GetLex (make_qname "obj");
           Swap;
-          SetProperty (make_qname "x")])
+          SetProperty (make_qname "x");
+          PushUndefined])
     (generate_script @@ compile_string "(slot-set! obj x 42)")