OSDN Git Service

[FIX] fix lambda for latest-tamarin assersion
authormzp <mzpppp@gmail.com>
Sun, 21 Dec 2008 01:57:21 +0000 (10:57 +0900)
committermzp <mzpppp@gmail.com>
Sun, 21 Dec 2008 01:57:21 +0000 (10:57 +0900)
Latest tamarin asserts follow code:

  (define x (lambda ()))
  (define y (lambda ()))

This is caused by initialize same method many times.

I've avoided this assertion by assignning uniq number to each method.

example/rec.scm
example/test.sh
src/codegen.ml

index a31880f..a00ddef 100644 (file)
@@ -26,7 +26,7 @@
     (f 1)))
 
 ;; check if recursion
-(letrec ([fact (lambda (n) 
+(letrec ([fact (lambda (n)
                 (if (<= n 1)
                     1
                     (* n (fact (- n 1)))))])
index 1678046..c5f49dc 100755 (executable)
@@ -3,7 +3,7 @@ for file in $@; do
     /bin/echo -n "${file}..."
     # generate expected output
     sed -n 's/;;; *//p' $file > $file.expect
-    
+
     # compile and execute
     src/habc-scm $file
     avmplus a.abc > $file.actual
@@ -21,5 +21,5 @@ for file in $@; do
        echo "ok"
     fi
 
-    rm -f $file.expect $file.actual $file.diff    
+    rm -f $file.expect $file.actual $file.diff
 done
index ea74c87..9686c6a 100644 (file)
@@ -4,6 +4,10 @@ open Asm
 open Node
 open Cpool
 
+let count = ref 0
+let uniq _ =
+  incr count;
+  !count
 
 let qname_of_stmt_name : Ast.stmt_name -> Cpool.multiname=
   function
@@ -68,7 +72,7 @@ let rec generate_expr (expr  : VarResolve.expr) =
          generate_expr body in
        let m =
          {Asm.empty_method with
-            name   = make_qname "";
+            name   = make_qname @@ string_of_int @@ uniq ();
             params = List.map (const 0) args;
             instructions = body' @ [ReturnValue] } in
          [NewFunction m]
@@ -279,7 +283,7 @@ let generate_script xs =
     {Asm.empty_method with
        name =
        make_qname "";
-       instructions =
+r       instructions =
        [ GetLocal_0; PushScope ] @ program @ [ReturnVoid]}
 
 let generate program =