public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Compile literal patterns for match expressions Date: Wed, 8 Jun 2022 12:42:32 +0000 (GMT) [thread overview] Message-ID: <20220608124232.4F605386CE6C@sourceware.org> (raw) https://gcc.gnu.org/g:ca75e756e802ccfff445f7efb4f3b530c6f3891f commit ca75e756e802ccfff445f7efb4f3b530c6f3891f Author: David Faust <david.faust@oracle.com> Date: Tue May 3 12:55:08 2022 -0700 Compile literal patterns for match expressions Diff: --- gcc/rust/backend/rust-compile-pattern.cc | 14 ++++++++++++++ gcc/rust/backend/rust-compile-pattern.h | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/rust/backend/rust-compile-pattern.cc b/gcc/rust/backend/rust-compile-pattern.cc index 393fbd5d517..e8f1c51a1d4 100644 --- a/gcc/rust/backend/rust-compile-pattern.cc +++ b/gcc/rust/backend/rust-compile-pattern.cc @@ -80,6 +80,20 @@ CompilePatternCaseLabelExpr::visit (HIR::WildcardPattern &pattern) = build_case_label (NULL_TREE, NULL_TREE, associated_case_label); } +void +CompilePatternCaseLabelExpr::visit (HIR::LiteralPattern &pattern) +{ + // Compile the literal + HIR::LiteralExpr *litexpr + = new HIR::LiteralExpr (pattern.get_pattern_mappings (), + pattern.get_literal (), pattern.get_locus (), + std::vector<AST::Attribute> ()); + + tree lit = CompileExpr::Compile (litexpr, ctx); + + case_label_expr = build_case_label (lit, NULL_TREE, associated_case_label); +} + // setup the bindings void diff --git a/gcc/rust/backend/rust-compile-pattern.h b/gcc/rust/backend/rust-compile-pattern.h index 5bff317fe98..1b6e80fb88d 100644 --- a/gcc/rust/backend/rust-compile-pattern.h +++ b/gcc/rust/backend/rust-compile-pattern.h @@ -41,7 +41,7 @@ public: // Empty visit for unused Pattern HIR nodes. void visit (HIR::GroupedPattern &) override {} void visit (HIR::IdentifierPattern &) override {} - void visit (HIR::LiteralPattern &) override {} + void visit (HIR::LiteralPattern &) override; void visit (HIR::QualifiedPathInExpression &) override {} void visit (HIR::RangePattern &) override {} void visit (HIR::ReferencePattern &) override {}
reply other threads:[~2022-06-08 12:42 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220608124232.4F605386CE6C@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).