lua-users home
lua-l archive

Re: getinfo for activelines on load/loadstring result

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


Hi Luiz,

>This main function only has *two* executable instructions:
>        - an assigment to a global variable 'a' on line 1
>        - an implicit return after line 4

Indeed; I can see it in the luac output.

> See also the output of chunk given by luac -l:
> main <2:0,0> (3 instructions at 0x7f9228c016d0)
> function <2:1,4> (7 instructions at 0x7f9228c01910)

So luac does have the information about the main chunk and the compiled function. Is there any way to get this information using debug.* functions without calling luac or executing the code?

It seems like luac has information about all the levels of functions in the code; for example, the following fragment:

function a()
  print("a")
  local function b()
    print("c")
  end
  print("b")
end

shows one main chunk and two functions:

main <test.lua:0,0> (3 instructions, 12 bytes at 007B1170)
function <test.lua:1,7> (8 instructions, 32 bytes at 007B12A8)
function <test.lua:3,5> (4 instructions, 16 bytes at 007B1B98)

If luac output does have all this information, why is it not available through .activelines for that chunk? Is there any way to get to it?

Paul.


AltStyle によって変換されたページ (->オリジナル) /