On 19/02/15 12:38 PM, Andrew Starks
wrote:
On Thursday, February 19, 2015, Soni L. <fakedme@gmail.com>
wrote:
On 19/02/15 09:39 AM, Roberto Ierusalimschy wrote:
local b = (loadstring or load)("function a()\n print(1)\n
print(2)\nend\n return a") -- added "return a"
local d = b()
Right, this works, but this is not quite what I'm looking
for; this is why
I added "without executing the fragment". The general task
is to figure out
the code lines in a file (those that may have breakpoints)
without
executing it. I thought that's what activelines gives me,
but it doesn't
seem to be the case (or maybe I'm not using it the right
way), hence the
question.
Functions in a chunk are only created when you execute the
chunk. So,
while you do not run the fragment, there is no "function a" to
be talked
about.
-- Roberto
Could this be solved by adding something like
debug.getclosure(chunk, cl_id)? (and functions to instantiate
such a closure?)
I mean, string.dump DOES dump inner closures, doesn't it?
--
Disclaimer: these emails are public and can be accessed from
<TODO: get a non-DHCP IP and put it here>. If you do not
agree with this, DO NOT REPLY.
As far as I can recall, it dumps code that creates a closure,
but it is a new closure on every execution (unless it is
optimized to be the same closure, but that *should* be
transparent).
-Andrew
It dumps the code OF the closure as well, no? So e.g. if you have
function f() function g() end end and dump f, you'll get the code
for f and the code for g.
I guess what I really want is debug.getconstant() but that's more
like implementation detail and not particularly useful. (e.g. what
if the implementation decides to store numbers in the opcodes? would
get quite expensive to look them up...)
--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.
|