From: Philip Herron <philip.herron@embecosm.com>
gcc/rust/ChangeLog:
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::ASTLoweringPattern):
Improve formatting.
(ASTLoweringPattern::translate): Likewise.
* hir/rust-ast-lower-pattern.h: Likewise.
* resolve/rust-ast-resolve-expr.h: Likewise.
---
gcc/rust/hir/rust-ast-lower-pattern.cc | 18 ++++++++++
gcc/rust/hir/rust-ast-lower-pattern.h | 24 ++-----------
gcc/rust/resolve/rust-ast-resolve-expr.h | 43 ------------------------
3 files changed, 20 insertions(+), 65 deletions(-)
@@ -22,6 +22,24 @@
namespace Rust {
namespace HIR {
+ASTLoweringPattern::ASTLoweringPattern () : translated (nullptr) {}
+
+HIR::Pattern *
+ASTLoweringPattern::translate (AST::Pattern *pattern)
+{
+ ASTLoweringPattern resolver;
+ pattern->accept_vis (resolver);
+
+ rust_assert (resolver.translated != nullptr);
+
+ resolver.mappings->insert_hir_pattern (resolver.translated);
+ resolver.mappings->insert_location (
+ resolver.translated->get_pattern_mappings ().get_hirid (),
+ pattern->get_locus ());
+
+ return resolver.translated;
+}
+
void
ASTLoweringPattern::visit (AST::IdentifierPattern &pattern)
{
@@ -29,39 +29,19 @@ class ASTLoweringPattern : public ASTLoweringBase
using Rust::HIR::ASTLoweringBase::visit;
public:
- static HIR::Pattern *translate (AST::Pattern *pattern)
- {
- ASTLoweringPattern resolver;
- pattern->accept_vis (resolver);
-
- rust_assert (resolver.translated != nullptr);
-
- resolver.mappings->insert_hir_pattern (resolver.translated);
- resolver.mappings->insert_location (
- resolver.translated->get_pattern_mappings ().get_hirid (),
- pattern->get_locus ());
-
- return resolver.translated;
- }
+ static HIR::Pattern *translate (AST::Pattern *pattern);
void visit (AST::IdentifierPattern &pattern) override;
-
void visit (AST::PathInExpression &pattern) override;
-
void visit (AST::StructPattern &pattern) override;
-
void visit (AST::TupleStructPattern &pattern) override;
-
void visit (AST::WildcardPattern &pattern) override;
-
void visit (AST::TuplePattern &pattern) override;
-
void visit (AST::LiteralPattern &pattern) override;
-
void visit (AST::RangePattern &pattern) override;
private:
- ASTLoweringPattern () : translated (nullptr) {}
+ ASTLoweringPattern ();
HIR::Pattern *translated;
};
@@ -34,89 +34,46 @@ public:
const CanonicalPath &canonical_prefix);
void visit (AST::TupleIndexExpr &expr) override;
-
void visit (AST::TupleExpr &expr) override;
-
void visit (AST::PathInExpression &expr) override;
-
void visit (AST::QualifiedPathInExpression &expr) override;
-
void visit (AST::ReturnExpr &expr) override;
-
void visit (AST::CallExpr &expr) override;
-
void visit (AST::MethodCallExpr &expr) override;
-
void visit (AST::AssignmentExpr &expr) override;
-
void visit (AST::IdentifierExpr &expr) override;
-
void visit (AST::ArithmeticOrLogicalExpr &expr) override;
-
void visit (AST::CompoundAssignmentExpr &expr) override;
-
void visit (AST::ComparisonExpr &expr) override;
-
void visit (AST::LazyBooleanExpr &expr) override;
-
void visit (AST::NegationExpr &expr) override;
-
void visit (AST::TypeCastExpr &expr) override;
-
void visit (AST::IfExpr &expr) override;
-
void visit (AST::IfExprConseqElse &expr) override;
-
void visit (AST::IfExprConseqIf &expr) override;
-
void visit (AST::IfLetExpr &expr) override;
-
void visit (AST::BlockExpr &expr) override;
-
void visit (AST::UnsafeBlockExpr &expr) override;
-
void visit (AST::ArrayElemsValues &elems) override;
-
void visit (AST::ArrayExpr &expr) override;
-
void visit (AST::ArrayIndexExpr &expr) override;
-
void visit (AST::ArrayElemsCopied &elems) override;
-
- // this this an empty struct constructor like 'S {}'
void visit (AST::StructExprStruct &struct_expr) override;
-
- // this this a struct constructor with fields
void visit (AST::StructExprStructFields &struct_expr) override;
-
void visit (AST::GroupedExpr &expr) override;
-
void visit (AST::FieldAccessExpr &expr) override;
-
void visit (AST::LoopExpr &expr) override;
-
void visit (AST::BreakExpr &expr) override;
-
void visit (AST::WhileLoopExpr &expr) override;
-
void visit (AST::ForLoopExpr &expr) override;
-
void visit (AST::ContinueExpr &expr) override;
-
void visit (AST::BorrowExpr &expr) override;
-
void visit (AST::DereferenceExpr &expr) override;
-
void visit (AST::MatchExpr &expr) override;
-
void visit (AST::RangeFromToExpr &expr) override;
-
void visit (AST::RangeFromExpr &expr) override;
-
void visit (AST::RangeToExpr &expr) override;
-
void visit (AST::RangeFullExpr &expr) override;
-
void visit (AST::RangeFromToInclExpr &expr) override;
private: