Beispiel #1
0
        public static void luaS_fix(TString s)
        {
            ly_byte marked = s.tsv.marked;              // can't pass properties in as ref

            LSetBit(ref marked, FIXEDBIT);
            s.tsv.marked = marked;
        }
Beispiel #2
0
        private static void traceexec(LinyeeState L, InstructionPtr pc)
        {
            ly_byte        mask  = L.hookmask;
            InstructionPtr oldpc = InstructionPtr.Assign(L.savedpc);

            L.savedpc = InstructionPtr.Assign(pc);
            if (((mask & LINYEE_MASKCOUNT) != 0) && (L.hookcount == 0))
            {
                ResetHookCount(L);
                LinyeeDCallHook(L, LINYEE_HOOKCOUNT, -1);
            }
            if ((mask & LINYEE_MASKLINE) != 0)
            {
                Proto p       = CIFunc(L.ci).l.p;
                int   npc     = PCRel(pc, p);
                int   newline = GetLine(p, npc);

                /* call linehook when enter a new function, when jump back (loop),
                 * or when enter a new line */
                if (npc == 0 || pc <= oldpc || newline != GetLine(p, PCRel(oldpc, p)))
                {
                    LinyeeDCallHook(L, LINYEE_HOOKLINE, newline);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 打开一个新线程
        /// </summary>
        /// <returns></returns>
        public static LinyeeState LinyeeNewState(ly_Alloc f, object ud)
        {
            int         i;
            LinyeeState L;
            GlobalState g;
            //object l = f(ud, null, 0, (uint)state_size(typeof(LG)));
            var lg = new LG();

            if (lg == null)
            {
                return(null);
            }
            L              = lg.l; // tostate(l);
            g              = lg.g; // (L as LG).g;
            L.next         = null;
            L.tt           = LINYEE_TTHREAD;
            g.currentwhite = (ly_byte)Bit2Mask(WHITE0BIT, FIXEDBIT);
            L.marked       = LinyeeCWhite(g);
            ly_byte marked = L.marked;  // can't pass properties in as ref

            Set2Bits(ref marked, FIXEDBIT, SFIXEDBIT);
            L.marked = marked;
            preinit_state(L, g);
            g.frealloc        = f;
            g.ud              = ud;
            g.mainthread      = L;
            g.uvhead.u.l.prev = g.uvhead;
            g.uvhead.u.l.next = g.uvhead;
            g.GCthreshold     = 0; /* mark it as unfinished state */
            g.strt.size       = 0;
            g.strt.nuse       = 0;
            g.strt.hash       = null;
            SetNilValue(Registry(L));
            luaZ_initbuffer(L, g.buff);
            g.panic      = null;
            g.gcstate    = GCSpause;
            g.rootgc     = obj2gco(L);
            g.sweepstrgc = 0;
            g.sweepgc    = new RootGCRef(g);
            g.gray       = null;
            g.grayagain  = null;
            g.weak       = null;
            g.tmudata    = null;
            g.totalbytes = (uint)GetUnmanagedSize(typeof(LG));
            g.gcpause    = LUAI_GCPAUSE;
            g.gcstepmul  = LUAI_GCMUL;
            g.gcdept     = 0;
            for (i = 0; i < NUMTAGS; i++)
            {
                g.mt[i] = null;
            }
            if (LinyeeDRawRunProtected(L, f_luaopen, null) != 0)
            {
                /* memory allocation error: free partial state */
                close_state(L);
                L = null;
            }
            else
            {
                luai_userstateopen(L);
            }
            return(L);
        }