aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-02-28 17:34:31 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:19:00 +0100
commit4516631ae20f9dfc8cb7b795dedda85ab11a0db8 (patch)
tree7141b58edcd10b85e6b1a26dfe5af0ed4fdc5fed /gcc/rust/ast
parent4c77c7ac0f2ad11e48a32d7a98b3ca1005df8678 (diff)
downloadgcc-4516631ae20f9dfc8cb7b795dedda85ab11a0db8.zip
gcc-4516631ae20f9dfc8cb7b795dedda85ab11a0db8.tar.gz
gcc-4516631ae20f9dfc8cb7b795dedda85ab11a0db8.tar.bz2
gccrs: ast: Add RestPattern AST node
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>
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r--gcc/rust/ast/rust-ast-dump.cc4
-rw-r--r--gcc/rust/ast/rust-ast-dump.h1
-rw-r--r--gcc/rust/ast/rust-ast-full-decls.h1
-rw-r--r--gcc/rust/ast/rust-ast-visitor.h1
-rw-r--r--gcc/rust/ast/rust-ast.cc6
-rw-r--r--gcc/rust/ast/rust-pattern.h14
6 files changed, 27 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index 97056c6..f619108 100644
--- a/gcc/rust/ast/rust-ast-dump.cc
+++ b/gcc/rust/ast/rust-ast-dump.cc
@@ -1610,6 +1610,10 @@ void
Dump::visit (WildcardPattern &)
{}
+void
+Dump::visit (RestPattern &)
+{}
+
// void Dump::visit(RangePatternBound& ){}
void
diff --git a/gcc/rust/ast/rust-ast-dump.h b/gcc/rust/ast/rust-ast-dump.h
index a6adab9..50c9e91 100644
--- a/gcc/rust/ast/rust-ast-dump.h
+++ b/gcc/rust/ast/rust-ast-dump.h
@@ -273,6 +273,7 @@ private:
void visit (LiteralPattern &pattern);
void visit (IdentifierPattern &pattern);
void visit (WildcardPattern &pattern);
+ void visit (RestPattern &pattern);
// void visit(RangePatternBound& bound);
void visit (RangePatternBoundLiteral &bound);
void visit (RangePatternBoundPath &bound);
diff --git a/gcc/rust/ast/rust-ast-full-decls.h b/gcc/rust/ast/rust-ast-full-decls.h
index 352c1b9..5a85646 100644
--- a/gcc/rust/ast/rust-ast-full-decls.h
+++ b/gcc/rust/ast/rust-ast-full-decls.h
@@ -228,6 +228,7 @@ class MetaListNameValueStr;
class LiteralPattern;
class IdentifierPattern;
class WildcardPattern;
+class RestPattern;
class RangePatternBound;
class RangePatternBoundLiteral;
class RangePatternBoundPath;
diff --git a/gcc/rust/ast/rust-ast-visitor.h b/gcc/rust/ast/rust-ast-visitor.h
index 776e1e2..6990d61 100644
--- a/gcc/rust/ast/rust-ast-visitor.h
+++ b/gcc/rust/ast/rust-ast-visitor.h
@@ -183,6 +183,7 @@ public:
virtual void visit (LiteralPattern &pattern) = 0;
virtual void visit (IdentifierPattern &pattern) = 0;
virtual void visit (WildcardPattern &pattern) = 0;
+ virtual void visit (RestPattern &pattern) = 0;
// virtual void visit(RangePatternBound& bound) = 0;
virtual void visit (RangePatternBoundLiteral &bound) = 0;
virtual void visit (RangePatternBoundPath &bound) = 0;
diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index 13d31cf..6572a3e 100644
--- a/gcc/rust/ast/rust-ast.cc
+++ b/gcc/rust/ast/rust-ast.cc
@@ -5575,6 +5575,12 @@ WildcardPattern::accept_vis (ASTVisitor &vis)
}
void
+RestPattern::accept_vis (ASTVisitor &vis)
+{
+ vis.visit (*this);
+}
+
+void
RangePatternBoundLiteral::accept_vis (ASTVisitor &vis)
{
vis.visit (*this);
diff --git a/gcc/rust/ast/rust-pattern.h b/gcc/rust/ast/rust-pattern.h
index 1fcd818..0f6cf8f 100644
--- a/gcc/rust/ast/rust-pattern.h
+++ b/gcc/rust/ast/rust-pattern.h
@@ -191,6 +191,20 @@ protected:
}
};
+class RestPattern : public Pattern
+{
+ Location locus;
+
+public:
+ std::string as_string () const override { return ".."; }
+
+ RestPattern (Location locus) : locus (locus) {}
+
+ Location get_locus () const override final { return locus; }
+
+ void accept_vis (ASTVisitor &vis) override;
+};
+
// Base range pattern bound (lower or upper limit) - abstract
class RangePatternBound
{