issue #198 Updated interface to the compiler lib

llvm
Dibyendu Majumdar 3 years ago
parent f9acba8142
commit 53ff35455a

@ -430,7 +430,7 @@ static int ravi_lookforfunc (lua_State *L, const char *path, const char *sym) {
} }
else { else {
LClosure* (*load_in_lua)(lua_State * L); 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) if (load_in_lua == NULL)
return ERRFUNC; /* unable to find function */ return ERRFUNC; /* unable to find function */
LClosure* cl = load_in_lua(L); LClosure* cl = load_in_lua(L);
@ -758,7 +758,7 @@ static int ll_seeall (lua_State *L) {
static const luaL_Reg pk_funcs[] = { static const luaL_Reg pk_funcs[] = {
{"loadlib", ll_loadlib}, {"loadlib", ll_loadlib},
{ "load_ravi_lib", ravi_loadlib }, {"load_ravi_lib", ravi_loadlib},
{"searchpath", ll_searchpath}, {"searchpath", ll_searchpath},
#if defined(LUA_COMPAT_MODULE) #if defined(LUA_COMPAT_MODULE)
{"seeall", ll_seeall}, {"seeall", ll_seeall},

@ -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) { 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 CompilerContext ccontext = {.L = L, .jit = G(L)->ravi_state};
struct Ravi_CompilerInterface ravicomp_interface = {.source = s, struct Ravi_CompilerInterface ravicomp_interface = {.source = s,
@ -56,6 +60,7 @@ static int load_and_compile(lua_State* L) {
.error_message = error_message}; .error_message = error_message};
snprintf(ravicomp_interface.main_func_name, sizeof ravicomp_interface.main_func_name, "__luachunk_%lld", snprintf(ravicomp_interface.main_func_name, sizeof ravicomp_interface.main_func_name, "__luachunk_%lld",
ccontext.jit->id++); ccontext.jit->id++);
ravicomp_interface.compiler_options = options;
int rc = raviX_compile(&ravicomp_interface); int rc = raviX_compile(&ravicomp_interface);
if (ravicomp_interface.generated_code) { if (ravicomp_interface.generated_code) {
fprintf(stdout, "%s\n", ravicomp_interface.generated_code); fprintf(stdout, "%s\n", ravicomp_interface.generated_code);

Loading…
Cancel
Save