[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

[E8] E8Blob.st

The following code was used to generate blob classes

Object
	subclass: #E8Blob
	instanceVariableNames: ''
	category: #E8 !

! E8Blob class methodsFor: #clone !
clone: tag
	" Create a clone subclass of the receiver.
	Note the clone subclass will have all methods obtained modifying Object method export.
	"

	| cls samples js src |
	tag isNumber ifTrue: [
		^tag timesRepeat: [:i| self clone: i toString ]
	].
	cls := 'smalltalk.addClass("E8Blob' ,tag ,'",smalltalk.E8Blob, [], "E8");
'.	samples :=
		 (Object selectors sorted collect: [:each| Object >> each ])
		,(Object class selectors sorted collect: [:each| Object class >> each ]).
	js := Exporter exportAll: samples.
	src := cls ,(js replace: 'smalltalk.Object' with: 'smalltalk.E8Blob',tag).
	Compiler new eval: src! !

! E8Blob class methodsFor: #polution !
pollute: tag
	" Pollute global pool with object samples. "

	| random garbage |
	tag isNumber ifTrue: [
		^tag timesRepeat: [:i|
			self pollute: i toString
		]
	].
	random := Random new.
	PollutionPool isNil ifTrue: [
		PollutionPool := PoolDictionary new
	].
	garbage := Array
		with: ((1 to: 1000) collect: [:i| random next ]) 
		with: (Object selectors sorted collect: [:each|
			Array with: each with: (Object >> each) source reversed
			]).
	PollutionPool at: tag put: garbage! !