diff options
author | John Hodge (bugs) <tpg@mutabah.net> | 2017-06-04 21:23:24 +0800 |
---|---|---|
committer | John Hodge (bugs) <tpg@mutabah.net> | 2017-06-04 21:23:24 +0800 |
commit | 83dbb728f62306d2e43b2688dd0f2d320fd5b038 (patch) | |
tree | a064267bdf8d0455ed725140abfcbed3e04b2d4a /src/hir/from_ast.cpp | |
parent | 0b9fd0014c8f32ecf299dae2ad1811dfb484af46 (diff) | |
parent | f19c75571c48588fb3816e8eb5b96f03474fbdf5 (diff) | |
download | mrust-83dbb728f62306d2e43b2688dd0f2d320fd5b038.tar.gz |
Merge branch 'master' of https://github.com/thepowersgang/mrustc
Diffstat (limited to 'src/hir/from_ast.cpp')
-rw-r--r-- | src/hir/from_ast.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index 255546e7..c0a3151e 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -819,18 +819,16 @@ namespace { ::HIR::Struct::Data data; TU_MATCH(::AST::StructData, (ent.m_data), (e), + (Unit, + data = ::HIR::Struct::Data::make_Unit({}); + ), (Tuple, - if( e.ents.size() == 0 ) { - data = ::HIR::Struct::Data::make_Unit({}); - } - else { - ::HIR::Struct::Data::Data_Tuple fields; + ::HIR::Struct::Data::Data_Tuple fields; - for(const auto& field : e.ents) - fields.push_back( { field.m_is_public, LowerHIR_Type(field.m_type) } ); + for(const auto& field : e.ents) + fields.push_back( { field.m_is_public, LowerHIR_Type(field.m_type) } ); - data = ::HIR::Struct::Data::make_Tuple( mv$(fields) ); - } + data = ::HIR::Struct::Data::make_Tuple( mv$(fields) ); ), (Struct, ::HIR::Struct::Data::Data_Named fields; @@ -1218,12 +1216,14 @@ void _add_mod_val_item(::HIR::Module& mod, ::std::string name, bool is_pub, ::H ), (Struct, /// Add value reference - TU_IFLET( ::AST::StructData, e.m_data, Tuple, e2, - if( e2.ents.size() == 0 ) - _add_mod_val_item( mod, item.name, item.is_pub, ::HIR::ValueItem::make_StructConstant({item_path.get_simple_path()}) ); - else - _add_mod_val_item( mod, item.name, item.is_pub, ::HIR::ValueItem::make_StructConstructor({item_path.get_simple_path()}) ); - ) + if( e.m_data.is_Unit() ) { + _add_mod_val_item( mod, item.name, item.is_pub, ::HIR::ValueItem::make_StructConstant({item_path.get_simple_path()}) ); + } + else if( e.m_data.is_Tuple() ) { + _add_mod_val_item( mod, item.name, item.is_pub, ::HIR::ValueItem::make_StructConstructor({item_path.get_simple_path()}) ); + } + else { + } _add_mod_ns_item( mod, item.name, item.is_pub, LowerHIR_Struct(item_path, e) ); ), (Enum, |