random cleanups
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 30 Mar 2021 16:48:53 +0000 (11:48 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 30 Mar 2021 16:48:53 +0000 (11:48 -0500)
bin/onyx
core/string.onyx
core/sys/wasi.onyx
core/wasi.onyx
src/onyxsymres.c
src/onyxtypes.c

index cf48b2c31aeea3415f0b6f02903cd9f0803589ac..2cd9c3488783a3389a5f4c0c9f89f50d4aff95d0 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index ab8949d59f74945a6f82e8df7da69c54e7e0210d..2c5997b6b8d75d7236a95dd59db35588a400ae99 100644 (file)
@@ -38,7 +38,7 @@ copy :: (orig: str, dest: str) {
     len := orig.count;
     if dest.count < len do len = dest.count;
 
-    for i: 0 .. len do dest.data[i] = orig.data[i];
+    memory.copy(dest.data, orig.data, len);
 }
 
 concat :: (s1: str, s2: str) -> str {
@@ -46,8 +46,8 @@ concat :: (s1: str, s2: str) -> str {
     len2 := length(s2);
 
     data := cast(^u8) calloc(len1 + len2);
-    for i: 0 .. len1 do data[i]        = s1[i];
-    for i: 0 .. len2 do data[i + len1] = s2[i];
+    memory.copy(data, s1.data, len1);
+    memory.copy(data + len1, s2.data, len2);
 
     return str.{ data, len1 + len2 };
 }
index ebfbf06e303542f07f0880ba801f662f0676adc7..2805a217bf039e4e7d6bccb55476702e018ce7de 100644 (file)
@@ -31,6 +31,17 @@ assert_handler :: (msg: str, file: str) {
     proc_exit(1);
 }
 
+proc () #export "_initialize" {
+    alloc.init();
+
+    __initialize(^context);
+    context.allocator = alloc.heap_allocator;
+    context.temp_allocator = alloc.temp_allocator;
+    context.assert_handler = assert_handler;
+
+    stdio_init();
+}
+
 // The builtin _start proc.
 // Sets up everything needed for execution.
 proc () #export "_start" {
@@ -41,6 +52,8 @@ proc () #export "_start" {
     context.temp_allocator = alloc.temp_allocator;
     context.assert_handler = assert_handler;
 
+    stdio_init();
+
     args : [] cstr;
     argv_buf_size : Size;
     args_sizes_get(^args.count, ^argv_buf_size);
@@ -63,10 +76,6 @@ proc () #export "_start" {
         args[i] = cast(cstr) (cast(^u32) args.data)[i];
     }
 
-
-
-    stdio_init();
-
     main.main(args);
 
     print_stream_flush();
