lua-users home
lua-l archive

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


Florian Berger wrote:

Ok. What I want to control at this point are variable assignments (global and local) and function calls. With function calls I mean function's parameters and return values. So I want to have control over parameters before function is called and return values before they are returned.

At least for global functions and variables, you could implement this in Lua itself:

For your chunk of code to be executed, set a private environment (setfenv) with a metatable containing __index and __newindex functions. Inside these functions you could catch the assigment and retrieval of global variables. For the case there is a retrieval of a function (because a function call is to be made), you could return a proxy function (a closure) which checks the arguments if it gets called and call the real function after the checks.

You can't trace local variables with this approach.

Attachment: signature.asc
Description: OpenPGP digital signature