binast / binjs-ref

Reference implementation for the JavaScript Binary AST format
https://binast.github.io/binjs-ref/binjs/index.html
Other
433 stars 38 forks source link

Introducing a new enum variant BinASTStolen to represent stolen AST nodes #365

Closed Yoric closed 5 years ago

Yoric commented 5 years ago

The ViewMut mechanism lets clients steal* subnodes of a tree for rewriting purposes. To steal a subnode, it needs to create a Default::default() node, but this can lead to infinite recursions if the default case happens to rely upon a node of the same type.

This patch introduces Foo::BinASTStolen for all AST enums Foo, which serves to generate the default node, and serves whenever we steal a node.