On Thu, 2007-01-11 at 11:44 +0100, Paolo Bonzini wrote: > If you can eliminate "visitor:" keyword by having them be mostly copies, > do it. If you can eliminate "visitor:" and not have them be mostly > copies, even better...
I could do it by merging #visitNode:onMatch: and #visitArgument:onMatch: into calls to #visitNode:withSearches:onMatch:. The attached patch doesn't do it that way. > Sure. I don't have a clue what time zone you are in, so... UTC-0600, meaning my last message was sent at 4:40 AM. I should really learn normal waking hours... -- Stephen Compall http://scompall.nocandysw.com/blog
--- smalltalk-tmp/compiler/ParseTreeSearcher.st 2007-01-11 11:50:03.000000000 -0600
+++ smalltalk--devo--2.2/compiler/ParseTreeSearcher.st 2007-01-11 11:45:33.000000000 -0600
@@ -747,7 +747,6 @@
(key isString not and: [key recurseInto]) ifTrue: [
self visitNodeList: (oldContext at: key put:
(value collect: [:v | v copy]))
- visitor: #visitNode:onMatch:
onMatch: [:newValue |
oldContext at: key put: newValue]]]! !
@@ -775,20 +774,34 @@
^newNode isNil ifTrue: [aNode acceptVisitor: self. aNode]
ifFalse: [aBlock value: newNode. newNode]!
-visitNodeList: aNodeList visitor: vSelector onMatch: aBlock
+visitNodeList: aNodeList onMatch: aBlock
"Answer aNodeList but with each element replaced by the result of
- sending vSelector to me with said element (and a block of my
- own). If any matches occur, I'll call aBlock afterwards with the
+ visitNode:onMatch: with said element (and a block of my own). If
+ any matches occur, I'll call aBlock afterwards with the
replacement of aNodeList before answering it."
| replacementList rlHasMatch |
rlHasMatch := false.
replacementList := aNodeList collect: [:eltNode |
- self perform: vSelector with: eltNode
- with: [:newElt | rlHasMatch := true]].
+ self visitNode: eltNode
+ onMatch: [:newElt | rlHasMatch := true]].
^rlHasMatch
ifTrue: [aBlock value: replacementList. replacementList]
ifFalse: [aNodeList]!
+visitArgumentList: aNodeList onMatch: aBlock
+ "Answer aNodeList but with each element replaced by the result of
+ visitArgument:onMatch: with said element (and a block of my own).
+ If any matches occur, I'll call aBlock afterwards with the
+ replacement of aNodeList before answering it."
+ | replacementList rlHasMatch |
+ rlHasMatch := false.
+ replacementList := aNodeList collect: [:eltNode |
+ self visitArgument: eltNode
+ onMatch: [:newElt | rlHasMatch := true]].
+ ^rlHasMatch
+ ifTrue: [aBlock value: replacementList. replacementList]
+ ifFalse: [aNodeList]! !
+
!ParseTreeRewriter methodsFor: 'visitor-double dispatching'!
acceptAssignmentNode: anAssignmentNode
signature.asc
Description: This is a digitally signed message part
_______________________________________________ help-smalltalk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-smalltalk
