private void popLuaStack() { LuaStack top = this.stack; this.stack = top.Prev; top.Prev = null; }
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); } }
private void pushLuaStack(LuaStack newTop) { newTop.Prev = this.stack; this.stack = newTop; }