コード例 #1
0
 static Lua.CharPtr get_prompt(Lua.LuaState L, int firstline)
 {
     Lua.CharPtr p;
     Lua.lua_getfield(L, Lua.LUA_GLOBALSINDEX, (firstline != 0) ? "_PROMPT" : "_PROMPT2");
     p = Lua.lua_tostring(L, -1);
     if (p == null)
     {
         p = ((firstline != 0) ? Lua.LUA_PROMPT : Lua.LUA_PROMPT2);
     }
     Lua.lua_pop(L, 1);  /* remove global */
     return(p);
 }
コード例 #2
0
 static int traceback(Lua.LuaState L)
 {
     if (Lua.lua_isstring(L, 1) == 0) /* 'message' not a string? */
     {
         return(1);                   /* keep it intact */
     }
     Lua.lua_getfield(L, Lua.LUA_GLOBALSINDEX, "debug");
     if (!Lua.lua_istable(L, -1))
     {
         Lua.lua_pop(L, 1);
         return(1);
     }
     Lua.lua_getfield(L, -1, "traceback");
     if (!Lua.lua_isfunction(L, -1))
     {
         Lua.lua_pop(L, 2);
         return(1);
     }
     Lua.lua_pushvalue(L, 1);   /* pass error message */
     Lua.lua_pushinteger(L, 2); /* skip this function and traceback */
     Lua.lua_call(L, 2, 1);     /* call debug.traceback */
     return(1);
 }