lua-users home
lua-l archive

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


With regard to (2), you could either go after singlevar in lparser.c or the references to OP_GETGLOBAL and OP_SETGLOBAL in lcode.c. For example, the code that emits OP_GETGLOBAL could be modified to check against a set of valid globals. (Generalizing on that notion, I could also see doing things that would limit method calls to known valid methods.)

Mark

On Nov 29, 2009, at 5:47 PM, Mark Hamburg wrote:

> There are a couple of approaches:
> 
> 1. Take the byte code generated by load followed by dump, scan it for access to globals, and complain if there are any values not on your list. See the various discussions of "linting" Lua.
> 
> 2. If you are prepared to modify the compiler, I think that it's actually possible to move that check into the compiler itself.
> 
> So, this is entirely doable but it isn't trivial since what you are looking for isn't a syntax error (though option 2 makes it one).
> 
> Mark
> 
>