better gc
This commit is contained in:
parent
a2f2f18910
commit
6c7153e42d
3 changed files with 21 additions and 2 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
BIN
tests/fps_game.o
BIN
tests/fps_game.o
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue