summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-14 11:54:34 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-14 11:54:34 +0800
commita87760026d161e19375d0c01f9163147442c2cb7 (patch)
treed8a51fae280f29c5d70bc8187f482d6238022b8c /src
parent0e3a06a5ab363980a8362f346ee44876fc163936 (diff)
downloadmrust-a87760026d161e19375d0c01f9163147442c2cb7.tar.gz
MIR Gen Match - Enum struct patterns in _Simple
Diffstat (limited to 'src')
-rw-r--r--src/mir/from_hir_match.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp
index 029f00d9..3ea61cf9 100644
--- a/src/mir/from_hir_match.cpp
+++ b/src/mir/from_hir_match.cpp
@@ -395,7 +395,24 @@ int MIR_LowerHIR_Match_Simple__GeneratePattern(MirBuilder& builder, const Span&
}
),
(Struct,
- TODO(sp, "Enum Struct");
+ auto lval_var = ::MIR::LValue::make_Downcast({ box$(match_val.clone()), var_idx });
+ const auto* subrules = re.sub_rules.data();
+ unsigned int subrule_count = re.sub_rules.size();
+
+ for(unsigned int i = 0; i < ve.size(); i ++)
+ {
+ const auto& tpl_ty = ve[i].second.ent;
+ ::HIR::TypeRef ent_ty_tmp;
+ const auto& ent_ty = (monomorphise_type_needed(tpl_ty) ? ent_ty_tmp = monomorph(tpl_ty) : tpl_ty);
+ unsigned int cnt = MIR_LowerHIR_Match_Simple__GeneratePattern(
+ builder, sp,
+ subrules, subrule_count, ent_ty,
+ ::MIR::LValue::make_Field({ box$(lval_var.clone()), i }),
+ fail_bb
+ );
+ subrules += cnt;
+ subrule_count -= cnt;
+ }
)
)
// NOTE: All enum variant patterns take one slot