GCC Middle and Back End API Reference
tree-widget.h
Go to the documentation of this file.
1/* Tree diagrams.
2 Copyright (C) 2024-2025 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#ifndef GCC_TEXT_ART_TREE_WIDGET_H
22#define GCC_TEXT_ART_TREE_WIDGET_H
23
24#include "text-art/canvas.h"
25#include "text-art/widget.h"
26
27namespace text_art {
28
30
31class tree_widget : public widget
32{
33public:
34 tree_widget (std::unique_ptr<widget> node,
35 const theme &theme,
36 style::id_t style_id)
37 : m_node (std::move (node)),
38 m_theme (theme),
39 m_style_id (style_id)
40 {
41 }
42
43 static std::unique_ptr<tree_widget>
44 make (styled_string str, const theme &theme, style::id_t style_id);
45
46 static std::unique_ptr<tree_widget>
47 make (const dump_widget_info &dwi, pretty_printer *pp);
48
49 static std::unique_ptr<tree_widget>
50 make (const dump_widget_info &dwi, const char *str);
51
52 static std::unique_ptr<tree_widget>
53 from_fmt (const dump_widget_info &dwi,
54 printer_fn format_decoder,
55 const char *fmt, ...)
57
58 const char *get_desc () const override;
59 canvas::size_t calc_req_size () final override;
60 void update_child_alloc_rects () final override;
61 void paint_to_canvas (canvas &canvas) final override;
62
63 void add_child (std::unique_ptr<widget> child)
64 {
65 if (child)
66 m_children.push_back (std::move (child));
67 }
68
69 size_t get_num_children () const
70 {
71 return m_children.size ();
72 }
73
74private:
75 std::unique_ptr<widget> m_node;
76 std::vector<std::unique_ptr<widget>> m_children;
77 const theme &m_theme;
79};
80
81} // namespace text_art
82
83#endif /* GCC_TEXT_ART_TREE_WIDGET_H */
Definition pretty-print.h:241
Definition canvas.h:38
Definition types.h:424
Definition theme.h:30
void add_child(std::unique_ptr< widget > child)
Definition tree-widget.h:63
std::unique_ptr< widget > m_node
Definition tree-widget.h:75
void update_child_alloc_rects() final override
Definition tree-widget.cc:101
void paint_to_canvas(canvas &canvas) final override
Definition tree-widget.cc:124
static std::unique_ptr< tree_widget > make(styled_string str, const theme &theme, style::id_t style_id)
Definition tree-widget.cc:38
style::id_t m_style_id
Definition tree-widget.h:78
std::vector< std::unique_ptr< widget > > m_children
Definition tree-widget.h:76
tree_widget(std::unique_ptr< widget > node, const theme &theme, style::id_t style_id)
Definition tree-widget.h:34
canvas::size_t calc_req_size() final override
Definition tree-widget.cc:82
size_t get_num_children() const
Definition tree-widget.h:69
static std::unique_ptr< tree_widget > const char * get_desc() const override
Definition tree-widget.cc:76
static std::unique_ptr< tree_widget > from_fmt(const dump_widget_info &dwi, printer_fn format_decoder, const char *fmt,...) ATTRIBUTE_GCC_PPDIAG(3
Definition tree-widget.cc:63
const theme & m_theme
Definition tree-widget.h:77
widget()
Definition widget.h:121
void final(rtx_insn *first, FILE *file, int optimize_p)
Definition final.cc:2009
Definition diagnostics/context.h:56
bool(* printer_fn)(pretty_printer *, text_info *, const char *, int, bool, bool, bool, bool *, pp_token_list &)
Definition pretty-print.h:190
#define ATTRIBUTE_GCC_PPDIAG(m, n)
Definition pretty-print.h:582
Definition ira-emit.cc:158
Definition dump-widget-info.h:31
unsigned char id_t
Definition types.h:223