Say I have a function:

```
function hi()
    print('hi')
end

```

I'd like to be able to take this function as an argument and perform analysis on it, such as listing all the function calls in it, seeing all the variables it references, etc.

Note that I'm not talking about analysing *source code*; I don't have the source text of the function, I just have the function object, i.e. this is being done at runtime.

The way I think you'd go about doing this is to get the AST of the function. But I don't know how to do that. So how would I go about getting the AST of a function (or otherwise analysing it if there's a better way)?