aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-12-16 10:56:13 +0000
committerPhilip Herron <philip.herron@embecosm.com>2021-12-16 14:29:08 +0000
commit45edfc2b265cffab529d2cd70b37af559bd02c21 (patch)
treee8f01a8d974b5f2e05999b8e580f2df471ef3bf9 /gcc/rust/hir
parentde1ed2e805cc7de7ab29b5e183354bae86173669 (diff)
downloadgcc-45edfc2b265cffab529d2cd70b37af559bd02c21.zip
gcc-45edfc2b265cffab529d2cd70b37af559bd02c21.tar.gz
gcc-45edfc2b265cffab529d2cd70b37af559bd02c21.tar.bz2
Add typechecking for match-expr
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/tree/rust-hir-expr.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h
index 0e5d97b..e50e210 100644
--- a/gcc/rust/hir/tree/rust-hir-expr.h
+++ b/gcc/rust/hir/tree/rust-hir-expr.h
@@ -3614,15 +3614,9 @@ struct MatchArm
{
private:
AST::AttrVec outer_attrs;
- // MatchArmPatterns patterns;
- std::vector<std::unique_ptr<Pattern> > match_arm_patterns; // inlined
-
- // bool has_match_arm_guard;
- // inlined from MatchArmGuard
+ std::vector<std::unique_ptr<Pattern> > match_arm_patterns;
std::unique_ptr<Expr> guard_expr;
- // TODO: should this store location data?
-
public:
// Returns whether the MatchArm has a match arm guard expression
bool has_match_arm_guard () const { return guard_expr != nullptr; }
@@ -3679,6 +3673,11 @@ public:
}
std::string as_string () const;
+
+ std::vector<std::unique_ptr<Pattern> > &get_patterns ()
+ {
+ return match_arm_patterns;
+ }
};
/* A "match case" - a correlated match arm and resulting expression. Not
@@ -3718,6 +3717,9 @@ public:
std::string as_string () const;
Analysis::NodeMapping get_mappings () const { return mappings; }
+
+ MatchArm &get_arm () { return arm; }
+ std::unique_ptr<Expr> &get_expr () { return expr; }
};
#if 0
@@ -3868,6 +3870,15 @@ public:
void accept_vis (HIRVisitor &vis) override;
+ std::unique_ptr<Expr> &get_scrutinee_expr ()
+ {
+ rust_assert (branch_value != nullptr);
+ return branch_value;
+ }
+
+ const std::vector<MatchCase> &get_match_cases () const { return match_arms; }
+ std::vector<MatchCase> &get_match_cases () { return match_arms; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */