Exemplo n.º 1
0
        static CharPtr get_prompt(LuaState L, int firstline)
        {
            CharPtr p;

            Lua.LuaGetField(L, Lua.LUA_GLOBALSINDEX, (firstline != 0) ? "_PROMPT" : "_PROMPT2");
            p = Lua.LuaToString(L, -1);
            if (p == null)
            {
                p = ((firstline != 0) ? Lua.LUA_PROMPT : Lua.LUA_PROMPT2);
            }
            Lua.LuaPop(L, 1);              /* remove global */
            return(p);
        }
Exemplo n.º 2
0
 static int traceback(LuaState L)
 {
     if (Lua.LuaIsString(L, 1) == 0) /* 'message' not a string? */
     {
         return(1);                  /* keep it intact */
     }
     Lua.LuaGetField(L, Lua.LUA_GLOBALSINDEX, "debug");
     if (!Lua.LuaIsTable(L, -1))
     {
         Lua.LuaPop(L, 1);
         return(1);
     }
     Lua.LuaGetField(L, -1, "traceback");
     if (!Lua.LuaIsFunction(L, -1))
     {
         Lua.LuaPop(L, 2);
         return(1);
     }
     Lua.LuaPushValue(L, 1);            /* pass error message */
     Lua.LuaPushInteger(L, 2);          /* skip this function and traceback */
     Lua.LuaCall(L, 2, 1);              /* call debug.traceback */
     return(1);
 }