ratel-rust / ratel-core

High performance JavaScript to JavaScript compiler with a Rust core
Apache License 2.0
435 stars 17 forks source link

Add parent tracking to visitor #79

Closed s-coimbra21 closed 6 years ago

s-coimbra21 commented 6 years ago

Add parent tracking using a stack to track the path from the current node being visited to the tree root. I'm using a ParentNode enum with two variants, one for ExpressionNode and another for StatementNode which covers all possible visitable nodes that may have children, the variants store a reference to the actual node so I had to change the lifetimes to &'ast explicitly on the Visitable trait, perhaps there is a better way.

maciejhirsz commented 6 years ago

Will review in depth when I can, but just glossing over the code, it looks really good!