aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-12-17 17:36:59 +0000
committergingerBill <bill@gingerbill.org>2020-12-17 17:36:59 +0000
commit3558848da818dc330d139ff5d756bb9b9498b1d4 (patch)
treee610f06a230cca9d89bf075ec55e520dae83ad8e /src/ir.cpp
parent720f2c7c61ddfc79deba2bb29b3727b50314cafb (diff)
Fix ir_print.cpp for typeid constants
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index f69b25494..90cce3699 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -1638,6 +1638,7 @@ irValue *ir_check_compound_lit_constant(irModule *m, Ast *expr) {
if (expr == nullptr) {
return nullptr;
}
+
if (expr->kind == Ast_CompoundLit) {
ast_node(cl, CompoundLit, expr);
for_array(i, cl->elems) {
@@ -1661,6 +1662,7 @@ irValue *ir_check_compound_lit_constant(irModule *m, Ast *expr) {
}
}
+
return nullptr;
}
@@ -6743,7 +6745,10 @@ irValue *ir_type_info(irProcedure *proc, Type *type) {
return ir_emit_array_ep(proc, ir_global_type_info_data, ir_const_i32(id));
}
-irValue *ir_typeid(irModule *m, Type *type) {
+u64 ir_typeid_as_integer(irModule *m, Type *type) {
+ if (type == nullptr) {
+ return 0;
+ }
type = default_type(type);
u64 id = cast(u64)ir_type_info_index(m->info, type);
@@ -6808,8 +6813,11 @@ irValue *ir_typeid(irModule *m, Type *type) {
data |= (reserved &~ (1ull<<1)) << 63ull; // kind
}
+ return id;
+}
- return ir_value_constant(t_typeid, exact_value_u64(data));
+irValue *ir_typeid(irModule *m, Type *type) {
+ return ir_value_constant(t_typeid, exact_value_u64(ir_typeid_as_integer(m, type)));
}