summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-07-14 17:53:53 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-07-14 17:53:53 +0800
commit0d5fe417e6ff1806987f77c97b0841b0b600cde0 (patch)
treebf8ee10c655858254e7905ef943178988f7bc50a /src
parentbee6b04dc12e50a33eb382b2c12276b91ae32493 (diff)
downloadmrust-0d5fe417e6ff1806987f77c97b0841b0b600cde0.tar.gz
standalone_miri - Fix after MIR refactor
Diffstat (limited to 'src')
-rw-r--r--src/trans/codegen_mmir.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/trans/codegen_mmir.cpp b/src/trans/codegen_mmir.cpp
index 76d79e93..a86eadc9 100644
--- a/src/trans/codegen_mmir.cpp
+++ b/src/trans/codegen_mmir.cpp
@@ -31,6 +31,12 @@ namespace
::std::ostream& operator<<(::std::ostream& os, const Fmt<::MIR::LValue>& x)
{
+ for(const auto& w : ::reverse(x.e.m_wrappers))
+ {
+ if( w.is_Deref() ) {
+ os << "(*";
+ }
+ }
TU_MATCHA( (x.e.m_root), (e),
(Return,
os << "RETURN";
@@ -52,7 +58,7 @@ namespace
switch(w.tag())
{
TU_ARM(w, Deref, e)
- os << "*";
+ os << ")";
break;
TU_ARM(w, Field, field_index) {
// Add a space to prevent accidental float literals
@@ -62,7 +68,7 @@ namespace
was_num = true;
} break;
TU_ARM(w, Index, e) {
- os << "[var" << fmt(::MIR::LValue::new_Local(e)) << "]";
+ os << "[" << fmt(::MIR::LValue::new_Local(e)) << "]";
} break;
TU_ARM(w, Downcast, variant_index) {
os << "@" << variant_index;
@@ -147,12 +153,12 @@ namespace
CodeGenerator_MonoMir(const ::HIR::Crate& crate, const ::std::string& outfile):
m_crate(crate),
m_resolve(crate),
- m_outfile_path(outfile + ".mir"),
- m_of(m_outfile_path)
+ m_outfile_path(outfile),
+ m_of(m_outfile_path + ".mir")
{
for( const auto& crate : m_crate.m_ext_crates )
{
- m_of << "crate \"" << FmtEscaped(crate.second.m_path) << ".o.mir\";\n";
+ m_of << "crate \"" << FmtEscaped(crate.second.m_path) << ".mir\";\n";
}
}
@@ -183,6 +189,15 @@ namespace
m_of.flush();
m_of.close();
+
+ // HACK! Create the output file, but keep it empty
+ {
+ ::std::ofstream of( m_outfile_path );
+ if( !of.good() )
+ {
+ // TODO: Error?
+ }
+ }
}
@@ -1108,8 +1123,8 @@ namespace
case ::MIR::eBinOp::SUB_OV: m_of << "-^"; break;
case ::MIR::eBinOp::MUL: m_of << "*"; break;
case ::MIR::eBinOp::MUL_OV: m_of << "*^"; break;
- case ::MIR::eBinOp::DIV: m_of << "*"; break;
- case ::MIR::eBinOp::DIV_OV: m_of << "*^"; break;
+ case ::MIR::eBinOp::DIV: m_of << "/"; break;
+ case ::MIR::eBinOp::DIV_OV: m_of << "/^"; break;
case ::MIR::eBinOp::MOD: m_of << "%"; break;
case ::MIR::eBinOp::BIT_OR: m_of << "|"; break;
case ::MIR::eBinOp::BIT_AND:m_of << "&"; break;