From: Lukas Krickl Date: Sat, 14 Mar 2026 06:23:13 +0000 (+0100) Subject: scripting: Added stub for gc struct X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=ba8af57cd0d8444810a286bd17042c8b4a936cab;p=lrts%2F.git scripting: Added stub for gc struct --- diff --git a/src/l_lsl.h b/src/l_lsl.h index 394e6cc..403c3cc 100644 --- a/src/l_lsl.h +++ b/src/l_lsl.h @@ -35,7 +35,10 @@ enum l_lsl_data_type { L_LSL_TYPE_INT, L_LSL_TYPE_STRING, L_LSL_FUNCTION, - L_LSL_NATIVE_CALL + L_LSL_NATIVE_CALL, + /* a name binding binds the data following next + * to a name */ + L_LSL_NAME_BINDING }; enum l_lsl_error { @@ -50,27 +53,28 @@ struct l_lsl_table; union l_lsl_value_data { i32 int_val; char *str_val; + const char *name; }; /* a signle value single value * of a specific data type */ struct l_lsl_value { - /* name might be null for literals */ - const char *name; - /* reference count for the - * current entry. - * if rc is 0 this entry should be freed - * rc should increase when: - * - entry is assigned to a list - * rc should decrease when - * - entry is removed from a list - */ - u32 rc; enum l_lsl_data_type type; union l_lsl_value_data data; struct l_lsl_value *next; }; +/* the garbage collector + * it keeps a list of all allocated objects + * it then followgs all defined entries in the + * current vm's program and marks all referenced + * pointers as used. + * all unused pointers are freed. */ +struct l_lsl_gc { + u32 len; + void *ptrs; +}; + struct l_lsl_vm { enum l_lsl_error err; enum l_lsl_flags flags; @@ -78,6 +82,8 @@ struct l_lsl_vm { const char *path; u32 lex_pos; + struct l_lsl_gc gc; + u_malloc_fp malloc; u_free_fp free; u_realloc_fp realloc;