Commit 37049b46 authored by POTTIER Francois's avatar POTTIER Francois

Add a use of [strip] and [number] in polymorphic mode.

parent f262b731
......@@ -32,5 +32,7 @@ expr_info_mapreduce
expr_info_mapreduce_test
expr_info_mapreduce_use
expr_info_polymorphic
expr_info_polymorphic_use
expr_info_polymorphic_use_test
expr_info_use
expr_redef
open Expr_info_polymorphic
let v = new map
let strip : _ expr -> unit expr =
let visit_'info _env _info = () in
fun e ->
v # visit_expr visit_'info () e
let number : _ expr -> int expr =
let visit_'info count _info =
let c = !count in count := c + 1; c in
fun e ->
let count = ref 0 in
v # visit_expr visit_'info count e
open Expr_info_polymorphic
open Expr_info_polymorphic_use
let strip : 'a . 'a expr -> unit expr = strip
let number : 'a . 'a expr -> int expr = number
let mk node = { info = (); node }
let const i =
mk (EConst i)
let add e1 e2 =
mk (EAdd (e1, e2))
let e =
add (const 1) (add (const 0) (const 3))
let e = number (strip e)
let () =
assert (e.info = 0);
match e.node with
| EAdd (e1, e2) ->
assert (e1.info = 1);
assert (e2.info = 2)
| _ ->
assert false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment