diff options
author | John Hodge <tpg@mutabah.net> | 2018-02-11 13:59:31 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2018-02-11 13:59:31 +0800 |
commit | aeda962b0b24582ec39c8a866918c9477157e83c (patch) | |
tree | 3f08e351b1316a37e5e2da690a049b2e51b8d4fc | |
parent | 34e5fe1f59e0c4b446cd765464d7bcdaded9433d (diff) | |
download | mrust-aeda962b0b24582ec39c8a866918c9477157e83c.tar.gz |
Codegen C - Fix some minor issues
-rw-r--r-- | src/trans/codegen_c.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index bcf5f20f..6cfbaf3b 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -1232,13 +1232,13 @@ namespace { switch(repr->variants.tag()) { case TypeRepr::VariantMode::TAGDEAD: throw ""; - TU_ARM(repr->variants, Values, ve) + TU_ARM(repr->variants, Values, ve) { m_of << " .TAG = " << ve.values[var_idx] << ","; - break; - TU_ARM(repr->variants, NonZero, ve) - break; - TU_ARM(repr->variants, None, ve) - break; + } break; + TU_ARM(repr->variants, NonZero, ve) { + } break; + TU_ARM(repr->variants, None, ve) { + } break; } if( e.empty() ) @@ -3566,7 +3566,7 @@ namespace { } else if( name == "write_bytes" ) { // 0: Destination, 1: Value, 2: Count - m_of << "memset( "; emit_param(e.args.at(0)); + m_of << "if( "; emit_param(e.args.at(2)); m_of << " > 0) memset( "; emit_param(e.args.at(0)); m_of << ", "; emit_param(e.args.at(1)); m_of << ", "; emit_param(e.args.at(2)); m_of << " * sizeof("; emit_ctype(params.m_types.at(0)); m_of << ")"; m_of << ")"; @@ -3685,13 +3685,13 @@ namespace { TU_ARM(repr->variants, None, _e) m_of << "0"; break; - TU_ARM(repr->variants, Values, _e) { - emit_param(e.args.at(0)); m_of << "->TAG"; + TU_ARM(repr->variants, Values, ve) { + m_of << "(*"; emit_param(e.args.at(0)); m_of << ")"; emit_enum_path(repr, ve.field); } break; TU_ARM(repr->variants, NonZero, ve) { - emit_param(e.args.at(0)); emit_enum_path(repr, ve.field); m_of << " "; + m_of << "(*"; emit_param(e.args.at(0)); m_of << ")"; emit_enum_path(repr, ve.field); m_of << " "; m_of << (ve.zero_variant ? "==" : "!="); - m_of << "0"; + m_of << " 0"; } break; } } |