Skip to content
Snippets Groups Projects
Commit 13a4a4da authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[printer] fix pp-print-head api

parent 872c513d
No related branches found
No related tags found
No related merge requests found
...@@ -1442,15 +1442,15 @@ class cil_printer () = object (self) ...@@ -1442,15 +1442,15 @@ class cil_printer () = object (self)
directive (fst l).Filepath.pos_lnum filename directive (fst l).Filepath.pos_lnum filename
(* Print a recovered while condition from Loop *) (* Print a recovered while condition from Loop *)
method pp_while fmt cond = method pp_while_head fmt cond =
fprintf fmt "%a (%a)" fprintf fmt "%a (%a)"
self#pp_keyword "while" self#pp_keyword "while"
self#exp cond self#exp cond
method private stacked_while ~stmt ~cond fmt = method private pp_while_head_stacked ~stmt ~cond fmt =
begin begin
Stack.push stmt current_stmt; Stack.push stmt current_stmt;
self#pp_while fmt cond; self#pp_while_head fmt cond;
ignore (Stack.pop current_stmt); ignore (Stack.pop current_stmt);
end end
...@@ -1642,7 +1642,7 @@ class cil_printer () = object (self) ...@@ -1642,7 +1642,7 @@ class cil_printer () = object (self)
in in
Format.fprintf fmt "%a@[<v 2>%t %t%a@]" Format.fprintf fmt "%a@[<v 2>%t %t%a@]"
(fun fmt -> self#line_directive fmt) l (fun fmt -> self#line_directive fmt) l
(self#stacked_while ~stmt ~cond) (self#pp_while_head_stacked ~stmt ~cond)
pp_sattr pp_sattr
(self#unboxed_block Other) b; (self#unboxed_block Other) b;
with Not_found -> with Not_found ->
......
...@@ -312,11 +312,11 @@ class type extensible_printer_type = object ...@@ -312,11 +312,11 @@ class type extensible_printer_type = object
(** {3 Modifying pretty-printer behavior} *) (** {3 Modifying pretty-printer behavior} *)
(* ******************************************************************* *) (* ******************************************************************* *)
method pp_while: Format.formatter -> exp -> unit method pp_while_head: Format.formatter -> exp -> unit
(** Prints the recovered [while (cond)] exit condition of a loop. The current (** Prints the recovered [while (cond)] exit condition of a loop. Note: this
stmt is expected to be positionned to the original AST statement method will be called in a context where 'current_stmt' is tied to the
containing the breaking condition (which is not printed at all). *) original AST conditional statement that exits the loop, as expected. *)
method pp_keyword: Format.formatter -> string -> unit method pp_keyword: Format.formatter -> string -> unit
(** All C99 keywords except types "char", "int", "long", "signed", (** All C99 keywords except types "char", "int", "long", "signed",
"short", "unsigned", "void" and "_XXX" (like "_Bool") **) "short", "unsigned", "void" and "_XXX" (like "_Bool") **)
......
...@@ -582,12 +582,12 @@ struct ...@@ -582,12 +582,12 @@ struct
pp_by_kf fmt ips_all_kfs pp_by_kf fmt ips_all_kfs
| _ -> () | _ -> ()
method! pp_while fmt cond = method! pp_while_head fmt cond =
let kf = Option.get self#current_kf in let kf = Option.get self#current_kf in
let stmt = Option.get self#current_stmt in let stmt = Option.get self#current_stmt in
Format.fprintf fmt "@{<%s>%a@}" Format.fprintf fmt "@{<%s>%a@}"
(Tag.create (PStmtStart(kf,stmt))) (Tag.create (PStmtStart(kf,stmt)))
super#pp_while cond super#pp_while_head cond
method! next_stmt next fmt current = method! next_stmt next fmt current =
if Tag.unfold current if Tag.unfold current
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment