Here is some preliminary code I have been playing with:
| hasWorthlessDoBlockSearch foundList handleParseError |
hasWorthlessDoBlockSearch := STInST.ParseTreeSearcher new
matches: '[:`var | [EMAIL PROTECTED] value: `var]'
do: [:aNode :ans | true].
foundList := OrderedCollection new.
handleParseError := [:class :methodSrc :error :posn |
Transcript nextPutAll: 'Error while parsing in ';
print: class;
nextPutAll: ': '; display: error; nl;
next: posn - 1 putAll: methodSrc startingAt: 1;
nextPutAll: '<**>';
next: methodSrc size - (posn - 1) putAll: methodSrc startingAt: posn;
nl].
Object withAllSubclassesDo: [:class |
class methodDictionary isNil
ifFalse: [class methodDictionary keysDo: [:methodName |
| methodSrc errorHandle gotError |
gotError := false.
methodSrc := class sourceCodeAt: methodName.
errorHandle := [:error :posn |
handleParseError valueWithArguments:
{class. methodSrc. error. posn}.
gotError := true].
[(hasWorthlessDoBlockSearch
executeTree: (STInST.RBParser parseMethod: methodSrc
onError: errorHandle)
initialAnswer: false)
ifTrue: [foundList add: (class compiledMethodAt: methodName).
Transcript print: class; nextPutAll: '>>';
nextPutAll: methodSrc; nl; nl]]
on: Error
do: [:e | gotError ifTrue: [e return] ifFalse: [e pass]]]]].
foundList do: [:each | each printNl]
!No clean design here, but it's a quick way to look for patterns throughout the GST Smalltalk codebase (the loaded packages, anyway). Just change the matches: string to whatever pattern you're looking for. It scans every method source code and prints the methods that match, with a summary list at the end. For example, I used this one to produce [EMAIL PROTECTED]/smalltalk--backstage--2.2--patch-5, also attached. (I was looking at Dictionary>>#associationsDo: when I noticed this pattern, hence my choice of searches.) This is also a good benchmark for method source storage and access, as accessing every method for a given class is a common pattern. -- ;;; Stephen Compall ** http://scompall.nocandysw.com/blog ** "Peta" is Greek for fifth; a petabyte is 10 to the fifth power, as well as fifth in line after kilo, mega, giga, and tera. -- Lee Gomes, performing every Wednesday in his tech column "Portals" on page B1 of The Wall Street Journal
2007-01-23 Stephen Compall <[EMAIL PROTECTED]>
* kernel/Dictionary.st: Use aBlock directly in associationsDo:.
* kernel/AbstNamespc.st: Likewise with subspacesDo:.
--- orig/kernel/AbstNamespc.st
+++ mod/kernel/AbstNamespc.st
@@ -409,7 +409,7 @@
subspacesDo: aBlock
"Invokes aBlock for all direct subspaces."
- self subspaces do: [ :subclass | aBlock value: subclass ]
+ self subspaces do: aBlock
!
withAllSubspaces
--- orig/kernel/Dictionary.st
+++ mod/kernel/Dictionary.st
@@ -287,7 +287,7 @@
associationsDo: aBlock
"Pass each association in the dictionary to aBlock"
- super do: [ :assoc | aBlock value: assoc ]
+ super do: aBlock
!
keysDo: aBlock
signature.asc
Description: This is a digitally signed message part
_______________________________________________ help-smalltalk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-smalltalk
