[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: About Lua line hook
- From: "Tai Meng" <tmeng@...>
- Date: Mon, 29 Sep 2003 12:21:34 -0700
Thank you Rici for your reply, I had some more questions typed inline.
> So it cannot trigger the linehook at that point
> because the VM instruction at that point might not be the start of a line;
I thought line hooks are only triggered for valid Lua code. So, in my understanding (and through limited testing), if a line hook is triggered, the line number has to point to a valid line of Lua code.) Is that not right?
> So if you think of a line hook happening *after* each line, instead of
> *before* each line
To test that concept, I placed a 'print("end of script")' message as the very last line in a Lua script, and let it run with the line hook attached (the line hook currently prints debug info to the command line). If the line hooks are fired after each line, one would expect the line hook to fire after the last line of Lua code. But it is not, so I am certain that line hooks are fired before each line.
Right now, I am simply initializing the line hook after I attach it to the Lua state. I am calling luaG_inithooks() declared in ldebug.h, and so far I have not experienced any problems. It is also possible to include lstate.h and write lua_state_pointer->hookinit = 1, which seems to work the same way, although the assignment is only a part of what luaG_inithooks() does. My main concern is whether any of these two solutions may cause problems later, or if they are both completely safe.
Tai