MCPcopy Create free account
hub / github.com/PlutoLang/Pluto / loadline

Function loadline

src/lua.cpp:651–665  ·  view source on GitHub ↗

** Read a line and try to load (compile) it first as an expression (by ** adding "return " in front of it) and second as a statement. Return ** the final status of load/call with the resulting function (if any) ** in the top of the stack. */

Source from the content-addressed store, hash-verified

649** in the top of the stack.
650*/
651static int loadline (lua_State *L) {
652 const char *line;
653 int status;
654 lua_settop(L, 0);
655 if (!pushline(L, 1))
656 return -1; /* no input */
657 if ((status = addreturn(L)) != LUA_OK) /* 'return ...' did not work? */
658 status = multiline(L); /* try as command, maybe with continuation lines */
659 line = lua_tostring(L, 1);
660 if (line[0] != '\0') /* non empty? */
661 lua_saveline(line); /* keep history */
662 lua_remove(L, 1); /* remove line from the stack */
663 lua_assert(lua_gettop(L) == 1);
664 return status;
665}
666
667
668/*

Callers 1

doREPLFunction · 0.85

Calls 7

lua_settopFunction · 0.85
pushlineFunction · 0.85
addreturnFunction · 0.85
multilineFunction · 0.85
lua_savelineFunction · 0.85
lua_removeFunction · 0.85
lua_gettopFunction · 0.85

Tested by

no test coverage detected