From 53ff35455a0436462e246a437e41f623f2091c6f Mon Sep 17 00:00:00 2001 From: Dibyendu Majumdar Date: Sat, 12 Dec 2020 18:28:36 +0000 Subject: [PATCH] issue #198 Updated interface to the compiler lib --- src/loadlib.c | 4 ++-- src/ravi_complib.c | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/loadlib.c b/src/loadlib.c index 427c340..573c851 100644 --- a/src/loadlib.c +++ b/src/loadlib.c @@ -430,7 +430,7 @@ static int ravi_lookforfunc (lua_State *L, const char *path, const char *sym) { } else { LClosure* (*load_in_lua)(lua_State * L); - load_in_lua = lsys_sym(L, reg, sym); + load_in_lua = (void*) lsys_sym(L, reg, sym); if (load_in_lua == NULL) return ERRFUNC; /* unable to find function */ LClosure* cl = load_in_lua(L); @@ -758,7 +758,7 @@ static int ll_seeall (lua_State *L) { static const luaL_Reg pk_funcs[] = { {"loadlib", ll_loadlib}, - { "load_ravi_lib", ravi_loadlib }, + {"load_ravi_lib", ravi_loadlib}, {"searchpath", ll_searchpath}, #if defined(LUA_COMPAT_MODULE) {"seeall", ll_seeall}, diff --git a/src/ravi_complib.c b/src/ravi_complib.c index f08c011..97a5349 100644 --- a/src/ravi_complib.c +++ b/src/ravi_complib.c @@ -44,7 +44,11 @@ static void setup_lua_closure(lua_State* L, LClosure* (*load_in_lua)(lua_State*) } static int load_and_compile(lua_State* L) { - const char* s = luaL_checkstring(L, 1); + const char *s = luaL_checkstring(L, 1); + const char *options = ""; + if (lua_isstring(L, 2)) { + options = luaL_checkstring(L, 2); + } struct CompilerContext ccontext = {.L = L, .jit = G(L)->ravi_state}; struct Ravi_CompilerInterface ravicomp_interface = {.source = s, @@ -56,6 +60,7 @@ static int load_and_compile(lua_State* L) { .error_message = error_message}; snprintf(ravicomp_interface.main_func_name, sizeof ravicomp_interface.main_func_name, "__luachunk_%lld", ccontext.jit->id++); + ravicomp_interface.compiler_options = options; int rc = raviX_compile(&ravicomp_interface); if (ravicomp_interface.generated_code) { fprintf(stdout, "%s\n", ravicomp_interface.generated_code);