Allow specifying context for #to_ruby calls

The context will be used to track in which part of the AST we are so
that we can e.g. detect nested functions.
Raise an exception when encountering a nested function