#593 fixed crash

This commit is contained in:
Vadim Grigoruk 2018-08-25 01:33:33 +03:00
parent 26551ca5ec
commit 60c43863c6
3 changed files with 17 additions and 9 deletions

View File

@ -2239,7 +2239,17 @@ static void onConsoleEvalCommand(Console* console, const char* param)
printLine(console);
const tic_script_config* script_config = console->tic->api.get_script_config(console->tic);
if (script_config->eval)
{
if(param)
script_config->eval(console->tic, param);
else printError(console, "nothing to eval");
}
else
{
printError(console, "'eval' not implemented for the script");
}
commandDone(console);
}

View File

@ -1414,10 +1414,12 @@ static const tic_outline_item* getLuaOutline(const char* code, s32* size)
return items;
}
void evalLua(tic_mem* tic, const char* code) {
static void evalLua(tic_mem* tic, const char* code) {
tic_machine* machine = (tic_machine*)tic;
lua_State* lua = machine->lua;
if (!lua) return;
lua_settop(lua, 0);
if(luaL_loadstring(lua, code) != LUA_OK || lua_pcall(lua, 0, LUA_MULTRET, 0) != LUA_OK)
@ -1426,10 +1428,6 @@ void evalLua(tic_mem* tic, const char* code) {
}
}
void evalPlaceholder(tic_mem* tic, const char* code) {
printf("TODO: not yet implemented\n.");
}
static const tic_script_config LuaSyntaxConfig =
{
.init = initLua,
@ -1609,7 +1607,7 @@ static const tic_script_config MoonSyntaxConfig =
.getOutline = getMoonOutline,
.parse = parseCode,
.eval = evalPlaceholder,
.eval = NULL,
.blockCommentStart = NULL,
.blockCommentEnd = NULL,
@ -1750,7 +1748,7 @@ static const tic_outline_item* getFennelOutline(const char* code, s32* size)
return items;
}
void evalFennel(tic_mem* tic, const char* code) {
static void evalFennel(tic_mem* tic, const char* code) {
tic_machine* machine = (tic_machine*)tic;
lua_State* fennel = machine->lua;

View File

@ -1372,7 +1372,7 @@ static const tic_outline_item* getWrenOutline(const char* code, s32* size)
return items;
}
void evalWren(tic_mem* memory, const char* code)
static void evalWren(tic_mem* memory, const char* code)
{
tic_machine* machine = (tic_machine*)memory;
wrenInterpret(machine->wren, code);