Skip to content

Commit

Permalink
issue #198 WIP flesh out some more api functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyendumajumdar committed Aug 29, 2020
1 parent be67d11 commit 2cab1f1
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/ravi_complib.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,25 @@ static int lua_newStringConstant(void *context, Proto* proto, struct string_obje
return lua_stringK(L, proto, h, ts);
}

/* Compile the C code for the given proto, and C source */
int lua_compileProto(void *context, Proto* proto, const char* C_src, unsigned len) {
struct CompilerContext* ccontext = (struct CompilerContext*)context;
lua_State* L = ccontext->L;
static void init_C_compiler(void* context) {
struct CompilerContext* ccontext = (struct CompilerContext*)context;
mir_prepare(ccontext->jit->jit, 2);
}
static void* compile_C(void* context, const char* C_src, unsigned len) {
struct CompilerContext* ccontext = (struct CompilerContext*)context;

return NULL;
}
static void finish_C_compiler(void* context) {
struct CompilerContext* ccontext = (struct CompilerContext*)context;
mir_cleanup(ccontext->jit->jit);
}
static lua_CFunction get_compiled_function(void* context, void* module, const char* name) {
struct CompilerContext* ccontext = (struct CompilerContext*)context;
MIR_module_t M = (MIR_module_t)module;
return (lua_CFunction)mir_get_func(ccontext->jit->jit, M, name);
}
static void lua_setProtoFunction(void* context, Proto* p, lua_CFunction func) { p->ravi_jit.jit_function = func; }

static int load_and_compile(lua_State* L) {
const char* s = luaL_checkstring(L, 1);
Expand Down

0 comments on commit 2cab1f1

Please sign in to comment.