static Lua.Proto combine(LuaState L, int n) { if (n == 1) { return(toproto(L, -1)); } else { int i, pc; Lua.Proto f = Lua.LuaFNewProto(L); Lua.SetPTValue2S(L, L.top, f); Lua.IncrTop(L); f.source = Lua.luaS_newliteral(L, "=(" + PROGNAME + ")"); f.maxstacksize = 1; pc = 2 * n + 1; f.code = (Instruction[])Lua.LuaMNewVector <Instruction>(L, pc); f.sizecode = pc; f.p = Lua.LuaMNewVector <Lua.Proto>(L, n); f.sizep = n; pc = 0; for (i = 0; i < n; i++) { f.p[i] = toproto(L, i - n - 1); f.code[pc++] = (uint)Lua.CREATE_ABx(Lua.OpCode.OP_CLOSURE, 0, i); f.code[pc++] = (uint)Lua.CREATE_ABC(Lua.OpCode.OP_CALL, 0, 1, 1); } f.code[pc++] = (uint)Lua.CREATE_ABC(Lua.OpCode.OP_RETURN, 0, 1, 0); return(f); } }