inc() публичный статический Метод

public static inc ( lua_TValue &value ) : lua_TValue
value lua_TValue
Результат lua_TValue
Пример #1
0
        public static int luaD_poscall(lua_State L, StkId firstResult)
        {
            StkId    res;
            int      wanted, i;
            CallInfo ci;

            if ((L.hookmask & LUA_MASKRET) != 0)
            {
                firstResult = callrethooks(L, firstResult);
            }
            ci      = CallInfo.dec(ref L.ci);
            res     = ci.func;                                      /* res == final position of 1st result */
            wanted  = ci.nresults;
            L.base_ = (ci - 1).base_;                               /* restore base */
            InstructionPtr.Assign((ci - 1).savedpc, ref L.savedpc); /* restore savedpc */
            /* move results to correct place */
            for (i = wanted; i != 0 && firstResult < L.top; i--)
            {
                setobjs2s(L, res, firstResult);
                res         = res + 1;
                firstResult = firstResult + 1;
            }
            while (i-- > 0)
            {
                setnilvalue(StkId.inc(ref res));
            }
            L.top = res;
            return(wanted - LUA_MULTRET);         /* 0 iff wanted == LUA_MULTRET */
        }
Пример #2
0
        private static void traversestack(global_State g, lua_State l)
        {
            StkId    o, lim;
            CallInfo ci;

            markvalue(g, gt(l));
            lim = l.top;
            for (ci = l.base_ci[0]; ci <= l.ci; CallInfo.inc(ref ci))
            {
                lua_assert(ci.top <= l.stack_last);
                if (lim < ci.top)
                {
                    lim = ci.top;
                }
            }
            for (o = l.stack[0]; o < l.top; StkId.inc(ref o))
            {
                markvalue(g, o);
            }
            for (; o <= lim; StkId.inc(ref o))
            {
                setnilvalue(o);
            }
            checkstacksizes(l, lim);
        }
Пример #3
0
        /* only ANSI way to check whether a pointer points to an array */
        private static int isinstack(CallInfo ci, TValue o)
        {
            StkId p;

            for (p = ci.base_; p < ci.top; StkId.inc(ref p))
            {
                if (o == p)
                {
                    return(1);
                }
            }
            return(0);
        }
Пример #4
0
        private static StkId adjust_varargs(lua_State L, Proto p, int actual)
        {
            int   i;
            int   nfixargs = p.numparams;
            Table htab = null;
            StkId base_, fixed_;

            for (; actual < nfixargs; ++actual)
            {
                setnilvalue(StkId.inc(ref L.top));
            }
                #if LUA_COMPAT_VARARG
            if ((p.is_vararg & VARARG_NEEDSARG) != 0)  /* compat. with old-style vararg? */
            {
                int nvar = actual - nfixargs;          /* number of extra arguments */
                lua_assert(p.is_vararg & VARARG_HASARG);
                luaC_checkGC(L);
                htab = luaH_new(L, nvar, 1);    /* create `arg' table */
                for (i = 0; i < nvar; i++)      /* put extra arguments into `arg' table */
                {
                    setobj2n(L, luaH_setnum(L, htab, i + 1), L.top - nvar + i);
                }
                /* store counter in field `n' */
                setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
            }
                #endif
            /* move fixed parameters to final position */
            fixed_ = L.top - actual; /* first fixed argument */
            base_  = L.top;          /* final position of first argument */
            for (i = 0; i < nfixargs; i++)
            {
                setobjs2s(L, StkId.inc(ref L.top), fixed_ + i);
                setnilvalue(fixed_ + i);
            }
            /* add `arg' parameter */
            if (htab != null)
            {
                StkId top = L.top;
                StkId.inc(ref L.top);
                sethvalue(L, top, htab);
                lua_assert(iswhite(obj2gco(htab)));
            }
            return(base_);
        }
Пример #5
0
 public static void incr_top(lua_State L)
 {
     StkId.inc(ref L.top);
     luaD_checkstack(L, 0);
 }
Пример #6
0
        public static int luaD_precall(lua_State L, StkId func, int nresults)
        {
            LClosure  cl;
            ptrdiff_t funcr;

            if (!ttisfunction(func))       /* `func' is not a function? */
            {
                func = tryfuncTM(L, func); /* check the `function' tag method */
            }
            funcr = savestack(L, func);
            cl    = clvalue(func).l;
            InstructionPtr.Assign(L.savedpc, ref L.ci.savedpc);
            if (cl.isC == 0)        /* Lua function? prepare its call */
            {
                CallInfo ci;
                StkId    st, base_;
                Proto    p = cl.p;
                luaD_checkstack(L, p.maxstacksize);
                func = restorestack(L, funcr);
                if (p.is_vararg == 0)            /* no varargs? */
                {
                    base_ = L.stack[func + 1];
                    if (L.top > base_ + p.numparams)
                    {
                        L.top = base_ + p.numparams;
                    }
                }
                else            /* vararg function */
                {
                    int nargs = L.top - func - 1;
                    base_ = adjust_varargs(L, p, nargs);
                    func  = restorestack(L, funcr); /* previous call may change the stack */
                }
                ci      = inc_ci(L);                /* now `enter' new function */
                ci.func = func;
                L.base_ = ci.base_ = base_;
                ci.top  = L.base_ + p.maxstacksize;
                lua_assert(ci.top <= L.stack_last);
                L.savedpc    = new InstructionPtr(p.code, 0);       /* starting point */
                ci.tailcalls = 0;
                ci.nresults  = nresults;
                for (st = L.top; st < ci.top; StkId.inc(ref st))
                {
                    setnilvalue(st);
                }
                L.top = ci.top;
                if ((L.hookmask & LUA_MASKCALL) != 0)
                {
                    InstructionPtr.inc(ref L.savedpc);        /* hooks assume 'pc' is already incremented */
                    luaD_callhook(L, LUA_HOOKCALL, -1);
                    InstructionPtr.dec(ref L.savedpc);        /* correct 'pc' */
                }
                return(PCRLUA);
            }
            else          /* if is a C function, call it */
            {
                CallInfo ci;
                int      n;
                luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
                ci      = inc_ci(L);              /* now `enter' new function */
                ci.func = restorestack(L, funcr);
                L.base_ = ci.base_ = ci.func + 1;
                ci.top  = L.top + LUA_MINSTACK;
                lua_assert(ci.top <= L.stack_last);
                ci.nresults = nresults;
                if ((L.hookmask & LUA_MASKCALL) != 0)
                {
                    luaD_callhook(L, LUA_HOOKCALL, -1);
                }
                lua_unlock(L);
                n = curr_func(L).c.f(L); /* do the actual call */
                lua_lock(L);
                if (n < 0)               /* yielding? */
                {
                    return(PCRYIELD);
                }
                else
                {
                    luaD_poscall(L, L.top - n);
                    return(PCRC);
                }
            }
        }
Пример #7
0
 private static void api_incr_top(lua_State L)
 {
     StkId.inc(ref L.top);
     api_check(L, L.top <= L.ci.top);
 }