OSDN Git Service

bug fix: open
authormzp <mzpppp@gmail.com>
Wed, 3 Jun 2009 22:36:34 +0000 (07:36 +0900)
committermzp <mzpppp@gmail.com>
Wed, 3 Jun 2009 22:36:34 +0000 (07:36 +0900)
scm/example/scope.scm
scm/src/filter/binding.ml
scm/src/parser/clos.ml

index 6c2b70b..021833d 100644 (file)
@@ -1,7 +1,11 @@
 ;;;  3628800
+;;;  3628800
 (module foo ()
        (define (fact n)
          (if (<= n 1)
              1
              (* n (fact (- n 1))))))
 (trace (foo.fact 10))
+
+(open foo)
+(trace (fact 10))
index 807431f..4da6af0 100644 (file)
@@ -23,8 +23,8 @@ type access = Public | Internal | Local
 type qname  = string list * string
 
 class type table = object
-  method mem_symbol : qname -> bool
-  method mem_method : string -> bool
+  method mem_symbol : qname       -> bool
+  method mem_method : string      -> bool
 end
 
 type env = {
@@ -144,7 +144,7 @@ let rec bind_stmt exports env  stmt =
                         methods   = methods'}
     | `Open { Node.value = name}->
        (* fixme *)
-       {env with opened = name::env.opened}, stmt
+       {env with opened = (env.current @ name)::env.opened}, stmt
 
 let bind table program =
   let env = {
@@ -154,5 +154,3 @@ let bind table program =
     opened  = [["std"]];
     table   = (table :> table) } in
     snd @@ map_accum_left (bind_stmt `All) env program
-
-
index 1052e23..da662f5 100644 (file)
@@ -140,7 +140,7 @@ let rec expand_class nss tbl table s =
                   attrs          = attrs;
                   methods        = Hashtbl.find_all tbl (nss,name)
                 }]
-        | `DefineMethod _ | `DefineStaticMethod _ | `Open _ ->
+        | `DefineMethod _ | `DefineStaticMethod _  ->
             []
         | #Ast.expr_stmt as s ->
             let rec lift f s =
@@ -152,6 +152,8 @@ let rec expand_class nss tbl table s =
               [lift (call_to_invoke table)
                 (`Module {m with
                             Ast.stmts = List.concat m.Ast.stmts})]
+        | `Open _ as s ->
+            [s]
     end
     nss s