Resolve other TODOs

This commit is contained in:
Harold Brenes
2025-05-03 13:06:57 -04:00
parent fc082f5ea5
commit be2e4dec7d
2 changed files with 97 additions and 95 deletions
+2 -3
View File
@@ -551,7 +551,7 @@ gb_internal void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr,
mpsc_enqueue(&ctx->checker->procs_with_objc_context_provider_to_check, e); mpsc_enqueue(&ctx->checker->procs_with_objc_context_provider_to_check, e);
} }
// @TODO(harold): I think there's a Check elsewhere in the checker for checking cycles. // TODO(harold): I think there's a Check elsewhere in the checker for checking cycles.
// See about moving this to the right location. // See about moving this to the right location.
// Ensure superclass hierarchy are all Objective-C classes and does not cycle // Ensure superclass hierarchy are all Objective-C classes and does not cycle
@@ -1013,7 +1013,7 @@ gb_internal void check_objc_methods(CheckerContext *ctx, Entity *e, AttributeCon
} else { } else {
Type *t = ac.objc_type; Type *t = ac.objc_type;
if (t->kind == Type_Named) { // TODO(harold): Shouldn't this be an error otherwise? Or is it checked elsehwere? GB_ASSERT(t->kind == Type_Named); // NOTE(harold): This is already checked for at the attribute resolution stage.
Entity *tn = t->Named.type_name; Entity *tn = t->Named.type_name;
GB_ASSERT(tn->kind == Entity_TypeName); GB_ASSERT(tn->kind == Entity_TypeName);
@@ -1117,7 +1117,6 @@ gb_internal void check_objc_methods(CheckerContext *ctx, Entity *e, AttributeCon
} }
} }
} }
}
} }
gb_internal void check_foreign_procedure(CheckerContext *ctx, Entity *e, DeclInfo *d) { gb_internal void check_foreign_procedure(CheckerContext *ctx, Entity *e, DeclInfo *d) {
+5 -2
View File
@@ -1173,7 +1173,6 @@ gb_internal lbProcedure *lb_create_objc_names(lbModule *main_module) {
return p; return p;
} }
// TODO(harold): Perhaps move this out of here and into a more suitable place?
String lb_get_objc_type_encoding(Type *t, isize pointer_depth = 0) { String lb_get_objc_type_encoding(Type *t, isize pointer_depth = 0) {
// NOTE(harold): See https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html#//apple_ref/doc/uid/TP40008048-CH100 // NOTE(harold): See https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html#//apple_ref/doc/uid/TP40008048-CH100
@@ -1424,6 +1423,7 @@ String lb_get_objc_type_encoding(Type *t, isize pointer_depth = 0) {
#undef INT_SIZE_ENCODING #undef INT_SIZE_ENCODING
GB_PANIC("Unreachable"); GB_PANIC("Unreachable");
return str_lit("");
} }
struct lbObjCGlobalClass { struct lbObjCGlobalClass {
@@ -1778,7 +1778,10 @@ gb_internal void lb_finalize_objc_names(lbGenerator *gen, lbProcedure *p) {
const i64 size = type_size_of(ivar_base); const i64 size = type_size_of(ivar_base);
const i64 alignment = (i64)floor_log2((u64)type_align_of(ivar_base)); const i64 alignment = (i64)floor_log2((u64)type_align_of(ivar_base));
// TODO(harold): Should we pass the actual type encoding? Might not be ideal for obfuscation. // NOTE(harold): I've opted to not emit the type encoding for ivars in order to keep the data private.
// If there is desire in the future to emit the type encoding for introspection through the Obj-C runtime,
// then perhaps an option can be added for it then.
// Should we pass the actual type encoding? Might not be ideal for obfuscation.
String ivar_name = str_lit("__$ivar"); String ivar_name = str_lit("__$ivar");
String ivar_types = str_lit("{= }"); //lb_get_objc_type_encoding(ivar_type); String ivar_types = str_lit("{= }"); //lb_get_objc_type_encoding(ivar_type);
args.count = 5; args.count = 5;