diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-07 21:41:09 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-07 21:41:09 +0800 |
commit | 25c42264a5d84a099ae778d83dd5ac110577cde6 (patch) | |
tree | 6796dbc478eab333058e5fac7886d3da88036589 | |
parent | 067adff6c9847aa948d40880b9a0127b99dac8b5 (diff) | |
download | mrust-25c42264a5d84a099ae778d83dd5ac110577cde6.tar.gz |
MIR Gen Match - (Simple) support array patterns
-rw-r--r-- | src/mir/from_hir_match.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp index 2cdcc288..756e5ef5 100644 --- a/src/mir/from_hir_match.cpp +++ b/src/mir/from_hir_match.cpp @@ -557,7 +557,21 @@ int MIR_LowerHIR_Match_Simple__GeneratePattern(MirBuilder& builder, const Span& ), (Array, if( !rule.is_Any() ) { - TODO(sp, "Match over Array"); + unsigned int total = 0; + for( unsigned int i = 0; i < te.size_val; i ++ ) { + unsigned int cnt = MIR_LowerHIR_Match_Simple__GeneratePattern( + builder, sp, + rules, num_rules, *te.inner, + ::MIR::LValue::make_Field({ box$(match_val.clone()), i }), + fail_bb + ); + total += cnt; + rules += cnt; + num_rules -= cnt; + if( num_rules == 0 ) + return total; + } + return total; } return 1; ), |