void callLuaClosure(int nArgs, int nResults, Closure c) { var nRegs = c.proto.MaxStackSize; var nParams = c.proto.NumParams; var isVararg = c.proto.IsVararg == 1; // create new lua stack var newStack = new LuaStack { closure = c }; // pass args, pop func var funcAndArgs = stack.popN(nArgs + 1); newStack.pushN(funcAndArgs.Skip(1).ToArray().ToList(), nParams); if (nArgs > nParams && isVararg) { newStack.varargs = funcAndArgs.Skip(nParams + 1).ToArray().ToList(); } // run closure pushLuaStack(newStack); SetTop(nRegs); runLuaClosure(); popLuaStack(); // return results if (nResults != 0) { var results = newStack.popN(newStack.top() - nRegs); //stack.check(results.size()) stack.pushN(results, nResults); } }
public int GetTop() { return(stack.top()); }