[squeak-dev] The Trunk: Traits-nice.280.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Feb 4 19:21:39 UTC 2010


Nicolas Cellier uploaded a new version of Traits to project The Trunk:
http://source.squeak.org/trunk/Traits-nice.280.mcz

==================== Summary ====================

Name: Traits-nice.280
Author: nice
Time: 4 February 2010, 8:21:32.572 pm
UUID: c73f76e5-ba68-4e91-bc27-ef1754513b29
Ancestors: Traits-ar.279

push some temp declarations inside blocks

=============== Diff against Traits-ar.279 ===============

Item was changed:
  ----- Method: Trait classSide>>flattenTraitMethodsInClass: (in category 'load-unload') -----
  flattenTraitMethodsInClass: aClass
  	"Flatten all the trait methods in the given class"
+ 	
- 	| oldClass |
  	(aClass isTrait or:[aClass hasTraitComposition]) ifFalse:[^self].
  	self storeTraitInfoInClass: aClass.
+ 	aClass selectorsAndMethodsDo:[:sel :meth| | oldClass |
- 	aClass selectorsAndMethodsDo:[:sel :meth|
  		(aClass includesLocalSelector: sel) ifFalse:[
  			oldClass := meth methodHome.
  			aClass compile: (aClass sourceCodeAt: sel)
  				classified: (aClass organization categoryOfElement: sel)
  				withStamp: (oldClass compiledMethodAt: sel ifAbsent:[meth]) timeStamp
  				notifying: nil]].
  	aClass traitComposition: #().!

Item was changed:
  ----- Method: ClassDescription>>assembleTraitMethodsFrom: (in category '*Traits-NanoKernel') -----
  assembleTraitMethodsFrom: aTraitComposition
  	"Assemble the resulting methods for installing the given trait composition.
  	Returns a Dictionary instead of a MethodDictionary for speed (MDs grow by #become:)"
+ 	| methods |
- 	| methods oldMethod |
  	methods := Dictionary new.
  	"Stick in the local methods first, since this avoids generating conflict methods unnecessarily"
  	self selectorsAndMethodsDo:[:sel :newMethod|
  		(self isLocalMethod: newMethod)
  			ifTrue:[methods at: sel put:newMethod]].
  	"Now assemble the traits methods"
  	aTraitComposition do:[:trait|
+ 		trait selectorsAndMethodsDo:[:sel :newMethod| | oldMethod |
- 		trait selectorsAndMethodsDo:[:sel :newMethod|
  			oldMethod := methods at: sel ifAbsentPut:[newMethod].
  			newMethod == oldMethod ifFalse:["a conflict"
  				(self isLocalMethod: oldMethod) ifFalse:[
  					methods at: sel put: (self resolveTraitsConflict: sel from: oldMethod to: newMethod)]]]].
  	^methods!

Item was changed:
  ----- Method: ClassDescription>>installTraitMethodDict: (in category '*Traits-NanoKernel') -----
  installTraitMethodDict: methods
  	"After having assembled the trait composition, install its methods."
+ 	| oldCategories removals |
- 	| oldCategories oldMethod removals |
  	"Apply the changes. We first add the new or changed methods."
  	oldCategories := Set new.
+ 	methods keysAndValuesDo:[:sel :newMethod| | oldMethod |
- 	methods keysAndValuesDo:[:sel :newMethod|
  		oldMethod := self compiledMethodAt: sel ifAbsent:[nil].
  		oldMethod == newMethod ifFalse:[
  			self traitAddSelector: sel withMethod: newMethod.
  			(self organization categoryOfElement: sel) ifNotNil:[:cat| oldCategories add: cat].
  			self organization classify: sel under: 
  				(newMethod methodHome organization categoryOfElement: newMethod selector)]].
  
  	"Now remove the old or obsoleted ones"
  	removals := OrderedCollection new.
  	self selectorsDo:[:sel| (methods includesKey: sel) ifFalse:[removals add: sel]].
  	removals do:[:sel| self traitRemoveSelector: sel].
  
  	"Clean out empty categories"
  	oldCategories do:[:cat|
  		(self organization isEmptyCategoryNamed: cat)
  			ifTrue:[self organization removeCategory: cat]].
  
  !

Item was changed:
  ----- Method: ClassDescription>>updateTraitsFrom: (in category '*Traits-NanoKernel') -----
  updateTraitsFrom: instanceTraits
  	"ClassTrait/Metaclass only. Update me from the given instance traits"
+ 	| map newTraits |
- 	| map newTraits trait |
  	self isMeta ifFalse:[self error: 'This is a metaclass operation'].
  	map := Dictionary new.
  	self traitComposition do:[:composed| map at: composed trait put: composed].
+ 	newTraits := (instanceTraits collect:[:composed| | trait |
- 	newTraits := (instanceTraits collect:[:composed|
  		trait := composed trait classTrait.
  		map at: trait ifAbsent:[trait]] 
  	), (self traitComposition select:[:comp| comp trait isBaseTrait]).
  
  	self installTraitsFrom: newTraits!

Item was changed:
  ----- Method: Trait classSide>>restoreAllTraits (in category 'load-unload') -----
  restoreAllTraits		"Trait restoreAllTraits"
  	"Restores traits that had been previously removed.
  	This is the inverse operation to removeAllTraits."
+ 	| classes |
- 	| classes method |
  	classes := Smalltalk allClasses select:[:aClass| aClass includesSelector: #traitInfo].
+ 	classes do:[:aClass| | method |
- 	classes do:[:aClass|
  		method := aClass compiledMethodAt: #traitInfo.
  		(method pragmaAt: #traitDefinition:) ifNotNil:[:pragma| 
  			pragma arguments first
  				ifTrue:[self convertClassToTrait: aClass]].
  	] displayingProgress:[:aClass| 'Creating trait ', aClass name].
  	classes := Smalltalk allClassesAndTraits select:[:aClass| 
  		(aClass includesSelector: #traitInfo) 
  			or:[aClass classSide includesSelector: #traitInfo]].
  	classes do:[:aClass|
  		self restoreCompositionOf: aClass.
  		self restoreCompositionOf: aClass classSide.
  	] displayingProgress:[:aClass| 'Updating ', aClass name].
  !




More information about the Squeak-dev mailing list