Commit fd3c42d6 authored by Julien Lopez's avatar Julien Lopez

[DEBUG] Add typed and lambda in debug directives

parent 33a1a15d
......@@ -12,6 +12,7 @@ val empty_toplevel : env
val find : id -> env -> var_loc
val find_slot : id -> env -> int
val compile_expr : env -> Typed.texpr -> Lambda.expr * int
val compile_eval_expr : env -> Typed.texpr -> Value.t
val comp_unit:
......
......@@ -234,7 +234,15 @@ let debug ppf tenv cenv = function
with
| Exit -> Format.fprintf ppf "Non constant@."
| Not_found -> Format.fprintf ppf "Empty@.")
| `Typed e ->
Format.fprintf ppf "[DEBUG:typed]@.";
let r, _ = Typer.type_expr tenv e in
Format.fprintf ppf "%a\n" Typed.Print.pp_typed r
| `Lambda e ->
Format.fprintf ppf "[DEBUG:typed]@.";
let r, _ = Typer.type_expr tenv e in
let lambdaexpr,lsize = Compile.compile_expr Compile.empty_toplevel r in
Format.fprintf ppf "%a\n" Lambda.Print.pp_lambda lambdaexpr
let flush_ppf ppf = Format.fprintf ppf "@."
......
......@@ -26,6 +26,8 @@ and debug_directive =
| `Compile of ppat * ppat list
| `Subtype of ppat * ppat
| `Single of ppat
| `Typed of pexpr
| `Lambda of pexpr
]
and toplevel_directive =
[ `Quit
......
......@@ -216,6 +216,8 @@ EXTEND Gram
| IDENT "sample"; t = pat -> `Sample t
| IDENT "subtype"; t1 = pat; t2 = pat -> `Subtype (t1,t2)
| IDENT "single"; t = pat -> `Single t
| IDENT "typed"; e = expr -> `Typed e
| IDENT "lambda"; e = expr -> `Lambda e
]
];
......
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