Open SnirkImmington opened 6 years ago
I opened mutable-visitor
to do this and after writing all the _mut
methods the borrow checker complains wherever it can. The main problem is that an entire mode is mutably borrowed while its children are being visited or iterated over. This means that I can't even log the name of a function while iterating through its arguments.
I'm marking this as blocked on a better AST representation. If we used i.e. petgraph then we would be able to do iteration without borrowing the core data structure. If we build a CST before building an AST, we could possibly construct the initial AST with symbol IDs from the start.
Currently (on the
typeck
branch), there are a few passes of the parsed AST which are done:Construction of AST
Identify Pass
ASTIdentifier
sets each expressionIdentifier
'sScopedId
(a kind of De Brujin Index) to match the binding it refers to (taking into account i.e. recursive functions and shadowing).ScopedId
s of type expressions with a table ofType ScopedId -> ConcreteType
. This is the basis for type inference.Check pass
TypeGraph
, producing a more complete mapping of types of expressions which is given to the next passes.Lint Pass
Compile pass
ModuleCompiler
constructs an LLVM Module using the AST and type information.The "identification pass" is the only pass which modifies the AST: it causes nodes to have specific Ids to allow other passes to accumulate information about them.
Code in the
visit
module should be expanded to allow for a "mutating AST visitor."