MCPcopy Create free account
hub / github.com/crownengine/crown / loadline

Function loadline

src/lua/lua_environment.cpp:164–176  ·  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

162** in the top of the stack.
163*/
164static int loadline(lua_State *L)
165{
166 int status;
167 if ((status = addreturn(L)) != LUA_OK) { /* 'return ...' did not work? */
168 // status = multiline(L); /* try as command, maybe with continuation lines */
169 size_t len;
170 const char *line = lua_tolstring(L, 1, &len); /* get what it has */
171 status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */
172 }
173 lua_remove(L, 1); /* remove line from the stack */
174 lua_assert(lua_gettop(L) == 1);
175 return status;
176}
177
178/*
179** Check whether 'status' is not OK and, if so, prints the error

Callers 1

do_REPLFunction · 0.70

Calls 5

addreturnFunction · 0.85
lua_tolstringFunction · 0.50
luaL_loadbufferFunction · 0.50
lua_removeFunction · 0.50
lua_gettopFunction · 0.50

Tested by

no test coverage detected