diff options
author | Matthew Jasper <mjjasper1@gmail.com> | 2023-05-09 12:53:33 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:37:18 +0100 |
commit | 9e9ee593cf0507e5b54a556737909a46c6e91319 (patch) | |
tree | 69088e01eb6d0a6421cb80f76f7302daf28b7b99 /gcc/rust/hir | |
parent | 2aeff9ce08576ad33a29ed6fc6a87e9516b0641f (diff) | |
download | gcc-9e9ee593cf0507e5b54a556737909a46c6e91319.zip gcc-9e9ee593cf0507e5b54a556737909a46c6e91319.tar.gz gcc-9e9ee593cf0507e5b54a556737909a46c6e91319.tar.bz2 |
gccrs: ast: Remove ExprStmtWithBlock / ExprStmtWithoutBlock distinction
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>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-base.cc | 5 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-base.h | 3 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-stmt.cc | 23 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-stmt.h | 3 |
4 files changed, 7 insertions, 27 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-base.cc b/gcc/rust/hir/rust-ast-lower-base.cc index 70f57c3..096bc4f 100644 --- a/gcc/rust/hir/rust-ast-lower-base.cc +++ b/gcc/rust/hir/rust-ast-lower-base.cc @@ -467,10 +467,7 @@ void ASTLoweringBase::visit (AST::LetStmt &) {} void -ASTLoweringBase::visit (AST::ExprStmtWithoutBlock &) -{} -void -ASTLoweringBase::visit (AST::ExprStmtWithBlock &) +ASTLoweringBase::visit (AST::ExprStmt &) {} // rust-type.h diff --git a/gcc/rust/hir/rust-ast-lower-base.h b/gcc/rust/hir/rust-ast-lower-base.h index f839eae..7e8cbf7 100644 --- a/gcc/rust/hir/rust-ast-lower-base.h +++ b/gcc/rust/hir/rust-ast-lower-base.h @@ -234,8 +234,7 @@ public: // rust-stmt.h virtual void visit (AST::EmptyStmt &stmt); virtual void visit (AST::LetStmt &stmt); - virtual void visit (AST::ExprStmtWithoutBlock &stmt); - virtual void visit (AST::ExprStmtWithBlock &stmt); + virtual void visit (AST::ExprStmt &stmt); // rust-type.h virtual void visit (AST::TraitBound &bound); diff --git a/gcc/rust/hir/rust-ast-lower-stmt.cc b/gcc/rust/hir/rust-ast-lower-stmt.cc index dc14cb0..d99a3f3 100644 --- a/gcc/rust/hir/rust-ast-lower-stmt.cc +++ b/gcc/rust/hir/rust-ast-lower-stmt.cc @@ -55,23 +55,7 @@ ASTLoweringStmt::translate (AST::Stmt *stmt, bool *terminated) } void -ASTLoweringStmt::visit (AST::ExprStmtWithBlock &stmt) -{ - HIR::ExprWithBlock *expr - = ASTLoweringExprWithBlock::translate (stmt.get_expr ().get (), - &terminated); - - auto crate_num = mappings->get_current_crate (); - Analysis::NodeMapping mapping (crate_num, stmt.get_node_id (), - mappings->get_next_hir_id (crate_num), - UNKNOWN_LOCAL_DEFID); - translated - = new HIR::ExprStmt (mapping, std::unique_ptr<HIR::ExprWithBlock> (expr), - stmt.get_locus (), !stmt.is_semicolon_followed ()); -} - -void -ASTLoweringStmt::visit (AST::ExprStmtWithoutBlock &stmt) +ASTLoweringStmt::visit (AST::ExprStmt &stmt) { HIR::Expr *expr = ASTLoweringExpr::translate (stmt.get_expr ().get (), &terminated); @@ -80,8 +64,9 @@ ASTLoweringStmt::visit (AST::ExprStmtWithoutBlock &stmt) Analysis::NodeMapping mapping (crate_num, stmt.get_node_id (), mappings->get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); - translated = new HIR::ExprStmt (mapping, std::unique_ptr<HIR::Expr> (expr), - stmt.get_locus ()); + translated + = new HIR::ExprStmt (mapping, std::unique_ptr<HIR::Expr> (expr), + stmt.get_locus (), !stmt.is_semicolon_followed ()); } void diff --git a/gcc/rust/hir/rust-ast-lower-stmt.h b/gcc/rust/hir/rust-ast-lower-stmt.h index 60ba1f4..afd4dca 100644 --- a/gcc/rust/hir/rust-ast-lower-stmt.h +++ b/gcc/rust/hir/rust-ast-lower-stmt.h @@ -31,8 +31,7 @@ class ASTLoweringStmt : public ASTLoweringBase public: static HIR::Stmt *translate (AST::Stmt *stmt, bool *terminated); - void visit (AST::ExprStmtWithBlock &stmt) override; - void visit (AST::ExprStmtWithoutBlock &stmt) override; + void visit (AST::ExprStmt &stmt) override; void visit (AST::ConstantItem &constant) override; void visit (AST::LetStmt &stmt) override; void visit (AST::TupleStruct &struct_decl) override; |