From c4e63ec4901e5083e78cb8a2c0839a4040fa041a Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 24 Aug 2016 18:35:33 +0800 Subject: MIR Gen - Handle StructConstant and StructConstructor items --- src/mir/from_hir.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp index 07fb2ade..ede4ba88 100644 --- a/src/mir/from_hir.cpp +++ b/src/mir/from_hir.cpp @@ -1193,7 +1193,11 @@ namespace { m_builder.set_result( node.span(), ::MIR::LValue::make_Static(node.m_path.clone()) ); ), (StructConstant, - BUG(sp, "StructConstant as PathValue"); + // TODO: Why is this still a PathValue? + m_builder.set_result( node.span(), ::MIR::RValue::make_Struct({ + pe.clone(), + {} + }) ); ), (Function, // TODO: Obtain function type for this function (i.e. a type that is specifically for this function) @@ -1213,7 +1217,10 @@ namespace { m_builder.set_result( sp, mv$(tmp) ); ), (StructConstructor, - BUG(sp, "StructConstructor as PathValue"); + // TODO: Ideally, the creation of the wrapper function would happen somewhere before this? + auto tmp = m_builder.new_temporary( node.m_res_type ); + m_builder.push_stmt_assign( sp, tmp.clone(), ::MIR::Constant::make_ItemAddr(node.m_path.clone()) ); + m_builder.set_result( sp, mv$(tmp) ); ) ) ), -- cgit v1.2.3