[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Detecting an "empty" script?
- From: "Peter Loveday" <peter@...>
- Date: Thu, 21 Aug 2003 14:05:24 -0400
> For example, this script does nothing:
> "function main(arg)
> While this one does:
> "x = 4"
I wouldn't really consider the first example a script that does nothing. It
defines a global called 'main' - it happens to be an empty function, but it
can still stomp over any other 'main' I might already have.
Basically both scripts re-define the values of global variables; whether
they are set to 4 or an empty function is beside the point.
In any case, it might be adequate for you to install a global metatable and
catch added globals.. though if you want to catch modified ones you'll need
to do the proxy table trick and switch the global environment. This will
allow you to tell if the script has any side-effects (like modifying vars
etc), but will not help if you truly want to know if the script executes
For example, 'print("Hello")' would execute code, but not modify anything in
global space, or have any side effects on the calling code. Nor would
declaring locals etc.
Love, Light and Peace,
- Peter Loveday
Director of Development, eyeon Software
----- Original Message -----
From: "Ando Sonenblick" <email@example.com>
To: "Lua list" <firstname.lastname@example.org>
Sent: Thursday, August 21, 2003 1:48 PM
Subject: Detecting an "empty" script?
> I need to determine if a Lua script does something -- anything -- nor not.
> I know I can technically parse the text of the script to determine if it
> will do anything or not, but that seems like a lot of work trying to
> decipher things.
> Is there a way that Lua can be convinced to determine this for me? I'm
> thinking that once the script is compiled, one could quickly scan it for
> "set" opcodes and such?
> Any thoughts?
> SpriTec Software