mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix ir_print.cpp for typeid constants
This commit is contained in:
+10
-2
@@ -1638,6 +1638,7 @@ irValue *ir_check_compound_lit_constant(irModule *m, Ast *expr) {
|
|||||||
if (expr == nullptr) {
|
if (expr == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expr->kind == Ast_CompoundLit) {
|
if (expr->kind == Ast_CompoundLit) {
|
||||||
ast_node(cl, CompoundLit, expr);
|
ast_node(cl, CompoundLit, expr);
|
||||||
for_array(i, cl->elems) {
|
for_array(i, cl->elems) {
|
||||||
@@ -1661,6 +1662,7 @@ irValue *ir_check_compound_lit_constant(irModule *m, Ast *expr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return nullptr;
|
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));
|
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);
|
type = default_type(type);
|
||||||
|
|
||||||
u64 id = cast(u64)ir_type_info_index(m->info, 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
|
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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -787,6 +787,11 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (value.kind) {
|
switch (value.kind) {
|
||||||
|
case ExactValue_Typeid:
|
||||||
|
GB_ASSERT(is_type_typeid(type));
|
||||||
|
ir_write_u64(f, ir_typeid_as_integer(m, value.value_typeid));
|
||||||
|
break;
|
||||||
|
|
||||||
case ExactValue_Bool:
|
case ExactValue_Bool:
|
||||||
if (value.value_bool) {
|
if (value.value_bool) {
|
||||||
ir_write_string(f, are_types_identical(type, t_llvm_bool) ? str_lit("true") : str_lit("1"));
|
ir_write_string(f, are_types_identical(type, t_llvm_bool) ? str_lit("true") : str_lit("1"));
|
||||||
|
|||||||
Reference in New Issue
Block a user