Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{
let buffer = lua.to_luastring("return " + input);
status = lauxlib.luaL_loadbuffer(L, buffer, buffer.length, stdin);
}
if (status !== lua.LUA_OK) {
lua.lua_pop(L, 1);
let buffer = lua.to_luastring(input);
if (lauxlib.luaL_loadbuffer(L, buffer, buffer.length, stdin) === lua.LUA_OK) {
status = lua.LUA_OK;
}
}
while (status === lua.LUA_ERRSYNTAX && lua.lua_tojsstring(L, -1).endsWith("")) {
/* continuation */
lua.lua_pop(L, 1);
lua.lua_getglobal(L, _PROMPT2);
input += "\n" + readlineSync.prompt({
prompt: lua.lua_tojsstring(L, -1) || '>> '
});
lua.lua_pop(L, 1);
let buffer = lua.to_luastring(input);
status = lauxlib.luaL_loadbuffer(L, buffer, buffer.length, stdin);
}
if (status === lua.LUA_OK) {
status = docall(L, 0, lua.LUA_MULTRET);
}
if (status === lua.LUA_OK) {
let n = lua.lua_gettop(L);
if (n > 0) { /* any result to be printed? */
lua.lua_getglobal(L, lua.to_luastring("print"));
lua.lua_insert(L, 1);
if (lua.lua_pcall(L, n, 0, 0) != lua.LUA_OK) {
lauxlib.lua_writestringerror(`error calling 'print' (${lua.lua_tojsstring(L, -1)})\n`);
const doREPL = function(L) {
for (;;) {
lua.lua_getglobal(L, _PROMPT);
let input = readlineSync.prompt({
prompt: lua.lua_tojsstring(L, -1) || '> '
});
lua.lua_pop(L, 1);
if (input.length === 0)
continue;
let status;
{
let buffer = lua.to_luastring("return " + input);
status = lauxlib.luaL_loadbuffer(L, buffer, buffer.length, stdin);
}
if (status !== lua.LUA_OK) {
lua.lua_pop(L, 1);
let buffer = lua.to_luastring(input);
if (lauxlib.luaL_loadbuffer(L, buffer, buffer.length, stdin) === lua.LUA_OK) {
function prompt(questionText: string, options?: readlineSync.BasicOptions) {
writeStdOut(questionText);
return readlineSync.prompt({
...options,
prompt: (options && options.prompt && options.prompt + DEFAULT_PROMPT) || DEFAULT_PROMPT
});
}