'From Cuis 2.0 of 12 February 2010 [latest update: #418] on 17 February 2010 at 10:35:54 pm'!

!EventSensor methodsFor: 'private' stamp: 'jmv 2/11/2010 15:47'!
eventTickler
	"Poll infrequently to make sure that the UI process is not been stuck. 
	If it has been stuck, then spin the event loop so that I can detect the 
	interrupt key."
	"Move declaration of delta to the method start, to avoid a bug in the decompiler"
	| delay delta |
	delay := Delay forMilliseconds: self class eventPollPeriod.
	self lastEventPoll.	"ensure not nil."
	[
		[ 
			delay wait.
			delta := Time millisecondClockValue - lastEventPoll.
			(delta < 0
					or: [delta > self class eventPollPeriod])
				ifTrue: ["force check on rollover"
					self fetchMoreEvents]
		] on: Error do: [:ex | ].
		true 
	] whileTrue.! !


!SystemDictionary methodsFor: 'housekeeping' stamp: 'jmv 2/11/2010 15:50'!
testDecompiler    "Smalltalk testDecompiler"
	"Decompiles the source for every method in the system, and then compiles that source and verifies that it generates (and decompiles to) identical code.  This currently fails in a number of places because some different patterns (esp involving conditionals where the first branch returns) decompile the same."
	 | methodNode oldMethod newMethod badOnes oldCodeString n |
	badOnes _ OrderedCollection new.
	Smalltalk forgetDoIts.
'Decompiling all classes...'
displayProgressAt: Sensor cursorPoint
from: 0 to: CompiledMethod instanceCount
during: [:bar | n _ 0.
	Smalltalk allBehaviorsDo:
		[:cls | 
		"Transcript cr; show: cls name."
		cls selectors do:
			[:selector | (n _ n+1) \\ 100 = 0 ifTrue: [bar value: n].
			oldMethod _ cls compiledMethodAt: selector.
			oldCodeString _ (cls decompilerClass new
								decompile: selector in: cls method: oldMethod)
							decompileString.
			methodNode _ cls compilerClass new
						compile: oldCodeString
						in: cls notifying: nil ifFail: [].
			newMethod _ methodNode generate: #(0 0 0 0).
			oldCodeString = (cls decompilerClass new decompile: selector in: cls method: newMethod) decompileString 
				ifFalse: [
					Transcript cr; show: '***' , cls name , ' ' , selector.
					badOnes add: cls name , ' ' , selector]]].
].
	Smalltalk browseMessageList: badOnes asSortedCollection name: 'Decompiler Discrepancies'! !

SystemDictionary removeSelector: #discardOddsAndEnds!
SystemDictionary removeSelector: #hasMorphic!
SystemDictionary removeSelector: #removeClassFromSystem:logged:!
SystemDictionary removeSelector: #swapBytesIn:from:to:!
SystemDictionary removeSelector: #verifyMorphicAvailability!
