Example #1
0
        public static int LuaDPCall(LuaState 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);
            LuaByteType old_allowhooks = L.allowhook;
            ptrdiff_t   old_errfunc    = L.errfunc;

            L.errfunc = ef;
            status    = LuaDRawRunProtected(L, func, u);
            if (status != 0)          /* an error occurred? */
            {
                StkId oldtop = RestoreStack(L, old_top);
                LuaFClose(L, oldtop);          /* close eventual pending closures */
                LuaDSetErrorObj(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);
        }
Example #2
0
        public static void MarkFinalized(UdataUV u)
        {
            LuaByteType marked = u.marked;              // can't pass properties in as ref

            LSetBit(ref marked, FINALIZEDBIT);
            u.marked = marked;
        }
Example #3
0
        private static void GCTM(LuaState 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)
            {
                LuaByteType oldah = L.allowhook;
                lu_mem      oldt  = (lu_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;
                LuaDCall(L, L.top - 2, 0);
                L.allowhook   = oldah;        /* restore hooks */
                g.GCthreshold = (uint)oldt;   /* restore threshold */
            }
        }
Example #4
0
        public static void LuaCLink(LuaState L, GCObject o, LuaByteType tt)
        {
            GlobalState g = G(L);

            o.gch.next   = g.rootgc;
            g.rootgc     = o;
            o.gch.marked = LuaCWhite(g);
            o.gch.tt     = tt;
        }
Example #5
0
File: lgc.cs Project: oathx/Six
		public static bool TestBits(LuaByteType x, int m) { return (x & (LuaByteType)m) != 0; }
Example #6
0
File: lgc.cs Project: oathx/Six
		public static int SetBits(ref LuaByteType x, int m) { x |= (LuaByteType)m; return x; }
Example #7
0
File: lgc.cs Project: oathx/Six
		/*
		** some userful bit tricks
		*/
		public static int ResetBits(ref LuaByteType x, int m) { x &= (LuaByteType)~m; return x; }
Example #8
0
File: lgc.cs Project: oathx/Six
		public static void LuaCLink (LuaState L, GCObject o, LuaByteType tt) {
		  GlobalState g = G(L);
		  o.gch.next = g.rootgc;
		  g.rootgc = o;
		  o.gch.marked = LuaCWhite(g);
		  o.gch.tt = tt;
		}
Example #9
0
File: lgc.cs Project: oathx/Six
		public static int Reset2Bits(ref LuaByteType x, int b1, int b2) { return ResetBits(ref x, (Bit2Mask(b1, b2))); }
Example #10
0
 public static bool TestBit(LuaByteType x, int b)
 {
     return(TestBits(x, BitMask(b)));
 }
Example #11
0
 public static int ResetBit(ref LuaByteType x, int b)
 {
     return(ResetBits(ref x, BitMask(b)));
 }
Example #12
0
 public static bool TestBits(LuaByteType x, int m)
 {
     return((x & (LuaByteType)m) != 0);
 }
Example #13
0
 public static int SetBits(ref LuaByteType x, int m)
 {
     x |= (LuaByteType)m; return(x);
 }
Example #14
0
 /*
 ** some userful bit tricks
 */
 public static int ResetBits(ref LuaByteType x, int m)
 {
     x &= (LuaByteType) ~m; return(x);
 }
Example #15
0
File: lgc.cs Project: oathx/Six
		public static int ResetBit(ref LuaByteType x, int b) { return ResetBits(ref x, BitMask(b)); }
Example #16
0
File: lgc.cs Project: oathx/Six
		public static bool TestBit(LuaByteType x, int b) { return TestBits(x, BitMask(b)); }
Example #17
0
 public static int Reset2Bits(ref LuaByteType x, int b1, int b2)
 {
     return(ResetBits(ref x, (Bit2Mask(b1, b2))));
 }
Example #18
0
File: lgc.cs Project: oathx/Six
		public static bool Test2Bits(LuaByteType x, int b1, int b2) { return TestBits(x, (Bit2Mask(b1, b2))); }
Example #19
0
 public static bool Test2Bits(LuaByteType x, int b1, int b2)
 {
     return(TestBits(x, (Bit2Mask(b1, b2))));
 }
Example #20
0
 private static LuaByteType opmode(LuaByteType t, LuaByteType a, OpArgMask b, OpArgMask c, OpMode m)
 {
     return((LuaByteType)(((t) << 7) | ((a) << 6) | (((LuaByteType)b) << 4) | (((LuaByteType)c) << 2) | ((LuaByteType)m)));
 }
Example #21
0
		private static LuaByteType opmode(LuaByteType t, LuaByteType a, OpArgMask b, OpArgMask c, OpMode m)
		{
			return (LuaByteType)(((t) << 7) | ((a) << 6) | (((LuaByteType)b) << 4) | (((LuaByteType)c) << 2) | ((LuaByteType)m));
		}