diff options
author | David Faust <david.faust@oracle.com> | 2022-05-03 12:55:08 -0700 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2022-05-03 12:55:08 -0700 |
commit | ca75e756e802ccfff445f7efb4f3b530c6f3891f (patch) | |
tree | bab52b60cf8bf9cc2fd99cbbe6bd7b128977b73b /gcc/rust/backend/rust-compile-pattern.cc | |
parent | ca722fe423bdd8c7895a40aac0410b2646917805 (diff) | |
download | gcc-ca75e756e802ccfff445f7efb4f3b530c6f3891f.zip gcc-ca75e756e802ccfff445f7efb4f3b530c6f3891f.tar.gz gcc-ca75e756e802ccfff445f7efb4f3b530c6f3891f.tar.bz2 |
Compile literal patterns for match expressions
Diffstat (limited to 'gcc/rust/backend/rust-compile-pattern.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-pattern.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-pattern.cc b/gcc/rust/backend/rust-compile-pattern.cc index 393fbd5..e8f1c51 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 |