diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-04 22:53:25 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-04 22:53:25 +0800 |
commit | c1287df0fd4ec4346a4e8f470149ae3108c3597c (patch) | |
tree | 318f74c8b79f3c3c869a6e7691fac00465ec440f /src | |
parent | 6430d423e8bc0cca56709221996194bdb8facd51 (diff) | |
download | mrust-c1287df0fd4ec4346a4e8f470149ae3108c3597c.tar.gz |
Trans C - Small fix to handling of arrays
Diffstat (limited to 'src')
-rw-r--r-- | src/trans/codegen_c.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index ee0719ef..8a987399 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -281,7 +281,7 @@ namespace { m_of << "\n"; m_of << "{\n"; // Variables - m_of << "\t"; emit_ctype(params.monomorph(m_crate, item.m_return)); m_of << " rv;\n"; + m_of << "\t"; emit_ctype(params.monomorph(m_crate, item.m_return), FMT_CB(ss, ss << "rv";)); m_of << ";\n"; for(unsigned int i = 0; i < code->named_variables.size(); i ++) { DEBUG("var" << i << " : " << code->named_variables[i]); m_of << "\t"; emit_ctype(code->named_variables[i], FMT_CB(ss, ss << "var" << i;)); m_of << ";"; @@ -602,23 +602,24 @@ namespace { private: void emit_function_header(const ::HIR::Path& p, const ::HIR::Function& item, const Trans_Params& params) { - emit_ctype( params.monomorph(m_crate, item.m_return) ); - m_of << " " << Trans_Mangle(p) << "("; - if( item.m_args.size() == 0 ) - { - m_of << "void)"; - } - else - { - for(unsigned int i = 0; i < item.m_args.size(); i ++) + emit_ctype( params.monomorph(m_crate, item.m_return), FMT_CB(ss, + ss << " " << Trans_Mangle(p) << "("; + if( item.m_args.size() == 0 ) { - if( i != 0 ) m_of << ","; - m_of << "\n\t\t"; - emit_ctype( params.monomorph(m_crate, item.m_args[i].second) ); - m_of << " arg" << i; + ss << "void)"; } - m_of << "\n\t\t)"; - } + else + { + for(unsigned int i = 0; i < item.m_args.size(); i ++) + { + if( i != 0 ) m_of << ","; + ss << "\n\t\t"; + this->emit_ctype( params.monomorph(m_crate, item.m_args[i].second) ); + ss << " arg" << i; + } + ss << "\n\t\t)"; + } + )); } void emit_lvalue(const ::MIR::LValue& val) { TU_MATCHA( (val), (e), |