summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKathy Gray2014-11-21 15:46:23 +0000
committerKathy Gray2014-11-21 15:46:23 +0000
commit405fa876b603703185ea834f65ddd14808544331 (patch)
treeac3de61e2703e4e6b93eaf6435105a807984eab5 /src
parenta2ffb770435e398fd23efce9e9a1238a914bfbee (diff)
Print out default values for underspecified vectors instead of leaving them and letting them turn into undefineds
Diffstat (limited to 'src')
-rw-r--r--src/lem_interp/interp_lib.lem1
-rw-r--r--src/lem_interp/pretty_interp.ml9
-rw-r--r--src/lem_interp/printing_functions.ml2
-rw-r--r--src/pretty_print.ml9
4 files changed, 14 insertions, 7 deletions
diff --git a/src/lem_interp/interp_lib.lem b/src/lem_interp/interp_lib.lem
index 483253b6..6c6bbb46 100644
--- a/src/lem_interp/interp_lib.lem
+++ b/src/lem_interp/interp_lib.lem
@@ -142,6 +142,7 @@ let rec to_vec_inc (V_tuple[v1;v2]) = match (v1,v2) with
| (v1,V_track v2 r2) -> taint (to_vec_inc (V_tuple[v1;v2])) r2
| (V_unknown,_) -> V_unknown
| (_,V_unknown) -> V_unknown
+ | _ -> Assert_extra.failwith ("to_vec_inc parameters were " ^ (string_of_value (V_tuple[v1;v2])))
end
;;
let rec to_vec_dec (V_tuple([v1;v2])) = match (v1,v2) with
diff --git a/src/lem_interp/pretty_interp.ml b/src/lem_interp/pretty_interp.ml
index 82f7ac97..ee954766 100644
--- a/src/lem_interp/pretty_interp.ml
+++ b/src/lem_interp/pretty_interp.ml
@@ -366,10 +366,13 @@ let doc_exp, doc_let =
("0b" ^
(List.fold_right (fun (E_aux(E_lit(L_aux(l, _)),_)) rst -> match l with | L_one -> "1"^rst | L_zero -> "0"^rst) exps ""))
| _ -> default_print ()))
- | E_vector_indexed (iexps, default) ->
- (* XXX TODO print default when it is non-empty *)
+ | E_vector_indexed (iexps, (Def_val_aux(default,_))) ->
+ let default_string =
+ (match default with
+ | Def_val_empty -> string ""
+ | Def_val_dec e -> concat [semi; space; string "default"; equals; (exp env add_red e)]) in
let iexp (i,e) = doc_op equals (doc_int i) (exp env add_red e) in
- brackets (separate_map comma iexp iexps)
+ brackets (concat [(separate_map comma iexp iexps);default_string])
| E_vector_update(v,e1,e2) ->
brackets (doc_op (string "with") (exp env add_red v) (doc_op equals (atomic_exp env add_red e1) (exp env add_red e2)))
| E_vector_update_subrange(v,e1,e2,e3) ->
diff --git a/src/lem_interp/printing_functions.ml b/src/lem_interp/printing_functions.ml
index 14701633..3fb85134 100644
--- a/src/lem_interp/printing_functions.ml
+++ b/src/lem_interp/printing_functions.ml
@@ -43,7 +43,7 @@ let collapse_leading s =
let bitvec_to_string l = "0b" ^ collapse_leading (String.concat "" (List.map (function
| Interp.V_lit(L_aux(L_zero, _)) -> "0"
| Interp.V_lit(L_aux(L_one, _)) -> "1"
- | _ -> assert false) l))
+ | v -> (Printf.printf "bitvec found a non bit %s%!\n" (Interp.string_of_value v));assert false) l))
;;
(* pp the bytes of a Bytevector as a hex value *)
diff --git a/src/pretty_print.ml b/src/pretty_print.ml
index 48855e64..2eec2383 100644
--- a/src/pretty_print.ml
+++ b/src/pretty_print.ml
@@ -919,10 +919,13 @@ let doc_exp, doc_let =
("0b" ^
(List.fold_right (fun (E_aux(E_lit(L_aux(l, _)),_)) rst -> match l with | L_one -> "1"^rst | L_zero -> "0"^rst) exps ""))
| _ -> default_print ()))
- | E_vector_indexed (iexps, default) ->
- (* XXX TODO print default when it is non-empty *)
+ | E_vector_indexed (iexps, (Def_val_aux (default,_))) ->
+ let default_string =
+ (match default with
+ | Def_val_empty -> string ""
+ | Def_val_dec e -> concat [semi; space; string "default"; equals; (exp e)]) in
let iexp (i,e) = doc_op equals (doc_int i) (exp e) in
- brackets (separate_map comma iexp iexps)
+ brackets (concat [(separate_map comma iexp iexps); default_string])
| E_vector_update(v,e1,e2) ->
brackets (doc_op (string "with") (exp v) (doc_op equals (atomic_exp e1) (exp e2)))
| E_vector_update_subrange(v,e1,e2,e3) ->