Ejemplo n.º 1
0
        static void dotty(LuaState L)
        {
            int     status;
            CharPtr oldprogname = progname;

            progname = null;
            while ((status = loadline(L)) != -1)
            {
                if (status == 0)
                {
                    status = docall(L, 0, 0);
                }
                report(L, status);
                if (status == 0 && Lua.LuaGetTop(L) > 0)
                {                  /* any result to print? */
                    Lua.LuaGetGlobal(L, "print");
                    Lua.LuaInsert(L, 1);
                    if (Lua.LuaPCall(L, Lua.LuaGetTop(L) - 1, 0, 0) != 0)
                    {
                        l_message(progname, Lua.LuaPushFString(L,
                                                               "error calling " + Lua.LUA_QL("print").ToString() + " (%s)",
                                                               Lua.LuaToString(L, -1)));
                    }
                }
            }
            Lua.LuaSetTop(L, 0);              /* clear stack */
            Lua.fputs("\n", Lua.stdout);
            Lua.fflush(Lua.stdout);
            progname = oldprogname;
        }
Ejemplo n.º 2
0
        static int docall(LuaState L, int narg, int clear)
        {
            int status;
            int base_ = Lua.LuaGetTop(L) - narg;  /* function index */

            Lua.LuaPushCFunction(L, traceback);   /* push traceback function */
            Lua.LuaInsert(L, base_);              /* put it under chunk and args */
            //signal(SIGINT, laction);
            status = Lua.LuaPCall(L, narg, ((clear != 0) ? 0 : Lua.LUA_MULTRET), base_);
            //signal(SIGINT, SIG_DFL);
            Lua.LuaRemove(L, base_);              /* remove traceback function */
            /* force a complete garbage collection in case of errors */
            if (status != 0)
            {
                Lua.LuaGC(L, Lua.LUA_GCCOLLECT, 0);
            }
            return(status);
        }