loki icon indicating copy to clipboard operation
loki copied to clipboard

IR: Symbol management on scoped nodes

Open mlange05 opened this issue 5 months ago • 2 comments

~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 general Variable 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.

mlange05 avatar Sep 10 '24 11:09 mlange05