diff options
| author | Kathy Gray | 2014-11-12 18:17:06 +0000 |
|---|---|---|
| committer | Kathy Gray | 2014-11-12 18:17:06 +0000 |
| commit | 1a9462c3937c5d48c776adef46d9207c772e95f9 (patch) | |
| tree | e9f9396f89cad5dc23999f6ff8592bc9d18e58ef /src | |
| parent | fa1fca03d9e62d01587166506cccba7895f3a2b0 (diff) | |
Add a function to print local variables and values, local_variables_to_string
will format them as one long ; separated line
Diffstat (limited to 'src')
| -rw-r--r-- | src/lem_interp/printing_functions.ml | 23 | ||||
| -rw-r--r-- | src/lem_interp/printing_functions.mli | 4 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/lem_interp/printing_functions.ml b/src/lem_interp/printing_functions.ml index 36b3ed7e..1626c781 100644 --- a/src/lem_interp/printing_functions.ml +++ b/src/lem_interp/printing_functions.ml @@ -109,28 +109,28 @@ let reg_name_to_string = function let dependencies_to_string dependencies = String.concat ", " (List.map reg_name_to_string dependencies) -let rec val_to_string_internal = function - | Interp.V_boxref(n, t) -> sprintf "boxref %d" n +let rec val_to_string_internal ((Interp.LMem (_,memory)) as mem) = function + | Interp.V_boxref(n, t) -> val_to_string_internal mem (Pmap.find n memory) | Interp.V_lit (L_aux(l,_)) -> sprintf "%s" (lit_to_string l) | Interp.V_tuple l -> - let repr = String.concat ", " (List.map val_to_string_internal l) in + let repr = String.concat ", " (List.map (val_to_string_internal mem) l) in sprintf "(%s)" repr | Interp.V_list l -> - let repr = String.concat "; " (List.map val_to_string_internal l) in + let repr = String.concat "; " (List.map (val_to_string_internal mem) l) in sprintf "[||%s||]" repr | Interp.V_vector (first_index, inc, l) -> let last_index = add_int_big_int (if inc then List.length l - 1 else 1 - List.length l) first_index in let repr = try bitvec_to_string l with Failure _ -> - sprintf "[%s]" (String.concat "; " (List.map val_to_string_internal l)) in + sprintf "[%s]" (String.concat "; " (List.map (val_to_string_internal mem) l)) in sprintf "%s [%s..%s]" repr (string_of_big_int first_index) (string_of_big_int last_index) | Interp.V_record(_, l) -> - let pp (id, value) = sprintf "%s = %s" (id_to_string id) (val_to_string_internal value) in + let pp (id, value) = sprintf "%s = %s" (id_to_string id) (val_to_string_internal mem value) in let repr = String.concat "; " (List.map pp l) in sprintf "{%s}" repr | Interp.V_ctor (id,_, value) -> - sprintf "%s %s" (id_to_string id) (val_to_string_internal value) + sprintf "%s %s" (id_to_string id) (val_to_string_internal mem value) | Interp.V_register r -> sprintf "reg-as-value" | Interp.V_unknown -> "unknown" @@ -242,6 +242,15 @@ let instruction_state_to_string stack = let top_instruction_state_to_string stack = let (exp,(env,_)) = top_frame_exp_state stack in exp_to_string env exp +let local_variables_to_string stack = + let (_,(env,mem)) = top_frame_exp_state stack in + match env with + | LEnv(_,env) -> + List.fold_right (fun (id,value) others -> + match id with + | Id_aux(Id "0",_) -> others (*Let's not print out the context hole again*) + | _ -> id_to_string id ^ "=" ^ val_to_string_internal mem value ^ "; " ^ others) env "" + let instr_parm_to_string (name, typ, value) = name ^"="^ match (typ,value) with diff --git a/src/lem_interp/printing_functions.mli b/src/lem_interp/printing_functions.mli index 73150f93..8a0aaa7c 100644 --- a/src/lem_interp/printing_functions.mli +++ b/src/lem_interp/printing_functions.mli @@ -9,7 +9,7 @@ val loc_to_string : l -> string val get_loc : tannot exp -> string (*interp_interface.value to string*) val val_to_string : value0 -> string -val val_to_string_internal : Interp.value -> string +val val_to_string_internal : Interp.lmem -> Interp.value -> string (*Force all representations to hex strings instead of a mixture of hex and binary strings*) val val_to_hex_string : value0 -> string (* format one register *) @@ -39,6 +39,8 @@ val format_events : event list -> string val instruction_state_to_string : instruction_state -> string (*format just the top of the call stack*) val top_instruction_state_to_string : instruction_state -> string +val local_variables_to_string : instruction_state -> string + val instruction_to_string : instruction -> string |
