summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-09-03 12:44:10 +0800
committerJohn Hodge <tpg@mutabah.net>2016-09-03 12:44:10 +0800
commit4e3402d25141e55faa2b6e733817b7c770c45e7d (patch)
tree93a03ea53bcc12da183863fe203a6abb42517696 /src
parentdf7bfa80c3cc6f290297b084850c4c56a02a8393 (diff)
downloadmrust-4e3402d25141e55faa2b6e733817b7c770c45e7d.tar.gz
HIR Const Eval - More structure to MIR execution support
Diffstat (limited to 'src')
-rw-r--r--src/hir_conv/constant_evaluation.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/hir_conv/constant_evaluation.cpp b/src/hir_conv/constant_evaluation.cpp
index ff03fee4..c379ae0c 100644
--- a/src/hir_conv/constant_evaluation.cpp
+++ b/src/hir_conv/constant_evaluation.cpp
@@ -605,6 +605,8 @@ namespace {
::HIR::Literal retval;
::std::vector< ::HIR::Literal> locals;
::std::vector< ::HIR::Literal> temps;
+ locals.resize( fcn.named_variables.size() );
+ temps.resize( fcn.temporaries.size() );
auto get_lval = [&](const ::MIR::LValue& lv) -> ::HIR::Literal& {
TU_MATCHA( (lv), (e),
@@ -648,6 +650,12 @@ namespace {
(
return mv$(v);
),
+ (Invalid,
+ BUG(sp, "Read of invalid lvalue - " << lv);
+ ),
+ (BorrowOf,
+ return ::HIR::Literal(e.clone());
+ ),
(Integer,
return ::HIR::Literal(e);
),
@@ -664,7 +672,7 @@ namespace {
for(const auto& stmt : block.statements)
{
if( ! stmt.is_Assign() ) {
- BUG(sp, "");
+ BUG(sp, "Non-assign statement - drop " << stmt.as_Drop().slot);
}
::HIR::Literal val;
@@ -697,7 +705,7 @@ namespace {
TODO(sp, "Constant::Const - " << e);
),
(ItemAddr,
- TODO(sp, "Constant::ItemAddr - " << e);
+ val = ::HIR::Literal::make_BorrowOf( e2.clone() );
)
)
),
@@ -753,6 +761,9 @@ namespace {
val = ::HIR::Literal::make_List( mv$(vals) );
)
)
+
+ auto& dst = get_lval(sa.dst);
+ dst = mv$(val);
}
TU_MATCH_DEF( ::MIR::Terminator, (block.terminator), (e),
(
@@ -765,7 +776,13 @@ namespace {
return retval;
),
(Call,
- TODO(sp, "Execute MIR - call function");
+ //auto& dst = get_lval(e.ret_val);
+ auto fcn = read_lval(e.fcn_val);
+ if( ! fcn.is_BorrowOf() ) {
+ BUG(sp, "Execute MIR - Calling function through invalid value - " << fcn);
+ }
+ const auto& fcnp = fcn.as_BorrowOf();
+ TODO(sp, "Execute MIR - call function " << fcnp);
)
)
}