Class comments (was Re: ProtoObject?)

Daniel Vainsencher danielv at netvision.net.il
Sat Feb 12 20:15:42 UTC 2000


Well, Dan, I thought it was a tad slow...

Using the Decompiler turns out faster than the compiler, and is good enough 
for our purposes, as hopefully the attached change set will show (it has other 
really minor tweaks).

But the real improvement would be using a different data structure...

Daniel
-------------- next part --------------
'From Squeak2.8alpha of 12 February 2000 [latest update: #1852] on 12 February 2000 at 10:04:05 pm'!

!ClassDescription methodsFor: 'accessing class hierarchy' stamp: 'dvf 2/12/2000 22:03'!
gatherInto: classes classesThatImplementAllOf: selectorSet 
	"Return an array of any classes that implement all the messages in    
	selectorSet."
	| found remaining |
	found _ OrderedCollection new.
	selectorSet do: [:sel | (methodDict includesKey: sel)
			ifTrue: [found add: sel]].
	found isEmpty
		ifTrue: [^ self subclasses do: [:sub | sub gatherInto: classes classesThatImplementAllOf: selectorSet]]
		ifFalse: 
			[remaining _ selectorSet copyWithoutAll: found.
			remaining isEmpty ifTrue: [classes add: self].
			^ self subclasses do: [:sub | sub gatherInto: classes classesThatImplementAllOf: remaining]]! !

!ClassDescription methodsFor: 'accessing class hierarchy' stamp: 'dvf 2/12/2000 19:16'!
inittedTypes
	"Return the initted type of each instance variable. 
	This result is represented as an array parallel to self allInstVarNames, 
	with each element nil or a class."
	| inittedTypes parseNode |
	inittedTypes _ Array new: self instSize.
	self selectors do: 
		[:selector | 
		parseNode _ self decompilerClass new decompile: selector in: self.
		parseNode noteInittedTypes: inittedTypes].
	^ inittedTypes! !

!ClassDescription methodsFor: 'accessing class hierarchy' stamp: 'dvf 2/12/2000 22:02'!
likelyTypes
	"Return the likely types of each instance variable.    
	This result is represented as an array parallel to self allInstVarNames,   
	 with each element being an array of classes -- a union of concrete    
	types."
	| selectorsSent parseNode types inittedTypes inferredTypes classCol |
	selectorsSent _ (1 to: self instSize)
				collect: [:instVarOffset | Set new].
	self selectors do: 
		[:selector | 
		parseNode _ self decompilerClass new decompile: selector in: self.
		parseNode tallySendsToInstVarsInto: selectorsSent].
	selectorsSent _ selectorsSent collect: [:selSet | selSet asOrderedCollection].
	inferredTypes _ selectorsSent
				collect: 
					[:selSet | 
					classCol _ OrderedCollection new.
					ProtoObject gatherInto: classCol classesThatImplementAllOf: selSet.
					classCol asSet].
	inittedTypes _ self inittedTypes.
	"true ifTrue: [^ inferredTypes]."
	^ (1 to: self instSize)
		collect: [:i | (inittedTypes at: i)
				ifNil: 
					[types _ inferredTypes at: i.
					(types isEmpty or: [types = {ProtoObject}])
						ifTrue: [Object]
						ifFalse: [types detect: [:cl | cl inheritsFrom: Magnitude]
								ifNone: [types detectMax: [:cl | cl allSubclasses size]]]]]! !


-------------- next part --------------






More information about the Squeak-dev mailing list