diff options
author | John Hodge <tpg@mutabah.net> | 2016-11-05 14:58:52 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-11-05 14:58:52 +0800 |
commit | 85425660cc655b9b71966c5131e692739c04c159 (patch) | |
tree | 59803d457d2e10872fcb951010090614f5fc4bb0 | |
parent | 351957a215675d1a3035971ef4af0601a8cdf47a (diff) | |
download | mrust-85425660cc655b9b71966c5131e692739c04c159.tar.gz |
MIR Gen Match - struct tuples in Simple
-rw-r--r-- | src/mir/from_hir_match.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp index e1e90705..1c4a3486 100644 --- a/src/mir/from_hir_match.cpp +++ b/src/mir/from_hir_match.cpp @@ -1275,7 +1275,23 @@ int MIR_LowerHIR_Match_Simple__GeneratePattern(MirBuilder& builder, const Span& ), (Tuple, if( !rule.is_Any() ) { - TODO(sp, "Match over tuple struct"); + unsigned int total = 0; + unsigned int i = 0; + for( const auto& fld : sd ) { + ::HIR::TypeRef ent_ty_tmp; + const auto& ent_ty = (monomorphise_type_needed(fld.ent) ? ent_ty_tmp = monomorph(fld.ent) : fld.ent); + unsigned int cnt = MIR_LowerHIR_Match_Simple__GeneratePattern( + builder, sp, + rules, num_rules, ent_ty, + ::MIR::LValue::make_Field({ box$(match_val.clone()), i }), + fail_bb + ); + total += cnt; + rules += cnt; + num_rules -= cnt; + i += 1; + } + return total; } return 1; ), |