lua-users home
lua-l archive

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


> On 8 Feb 2022, at 17.50, Roman Gershman <romange@gmail.com> wrote:
> 
> Hi, suppose I compile the code below via luaL_loadbuffer and subsequent lua_pcall calls.
> 
> function foo(n)
>   return someundefined_func(1, n)
> end
> 
> 
> Is it possible to know somehow that foo calls someundefined_func which accepts 2 arguments?
> In other words, is there an API that allows querying referenced symbols and in the case of functions - their signatures?
> 

There is no such API in Lua. This may not be what you're looking for, but Luau, Roblox's custom Lua implementation, has a very good static code analysis machinery which would be a good basis to build somethig like this. You can easily build the AST from Lua source and iterate it. It's based on Lua 5.1 though.

Petri