diff options
| author | Alexandros Naskos <alex_naskos@hotmail.com> | 2018-04-24 11:20:33 +0300 |
|---|---|---|
| committer | Alexandros Naskos <alex_naskos@hotmail.com> | 2018-04-24 11:20:33 +0300 |
| commit | fb88f5a0d21f68632a8c712e14a9640f9c4f6cb3 (patch) | |
| tree | c94e1ac9233e9d615aabd868782a1ddbde0ee828 /src/ir.cpp | |
| parent | 7eab62325b539be4aacb17fd64f5b4445c8409e7 (diff) | |
| download | zig-fb88f5a0d21f68632a8c712e14a9640f9c4f6cb3.tar.gz zig-fb88f5a0d21f68632a8c712e14a9640f9c4f6cb3.zip | |
@typeInfo with void payloads now works!
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 69897f3b91..52136ec9c8 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -15705,11 +15705,32 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira, assert(var_value->type->id == TypeTableEntryIdMetaType); TypeTableEntry *result_type = var_value->data.x_type; - // TODO: Check if we need to explicitely make a &const TypeInfo here, I think we don't. ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); - out_val->data.x_struct.fields = create_const_vals(1); - // TODO: Fill the struct - zig_panic("Building TypeInfo..."); + bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry->id)); + out_val->data.x_union.parent.id = ConstParentIdNone; + + switch (type_entry->id) { + case TypeTableEntryIdInvalid: + zig_unreachable(); + case TypeTableEntryIdMetaType: + case TypeTableEntryIdVoid: + case TypeTableEntryIdBool: + case TypeTableEntryIdUnreachable: + case TypeTableEntryIdNumLitFloat: + case TypeTableEntryIdNumLitInt: + case TypeTableEntryIdUndefLit: + case TypeTableEntryIdNullLit: + case TypeTableEntryIdNamespace: + case TypeTableEntryIdBlock: + case TypeTableEntryIdArgTuple: + case TypeTableEntryIdOpaque: + // TODO: Check out this is the way to handle voids; + out_val->data.x_union.payload = nullptr; + break; + default: + zig_panic("@typeInfo unsupported for %s", buf_ptr(&type_entry->name)); + } + return result_type; } |
