authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2018-04-24 11:20:33+03:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2018-04-24 11:20:33+03:00
logfb88f5a0d21f68632a8c712e14a9640f9c4f6cb3
treec94e1ac9233e9d615aabd868782a1ddbde0ee828
parent7eab62325b539be4aacb17fd64f5b4445c8409e7

@typeInfo with void payloads now works!


1 files changed, 25 insertions(+), 4 deletions(-)

src/ir.cpp+25-4
...@@ -15705,11 +15705,32 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira,...@@ -15705,11 +15705,32 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira,
15705 assert(var_value->type->id == TypeTableEntryIdMetaType);15705 assert(var_value->type->id == TypeTableEntryIdMetaType);
15706 TypeTableEntry *result_type = var_value->data.x_type;15706 TypeTableEntry *result_type = var_value->data.x_type;
1570715707
15708 // TODO: Check if we need to explicitely make a &const TypeInfo here, I think we don't.
15709 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);15708 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
15710 out_val->data.x_struct.fields = create_const_vals(1);15709 bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry->id));
15711 // TODO: Fill the struct15710 out_val->data.x_union.parent.id = ConstParentIdNone;
15712 zig_panic("Building TypeInfo...");15711
15712 switch (type_entry->id) {
15713 case TypeTableEntryIdInvalid:
15714 zig_unreachable();
15715 case TypeTableEntryIdMetaType:
15716 case TypeTableEntryIdVoid:
15717 case TypeTableEntryIdBool:
15718 case TypeTableEntryIdUnreachable:
15719 case TypeTableEntryIdNumLitFloat:
15720 case TypeTableEntryIdNumLitInt:
15721 case TypeTableEntryIdUndefLit:
15722 case TypeTableEntryIdNullLit:
15723 case TypeTableEntryIdNamespace:
15724 case TypeTableEntryIdBlock:
15725 case TypeTableEntryIdArgTuple:
15726 case TypeTableEntryIdOpaque:
15727 // TODO: Check out this is the way to handle voids;
15728 out_val->data.x_union.payload = nullptr;
15729 break;
15730 default:
15731 zig_panic("@typeInfo unsupported for %s", buf_ptr(&type_entry->name));
15732 }
15733
15713 return result_type;15734 return result_type;
15714}15735}
1571515736