]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/graphviz.cc
PR fortran/95090 - ICE: identifier overflow
[thirdparty/gcc.git] / gcc / graphviz.cc
CommitLineData
757bf1df
DM
1/* Helper code for graphviz output.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#include "config.h"
22#include "system.h"
23#include "coretypes.h"
24#include "graphviz.h"
25
26/* graphviz_out's ctor, wrapping PP. */
27
28graphviz_out::graphviz_out (pretty_printer *pp)
29: m_pp (pp),
30 m_indent (0)
31{
32}
33
34/* Formatted print of FMT. */
35
36void
37graphviz_out::print (const char *fmt, ...)
38{
39 text_info text;
40 va_list ap;
41
42 va_start (ap, fmt);
43 text.err_no = errno;
44 text.args_ptr = &ap;
45 text.format_spec = fmt;
46 pp_format (m_pp, &text);
47 pp_output_formatted_text (m_pp);
48 va_end (ap);
49}
50
51/* Formatted print of FMT. The text is indented by the current
52 indent, and a newline is added. */
53
54void
55graphviz_out::println (const char *fmt, ...)
56{
57 text_info text;
58 va_list ap;
59
60 write_indent ();
61
62 va_start (ap, fmt);
63 text.err_no = errno;
64 text.args_ptr = &ap;
65 text.format_spec = fmt;
66 pp_format (m_pp, &text);
67 pp_output_formatted_text (m_pp);
68 va_end (ap);
69
70 pp_newline (m_pp);
71}
72
73/* Print the current indent to the underlying pp. */
74
75void
76graphviz_out::write_indent ()
77{
78 for (int i = 0; i < m_indent * 2; ++i)
79 pp_space (m_pp);
80}
81
42c63313 82/* Write the start of an HTML-like row via <TR>, writing to the stream
757bf1df
DM
83 so that followup text can be escaped. */
84
85void
86graphviz_out::begin_tr ()
42c63313
DM
87{
88 pp_string (m_pp, "<TR>");
89 pp_write_text_to_stream (m_pp);
90}
91
92/* Write the end of an HTML-like row via </TR>, writing to the stream
93 so that followup text can be escaped. */
94
95void
96graphviz_out::end_tr ()
97{
98 pp_string (m_pp, "</TR>");
99 pp_write_text_to_stream (m_pp);
100}
101
102/* Write the start of an HTML-like <TD>, writing to the stream
103 so that followup text can be escaped. */
104
105void
106graphviz_out::begin_td ()
107{
108 pp_string (m_pp, "<TD ALIGN=\"LEFT\">");
109 pp_write_text_to_stream (m_pp);
110}
111
112/* Write the end of an HTML-like </TD>, writing to the stream
113 so that followup text can be escaped. */
114
115void
116graphviz_out::end_td ()
117{
118 pp_string (m_pp, "</TD>");
119 pp_write_text_to_stream (m_pp);
120}
121
122/* Write the start of an HTML-like row via <TR><TD>, writing to the stream
123 so that followup text can be escaped. */
124
125void
126graphviz_out::begin_trtd ()
757bf1df
DM
127{
128 pp_string (m_pp, "<TR><TD ALIGN=\"LEFT\">");
129 pp_write_text_to_stream (m_pp);
130}
131
132/* Write the end of an HTML-like row via </TD></TR>, writing to the stream
133 so that followup text can be escaped. */
134
135void
42c63313 136graphviz_out::end_tdtr ()
757bf1df
DM
137{
138 pp_string (m_pp, "</TD></TR>");
139 pp_write_text_to_stream (m_pp);
140}