diff options
| author | gingerBill <bill@gingerbill.org> | 2018-05-12 17:39:04 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-05-12 17:39:04 +0100 |
| commit | 830f4f540fdbe30b22e93540249e61c1d1521f9b (patch) | |
| tree | c48704a31f31efdbe7645d02f86430b025079a82 /src/ir.cpp | |
| parent | 56ff5496bc81ca2ccce00f46d9477c6d559ee5b0 (diff) | |
`typeid`
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index f4f795e6d..c5061b38e 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4203,6 +4203,13 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv return ir_type_info(proc, t); } + case BuiltinProc_typeid_of: { + Type *t = default_type(type_of_expr(proc->module->info, ce->args[0])); + i32 entry_index = cast(i32)ir_type_info_index(proc->module->info, t); + GB_ASSERT(entry_index >= 0); + return ir_value_constant(proc->module->allocator, t_typeid, exact_value_i64(entry_index)); + } + case BuiltinProc_len: { irValue *v = ir_build_expr(proc, ce->args[0]); Type *t = base_type(ir_type(v)); @@ -7951,6 +7958,10 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info case Basic_any: tag = ir_emit_conv(proc, variant_ptr, t_type_info_any_ptr); break; + + case Basic_typeid: + tag = ir_emit_conv(proc, variant_ptr, t_type_info_typeid_ptr); + break; } break; |