lua-users home
lua-l archive

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


Thanks!

On Wed, Feb 9, 2022 at 8:27 PM Petri Häkkinen <petrih3@gmail.com> wrote:

> 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


--
Best regards,
     Roman