loki
loki copied to clipboard
IR: Symbol management on scoped nodes
~Note: This PR sits on top of #372, so I'm only filing a draft before anticipated rebase.~
This PR brings a set of convenience methods and expression constructors to the ScopedNode
and ProgramUnit
classes. The idea is that eventually, Subroutine
and Module
classes should become scoped nodes and the expression management API should be equivalent between them.
The idea is to add the following three utilities to the scope objects themselves, to enable quick(er) expression generation:
-
.get_symbol(name)
- utility to look up a symbol by it's name. This will first find it's true owning scope and attach the symbol. -
.Variable(name, ....)
- a shortcut to the generalVariable
constructor that will attempt to build array and scalar symbols, depending on available type information -
.parse_expr
- a shortcut to the general expression parser that can generate nested expression trees from pure strings.