summaryrefslogtreecommitdiff
path: root/src/mir/from_hir_match.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir/from_hir_match.cpp')
-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