diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-13 07:34:02 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-13 07:34:02 +0800 |
commit | f6c208f2a2592a0acfb85f997e028f89ef22b7f0 (patch) | |
tree | 57ea1fcf8acd47f08b84da0d5f6dc118a4c303d7 /src | |
parent | 8e8696dc777e9a4c6dae5d739268c32c2ad5707e (diff) | |
download | mrust-f6c208f2a2592a0acfb85f997e028f89ef22b7f0.tar.gz |
Trans C - Create tuple struct constructor functions
Diffstat (limited to 'src')
-rw-r--r-- | src/trans/codegen_c.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index 08874803..6b4f9ab7 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -148,6 +148,26 @@ namespace { ) ) m_of << "};\n"; + TU_IFLET(::HIR::Struct::Data, item.m_data, Tuple, e, + m_of << "struct s_" << Trans_Mangle(p) << " " << Trans_Mangle(p) << "("; + for(unsigned int i = 0; i < e.size(); i ++) + { + if(i != 0) + m_of << ", "; + emit_ctype( monomorph(e[i].ent), FMT_CB(ss, ss << "_" << i;) ); + } + m_of << ") {\n"; + m_of << "\tstruct s_" << Trans_Mangle(p) << " rv = {"; + for(unsigned int i = 0; i < e.size(); i ++) + { + if(i != 0) + m_of << ","; + m_of << "\n\t\t_" << i; + } + m_of << "\n\t\t};\n"; + m_of << "\treturn rv;\n"; + m_of << "}\n"; + ) } //virtual void emit_union(const ::HIR::GenericPath& p, const ::HIR::Union& item); void emit_enum(const Span& sp, const ::HIR::GenericPath& p, const ::HIR::Enum& item) override |