index 1383f60d9c28ed7d20e0b3334d0b669664d55ccc..fa0e3a1a8e26301b54c2b36514c445e113dced01 100644 (file)
@@ -364,42 +364,42 @@ IOVecArray :: struct {
 
 
 // FUNCTIONS
-args_get       :: (argv: ^^u8, argv_buf: ^u8) -> Errno #foreign "wasi_unstable" "args_get"---
-args_sizes_get :: (argc: ^Size, argv_buf_size: ^Size) -> Errno #foreign "wasi_unstable" "args_sizes_get" ---
-
-environ_get       :: (environ: ^^u8, environ_buf: ^u8) -> Errno #foreign "wasi_unstable" "environ_get" ---
-environ_sizes_get :: (environc: ^Size, environ_buf_size: ^Size) -> Errno #foreign "wasi_unstable" "environ_sizes_get" ---
-
-clock_res_get  :: (id: ClockID, resolution: ^Timestamp) -> Errno #foreign "wasi_unstable" "clock_res_get" ---
-clock_time_get :: (id: ClockID, precision: Timestamp, time: ^Timestamp) -> Errno #foreign "wasi_unstable" "clock_time_get" ---
-
-fd_advise             :: (fd: FileDescriptor, offset: Filesize, len: Filesize, advice: Advice) -> Errno #foreign "wasi_unstable" "fd_advise" ---
-fd_allocate           :: (fd: FileDescriptor, offset: Filesize, len: Filesize) -> Errno #foreign "wasi_unstable" "fd_allocate" ---
-fd_close              :: (fd: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_close" ---
-fd_datasync           :: (fd: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_datasync" ---
-fd_fdstat_get         :: (fd: FileDescriptor, stat: ^FDStat) -> Errno #foreign "wasi_unstable" "fd_fdstat_get" ---
-fd_fdstat_set_flags   :: (fd: FileDescriptor, flags: FDFlags) -> Errno #foreign "wasi_unstable" "fd_fdstat_set_flags" ---
-fd_fdstat_set_rights  :: (fd: FileDescriptor, rights_base: Rights, rights_inheriting: Rights) -> Errno #foreign "wasi_unstable" "fd_fdstat_set_rights" ---
-fd_filestat_get       :: (fd: FileDescriptor, buf: ^FileStat) -> Errno #foreign "wasi_unstable" "fd_filestat_get" ---
-fd_filestat_set_size  :: (fd: FileDescriptor, size: Filesize) -> Errno #foreign "wasi_unstable" "fd_filestat_set_size" ---
-fd_filestat_set_times :: (fd: FileDescriptor, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno #foreign "wasi_unstable" "fd_filestat_set_times" ---
-fd_pread              :: (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nread: ^Size) -> Errno #foreign "wasi_unstable" "fd_pread" ---
-fd_prestat_get        :: (fd: FileDescriptor, buf: ^PrestatTagged) -> Errno #foreign "wasi_unstable" "fd_prestat_get" ---
-fd_prestat_dir_name   :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "fd_prestat_dir_name" ---
-fd_pwrite             :: (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nwritten: ^Size) -> Errno #foreign "wasi_unstable" "fd_pwrite" ---
-fd_read               :: (fd: FileDescriptor, iovs: IOVecArray, nread: ^Size) -> Errno #foreign "wasi_unstable" "fd_read" ---
-fd_readdir            :: (fd: FileDescriptor, buf: ^u8, buf_len: Size, cookie: DirCookie, bufused: ^Size) -> Errno #foreign "wasi_unstable" "fd_readdir" ---
-fd_renumber           :: (fd: FileDescriptor, to: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_renumber" ---
-fd_seek               :: (fd: FileDescriptor, offset: FileDelta, whence: Whence, newoffset: ^Filesize) -> Errno #foreign "wasi_unstable" "fd_seek" ---
-fd_sync               :: (fd: FileDescriptor) -> Errno #foreign "wasi_unstable" "fd_sync" ---
-fd_tell               :: (fd: FileDescriptor, offset: ^Filesize) -> Errno #foreign "wasi_unstable" "fd_tell" ---
-fd_write              :: (fd: FileDescriptor, iovs: IOVecArray, nwritten: ^Size) -> Errno #foreign "wasi_unstable" "fd_write" ---
-
-path_create_directory   :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "path_create_directory" ---
-path_filestat_get       :: (fd: FileDescriptor, flags: LookupFlags, path: str, buf: ^FileStat) -> Errno #foreign "wasi_unstable" "path_filestat_get" ---
-path_filestat_set_times :: (fd: FileDescriptor, flags: LookupFlags, path: str, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno #foreign "wasi_unstable" "path_filestat_set_times" ---
-
-path_link :: (fd: FileDescriptor, old_flags: LookupFlags, old_path: str, new_fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_unstable" "path_link" ---
+args_get       :: (argv: ^^u8, argv_buf: ^u8) -> Errno #foreign "wasi_snapshot_preview1" "args_get"---
+args_sizes_get :: (argc: ^Size, argv_buf_size: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "args_sizes_get" ---
+
+environ_get       :: (environ: ^^u8, environ_buf: ^u8) -> Errno #foreign "wasi_snapshot_preview1" "environ_get" ---
+environ_sizes_get :: (environc: ^Size, environ_buf_size: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "environ_sizes_get" ---
+
+clock_res_get  :: (id: ClockID, resolution: ^Timestamp) -> Errno #foreign "wasi_snapshot_preview1" "clock_res_get" ---
+clock_time_get :: (id: ClockID, precision: Timestamp, time: ^Timestamp) -> Errno #foreign "wasi_snapshot_preview1" "clock_time_get" ---
+
+fd_advise             :: (fd: FileDescriptor, offset: Filesize, len: Filesize, advice: Advice) -> Errno #foreign "wasi_snapshot_preview1" "fd_advise" ---
+fd_allocate           :: (fd: FileDescriptor, offset: Filesize, len: Filesize) -> Errno #foreign "wasi_snapshot_preview1" "fd_allocate" ---
+fd_close              :: (fd: FileDescriptor) -> Errno #foreign "wasi_snapshot_preview1" "fd_close" ---
+fd_datasync           :: (fd: FileDescriptor) -> Errno #foreign "wasi_snapshot_preview1" "fd_datasync" ---
+fd_fdstat_get         :: (fd: FileDescriptor, stat: ^FDStat) -> Errno #foreign "wasi_snapshot_preview1" "fd_fdstat_get" ---
+fd_fdstat_set_flags   :: (fd: FileDescriptor, flags: FDFlags) -> Errno #foreign "wasi_snapshot_preview1" "fd_fdstat_set_flags" ---
+fd_fdstat_set_rights  :: (fd: FileDescriptor, rights_base: Rights, rights_inheriting: Rights) -> Errno #foreign "wasi_snapshot_preview1" "fd_fdstat_set_rights" ---
+fd_filestat_get       :: (fd: FileDescriptor, buf: ^FileStat) -> Errno #foreign "wasi_snapshot_preview1" "fd_filestat_get" ---
+fd_filestat_set_size  :: (fd: FileDescriptor, size: Filesize) -> Errno #foreign "wasi_snapshot_preview1" "fd_filestat_set_size" ---
+fd_filestat_set_times :: (fd: FileDescriptor, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno #foreign "wasi_snapshot_preview1" "fd_filestat_set_times" ---
+fd_pread              :: (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nread: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "fd_pread" ---
+fd_prestat_get        :: (fd: FileDescriptor, buf: ^PrestatTagged) -> Errno #foreign "wasi_snapshot_preview1" "fd_prestat_get" ---
+fd_prestat_dir_name   :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_snapshot_preview1" "fd_prestat_dir_name" ---
+fd_pwrite             :: (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nwritten: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "fd_pwrite" ---
+fd_read               :: (fd: FileDescriptor, iovs: IOVecArray, nread: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "fd_read" ---
+fd_readdir            :: (fd: FileDescriptor, buf: ^u8, buf_len: Size, cookie: DirCookie, bufused: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "fd_readdir" ---
+fd_renumber           :: (fd: FileDescriptor, to: FileDescriptor) -> Errno #foreign "wasi_snapshot_preview1" "fd_renumber" ---
+fd_seek               :: (fd: FileDescriptor, offset: FileDelta, whence: Whence, newoffset: ^Filesize) -> Errno #foreign "wasi_snapshot_preview1" "fd_seek" ---
+fd_sync               :: (fd: FileDescriptor) -> Errno #foreign "wasi_snapshot_preview1" "fd_sync" ---
+fd_tell               :: (fd: FileDescriptor, offset: ^Filesize) -> Errno #foreign "wasi_snapshot_preview1" "fd_tell" ---
+fd_write              :: (fd: FileDescriptor, iovs: IOVecArray, nwritten: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "fd_write" ---
+
+path_create_directory   :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_snapshot_preview1" "path_create_directory" ---
+path_filestat_get       :: (fd: FileDescriptor, flags: LookupFlags, path: str, buf: ^FileStat) -> Errno #foreign "wasi_snapshot_preview1" "path_filestat_get" ---
+path_filestat_set_times :: (fd: FileDescriptor, flags: LookupFlags, path: str, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno #foreign "wasi_snapshot_preview1" "path_filestat_set_times" ---
+
+path_link :: (fd: FileDescriptor, old_flags: LookupFlags, old_path: str, new_fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_snapshot_preview1" "path_link" ---
 path_open :: (fd: FileDescriptor
     , dirflags: LookupFlags
     , path: str
@@ -409,26 +409,26 @@ path_open :: (fd: FileDescriptor
     , fdflags: FDFlags
     , opened_fd: ^FileDescriptor
     ) -> Errno
-     #foreign "wasi_unstable" "path_open" ---
+     #foreign "wasi_snapshot_preview1" "path_open" ---
 
-path_readlink :: (fd: FileDescriptor, path: str, buf: ^u8, buf_len: Size, bufused: ^Size) -> Errno #foreign "wasi_unstable" "path_readlink" ---
-path_remove_directory :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "path_remove_directory" ---
-path_rename  :: (fd: FileDescriptor, old_path: str, new_fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_unstable" "path_rename" ---
-path_symlink :: (old_path: ^u8, old_path_len: Size, fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_unstable" "path_symlink" ---
-path_unlink_file :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_unstable" "path_unlink_file" ---
+path_readlink :: (fd: FileDescriptor, path: str, buf: ^u8, buf_len: Size, bufused: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "path_readlink" ---
+path_remove_directory :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_snapshot_preview1" "path_remove_directory" ---
+path_rename  :: (fd: FileDescriptor, old_path: str, new_fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_snapshot_preview1" "path_rename" ---
+path_symlink :: (old_path: ^u8, old_path_len: Size, fd: FileDescriptor, new_path: str) -> Errno #foreign "wasi_snapshot_preview1" "path_symlink" ---
+path_unlink_file :: (fd: FileDescriptor, path: str) -> Errno #foreign "wasi_snapshot_preview1" "path_unlink_file" ---
 
-poll_oneoff :: (in: ^Subscription, out: ^Event, nsubscriptions: Size, nevents: ^Size) -> Errno #foreign "wasi_unstable" "poll_oneoff" ---
+poll_oneoff :: (in: ^Subscription, out: ^Event, nsubscriptions: Size, nevents: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "poll_oneoff" ---
 
-proc_exit  :: (rval: ExitCode) -> void #foreign "wasi_unstable" "proc_exit" ---
-proc_raise :: (sig: Signal) -> Errno #foreign "wasi_unstable" "proc_raise" ---
+proc_exit  :: (rval: ExitCode) -> void #foreign "wasi_snapshot_preview1" "proc_exit" ---
+proc_raise :: (sig: Signal) -> Errno #foreign "wasi_snapshot_preview1" "proc_raise" ---
 
-sched_yield :: () -> Errno #foreign "wasi_unstable" "sched_yield" ---
+sched_yield :: () -> Errno #foreign "wasi_snapshot_preview1" "sched_yield" ---
 
-random_get :: (buf: ^u8, buf_len: Size) -> Errno #foreign "wasi_unstable" "random_get" ---
+random_get :: (buf: ^u8, buf_len: Size) -> Errno #foreign "wasi_snapshot_preview1" "random_get" ---
 
-sock_recv     :: (fd: FileDescriptor, ri_data: IOVecArray, ri_flags: RIFlags, ro_datalen: ^Size, ro_flags: ^ROFlags) -> Errno #foreign "wasi_unstable" "sock_recv" ---
-sock_send     :: (fd: FileDescriptor, si_data: IOVecArray, si_flags: SIFlags, so_datalen: ^Size) -> Errno #foreign "wasi_unstable" "sock_send" ---
-sock_shutdown :: (fd: FileDescriptor, how: SDFlags) -> Errno #foreign "wasi_unstable" "sock_shutdown" ---
+sock_recv     :: (fd: FileDescriptor, ri_data: IOVecArray, ri_flags: RIFlags, ro_datalen: ^Size, ro_flags: ^ROFlags) -> Errno #foreign "wasi_snapshot_preview1" "sock_recv" ---
+sock_send     :: (fd: FileDescriptor, si_data: IOVecArray, si_flags: SIFlags, so_datalen: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "sock_send" ---
+sock_shutdown :: (fd: FileDescriptor, how: SDFlags) -> Errno #foreign "wasi_snapshot_preview1" "sock_shutdown" ---
 
 
 
index efb5ec6ece34c03626122cdc0591e48b263d5330..beaa48068afa918d5aff6681dd920c8e5bba5d84 100644 (file)
@@ -1084,16 +1084,16 @@ void symres_entity(Entity* ent) {
         case Entity_Type_Function:                ss = symres_function(ent->function);        break;
 
         case Entity_Type_Foreign_Global_Header:
-        case Entity_Type_Global_Header:       ss = symres_global(ent->global); break;
+        case Entity_Type_Global_Header:           ss = symres_global(ent->global); break;
 
-        case Entity_Type_Use_Package:         ss = symres_use_package(ent->use_package);
-                                              if (ent->use_package->package) package_track_use_package(ent->use_package->package, ent);
-                                              next_state = Entity_State_Finalized;
-                                              break;
+        case Entity_Type_Use_Package:             ss = symres_use_package(ent->use_package);
+                                                  if (ent->use_package->package) package_track_use_package(ent->use_package->package, ent);
+                                                  next_state = Entity_State_Finalized;
+                                                  break;
 
-        case Entity_Type_Use:                 ss = symres_use(ent->use);
-                                              next_state = Entity_State_Finalized;
-                                              break;
+        case Entity_Type_Use:                     ss = symres_use(ent->use);
+                                                  next_state = Entity_State_Finalized;
+                                                  break;
 
         case Entity_Type_Overloaded_Function:     ss = symres_overloaded_function(ent->overloaded_function); break;
         case Entity_Type_Expression:              ss = symres_expression(&ent->expr); break;
index 993f97f24c5c55ec1b5cc47330d5ac42dc3c798b..42eab6b28229332d04d748de08e68f7802c42bcb 100644 (file)
@@ -37,95 +37,7 @@ Type basic_types[] = {
     { Type_Kind_Basic, 0, (AstType *) &basic_type_v128,  { Basic_Kind_V128,   Basic_Flag_SIMD,                        16, 16, "v128"  } },
 };
 
-b32 types_are_surface_compatible(Type* t1, Type* t2) {
-    // NOTE: If they are pointing to the same thing,
-    // it is safe to assume they are the same type
-    if (t1 == t2) return 1;
-    if (t1 == NULL || t2 == NULL) return 0;
-
-    switch (t1->kind) {
-        case Type_Kind_Basic:
-            if (t2->kind == Type_Kind_Basic) {
-                // HACK: Not sure if this is right way to check this?
-                if (t1 == t2) return 1;
-
-                if ((t1->Basic.flags & Basic_Flag_Integer) && (t2->Basic.flags & Basic_Flag_Integer)) {
-                    return t1->Basic.size == t2->Basic.size;
-                }
-
-                if (t1->Basic.kind == Basic_Kind_Rawptr && type_is_pointer(t2)) {
-                    return 1;
-                }
-            }
-            break;
-
-        case Type_Kind_Pointer:
-            if (t2->kind != Type_Kind_Pointer) return 0;
-
-            if (t1->Pointer.elem->kind == Type_Kind_Basic && t2->Pointer.elem->kind == Type_Kind_Basic)
-                return types_are_compatible(t1->Pointer.elem, t2->Pointer.elem);
-
-            return 1;
-
-        case Type_Kind_Array: {
-            if (t2->kind != Type_Kind_Array) return 0;
-
-            if (t1->Array.count != 0)
-                if (t1->Array.count != t2->Array.count) return 0;
-
-            return types_are_compatible(t1->Array.elem, t2->Array.elem);
-        }
-
-        case Type_Kind_Struct: {
-            if (t2->kind != Type_Kind_Struct) return 0;
-            if (t1->Struct.mem_count != t2->Struct.mem_count) return 0;
-            if (t1->Struct.name && t2->Struct.name)
-                if (strcmp(t1->Struct.name, t2->Struct.name) == 0) return 1;
-
-            b32 works = 1;
-            bh_table_each_start(StructMember, t1->Struct.members);
-                if (!bh_table_has(StructMember, t2->Struct.members, (char *) key)) return 0;
-                StructMember other = bh_table_get(StructMember, t2->Struct.members, (char *) key);
-                if (other.offset != value.offset) return 0;
-
-                if (!types_are_compatible(value.type, other.type)) {
-                    works = 0;
-                    break;
-                }
-            bh_table_each_end;
-
-            return works;
-        }
-
-        case Type_Kind_Enum: {
-            if (t2->kind != Type_Kind_Enum) return 0;
-            return t1 == t2;
-        }
-
-        case Type_Kind_Slice: {
-            if (t2->kind != Type_Kind_Slice) return 0;
-            return types_are_compatible(t1->Slice.ptr_to_data->Pointer.elem, t2->Slice.ptr_to_data->Pointer.elem);
-        }
-
-        case Type_Kind_VarArgs: {
-            if (t2->kind != Type_Kind_VarArgs) return 0;
-            return types_are_compatible(t1->VarArgs.ptr_to_data->Pointer.elem, t2->VarArgs.ptr_to_data->Pointer.elem);
-        }
-
-        case Type_Kind_DynArray: {
-            if (t2->kind != Type_Kind_DynArray) return 0;
-            return types_are_compatible(t1->DynArray.ptr_to_data->Pointer.elem, t2->DynArray.ptr_to_data->Pointer.elem);
-        }
-
-        default:
-            assert(("Invalid type", 0));
-            break;
-    }
-
-    return 0;
-}
-
-b32 types_are_compatible(Type* t1, Type* t2) {
+b32 types_are_compatible_(Type* t1, Type* t2, b32 recurse_pointers) {
     // NOTE: If they are pointing to the same thing,
     // it is safe to assume they are the same type
     if (t1 == t2) return 1;
@@ -151,6 +63,8 @@ b32 types_are_compatible(Type* t1, Type* t2) {
 
         case Type_Kind_Pointer: {
             if (t2->kind == Type_Kind_Pointer) {
+                if (!recurse_pointers) return 1;
+
                 if (types_are_compatible(t1->Pointer.elem, t2->Pointer.elem)) return 1;
 
                 if (t1->Pointer.elem->kind == Type_Kind_Struct && t2->Pointer.elem->kind == Type_Kind_Struct) {
@@ -178,6 +92,7 @@ b32 types_are_compatible(Type* t1, Type* t2) {
 
         case Type_Kind_Struct: {
             if (t2->kind != Type_Kind_Struct) return 0;
+            if (t1->Struct.unique_id != t2->Struct.unique_id) return 0;
             if (t1->Struct.mem_count != t2->Struct.mem_count) return 0;
 
             b32 works = 1;
@@ -186,7 +101,9 @@ b32 types_are_compatible(Type* t1, Type* t2) {
                 StructMember other = bh_table_get(StructMember, t2->Struct.members, (char *) key);
                 if (other.offset != value.offset) return 0;
 
-                if (!types_are_surface_compatible(value.type, other.type)) {
+                // NOTE: Don't recurse down pointers; This could be a problem, but it is a quick
+                // fix for the problem that occurs when using a linked-list style data structure.
+                if (!types_are_compatible_(value.type, other.type, 0)) {
                     works = 0;
                     break;
                 }
@@ -196,9 +113,8 @@ b32 types_are_compatible(Type* t1, Type* t2) {
         }
 
         case Type_Kind_Enum: {
+            // NOTE: The check above for t1 == t2 would already catch this.
             return 0;
-            // if (t2->kind != Type_Kind_Enum) return 0;
-            // return t1 == t2;
         }
 
         case Type_Kind_Function: {
@@ -250,6 +166,10 @@ b32 types_are_compatible(Type* t1, Type* t2) {
     return 0;
 }
 
+b32 types_are_compatible(Type* t1, Type* t2) {
+    return types_are_compatible_(t1, t2, 1);
+}
+
 u32 type_size_of(Type* type) {
     if (type == NULL) return 0;