diff --git a/compile.sh b/compile.sh index 9f66f30..09e2f22 100755 --- a/compile.sh +++ b/compile.sh @@ -67,7 +67,7 @@ ODE_LIBS=$(pkg-config --libs ode 2>/dev/null || echo "-lode -lm") # Compile C to executable with libsuicmez, raylib, and ODE support echo "Compiling C code and linking with libsuicmez, raylib, and ODE..." -gcc $OPTIMIZE_FLAG -I. "$C_FILE" libsuicmez/libsuicmez.c libsuicmez/suicmez_gc.c $RAYLIB_CFLAGS $RAYLIB_LIBS $ODE_CFLAGS $ODE_LIBS -lm -o "$OUTPUT_BINARY" || exit 1 +gcc $OPTIMIZE_FLAG -I. -Ilibfishsoup/include "$C_FILE" libsuicmez/libsuicmez.c libsuicmez/suicmez_gc.c libfishsoup/src/*.c $RAYLIB_CFLAGS $RAYLIB_LIBS $ODE_CFLAGS $ODE_LIBS -lm -o "$OUTPUT_BINARY" || exit 1 echo "✓ Successfully created: $OUTPUT_BINARY" echo " Run with: ./$OUTPUT_BINARY" diff --git a/src/codegen/transpiler.rs b/src/codegen/transpiler.rs index 90bd97f..8522c6b 100644 --- a/src/codegen/transpiler.rs +++ b/src/codegen/transpiler.rs @@ -154,6 +154,11 @@ impl Transpiler { output.push_str(&self.generate_typeinfo_decl(struct_decl)); output.push_str("\n"); } + // Generate TypeInfo for array wrapper structs + for array_type_name in &self.array_types { + output.push_str(&self.generate_array_typeinfo_decl(array_type_name)); + output.push_str("\n"); + } output.push_str("\n"); // Generate function declarations (prototypes) @@ -337,6 +342,20 @@ impl Transpiler { } } + fn generate_array_typeinfo_decl(&self, array_type_name: &str) -> String { + // Array wrapper struct has: void* data (pointer), size_t len (not pointer), size_t capacity (not pointer) + // So bitmap: 1, 0, 0 + format!( + "static const uint8_t sui_bitmap_{}[] = {{ 1, 0, 0 }};\n\ + static const TypeInfo sui_typeinfo_{} = {{\n \ + .field_count = 3,\n \ + .pointer_count = 1,\n \ + .pointer_bitmap = sui_bitmap_{}\n\ + }};", + array_type_name, array_type_name, array_type_name + ) + } + fn generate_func_proto(&self, func: &CFuncDecl) -> String { let params_str = if func.params.is_empty() { "void".to_string() @@ -395,7 +414,7 @@ impl Transpiler { fn generate_heap_alloc(&self, ty: &CType) -> String { match ty { CType::Struct(name) => { - format!("(struct {}*)gc_alloc(&sui_typeinfo_{}, sizeof(struct {}))", name, name, name) + format!("(struct {}*)suic_alloc_struct(&sui_typeinfo_{}, sizeof(struct {}), NULL)", name, name, name) } CType::Array(elem_type) => { let array_name = Self::get_array_struct_name(elem_type); diff --git a/tests/fps_game.o b/tests/fps_game.o deleted file mode 100755 index 5429807..0000000 Binary files a/tests/fps_game.o and /dev/null differ