diff options
| author | Kathy Gray | 2016-07-20 16:03:40 +0100 |
|---|---|---|
| committer | Kathy Gray | 2016-07-20 16:03:54 +0100 |
| commit | 4a1e5a3df739abd747e47fb26f8a21228bd30c75 (patch) | |
| tree | bfaa2c7115ed50b4e777afd2a5f3f91e69d57d2d /src | |
| parent | 0edd0cd209e163b5cb6af3e62a83aacd63c78fa3 (diff) | |
Make rewriter understand type abbreviations for removing internal_exp instances
Diffstat (limited to 'src')
| -rw-r--r-- | src/initial_check_full_ast.ml | 19 | ||||
| -rw-r--r-- | src/pretty_print.ml | 1 | ||||
| -rw-r--r-- | src/rewriter.ml | 3 |
3 files changed, 21 insertions, 2 deletions
diff --git a/src/initial_check_full_ast.ml b/src/initial_check_full_ast.ml index 86c1dd2c..19f7cc94 100644 --- a/src/initial_check_full_ast.ml +++ b/src/initial_check_full_ast.ml @@ -61,6 +61,16 @@ let to_kind (k_env : kind Envmap.t) (K_aux(K_kind(klst),l)) : (Ast.kind * kind) | K_Typ -> K_aux(K_kind(List.map fst k_pairs), l), { k = K_Lam(args,ret) } | _ -> typ_error l "Type constructor must have an -> kind ending in Type" None None None +let rec typ_to_string (Typ_aux(t,_)) = match t with + | Typ_id i -> id_to_string i + | Typ_var (Kid_aux (Var i,_)) -> i + | _ -> "bigger than var" + +and nexp_to_string (Nexp_aux(n,_)) = match n with + | Nexp_id i -> id_to_string i + | Nexp_var (Kid_aux (Var i,_)) -> i + | _ -> "nexp bigger than var" + let rec to_typ (k_env : kind Envmap.t) (def_ord : Ast.order) (t: Ast.typ) : Ast.typ = match t with | Typ_aux(t,l) -> @@ -178,7 +188,14 @@ and to_typ_arg (k_env : kind Envmap.t) (def_ord : Ast.order) (kind : kind) (arg | K_Efct,Typ_arg_effect e -> Typ_arg_effect (to_effects k_env e) | (K_Lam _ | K_infer | K_Val),_ -> raise (Reporting_basic.err_unreachable l "To_ast_typ_arg received Lam kind or infer kind") - | _ -> typ_error l "Kind declaration and kind of type argument don't match here" None None (Some kind)), + | _ -> + let tn_str = + (match ta with + | Typ_arg_typ t -> typ_to_string t + | Typ_arg_nexp n -> nexp_to_string n + | _ -> "order or effect") in + typ_error l ("Kind declaration and kind of type argument, " ^ tn_str ^ " don't match here") + None None (Some kind)), l) let to_nexp_constraint (k_env : kind Envmap.t) (c : n_constraint) : n_constraint = diff --git a/src/pretty_print.ml b/src/pretty_print.ml index 2fbd81e2..4b1ac213 100644 --- a/src/pretty_print.ml +++ b/src/pretty_print.ml @@ -724,6 +724,7 @@ let doc_effect (BE_aux (e,_)) = | BE_eamem -> "eamem" | BE_barr -> "barr" | BE_depend -> "depend" + | BE_escape -> "escape" | BE_undef -> "undef" | BE_unspec -> "unspec" | BE_nondet -> "nondet") diff --git a/src/rewriter.ml b/src/rewriter.ml index b8e60ef9..4e147b36 100644 --- a/src/rewriter.ml +++ b/src/rewriter.ml @@ -377,7 +377,8 @@ let rewrite_exp rewriters nmap (E_aux (exp,(l,annot))) = (match t.t with (*Old case; should possibly be removed*) | Tapp("register",[TA_typ {t= Tapp("vector",[ _; TA_nexp r;_;_])}]) - | Tapp("vector", [_;TA_nexp r;_;_]) -> + | Tapp("vector", [_;TA_nexp r;_;_]) + | Tabbrev(_, {t=Tapp("vector",[_;TA_nexp r;_;_])}) -> (*let _ = Printf.eprintf "vector case with %s, bounds are %s\n" (n_to_string r) (bounds_to_string bounds) in*) let nexps = expand_nexp r in |
