示例#1
0
        public static int LinyeeDPCall(LinyeeState L, Pfunc func, object u,
                                       ptrdiff_t old_top, ptrdiff_t ef)
        {
            int            status;
            ushort         oldnCcalls     = L.nCcalls;
            ptrdiff_t      old_ci         = SaveCI(L, L.ci);
            LinyeeByteType old_allowhooks = L.allowhook;
            ptrdiff_t      old_errfunc    = L.errfunc;

            L.errfunc = ef;
            status    = LinyeeDRawRunProtected(L, func, u);
            if (status != 0)          /* an error occurred? */
            {
                StkId oldtop = RestoreStack(L, old_top);
                LinyeeFClose(L, oldtop);          /* close eventual pending closures */
                LinyeeDSetErrorObj(L, status, oldtop);
                L.nCcalls   = oldnCcalls;
                L.ci        = RestoreCI(L, old_ci);
                L.base_     = L.ci.base_;
                L.savedpc   = InstructionPtr.Assign(L.ci.savedpc);
                L.allowhook = old_allowhooks;
                RestoreStackLimit(L);
            }
            L.errfunc = old_errfunc;
            return(status);
        }
示例#2
0
        private static void GCTM(LinyeeState L)
        {
            GlobalState g     = G(L);
            GCObject    o     = g.tmudata.gch.next; /* get first element */
            Udata       udata = rawgco2u(o);
            TValue      tm;

            /* remove udata from `tmudata' */
            if (o == g.tmudata)        /* last element? */
            {
                g.tmudata = null;
            }
            else
            {
                g.tmudata.gch.next = udata.uv.next;
            }
            udata.uv.next     = g.mainthread.next;    /* return it to `root' list */
            g.mainthread.next = o;
            MakeWhite(g, o);
            tm = fasttm(L, udata.uv.metatable, TMS.TM_GC);
            if (tm != null)
            {
                LinyeeByteType oldah = L.allowhook;
                ly_mem         oldt  = (ly_mem)g.GCthreshold;
                L.allowhook   = 0;                /* stop debug hooks during GC tag method */
                g.GCthreshold = 2 * g.totalbytes; /* avoid GC steps */
                SetObj2S(L, L.top, tm);
                SetUValue(L, L.top + 1, udata);
                L.top += 2;
                LinyeeDCall(L, L.top - 2, 0);
                L.allowhook   = oldah;        /* restore hooks */
                g.GCthreshold = (uint)oldt;   /* restore threshold */
            }
        }
示例#3
0
        public static void MarkFinalized(UdataUV u)
        {
            LinyeeByteType marked = u.marked;                   // can't pass properties in as ref

            LSetBit(ref marked, FINALIZEDBIT);
            u.marked = marked;
        }
示例#4
0
        public static void LinyeeCLink(LinyeeState L, GCObject o, LinyeeByteType tt)
        {
            GlobalState g = G(L);

            o.gch.next   = g.rootgc;
            g.rootgc     = o;
            o.gch.marked = LinyeeCWhite(g);
            o.gch.tt     = tt;
        }
示例#5
0
 public static bool Test2Bits(LinyeeByteType x, int b1, int b2)
 {
     return(TestBits(x, (Bit2Mask(b1, b2))));
 }
示例#6
0
 public static int Reset2Bits(ref LinyeeByteType x, int b1, int b2)
 {
     return(ResetBits(ref x, (Bit2Mask(b1, b2))));
 }
示例#7
0
 public static bool TestBit(LinyeeByteType x, int b)
 {
     return(TestBits(x, BitMask(b)));
 }
示例#8
0
 public static int ResetBit(ref LinyeeByteType x, int b)
 {
     return(ResetBits(ref x, BitMask(b)));
 }
示例#9
0
 public static bool TestBits(LinyeeByteType x, int m)
 {
     return((x & (LinyeeByteType)m) != 0);
 }
示例#10
0
 public static int SetBits(ref LinyeeByteType x, int m)
 {
     x |= (LinyeeByteType)m; return(x);
 }
示例#11
0
 /*
 ** some userful bit tricks
 */
 public static int ResetBits(ref LinyeeByteType x, int m)
 {
     x &= (LinyeeByteType) ~m; return(x);
 }
示例#12
0
 private static LinyeeByteType opmode(LinyeeByteType t, LinyeeByteType a, OpArgMask b, OpArgMask c, OpMode m)
 {
     return((LinyeeByteType)(((t) << 7) | ((a) << 6) | (((LinyeeByteType)b) << 4) | (((LinyeeByteType)c) << 2) | ((LinyeeByteType)m)));
 }