예제 #1
0
파일: ldo.cs 프로젝트: jiaguoxinzhi/KopiLua
        public static void LinyeeDCallHook(LinyeeState L, int event_, int line)
        {
            LinyeeHook hook = L.hook;

            if ((hook != null) && (L.allowhook != 0))
            {
                ptrdiff_t   top    = SaveStack(L, L.top);
                ptrdiff_t   ci_top = SaveStack(L, L.ci.top);
                LinyeeDebug ar     = new LinyeeDebug();
                ar.event_      = event_;
                ar.currentline = line;
                if (event_ == LINYEE_HOOKTAILRET)
                {
                    ar.i_ci = 0;        /* tail call; no debug information about it */
                }
                else
                {
                    ar.i_ci = L.ci - L.base_ci;
                }
                LinyeeDCheckStack(L, LINYEE_MINSTACK);          /* ensure minimum stack size */
                L.ci.top = L.top + LINYEE_MINSTACK;
                LinyeeAssert(L.ci.top <= L.stack_last);
                L.allowhook = 0;          /* cannot call hooks inside a hook */
                LinyeeUnlock(L);
                hook(L, ar);
                LinyeeLock(L);
                LinyeeAssert(L.allowhook == 0);
                L.allowhook = 1;
                L.ci.top    = RestoreStack(L, ci_top);
                L.top       = RestoreStack(L, top);
            }
        }
예제 #2
0
 /*
 ** this function can be called asynchronous (e.g. during a signal)
 */
 public static int LinyeeSetHook(LinyeeState L, LinyeeHook func, int mask, int count)
 {
     if (func == null || mask == 0)          /* turn off hooks? */
     {
         mask = 0;
         func = null;
     }
     L.hook          = func;
     L.basehookcount = count;
     ResetHookCount(L);
     L.hookmask = CastByte(mask);
     return(1);
 }
예제 #3
0
        private static int DBGetHook(LinyeeState L)
        {
            int         arg;
            LinyeeState L1   = GetThread(L, out arg);
            CharPtr     buff = new char[5];
            int         mask = LinyeeGetHookMask(L1);
            LinyeeHook  hook = LinyeeGetHook(L1);

            if (hook != null && hook != HookF)        /* external hook? */
            {
                LinyeePushLiteral(L, "external hook");
            }
            else
            {
                GetHookTable(L);
                LinyeePushLightUserData(L, L1);
                LinyeeRawGet(L, -2);          /* get hook */
                LinyeeRemove(L, -2);          /* remove hook table */
            }
            LinyeePushString(L, UnmakeMask(mask, buff));
            LinyeePushInteger(L, LinyeeGetHookCount(L1));
            return(3);
        }