aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-pattern.h
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-01-27 11:47:30 -0500
committerArthur Cohen <arthur.cohen@embecosm.com>2023-04-06 10:47:18 +0200
commitad9d75f50804a983a06e2fdf69772188432359ae (patch)
treeac8e69147406e82df0e631236acce6376545e66b /gcc/rust/backend/rust-compile-pattern.h
parent51b607c22278fd9c17fc174accd89a22c41fcf2e (diff)
downloadgcc-ad9d75f50804a983a06e2fdf69772188432359ae.zip
gcc-ad9d75f50804a983a06e2fdf69772188432359ae.tar.gz
gcc-ad9d75f50804a983a06e2fdf69772188432359ae.tar.bz2
gccrs: Create and use CompilePatternLet visitor for compiling let statments
gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc (CompilePatternLet::visit): New function. * backend/rust-compile-stmt.cc (CompileStmt::visit): Likewise. * backend/rust-compile-pattern.h (class CompilePatternLet): New visitor. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-pattern.h')
-rw-r--r--gcc/rust/backend/rust-compile-pattern.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-pattern.h b/gcc/rust/backend/rust-compile-pattern.h
index 43334af..317a345 100644
--- a/gcc/rust/backend/rust-compile-pattern.h
+++ b/gcc/rust/backend/rust-compile-pattern.h
@@ -91,5 +91,92 @@ protected:
tree match_scrutinee_expr;
};
+class CompilePatternLet : public HIRCompileBase, public HIR::HIRPatternVisitor
+{
+public:
+ static void Compile (HIR::Pattern *pattern, tree init_expr,
+ TyTy::BaseType *ty, Location rval_locus, Context *ctx)
+ {
+ CompilePatternLet compiler (ctx, init_expr, ty, rval_locus);
+ pattern->accept_vis (compiler);
+ }
+
+ void visit (HIR::IdentifierPattern &) override;
+ void visit (HIR::WildcardPattern &) override;
+
+ // check for unimplemented Pattern HIR nodes.
+ void visit (HIR::GroupedPattern &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "grouped pattern let statements not supported");
+ }
+
+ void visit (HIR::LiteralPattern &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "literal pattern let statements not supported");
+ }
+
+ void visit (HIR::PathInExpression &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "path-in-expression pattern let statements not supported");
+ }
+
+ void visit (HIR::QualifiedPathInExpression &pattern) override
+ {
+ rust_sorry_at (
+ pattern.get_locus (),
+ "qualified-path-in-expression pattern let statements not supported");
+ }
+
+ void visit (HIR::RangePattern &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "range pattern let statements not supported");
+ }
+
+ void visit (HIR::ReferencePattern &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "reference pattern let statements not supported");
+ }
+
+ void visit (HIR::SlicePattern &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "slice pattern let statements not supported");
+ }
+
+ void visit (HIR::StructPattern &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "struct pattern let statements not supported");
+ }
+
+ void visit (HIR::TuplePattern &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "tuple pattern let statements not supported");
+ }
+
+ void visit (HIR::TupleStructPattern &pattern) override
+ {
+ rust_sorry_at (pattern.get_locus (),
+ "tuple-struct pattern let statements not supported");
+ }
+
+protected:
+ CompilePatternLet (Context *ctx, tree init_expr, TyTy::BaseType *ty,
+ Location rval_locus)
+ : HIRCompileBase (ctx), init_expr (init_expr), ty (ty),
+ rval_locus (rval_locus)
+ {}
+
+ tree init_expr;
+ TyTy::BaseType *ty;
+ Location rval_locus;
+};
+
} // namespace Compile
} // namespace Rust