Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / rust / hir / rust-hir-dump.cc
blob10720c4329472862e8939f416f638f1628099aa5
1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
3 // This file is part of GCC.
5 // GCC is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation; either version 3, or (at your option) any later
8 // version.
10 // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 // for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with GCC; see the file COPYING3. If not see
17 // <http://www.gnu.org/licenses/>.
19 #include "rust-hir-dump.h"
21 namespace Rust {
22 namespace HIR {
24 Dump::Dump (std::ostream &stream) : stream (stream), indent (0) {}
26 void
27 Dump::go (HIR::Crate &crate)
29 stream << "Crate"
30 << " "
31 << "{" << std::endl;
34 indent++;
35 stream << std::string (indent, indent_char);
36 stream << "inner_attrs"
37 << ":"
38 << " "
39 << "[";
40 for (auto &attr : crate.inner_attrs)
41 stream << attr.as_string ();
42 stream << "]"
43 << "," << std::endl;
44 indent--;
46 indent++;
47 stream << std::string (indent, indent_char);
50 stream << "items"
51 << ":"
52 << " "
53 << "[";
55 stream << std::string (indent, indent_char);
56 for (const auto &item : crate.items)
58 stream << std::endl;
59 item->accept_vis (*this);
61 stream << std::string (indent, indent_char);
62 stream << "]"
63 << "," << std::endl;
64 indent--;
67 indent++;
68 stream << std::string (indent, indent_char);
69 stream << "node_mappings"
70 << ":"
71 << " "
72 << "[";
73 // TODO: print crate mapping attrs
74 stream << "]" << std::endl;
75 indent--;
77 stream << "}" << std::endl;
80 void
81 Dump::visit (Lifetime &)
83 void
84 Dump::visit (LifetimeParam &)
86 void
87 Dump::visit (PathInExpression &)
89 void
90 Dump::visit (TypePathSegment &)
92 void
93 Dump::visit (TypePathSegmentGeneric &)
95 void
96 Dump::visit (TypePathSegmentFunction &)
98 void
99 Dump::visit (TypePath &)
101 void
102 Dump::visit (QualifiedPathInExpression &)
104 void
105 Dump::visit (QualifiedPathInType &)
108 void
109 Dump::visit (LiteralExpr &literal_expr)
111 indent++;
112 stream << std::string (indent, indent_char);
113 stream << "( " + literal_expr.get_literal ().as_string () + " ("
114 + literal_expr.get_mappings ().as_string () + "))";
115 stream << "\n";
117 void
118 Dump::visit (BorrowExpr &)
120 void
121 Dump::visit (DereferenceExpr &)
123 void
124 Dump::visit (ErrorPropagationExpr &)
126 void
127 Dump::visit (NegationExpr &)
129 void
130 Dump::visit (ArithmeticOrLogicalExpr &)
132 void
133 Dump::visit (ComparisonExpr &)
135 void
136 Dump::visit (LazyBooleanExpr &)
138 void
139 Dump::visit (TypeCastExpr &)
141 void
142 Dump::visit (AssignmentExpr &)
144 void
145 Dump::visit (CompoundAssignmentExpr &)
147 void
148 Dump::visit (GroupedExpr &)
151 void
152 Dump::visit (ArrayElemsValues &)
154 void
155 Dump::visit (ArrayElemsCopied &)
157 void
158 Dump::visit (ArrayExpr &)
160 void
161 Dump::visit (ArrayIndexExpr &)
163 void
164 Dump::visit (TupleExpr &)
166 void
167 Dump::visit (TupleIndexExpr &)
169 void
170 Dump::visit (StructExprStruct &)
173 void
174 Dump::visit (StructExprFieldIdentifier &)
176 void
177 Dump::visit (StructExprFieldIdentifierValue &)
180 void
181 Dump::visit (StructExprFieldIndexValue &)
183 void
184 Dump::visit (StructExprStructFields &)
186 void
187 Dump::visit (StructExprStructBase &)
190 void
191 Dump::visit (CallExpr &)
193 void
194 Dump::visit (MethodCallExpr &)
196 void
197 Dump::visit (FieldAccessExpr &)
199 void
200 Dump::visit (ClosureExpr &)
202 void
203 Dump::visit (BlockExpr &)
205 stream << "BlockExpr"
206 << ":"
207 << " "
208 << "[";
209 indent++;
210 // TODO: print statements
211 // TODO: print tail expression if exists
212 stream << "]";
213 indent--;
216 void
217 Dump::visit (ContinueExpr &)
219 void
220 Dump::visit (BreakExpr &)
222 void
223 Dump::visit (RangeFromToExpr &)
225 void
226 Dump::visit (RangeFromExpr &)
228 void
229 Dump::visit (RangeToExpr &)
231 void
232 Dump::visit (RangeFullExpr &)
234 void
235 Dump::visit (RangeFromToInclExpr &)
237 void
238 Dump::visit (RangeToInclExpr &)
240 void
241 Dump::visit (ReturnExpr &)
243 void
244 Dump::visit (UnsafeBlockExpr &)
246 void
247 Dump::visit (LoopExpr &)
249 void
250 Dump::visit (WhileLoopExpr &)
252 void
253 Dump::visit (WhileLetLoopExpr &)
255 void
256 Dump::visit (ForLoopExpr &)
258 void
259 Dump::visit (IfExpr &)
261 void
262 Dump::visit (IfExprConseqElse &)
264 void
265 Dump::visit (IfExprConseqIf &)
267 void
268 Dump::visit (IfExprConseqIfLet &)
270 void
271 Dump::visit (IfLetExpr &)
273 void
274 Dump::visit (IfLetExprConseqElse &)
276 void
277 Dump::visit (IfLetExprConseqIf &)
279 void
280 Dump::visit (IfLetExprConseqIfLet &)
283 void
284 Dump::visit (MatchExpr &)
286 void
287 Dump::visit (AwaitExpr &)
289 void
290 Dump::visit (AsyncBlockExpr &)
293 void
294 Dump::visit (TypeParam &)
297 void
298 Dump::visit (ConstGenericParam &)
301 void
302 Dump::visit (LifetimeWhereClauseItem &)
304 void
305 Dump::visit (TypeBoundWhereClauseItem &)
307 void
308 Dump::visit (Module &)
310 void
311 Dump::visit (ExternCrate &)
314 void
315 Dump::visit (UseTreeGlob &)
317 void
318 Dump::visit (UseTreeList &)
320 void
321 Dump::visit (UseTreeRebind &)
323 void
324 Dump::visit (UseDeclaration &)
326 void
327 Dump::visit (Function &)
329 indent++;
330 stream << std::string (indent, indent_char);
331 stream << "Function"
332 << " ";
333 stream << "{" << std::endl;
334 // TODO: print function params
335 stream << std::string (indent, indent_char);
336 stream << "}" << std::endl;
337 // TODO: get function definition and visit block
339 stream << std::endl;
340 indent--;
342 void
343 Dump::visit (TypeAlias &)
345 void
346 Dump::visit (StructStruct &)
348 void
349 Dump::visit (TupleStruct &)
351 void
352 Dump::visit (EnumItem &)
354 void
355 Dump::visit (EnumItemTuple &)
357 void
358 Dump::visit (EnumItemStruct &)
360 void
361 Dump::visit (EnumItemDiscriminant &)
363 void
364 Dump::visit (Enum &)
366 void
367 Dump::visit (Union &)
369 void
370 Dump::visit (ConstantItem &)
372 void
373 Dump::visit (StaticItem &)
375 void
376 Dump::visit (TraitItemFunc &)
378 void
379 Dump::visit (TraitItemConst &)
381 void
382 Dump::visit (TraitItemType &)
384 void
385 Dump::visit (Trait &)
387 void
388 Dump::visit (ImplBlock &)
391 void
392 Dump::visit (ExternalStaticItem &)
394 void
395 Dump::visit (ExternalFunctionItem &)
397 void
398 Dump::visit (ExternBlock &)
401 void
402 Dump::visit (LiteralPattern &)
404 void
405 Dump::visit (IdentifierPattern &)
407 void
408 Dump::visit (WildcardPattern &)
411 void
412 Dump::visit (RangePatternBoundLiteral &)
414 void
415 Dump::visit (RangePatternBoundPath &)
417 void
418 Dump::visit (RangePatternBoundQualPath &)
420 void
421 Dump::visit (RangePattern &)
423 void
424 Dump::visit (ReferencePattern &)
427 void
428 Dump::visit (StructPatternFieldTuplePat &)
430 void
431 Dump::visit (StructPatternFieldIdentPat &)
433 void
434 Dump::visit (StructPatternFieldIdent &)
436 void
437 Dump::visit (StructPattern &)
440 void
441 Dump::visit (TupleStructItemsNoRange &)
443 void
444 Dump::visit (TupleStructItemsRange &)
446 void
447 Dump::visit (TupleStructPattern &)
450 void
451 Dump::visit (TuplePatternItemsMultiple &)
453 void
454 Dump::visit (TuplePatternItemsRanged &)
456 void
457 Dump::visit (TuplePattern &)
459 void
460 Dump::visit (SlicePattern &)
463 void
464 Dump::visit (EmptyStmt &)
466 void
467 Dump::visit (LetStmt &)
469 void
470 Dump::visit (ExprStmtWithoutBlock &)
472 void
473 Dump::visit (ExprStmtWithBlock &)
476 void
477 Dump::visit (TraitBound &)
479 void
480 Dump::visit (ImplTraitType &)
482 void
483 Dump::visit (TraitObjectType &)
485 void
486 Dump::visit (ParenthesisedType &)
488 void
489 Dump::visit (ImplTraitTypeOneBound &)
491 void
492 Dump::visit (TupleType &)
494 void
495 Dump::visit (NeverType &)
497 void
498 Dump::visit (RawPointerType &)
500 void
501 Dump::visit (ReferenceType &)
503 void
504 Dump::visit (ArrayType &)
506 void
507 Dump::visit (SliceType &)
509 void
510 Dump::visit (InferredType &)
512 void
513 Dump::visit (BareFunctionType &)
515 } // namespace HIR
516 } // namespace Rust