mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-03 11:42:28 +00:00
Include the ivar in the Objective-C class unconditionally of it being used or not.
Allow pseudo-fields for ivar access.
This commit is contained in:
@@ -5138,8 +5138,6 @@ gb_internal lbAddr lb_build_addr_internal(lbProcedure *p, Ast *expr) {
|
||||
return lb_build_addr(p, unparen_expr(se->selector));
|
||||
}
|
||||
|
||||
|
||||
Type *type = base_type(tav.type);
|
||||
if (tav.mode == Addressing_Type) { // Addressing_Type
|
||||
Selection sel = lookup_field(tav.type, selector, true);
|
||||
if (sel.pseudo_field) {
|
||||
@@ -5174,18 +5172,37 @@ gb_internal lbAddr lb_build_addr_internal(lbProcedure *p, Ast *expr) {
|
||||
return lb_addr_swizzle(a, type, swizzle_count, swizzle_indices);
|
||||
}
|
||||
|
||||
Selection sel = lookup_field(type, selector, false);
|
||||
Selection sel = lookup_field(tav.type, selector, false);
|
||||
GB_ASSERT(sel.entity != nullptr);
|
||||
if (sel.pseudo_field) {
|
||||
GB_ASSERT(sel.entity->kind == Entity_Procedure || sel.entity->kind == Entity_ProcGroup);
|
||||
if (sel.pseudo_field && (sel.entity->kind == Entity_Procedure || sel.entity->kind == Entity_ProcGroup)) {
|
||||
// GB_ASSERT(sel.entity->kind == Entity_Procedure || sel.entity->kind == Entity_ProcGroup);
|
||||
Entity *e = entity_of_node(sel_node);
|
||||
GB_ASSERT(e->kind == Entity_Procedure);
|
||||
return lb_addr(lb_find_value_from_entity(p->module, e));
|
||||
}
|
||||
|
||||
if (sel.is_bit_field) {
|
||||
lbAddr addr = lb_build_addr(p, se->expr);
|
||||
lbAddr addr = lb_build_addr(p, se->expr);
|
||||
|
||||
// TODO(harold): Ensure objc_ivar is always null when objc_implement is not set!
|
||||
Type *d_type = type_deref(tav.type); //base_type(tav.type);
|
||||
if (d_type->kind == Type_Named && d_type->Named.type_name->TypeName.objc_ivar) {
|
||||
// NOTE(harold): We need to load the ivar from the current address and
|
||||
// replace addr with the loaded ivar addr to apply the selector load properly.
|
||||
|
||||
// If it's a deep pointer, dereference it first
|
||||
// TODO(harold): Ensure this is save to do here. lb_emit_deep_field_gep() has several derefs, once per index.
|
||||
// Not sure what multiple indices represent...
|
||||
Type* type = tav.type;
|
||||
if (is_type_pointer(type)) {
|
||||
type = type_deref(type);
|
||||
addr = lb_addr(lb_emit_load(p, addr.addr));
|
||||
}
|
||||
|
||||
lbValue ivar_ptr = lb_handle_objc_ivar_for_objc_object_pointer(p, addr.addr);
|
||||
addr = lb_addr(ivar_ptr);
|
||||
}
|
||||
|
||||
if (sel.is_bit_field) {
|
||||
Selection sub_sel = sel;
|
||||
sub_sel.index.count -= 1;
|
||||
|
||||
@@ -5211,7 +5228,6 @@ gb_internal lbAddr lb_build_addr_internal(lbProcedure *p, Ast *expr) {
|
||||
}
|
||||
|
||||
{
|
||||
lbAddr addr = lb_build_addr(p, se->expr);
|
||||
if (addr.kind == lbAddr_Map) {
|
||||
lbValue v = lb_addr_load(p, addr);
|
||||
lbValue a = lb_address_from_load_or_generate_local(p, v);
|
||||
|
||||
Reference in New Issue
Block a user