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 {
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;
const char *path;
u32 lex_pos;
+ struct l_lsl_gc gc;
+
u_malloc_fp malloc;
u_free_fp free;
u_realloc_fp realloc;