On Fri, 2007-01-12 at 09:13 +0100, Paolo Bonzini wrote: > > Might visitNodeList:visitor:onMatch: also be included and used where > > relevant? This gives just enough dynamism that my rewriter subclass > > works without overriding accept*:. > > Ok, so here's my take. > > As far as I understood, what you want is to not use the new instance if > nothing changed in the parse tree. Which seems good.
It also allows visitNode*:*: et al to customize the context in which replacements are delivered to their final containing slots. > lookForMoreMatchesInContext: oldContext > - oldContext keysAndValuesDo: > - [:key :value | > - (key isString not and: [key recurseInto]) > - ifTrue: > - [oldContext at: key put: (value collect: [:each | self > visitNode: each])]]! ! > + oldContext keysAndValuesDo: [:key :value || newValue | > + (key isString not and: [key recurseInto]) ifTrue: [ > + "Of course, the following statement does nothing without the > `deepCopy' > + which fixes the bug." > + newValue := oldContext at: key put: value "deepCopy <<<". Please don't use deepCopy here; it copies too much data from the original tree. collect: [:node | node copy] does exactly the right thing in both the single-node and node-collection cases. > +visitNodes: aNodeList > + ^self visitNodes: aNodeList searches: searches onMatch: [:newNodes |]! Why does this inline visitNodes:onMatch:? (As with visitArguments:.) -- Stephen Compall http://scompall.nocandysw.com/blog
signature.asc
Description: This is a digitally signed message part
_______________________________________________ help-smalltalk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-smalltalk
