Open
Description
See the code in compiler/past.nim
and compiler/bitabs.nim
for a rather precise outline of the structure. The plan is to use NimTree
throughout the compiler which is a linearized representation of the AST that only supports in-place mutation in strategic places. In order to support Nim's VM / macro system there will be two operations:
proc fromTree(t: NimTree): PNode
proc toTree(n: PNode): NimTree
Instead of mutating an AST, you create a fresh one. The number of allocations is very low because a full tree is essentially stored as a single string/blob in memory.