scripting: Added stub for gc struct
authorLukas Krickl <lukas@krickl.dev>
Sat, 14 Mar 2026 06:23:13 +0000 (07:23 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sat, 14 Mar 2026 06:23:13 +0000 (07:23 +0100)
src/l_lsl.h

index 394e6cc81c329879d39ddac73e24fbed4465364e..403c3ccb2082a15960fa06a035886c54b2446b4c 100644 (file)
@@ -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;