-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Tree transformer&TreeTransform #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
What about |
|
||
def transformAnnotated(tree: Annotated, annot: Tree, arg: Tree)(implicit ctx: Context): Annotated = cpy.Annotated(tree, annot, arg) | ||
|
||
def transformSharedTree(tree: SharedTree, shared: Tree)(implicit ctx: Context): SharedTree = cpy.SharedTree(tree, shared) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this going away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially yes. But now it's still here.
@odersky I had a close look at optimizations in your implementation and incorporated similar ideas:
|
tree = tree match { | ||
case tree: Ident => | ||
var t: Tree = tree | ||
val mutatedInfo = mutateTransformers(info, _.prepareForIdent(tree), info.nx.nxPrepIdent, cur) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idea: preemptively create mutators
Result of discussion: split big method, have transformers responsible of calling remaining transformations on created nodes. |
LGTM, although I suggest squashing the 4 commits because their history is erased in the last one anyway. |
Agree on sqashing and another small thing: I would suggest to reorder prepare/transform methods so that each is a block. It's easier to see what kinds of methods are supported that way, and it's also simpler to just copy a block of transform methods in order to modify them in a subclass. Otherwise LGTM. |
1) using fast tracks in case node type isn't altered by Transformation; 2) using pre-computed hints(nxTransformXXX arrays) to quickly jump to next transformation interested in transforming particular Tree type; 3) using pre-computed hints(nxPrepareXXX arrays) to know which transformations are going to 'prepare' for transforming particular Tree type; 4) recomputing those hints in case some transformation changed implementation class during 'prepare'; 5) TreeTransform is now responsible of calling transformFollowing on nodes created by it.
Tree transformer&TreeTransform
Remove flow typing from main branch
Backport "Apply implicit conversion from derived Conversion instance defined as implicit rather than given" to 3.3 LTS
To speedup discussion I propose my implementation