lua_xmove

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

lua_xmove

Marius Gheorghe

Hello,

 

Does any one know whether it is safe to use lua_xmove() when both the source and destination states represent the same state and, if it is safe, does this operation leave the stack unchanged (as intuitively expected)?

 

<background info>

I am implementing a Lua debugger for one of our applications. In my implementation, a script is run as a coroutine by invoking lua_resume() while being debugged and run on the main Lua state with lua_pcall() when it’s not being debugged.

The decision to debug the script or not is done at run-time by reading from a properties file.

As the C-side (actually Delphi-side) code uses lua_xmove() in a few places, I could keep the code uncluttered by simply ignoring the fact that the ‘from’ and ‘to’ arguments of lua_xmove() are one and the same state. The two states would coincide when the script is not being debugged and I would expect that such an operation would result in no changes made to the stack.

</background info>

 

Thanks

Marius Gheorghe

 

Reply | Threaded
Open this post in threaded view
|

Re: lua_xmove

Mike Pall-4-2
Hi,

Marius Gheorghe wrote:
> Does any one know whether it is safe to use lua_xmove() when both the source
> and destination states represent the same state and, if it is safe, does
> this operation leave the stack unchanged (as intuitively expected)?

LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
...
  if (from == to) return;
...

Bye,
     Mike
Reply | Threaded
Open this post in threaded view
|

RE: lua_xmove

Marius Gheorghe
> LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
> ...
>   if (from == to) return;
> ...
>
> Bye,
>      Mike

Thanks. On a second thought I could have looked it up myself.

Marius Gheorghe