Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!udel!new From: new@udel.edu (Darren New) Newsgroups: comp.lang.smalltalk Subject: Smalltalk source examples 3 Message-ID: <909@nigel.udel.EDU> Date: 5 Oct 89 19:55:44 GMT Sender: usenet@udel.EDU Reply-To: new@udel.edu (Darren New) Organization: University of Delaware Lines: 55 Upon getting WISE (an Estelle interpreter in Smalltalk program from NIST), I found that most of the methods were formatted in a manner unpleasant to my eye. I therefore wrote this little gem, which goes through all the classes and metaclasses in WISE and reformats the program. Be sure to do a newSources (SystemDictionary) after this, because it does not put out the categories for the messages it formats. Also, it takes a long time. Hack away! -- Darren ---------------------------------------------------------- 'From Smalltalk-80, Version 2.2 of July 4, 1987 on 5 October 1989 at 3:26:52 pm'! !Wise class methodsFor: 'fileOut'! formatSources "Wise formatSources" | estClasses more i j src aCompiler newText | estClasses _ #GropeWiseDriver. estClasses _ OrderedCollection new. estClasses add: TypedValue; add: Definition; add: ActiveAction; add: VariableDeclaration; add: SynchronizationPrimitive; add: List; addAll: List allSubclasses; add: IpQueue; add: Parent; addAll: Parent allSubclasses; add: ServiceHandler; addAll: ServiceHandler allSubclasses; add: ModuleInstance; addAll: ModuleInstance allSubclasses; add: Range; add: IpReference. estClasses addAll: TypedValue allSubclasses. estClasses addAll: Definition allSubclasses. estClasses addAll: ActiveAction allSubclasses. estClasses addAll: VariableDeclaration allSubclasses. estClasses addAll: SynchronizationPrimitive allSubclasses. more _ OrderedCollection new. more addAll: (SystemOrganization listAtCategoryNamed: 'Estelle-ActivationEnvironment' asSymbol). more addAll: (SystemOrganization listAtCategoryNamed: 'Estelle-Interface' asSymbol). more do: [:n | estClasses add: (Smalltalk at: n)]. more _ estClasses shallowCopy. 1 to: more size do: [:n | more at: n put: (more at: n) class]. more do: [:n | estClasses add: n]. i _ j _ 0. estClasses do: [:cls | j _ j + 1. Transcript cr; show: cls printString , ' (' , j printString , ' of ' , estClasses size printString , ')'. cls selectors do: [:sel | i _ i + 1. src _ cls sourceCodeAt: sel. aCompiler _ cls compilerClass new. newText _ aCompiler format: src in: cls notifying: self. newText == nil ifFalse: [(cls compiledMethodAt: sel) putSource: newText inFile: 2]]]. Transcript cr; show: 'A total of ' , i printString , ' methods in ' , j printString , ' classes were modified.'; cr! !