1 /* Helper code for graphviz output.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
26 /* graphviz_out's ctor, wrapping PP. */
28 graphviz_out::graphviz_out (pretty_printer
*pp
)
34 /* Formatted print of FMT. */
37 graphviz_out::print (const char *fmt
, ...)
42 text_info
text (fmt
, &ap
, errno
);
43 pp_format (m_pp
, &text
);
44 pp_output_formatted_text (m_pp
);
48 /* Formatted print of FMT. The text is indented by the current
49 indent, and a newline is added. */
52 graphviz_out::println (const char *fmt
, ...)
59 text_info
text (fmt
, &ap
, errno
);
60 pp_format (m_pp
, &text
);
61 pp_output_formatted_text (m_pp
);
67 /* Print the current indent to the underlying pp. */
70 graphviz_out::write_indent ()
72 for (int i
= 0; i
< m_indent
* 2; ++i
)
76 /* Write the start of an HTML-like row via <TR>, writing to the stream
77 so that followup text can be escaped. */
80 graphviz_out::begin_tr ()
82 pp_string (m_pp
, "<TR>");
83 pp_write_text_to_stream (m_pp
);
86 /* Write the end of an HTML-like row via </TR>, writing to the stream
87 so that followup text can be escaped. */
90 graphviz_out::end_tr ()
92 pp_string (m_pp
, "</TR>");
93 pp_write_text_to_stream (m_pp
);
96 /* Write the start of an HTML-like <TD>, writing to the stream
97 so that followup text can be escaped. */
100 graphviz_out::begin_td ()
102 pp_string (m_pp
, "<TD ALIGN=\"LEFT\">");
103 pp_write_text_to_stream (m_pp
);
106 /* Write the end of an HTML-like </TD>, writing to the stream
107 so that followup text can be escaped. */
110 graphviz_out::end_td ()
112 pp_string (m_pp
, "</TD>");
113 pp_write_text_to_stream (m_pp
);
116 /* Write the start of an HTML-like row via <TR><TD>, writing to the stream
117 so that followup text can be escaped. */
120 graphviz_out::begin_trtd ()
122 pp_string (m_pp
, "<TR><TD ALIGN=\"LEFT\">");
123 pp_write_text_to_stream (m_pp
);
126 /* Write the end of an HTML-like row via </TD></TR>, writing to the stream
127 so that followup text can be escaped. */
130 graphviz_out::end_tdtr ()
132 pp_string (m_pp
, "</TD></TR>");
133 pp_write_text_to_stream (m_pp
);