diff options
author | John Hodge <tpg@mutabah.net> | 2017-01-01 16:44:10 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-01-01 16:44:10 +0800 |
commit | fa59ba5317f83d7bbb38aa7668360fa7e2bad7fc (patch) | |
tree | b2f10d78b906026533e09f7cb55ac813345fa2ff /src/trans/codegen_c.cpp | |
parent | 57d08b51b8f0a9aa87953feaef43530ff861c91b (diff) | |
download | mrust-fa59ba5317f83d7bbb38aa7668360fa7e2bad7fc.tar.gz |
Trans - Support forward declaration of types
Diffstat (limited to 'src/trans/codegen_c.cpp')
-rw-r--r-- | src/trans/codegen_c.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index 7bdce493..b73b4d37 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -73,6 +73,40 @@ namespace { << "}\n"; } + void emit_type_proto(const ::HIR::TypeRef& ty) override + { + TRACE_FUNCTION_F(ty); + TU_IFLET( ::HIR::TypeRef::Data, ty.m_data, Tuple, te, + // TODO: Pre-define tuple name + ) + else TU_IFLET( ::HIR::TypeRef::Data, ty.m_data, Function, te, + // TODO: Pre-define function type name + ) + else TU_IFLET( ::HIR::TypeRef::Data, ty.m_data, Array, te, + // TODO: Pre-define array type name + ) + else TU_IFLET( ::HIR::TypeRef::Data, ty.m_data, Path, te, + TU_MATCHA( (te.binding), (tpb), + (Unbound, throw ""; ), + (Opaque, throw ""; ), + (Struct, + m_of << "struct s_" << Trans_Mangle(te.path) << ";\n"; + ), + (Union, + m_of << "union u_" << Trans_Mangle(te.path) << ";\n"; + ), + (Enum, + m_of << "struct e_" << Trans_Mangle(te.path) << ";\n"; + ) + ) + ) + else if( ty.m_data.is_ErasedType() ) { + // TODO: Is this actually a bug? + return ; + } + else { + } + } void emit_type(const ::HIR::TypeRef& ty) override { ::MIR::TypeResolve top_mir_res { sp, m_resolve, FMT_CB(ss, ss << "type " << ty;), ::HIR::TypeRef(), {}, *(::MIR::Function*)nullptr }; |