aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-ast-dump.cc
AgeCommit message (Collapse)AuthorFilesLines
2025-01-02Update copyright years.Jakub Jelinek1-1/+1
2024-01-16gccrs: dump: Fix dollar spacing rulePierre-Emmanuel Patry1-1/+1
Space should be removed after the dollar sign, not before. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::require_spacing): Change dollar spacing rule. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: dump: Fix spacing with dots and referencesPierre-Emmanuel Patry1-0/+3
A space was output around dots as well as after references, this made things kinda horrible to look at and clearly not usual. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::require_spacing): Add a rule to remove spaces around dots and after references. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: collector: Fix some token collectorPierre-Emmanuel Patry1-0/+1
Some ast subtrees where not correctly collected. Among those where macro match repetition introducing empty tokens. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Fix several token collection rules. * ast/rust-ast-dump.cc (Dump::require_spacing): Add spacing rule for comma. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: dump: Add formatting to dumpPierre-Emmanuel Patry1-0/+5
Add formatting character output to ast dump. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Add comment after tail expressions. * ast/rust-ast-dump.cc (Dump::require_spacing): Check for missing previous token. * ast/rust-ast-dump.h: Output formatting characters. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: dump: Output separating space under conditionPierre-Emmanuel Patry1-0/+32
Separating space shall not be output between every tokens to make the dump clear and easy to read. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::require_spacing): Add a function to determine wether a space shall output. * ast/rust-ast-dump.h: Add function prototype as well as condition. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: dump: Replace ast dump internalsPierre-Emmanuel Patry1-1911/+7
Replace ast dump visitor with call to token collector. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Add a visit function for visitable abstract class so we can call a dump on any visitable item. * ast/rust-ast-collector.h: Add new visit function prototype. * ast/rust-ast-dump.cc (Dump::go): Add call to process function. (Dump::visit): Remove functions. (Dump::visit_items_joined_by_separator): Likewise. (Dump::visit_as_line): Likewise. (Dump::visit_items_as_lines): Likewise. (Dump::visit_items_as_block): Likewise. (Dump::visit_function_common): Likewise. (get_delimiters): Likewise. (Dump::debug): Update with call to tokencollector. * ast/rust-ast-dump.h (RUST_AST_DUMP_H): Move include directives. (class Dump): Remove multiple prototypes and add generic process function. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: Print macro invocations in AST dumpMatthew Jasper1-2/+5
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Print macro invocations. Signed-off-by: Matthew Jasper <mjjasper1@gmail.com>
2024-01-16gccrs: ast: dump literals correctlyCharalampos Mitrodimas1-1/+28
This commit fixes printing of literals based on their type. Previous implementation printed literals the same, regardless their type. Now we are printing: * int, float, bool don't require special printing * char -> '<char>' * string -> "<string>" * byte -> b'<byte>' * byte_string -> b"<byte_string>" gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): print literals based on their type. Signed-off-by: Charalampos Mitrodimas <charmitro@gmail.com>
2024-01-16gccrs: Add AST::AttrInputMacroOwen Avery1-0/+4
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add AttrInputMacro visitor. * ast/rust-ast-dump.h: (Dump::visit): Likewise. * ast/rust-ast-full-decls.h (class AttrInputMacro): New. * ast/rust-ast-collector.cc (TokenCollector::visit): Add and call out to AttrInputMacro visitor. * ast/rust-ast-collector.h: (TokenCollector::visit): Add AttrInputMacro visitor. * ast/rust-ast-visitor.h: (ASTVisitor::visit): Likewise. * ast/rust-ast.cc (AttrInputMacro::accept_vis): New. (AttrInputMacro::as_string): New. (AttrInputMacro::AttrInputMacro): New. (AttrInputMacro::operator=): New. * ast/rust-ast.h: (AttrInput::AttrInputType::MACRO): New. * ast/rust-expr.h (class AttrInputMacro): New. * checks/errors/rust-feature-gate.h: (FeatureGate::visit): Add AttrInputMacro visitor. * expand/rust-cfg-strip.cc (CfgStrip::visit): Likewise. * expand/rust-cfg-strip.h: (CfgStrip::visit): Likewise. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise. * expand/rust-expand-visitor.h: (ExpandVisitor::visit): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h: (ASTLoweringBase::visit): Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.h: (ResolverBase::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * resolve/rust-early-name-resolver.h: (EarlyNameResolver::visit): Likewise. * util/rust-attributes.cc (AttributeChecker::visit): Likewise. (check_doc_attribute): Handle AttrInputType::MACRO. * util/rust-attributes.h: (AttributeChecker::visit): Add AttrInputMacro visitor. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: dump: Dump `TupleIndexExpr`sArthur Cohen1-2/+5
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Implement dump for `TupleIndexExpr`.
2024-01-16gccrs: ast: Remove ExprStmtWithBlock / ExprStmtWithoutBlock distinctionMatthew Jasper1-7/+1
This distinction isn't very helpful and makes correct parsing harder. gcc/rust/ChangeLog: * ast/rust-ast-full-decls.h (class ExprStmtWithoutBlock): Remove. (class ExprStmtWithBlock): Remove. * ast/rust-stmt.h (class ExprStmtWithoutBlock): Remove. (class ExprStmtWithBlock): Remove. (class ExprStmt): Make non-abstract, add common functionality from removed base classes. * ast/rust-ast.h: Move to_stmt to base class. * ast/rust-ast.cc (ExprStmtWithBlock::as_string): Remove. * ast/rust-macro.h: Use new signature for to_stmt. (ExprStmt::as_string): New method. (ExprStmtWithoutBlock::as_string): Remove. (BlockExpr::strip_tail_expr): Update for removed classes. (ExprStmtWithoutBlock::accept_vis): Remove. (ExprStmtWithBlock::accept_vis): Remove. (ExprStmt::accept_vis): New method. * ast/rust-ast-dump.cc (Dump::visit): Update for removed classes. * ast/rust-ast-dump.h: Likewise. * ast/rust-ast-collector.h: Likewise. * ast/rust-ast-collector.cc (TokenStream::visit): Likewise. * ast/rust-ast-visitor.h: Likewise. * checks/errors/rust-feature-gate.h: Likewise. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise. * expand/rust-expand-visitor.h: Likewise. * expand/rust-cfg-strip.cc (CfgStrip::visit): Likewise. * expand/rust-cfg-strip.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Likewise. * hir/rust-ast-lower-stmt.h: Likewise. * util/rust-attributes.cc (AttributeChecker::visit): Likewise. * util/rust-attributes.h: Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.h: Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * resolve/rust-early-name-resolver.h: Likewise. * parse/rust-parse-impl.h (Parser::parse_match_expr): Likewise. (Parser::parse_stmt_or_expr_without_block): Likewise. * parse/rust-parse.h: Likewise. Signed-off-by: Matthew Jasper <mjjasper1@gmail.com>
2024-01-16gccrs: Minor tuning in AST dumpMarc Poulhiès1-2/+3
Use parentheses to remove any ambiguities when dumping expressions with unary ! and -. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): print parentheses around unique expression operand. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: Implement Dump:visit() function for QualifiedPathInType argument.Zheyuan Chen1-3/+15
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc: fix bad formatting for associated type. Signed-off-by: Zheyuan Chen <sephirotheca17@gmail.com>
2024-01-16gccrs: Unify AST::IfLetExprConseqIf{,Let} into AST::IfLetExprConseqElseOwen Avery1-8/+0
This simplifies the AST's representation of if-let-statements to match the HIR. gcc/rust/ChangeLog: * ast/rust-expr.h (class IfLetExprConseqElse): Make else_block ExprWithBlock. (class IfLetExprConseqIf): Remove. (class IfLetExprConseqIfLet): Remove. * ast/rust-ast-full-decls.h (class IfLetExprConseqIf): Remove. (class IfLetExprConseqIfLet): Remove. * ast/rust-ast.cc (IfLetExprConseqElse::as_string): Adjust output. (IfLetExprConseqIf::as_string): Remove. (IfLetExprConseqIfLet::as_string): Remove. (IfLetExprConseqIf::accept_vis): Remove. (IfLetExprConseqIfLet::accept_vis): Remove. * ast/rust-ast-visitor.h (ASTVisitor::visit): Remove IfLetExprConseqIf{,Let} visitors. * ast/rust-ast-dump.cc (Dump::visit): Likewise. * ast/rust-ast-dump.h: (Dump::visit): Likewise. * ast/rust-ast-tokenstream.cc (TokenStream::visit): Likewise. * ast/rust-ast-tokenstream.h (TokenStream::visit): Likewise. * util/rust-attributes.cc (AttributeChecker::visit): Likewise. * util/rust-attributes.h: (AttributeChecker::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * resolve/rust-early-name-resolver.h (EarlyNameResolver::visit): Likewise. * resolve/rust-ast-resolve-base.h (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * checks/errors/rust-feature-gate.h (FeatureGate::visit): Likewise. * expand/rust-cfg-strip.cc (CfgStrip::visit): Likewise. * expand/rust-cfg-strip.h: (CfgStrip::visit): Likewise. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise. * expand/rust-expand-visitor.h (ExpandVisitor::visit): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h: (ASTLoweringBase::visit): Likewise. * parse/rust-parse-impl.h (Parser::parse_if_let_expr): Replace IfLetExprConseqIf{,Let} with IfLetExprConseqElse. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Unify AST::IfExprConseqIf{,Let} into AST::IfExprConseqElseOwen Avery1-16/+0
This simplifies the AST's representation of if-statements to match the HIR. gcc/rust/ChangeLog: * ast/rust-expr.h (class IfExprConseqElse): Make else_block ExprWithBlock. (class IfExprConseqIf): Remove. (class IfExprConseqIfLet): Remove. * ast/rust-ast-full-decls.h (class IfExprConseqIf): Remove. (class IfExprConseqIfLet): Remove. * ast/rust-ast.cc (IfExprConseqElse::as_string): Adjust output. (IfExprConseqIf::as_string): Remove. (IfExprConseqIfLet::as_string): Remove. (IfExprConseqIf::accept_vis): Remove. (IfExprConseqIfLet::accept_vis): Remove. * ast/rust-ast-visitor.h (ASTVisitor::visit): Remove IfExprConseqIf{,Let} visitors. * ast/rust-ast-tokenstream.cc (TokenStream::visit): Likewise. * ast/rust-ast-tokenstream.h (TokenStream::visit): Likewise. * ast/rust-ast-dump.cc (Dump::visit): Likewise. * ast/rust-ast-dump.h (Dump::visit): Likewise. * checks/errors/rust-feature-gate.h (FeatureGate::visit): Likewise. * util/rust-attributes.cc (AttributeChecker::visit): Likewise. * util/rust-attributes.h (AttributeChecker::visit): Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * resolve/rust-early-name-resolver.h (EarlyNameResolver::visit): Likewise. * resolve/rust-ast-resolve-base.h (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-expr.h (ResolveExpr::visit): Remove IfExprConseqIf visitor. * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise. * expand/rust-cfg-strip.cc (CfgStrip::visit): Remove IfExprConseqIf{,Let} visitors. * expand/rust-cfg-strip.h (CfgStrip::visit): Likewise. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise. * expand/rust-expand-visitor.h (ExpandVisitor::visit): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-block.h (ASTLoweringIfBlock::visit): Remove IfExprConseqIf visitor. (ASTLoweringExprWithBlock::visit): Likewise. * hir/rust-ast-lower.cc (ASTLoweringIfBlock::visit): Remove IfExprConseqIf visitor, adjust IfExprConseqElse lowering. * hir/rust-ast-lower-expr.h (ASTLoweringExpr::visit): Remove IfExprConseqIf visitor. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * parse/rust-parse-impl.h (Parser::parse_if_expr): Replace IfExprConseqIf{,Let} with IfExprConseqElse. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2024-01-16gccrs: Introduce AST::Visitable class for ASTMarc Poulhiès1-0/+17
AST::Visitable is an abstract class with a unique accept_vis() method. Make all abstract AST node class inherit from this class. Allows for easy definition of operations on nodes that must accept a visitor. The static Dump::dump() is an example of such use: the static method accepts any AST node, creates a Dump visitor and have it visit the AST starting at the node. This change also inserts a debug(Visitable&) function in the global namespace to make it easy to call from the debugger (similar to debug_tree or debug(rtx*) functions). gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::debug): New. * ast/rust-ast-dump.h (Dump::debug): Untemplate it. (debug): New. * ast/rust-ast.h (class Visitable): New. (class TokenTree): Inherit from Visitable. (class MacroMatch): Likewise. (class AttrInput): Likewise. (class MetaItemInner): Likewise. (class Pattern): Likewise. (classTypeParamBound): Likewise. (class GenericParam): Likewise. (class TraitItem): Likewise. (classInherentImplItem): Likewise. (class TraitImplItem): Likewise. (class ExternalItem): Likewise. (class SingleASTNode): Likewise. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2024-01-16gccrs: ast: Dump each MacroRule properly without the extra semicolonArthur Cohen1-1/+0
Having the extra semicolon causes parsing errors when importing macros exported using the AST dump, as no rule expects multiple tokens after a single macro rule definition. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Remove extraneous semicolon when dumping macro rules.
2024-01-16gccrs: hir: Unify indentation approach with astJakub Dupak1-21/+0
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Indent::Indent): Move to separate file. (operator<<): Move to separate file. (Indent::increment): Move to separate file. (Indent::decrement): Move to separate file. * ast/rust-ast-dump.h (class Indent): Move to separate file. * hir/rust-hir-dump.cc (Dump::Dump): Use new indentation object. (Dump::go): Use new indentation object. (Dump::visit): Use new indention object. * hir/rust-hir-dump.h: Use new indentation object. * util/rust-dump.h: New file. Moved Indentation from rust-ast-dump.cc Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2024-01-16gccrs: ast: Add RestPattern AST nodePierre-Emmanuel Patry1-0/+4
Add the RestPattern AST node representing ".." code in some rust context. This commit also provides the different visitors for this node. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add visitor. * ast/rust-ast-dump.h: Add visitor prototype. * ast/rust-ast-full-decls.h (class RestPattern): Add forward declaration for class RestPattern. * ast/rust-ast-visitor.h: Add visitor prototype. * ast/rust-ast.cc (RestPattern::accept_vis): Add function to accept a foreign visitor. * ast/rust-pattern.h (class RestPattern): Add class RestPattern. * checks/errors/rust-feature-gate.h: Add visitor prototype. * expand/rust-attribute-visitor.cc (AttrVisitor::visit): Add visitor implementation. * expand/rust-attribute-visitor.h: Add visitor prototype. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add visitor implementation. * hir/rust-ast-lower-base.h: Add visitor prototype. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add visitor implementation. * resolve/rust-ast-resolve-base.h: Add visitor prototype. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Add visitor implementation. * resolve/rust-early-name-resolver.h: Add visitor prototype. * util/rust-attributes.cc (AttributeChecker::visit): Add visitor implementation. * util/rust-attributes.h: Add visitor prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2024-01-16gccrs: ast: Add proper visitors for ExternalTypeItemArthur Cohen1-1/+5
gcc/rust/ChangeLog: * ast/rust-item.h: Add non-const `get_visibility` to ExternalTypeItem. * ast/rust-ast-dump.cc (Dump::visit): Add implementation for ExternalTypeItem. * expand/rust-attribute-visitor.cc (AttrVisitor::visit): Likewise.
2024-01-16gccrs: ast: Add ExternalTypeItem nodeArthur Cohen1-0/+4
gcc/rust/ChangeLog: * ast/rust-item.h (class ExternalTypeItem): New class. * ast/rust-ast.cc (ExternalTypeItem::as_string): New function. (ExternalTypeItem::accept_vis): Likewise. * ast/rust-ast-full-decls.h (class ExternalTypeItem): Declare class. * ast/rust-ast-dump.cc (Dump::visit): Add base visitor for ExternalTypeItem. * ast/rust-ast-dump.h: Likewise. * ast/rust-ast-visitor.h: Likewise. * checks/errors/rust-feature-gate.h: Likewise. * expand/rust-attribute-visitor.cc (AttrVisitor::visit): Likewise. * expand/rust-attribute-visitor.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h: Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.h: Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * resolve/rust-early-name-resolver.h: Likewise. * util/rust-attributes.cc (AttributeChecker::visit): Likewise. * util/rust-attributes.h: Likewise.
2024-01-03Update copyright years.Jakub Jelinek1-1/+1
2023-04-06gccrs: Add AST::AltPattern classOwen Avery1-0/+4
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add AltPattern visitor. * ast/rust-ast-dump.h: (Dump::visit): Add AltPattern visitor. * ast/rust-ast-full-decls.h (class AltPattern): Add declaration. * ast/rust-ast-visitor.h: (ASTVisitor::visit): Add AltPattern visitor. * ast/rust-ast.cc (AltPattern::as_string): Add definition. (AltPattern::accept_vis): Add definition. * ast/rust-pattern.h (class AltPattern): Add declaration. * checks/errors/rust-feature-gate.h: (FeatureGate::visit) Add AltPattern visitor * expand/rust-attribute-visitor.cc (AttrVisitor::visit): Add AltPattern visitor. * expand/rust-attribute-visitor.h: (AttrVisitor::visit): Add AltPattern visitor. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add AltPattern visitor. * hir/rust-ast-lower-base.h: (ASTLoweringBase::visit): Add AltPattern visitor. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add AltPattern visitor. * resolve/rust-ast-resolve-base.h: (ResolverBase::visit): Add AltPattern visitor. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Add AltPattern visitor. * resolve/rust-early-name-resolver.h: (EarlyNameResolver::visit): Add AltPattern visitor. * util/rust-attributes.cc (AttributeChecker::visit): Add AltPattern visitor. * util/rust-attributes.h: (AttributeChecker::visit): Add AltPattern visitor. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2023-04-06gccrs: fixed indentations in AST pretty expanded dump of traitAbdul Rafey1-6/+1
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): removed extra indentations in trait ast dump Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
2023-02-21Update copyright years.Thomas Schwinge1-1/+1
... which accidentally had gotten reverted in recent commit r13-6156-g1e8eb102200902e12c1b00e867e338be0a92c292 "gccrs: dump: Emit visibility when dumping items".
2023-02-21gccrs: ast: Dump no comma after self in fn params if it is the last oneJakub Dupak1-4/+12
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Fix dumping of fn params. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump remove /* stmp */ comment to not clutter the dumpJakub Dupak1-2/+1
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Remove extraneous string when dumping statements. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Remove unused include in rust-ast-dump.ccJakub Dupak1-1/+0
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc: Remove unused include. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump generic parametersJakub Dupak1-9/+120
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor. * ast/rust-ast-dump.h: Likewise. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump type param typeJakub Dupak1-1/+13
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump trait object type one boundJakub Dupak1-2/+9
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump parenthesised typeJakub Dupak1-2/+9
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump trait object typeJakub Dupak1-4/+13
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump impl trait typeJakub Dupak1-2/+10
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump impl trait type one boundJakub Dupak1-2/+8
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump bare function typeJakub Dupak1-2/+92
+ Return FunctionQualifiers as ref to work in ast dump gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor. * ast/rust-ast-dump.h: Add missing getter declaration. * ast/rust-ast-full-test.cc (BareFunctionType::as_string): Fix bare function string representation. * ast/rust-type.h (class BareFunctionType): Declare said getter. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump inferred typeJakub Dupak1-0/+3
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump tuple typeJakub Dupak1-5/+13
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing tuple type visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump never typeJakub Dupak1-1/+6
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing never type visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump raw pointer typeJakub Dupak1-88/+112
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing RawPointer visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump array typeJakub Dupak1-0/+7
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing array visitor Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump slice typeJakub Dupak1-0/+5
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing slice visitor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump where clause and recursively needed nodesJakub Dupak1-17/+123
This is currently needed for lifetimes to use the existing infrastructure. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing visitors. * ast/rust-ast-dump.h: Likewise. * ast/rust-ast.h: Add `get_lifetime_bounds` method. * ast/rust-item.h: Add missing getter for lifetimes. * ast/rust-type.h: Likewise. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: add visit overload for referencesJakub Dupak1-4/+11
This is currently needed for lifetimes to use the existing infrastructure. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add new reference visitor wrapper. * ast/rust-ast-dump.h: Declare it. * ast/rust-item.h: Add mutable visibility getters. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: Dump unit structJakub Dupak1-1/+4
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add handling for unit structures. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: transform helper methods to visits and add methods to simplify ↵Jakub Dupak1-360/+199
repeated patterns gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::go): Use new API. (Dump::format_function_param): Refactor. (Dump::visit_items_joined_by_separator): New function. (Dump::emit_attrib): Refactor. (Dump::visit_as_line): New function. (Dump::visit_items_as_lines): Likewise. (Dump::visit_items_as_block): Likewise. (Dump::visit): Use new API. (Dump::emit_visibility): Likewise. (Dump::emit_indented_string): Likewise. (Dump::emit_generic_params): Likewise. (Dump::format_tuple_field): Likewise. (Dump::format_struct_field): Likewise. (Dump::format_function_common): Likewise. (Dump::visit_function_common): Likewise. * ast/rust-ast-dump.h: Declare new functions and add documentation. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: ast: visitor pattern -> overload syntax compatibility layerJakub Dupak1-0/+7
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add new visit function for overloading. * ast/rust-ast-dump.h: Add documentation for layer. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
2023-02-21gccrs: dump: Dump macro rules definitionArthur Cohen1-8/+118
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing visitors for macro definition dumping. (get_delimiters): New function. * ast/rust-ast-dump.h: Declare `get_delimiters` and add documentation. * ast/rust-macro.h: Add `get_token_tree` method.
2023-02-21gccrs: ast: Module: unloaded module and inner attributesJakub Dupak1-9/+32
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Properly handle unloaded modules. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>