コード例 #1
0
        private void popLuaStack()
        {
            LuaStack top = this.stack;

            this.stack = top.Prev;
            top.Prev   = null;
        }
コード例 #2
0
        private void callLuaClosure(int nArgs, int nResults, Closure c)
        {
            int  nRegs    = c.Proto.MaxStackSize;
            int  nParams  = c.Proto.NumParams;
            bool isVararg = c.Proto.IsVararg == 1;

            LuaStack newStack = new LuaStack();

            newStack.Closure = c;

            List <Object> funcAndArgs = stack.PopN(nArgs + 1);

            newStack.PushN(funcAndArgs.GetRange(1, funcAndArgs.Count - 1), nParams);
            if (nArgs > nParams && isVararg)
            {
                newStack.Varargs = funcAndArgs.GetRange(nParams + 1, funcAndArgs.Count);
            }

            pushLuaStack(newStack);
            SetTop(nRegs);
            runLuaClosure();
            popLuaStack();

            if (nResults != 0)
            {
                List <Object> results = newStack.PopN(stack.Top() - nRegs);
                stack.PushN(results, nResults);
            }
        }
コード例 #3
0
 private void pushLuaStack(LuaStack newTop)
 {
     newTop.Prev = this.stack;
     this.stack  = newTop;
 }