lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks Roberto and Francisco for the reply.

Can you please tell me how can I get the index of the returned value. I checked the value of fTransfer and nTransfer fields, and value of these fields are very large.

top : 24
Checking top element value : 255
ftransfer index : 57552
ntransfer index : 65535


To print the value of theses, I added following code:

printf("\nftransfer index : %d", ar->ftransfer);
printf("\nntransfer index : %d", ar->ntransfer);

On Tue, Aug 3, 2021 at 8:04 PM Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> I may be confused but...
>
> On Tue, Aug 3, 2021 at 12:57 PM aman agrawal <aman.161089@gmail.com> wrote:
> ...
> >> I'm trying to run the attached program in Lua 5.2.2 and 5.4.3 but I'm getting different number of arguments in Lua stack when I check in hook function. Is anything changed related to Lua hook function call?.
>
> Something seems to have changed, your code proves that. But AFAICS
> nothing is said in the docs regarding the stack contents on hook
> functions calls, so you seem to be purposely hitting undefined (tm)
> behaviour ( I may have misread the docs, please point me to the
> appropiate point if you know some place where stack contents are
> documented ) .

Right. The stack content during hooks is mostly undefined. Hooks neither
receive nor return anything through the stack, and the stack content
represents the internal code state when the hook is called.

The only thing significant in the stack during hooks are parameters
and return values during respectively call and return hooks. That
information became more organized in 5.4 with the creation of
fields fTransfer and nTransfer in the lua_Debug structure.

-- Roberto


--
Best Regards
Aman Agrawal