From b24796e2bcabe1febb0f55db23f2be969d685a60 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 8 Mar 2026 13:48:21 +0100 Subject: [PATCH] scripting: Added stubs for compiling scripts --- src/l_lsl.c | 21 +++++++++++++++++++-- src/l_lsl.h | 18 +++++++++++++++++- src/lrts_impl.h | 2 +- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/l_lsl.c b/src/l_lsl.c index 637cc2b..87b918c 100644 --- a/src/l_lsl.c +++ b/src/l_lsl.c @@ -1,5 +1,5 @@ -#include "u_lsl.h" -#include "m_mem.h" +#include "l_lsl.h" +#include "u_mem.h" struct l_lsl_vm l_lsl_vm_init() { struct l_lsl_vm v; @@ -9,4 +9,21 @@ struct l_lsl_vm l_lsl_vm_init() { } void l_lsl_vm_free(struct l_lsl_vm *vm) { + LRTS_UNUSED(vm); +} + +enum l_lsl_error l_lsl_compile_file(struct l_lsl_vm *v, const char *path) { + enum l_lsl_error err = L_LSL_ERR_OK; + LRTS_UNUSED(v); + LRTS_UNUSED(path); + + return err; +} + +enum l_lsl_error l_lsl_exec(struct l_lsl_vm *v, const char *path) { + enum l_lsl_error err = L_LSL_ERR_OK; + + err = l_lsl_compile_file(v, path); + + return err; } diff --git a/src/l_lsl.h b/src/l_lsl.h index 4e21daf..34d4f42 100644 --- a/src/l_lsl.h +++ b/src/l_lsl.h @@ -100,13 +100,23 @@ struct l_lsl_strings { u32 max_len; }; +struct l_lsl_table; + +union l_lsl_tableent_data { + i32 int_val; + char *str_val; + struct l_lsl_table *table; + /* start of code in bytecode table */ + u32 function_code_index; +}; + /* a table entry is a single value * of a specific data type */ struct l_lsl_tableent { /* string table entry */ u32 name; enum l_lsl_data_type type; - + union l_lsl_tableent_data data; }; /* @@ -174,4 +184,10 @@ enum l_lsl_error l_lsl_compile(struct l_lsl_vm *v, const char *code, u32 len); * if the entry point is NULL the global scope is executed */ enum l_lsl_error l_lsl_run(struct l_lsl_vm *v, const char *entry); +/* compiles from a file */ +enum l_lsl_error l_lsl_compile_file(struct l_lsl_vm *v, const char *path); + +/* loads a file, compiles it and runs it */ +enum l_lsl_error l_lsl_exec(struct l_lsl_vm *v, const char *path); + #endif diff --git a/src/lrts_impl.h b/src/lrts_impl.h index e387655..6bd2ac7 100644 --- a/src/lrts_impl.h +++ b/src/lrts_impl.h @@ -52,7 +52,7 @@ #include "i_input.c" #include "u_time.c" #include "t_update.c" -#include "l_lsl.h" +#include "l_lsl.c" #include "u_debug.c" #endif -- 2.30.2