mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-08 05:53:12 +00:00
Begin to support constant array of unions
This commit is contained in:
@@ -3253,11 +3253,18 @@ gb_internal lbAddr lb_add_global_generated_with_name(lbModule *m, Type *type, lb
|
||||
GB_ASSERT(type != nullptr);
|
||||
type = default_type(type);
|
||||
|
||||
LLVMTypeRef actual_type = lb_type(m, type);
|
||||
if (value.value != nullptr) {
|
||||
LLVMTypeRef value_type = LLVMTypeOf(value.value);
|
||||
GB_ASSERT(lb_sizeof(actual_type) == lb_sizeof(value_type));
|
||||
actual_type = value_type;
|
||||
}
|
||||
|
||||
Scope *scope = nullptr;
|
||||
Entity *e = alloc_entity_variable(scope, make_token_ident(name), type);
|
||||
lbValue g = {};
|
||||
g.type = alloc_type_pointer(type);
|
||||
g.value = LLVMAddGlobal(m->mod, lb_type(m, type), alloc_cstring(temporary_allocator(), name));
|
||||
g.value = LLVMAddGlobal(m->mod, actual_type, alloc_cstring(temporary_allocator(), name));
|
||||
if (value.value != nullptr) {
|
||||
GB_ASSERT_MSG(LLVMIsConstant(value.value), LLVMPrintValueToString(value.value));
|
||||
LLVMSetInitializer(g.value, value.value);
|
||||
@@ -3265,6 +3272,8 @@ gb_internal lbAddr lb_add_global_generated_with_name(lbModule *m, Type *type, lb
|
||||
LLVMSetInitializer(g.value, LLVMConstNull(lb_type(m, type)));
|
||||
}
|
||||
|
||||
g.value = LLVMConstPointerCast(g.value, lb_type(m, g.type));
|
||||
|
||||
lb_add_entity(m, e, g);
|
||||
lb_add_member(m, name, g);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user