summaryrefslogtreecommitdiff
path: root/src/mir/from_hir.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-11 12:57:31 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-11 12:57:31 +0800
commit700863e90b9a6b648b007d2bc9e46f724d47ddab (patch)
treef5cb46cce1b973ec330f58fbc9c0cce2fb921f7e /src/mir/from_hir.cpp
parent1ecde512a0757c0e5dd3bce6c267d76a757bd4e9 (diff)
downloadmrust-700863e90b9a6b648b007d2bc9e46f724d47ddab.tar.gz
MIR - Cleanup of match
Diffstat (limited to 'src/mir/from_hir.cpp')
-rw-r--r--src/mir/from_hir.cpp57
1 files changed, 33 insertions, 24 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index b2858946..b9ecbe39 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -269,6 +269,20 @@ namespace {
)
}
+ friend ::std::ostream& operator<<(::std::ostream& os, const Branch& x) {
+ TU_MATCHA( (x), (be),
+ (Unset,
+ os << "!";
+ ),
+ (Terminal,
+ os << "ARM " << be;
+ ),
+ (Subtree,
+ os << *be;
+ )
+ )
+ return os;
+ }
friend ::std::ostream& operator<<(::std::ostream& os, const DecisionTreeNode& x) {
os << "DTN { ";
TU_MATCHA( (x.m_branches), (e),
@@ -277,32 +291,12 @@ namespace {
),
(Variant,
for(const auto& branch : e) {
- TU_MATCHA( (branch.second), (be),
- (Unset,
- os << branch.first << " = !, ";
- ),
- (Terminal,
- os << branch.first << " = ARM " << be << ", ";
- ),
- (Subtree,
- os << branch.first << " = " << *be << ", ";
- )
- )
+ os << branch.first << " = " << branch.second << ", ";
}
)
)
- TU_MATCHA( (x.m_default), (be),
- (Unset,
- os << "* = !";
- ),
- (Terminal,
- os << "* = ARM " << be;
- ),
- (Subtree,
- os << "* = " << *be;
- )
- )
+ os << "* = " << x.m_default;
os << " }";
return os;
}
@@ -365,7 +359,8 @@ namespace {
TU_IFLET(Branch, b, Subtree, be,
be->simplify();
if( be->m_branches.is_Unset() ) {
- b = mv$( be->m_default );
+ auto v = mv$( be->m_default );
+ b = mv$(v);
}
)
}
@@ -953,7 +948,7 @@ namespace {
::std::function<void(const DecisionTreeNode&)> and_then
)
{
- TRACE_FUNCTION_F("ty=" << ty << ", ty_ofs=" << ty_ofs);
+ TRACE_FUNCTION_F("ty=" << ty << ", ty_ofs=" << ty_ofs << ", node=" << node);
TU_MATCHA( (ty.m_data), (e),
(Infer, BUG(sp, "Ivar for in match type"); ),
@@ -1031,6 +1026,7 @@ namespace {
{
auto bb = variant_blocks[branch.first];
const auto& var = variants[branch.first];
+ DEBUG(branch.first << " " << var.first << " = " << branch);
m_builder.set_cur_block(bb);
if( branch.second.is_Terminal() ) {
@@ -1063,6 +1059,19 @@ namespace {
)
}
}
+
+ DEBUG("_");
+ TU_MATCHA( (node.m_default), (be),
+ (Unset, ),
+ (Terminal,
+ m_builder.set_cur_block(any_block);
+ m_builder.end_block( ::MIR::Terminator::make_Goto( this->get_block_for_rule( be ) ) );
+ ),
+ (Subtree,
+ m_builder.set_cur_block(any_block);
+ and_then( *be );
+ )
+ )
)
)
),