1 /* General AST-related method implementations for Rust frontend.
2 Copyright (C) 2009-2025 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #include "rust-ast-full.h"
26 indent_spaces (enum indent_mode mode
)
28 static int indent
= 0;
32 for (int i
= 0; i
< indent
; i
++)
41 get_string_in_delims (std::string str_input
, DelimType delim_type
)
46 return "(" + str_input
+ ")";
48 return "[" + str_input
+ "]";
50 return "{" + str_input
+ "}";
52 return "ERROR-MARK-STRING (delims)";
58 get_mode_dump_desc (AttrMode mode
)
63 return "outer attributes";
65 return "inner attributes";
73 append_attributes (std::vector
<Attribute
> attrs
, AttrMode mode
)
75 indent_spaces (enter
);
78 = "\n" + indent_spaces (stay
) + get_mode_dump_desc (mode
) + ": ";
79 // str += "\n" + indent_spaces (stay) + "inner attributes: ";
86 /* note that this does not print them with outer or "inner attribute"
87 * syntax - just prints the body */
88 for (const auto &attr
: attrs
)
89 str
+= "\n" + indent_spaces (stay
) + attr
.as_string ();
98 unquote_string (std::string input
)
100 rust_assert (input
.front () == '"');
101 rust_assert (input
.back () == '"');
102 return input
.substr (1, input
.length () - 2);