diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2018-03-08 16:02:52 +0100 |
---|---|---|
committer | Bernhard Schommer <bernhardschommer@gmail.com> | 2018-03-08 16:02:52 +0100 |
commit | 1c4e0ece041f87cc0c328c94270f2b23facc8b77 (patch) | |
tree | 64a4d26d1f267edb1f3dc9284e2468c32335f466 /backend | |
parent | bbf922a184764a8f79b9e45dd302879568504703 (diff) | |
download | compcert-1c4e0ece041f87cc0c328c94270f2b23facc8b77.tar.gz compcert-1c4e0ece041f87cc0c328c94270f2b23facc8b77.zip |
Print symbols as symbols.
This allows us to replacing them by their address in valex and
additionally checking them.
Bug 22438
Diffstat (limited to 'backend')
-rw-r--r-- | backend/AisAnnot.ml | 21 | ||||
-rw-r--r-- | backend/AisAnnot.mli | 9 |
2 files changed, 26 insertions, 4 deletions
diff --git a/backend/AisAnnot.ml b/backend/AisAnnot.ml index d10dc8d4..5983f417 100644 --- a/backend/AisAnnot.ml +++ b/backend/AisAnnot.ml @@ -113,7 +113,7 @@ let loc_of_txt txt = let re_ais_annot_param = Str.regexp "%%\\|%[el][0-9]+\\|%here\\|\007" -let add_ais_annot lbl preg_string sp_reg_name txt args = +let ais_annot_txt warn lbl preg_string sp_reg_name txt args = let fragment = function | Str.Delim "%here" -> [Label lbl] @@ -138,8 +138,11 @@ let add_ais_annot lbl preg_string sp_reg_name txt args = List.concat (List.map fragment (Str.full_split re_ais_annot_param txt)) with | Bad_parameter s -> - let loc = loc_of_txt txt in - warning loc Wrong_ais_parameter "wrong ais parameter %s" s; [] + if warn then begin + let loc = loc_of_txt txt in + warning loc Wrong_ais_parameter "wrong ais parameter %s" s + end; + [] in let rec merge acc = function | [] -> List.rev acc @@ -149,10 +152,20 @@ let add_ais_annot lbl preg_string sp_reg_name txt args = merge acc (String (s1 ^ s2) :: rest) | String s:: rest -> merge ((String s)::acc) rest in - let annot = merge [] annot in + merge [] annot + +let add_ais_annot lbl preg_string sp_reg_name txt args = + let annot = ais_annot_txt true lbl preg_string sp_reg_name txt args in if annot <> [] then ais_annot_list := (annot)::!ais_annot_list +let json_ais_annot preg_string sp_reg_name txt args = + let txt = ais_annot_txt false 0 preg_string sp_reg_name txt args in + let t_to_json = function + | Label _ -> String "%here" + | s -> s in + (List.map t_to_json txt) + let validate_ais_annot env loc txt args = let used_params = Array.make (List.length args) false in let fragment arg = diff --git a/backend/AisAnnot.mli b/backend/AisAnnot.mli index 59676b26..6bed2eaa 100644 --- a/backend/AisAnnot.mli +++ b/backend/AisAnnot.mli @@ -33,3 +33,12 @@ val validate_ais_annot: Env.t -> string * int -> string -> C.exp list -> unit that no volatile variables or float expressions are used as well as that no illegal format specifier is used in the [txt] *) + +val json_ais_annot: ('a -> string) -> string -> string -> 'a AST.builtin_arg list -> t list +(** [json_ais_annot lbl preg spreg txt args] prints the ais annotation [txt] were the format + specifiers are replace according to their type: + -e: general expressions + -l: l-value expressions + -here: the address of the ais annotation [lbl] + for json export. +*) |