mirror of
https://github.com/CPunch/Cosmo.git
synced 2026-02-10 04:30:03 +00:00
Minor table refactor, added cosmoV_compileString and loadstring() to baselib
cosmoV_compileString is recommended since it'll push the result (<error> or <closure>) onto the stack. also, fixed some GC-related bugs, so yay!
This commit is contained in:
@@ -32,16 +32,14 @@ int cosmoB_input(CState *state, int nargs, CValue *args) {
|
||||
}
|
||||
|
||||
static void interpret(CState *state, const char *script, const char *mod) {
|
||||
// cosmoP_compileString pushes the result onto the stack (NIL or COBJ_CLOSURE)
|
||||
CObjFunction* func = cosmoP_compileString(state, script, mod);
|
||||
if (func != NULL) {
|
||||
disasmChunk(&func->chunk, func->name != NULL ? func->name->str : "_main", 0);
|
||||
|
||||
// cosmoV_compileString pushes the result onto the stack (COBJ_ERROR or COBJ_CLOSURE)
|
||||
if (cosmoV_compileString(state, script, mod)) {
|
||||
COSMOVMRESULT res = cosmoV_call(state, 0, 0); // 0 args being passed, 0 results expected
|
||||
|
||||
if (res == COSMOVM_RUNTIME_ERR)
|
||||
cosmoV_printError(state, state->error);
|
||||
} else {
|
||||
cosmoV_pop(state); // pop the error off the stack
|
||||
cosmoV_printError(state, state->error);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user