[squeak-dev] The Inbox: ST80-nice.127.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Mar 31 20:05:31 UTC 2011


A new version of ST80 was added to project The Inbox:
http://source.squeak.org/inbox/ST80-nice.127.mcz

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

Name: ST80-nice.127
Author: nice
Time: 31 March 2011, 10:05:15.793 pm
UUID: 04b556c6-fdea-46d0-b21a-9160ebd94302
Ancestors: ST80-nice.126

Get rid of FakeClassPool and #failedDoIt references.
This is implemented by the mean of #evaluateSelectionAndDo:
This method will pass the result to aBlock argument in case of success, and avoid testing for arbitrary return value (FakeClassPool new or #failedDoit)

=============== Diff against ST80-nice.126 ===============

Item was changed:
  ----- Method: ParagraphEditor>>evaluateSelection (in category 'do-its') -----
  evaluateSelection
  	"Treat the current selection as an expression; evaluate it and return the result"
+ 	
+ 	^self evaluateSelectionAndDo: [:result | result]!
- 	| result rcvr ctxt |
- 	self lineSelectAndEmptyCheck: [^ ''].
- 
- 	(model respondsTo: #doItReceiver) 
- 		ifTrue: [ rcvr := model doItReceiver.
- 				ctxt := model doItContext]
- 		ifFalse: [rcvr := ctxt := nil].
- 	result := [
- 		rcvr class evaluatorClass new 
- 			evaluate: self selectionAsStream
- 			in: ctxt
- 			to: rcvr
- 			notifying: self
- 			ifFail: [^ #failedDoit]
- 			logged: true.
- 	] 
- 		on: OutOfScopeNotification 
- 		do: [ :ex | ex resume: true].
- 	^ result!

Item was added:
+ ----- Method: ParagraphEditor>>evaluateSelectionAndDo: (in category 'do-its') -----
+ evaluateSelectionAndDo: aBlock
+ 	"Treat the current selection as an expression; evaluate it and invoke aBlock with the result."
+ 	| result rcvr ctxt |
+ 	self lineSelectAndEmptyCheck: [^ nil].
+ 
+ 	(model respondsTo: #doItReceiver) 
+ 		ifTrue: [ rcvr := model doItReceiver.
+ 				ctxt := model doItContext]
+ 		ifFalse: [rcvr := ctxt := nil].
+ 	result := [
+ 		rcvr class evaluatorClass new 
+ 			evaluate: self selectionAsStream
+ 			in: ctxt
+ 			to: rcvr
+ 			notifying: self
+ 			ifFail: [self flash. ^nil]
+ 			logged: true.
+ 	] 
+ 		on: OutOfScopeNotification 
+ 		do: [ :ex | ex resume: true].
+ 	^aBlock value: result!

Item was changed:
  ----- Method: ParagraphEditor>>exploreIt (in category 'do-its') -----
  exploreIt
+ 	self evaluateSelectionAndDo: [:result | result explore]
- 	| result |
- 	result := self evaluateSelection.
- 	((result isKindOf: FakeClassPool) or: [result == #failedDoit])
- 			ifTrue: [view flash]
- 			ifFalse: [result explore].
  !

Item was changed:
  ----- Method: ParagraphEditor>>inspectIt (in category 'do-its') -----
  inspectIt
+ 	self evaluateSelectionAndDo: [:result | result inspect].
- 	"1/13/96 sw: minor fixup"
- 	| result |
- 	result := self evaluateSelection.
- 	((result isKindOf: FakeClassPool) or: [result == #failedDoit])
- 			ifTrue: [view flash]
- 			ifFalse: [result inspect].
  !

Item was changed:
  ----- Method: ParagraphEditor>>objectsReferencingIt (in category 'do-its') -----
  objectsReferencingIt
  	"Open a list inspector on all objects that reference the object that results when the current selection is evaluated.  "
  	
+ 	self terminateAndInitializeAround:
+ 		[self evaluateSelectionAndDo: [:result |
+ 			self systemNavigation
- 	self terminateAndInitializeAround: [ | result |
- 	result := self evaluateSelection.
- 	((result isKindOf: FakeClassPool) or: [result == #failedDoit])
- 		ifTrue: [view flash]
- 		ifFalse: [self systemNavigation
  					browseAllObjectReferencesTo: result
  					except: #()
+ 					ifNone: [:obj | view topView flash]]]!
- 					ifNone: [:obj | view topView flash]].
- 	]!

Item was changed:
  ----- Method: ParagraphEditor>>printIt (in category 'do-its') -----
  printIt
  	"Treat the current text selection as an expression; evaluate it. Insert the 
  	description of the result of evaluation after the selection and then make 
  	this description the new text selection."
+ 	self evaluateSelectionAndDo: [:result |
+ 		self afterSelectionInsertAndSelect: result printString]!
- 	| result |
- 	result := self evaluateSelection.
- 	((result isKindOf: FakeClassPool) or: [result == #failedDoit])
- 			ifTrue: [view flash]
- 			ifFalse: [self afterSelectionInsertAndSelect: result printString]!

Item was changed:
  ----- Method: ParagraphEditor>>tallySelection (in category 'do-its') -----
  tallySelection
  	"Treat the current selection as an expression; evaluate it and return the time took for this evaluation"
  	| result rcvr ctxt valueAsString v |
+ 	self lineSelectAndEmptyCheck: [^self].
- 	self lineSelectAndEmptyCheck: [^ -1].
  
  	(model respondsTo: #doItReceiver) 
  		ifTrue: [ rcvr := model doItReceiver.
  				ctxt := model doItContext]
  		ifFalse: [rcvr := ctxt := nil].
  	result := [ | cm |
  		cm := rcvr class evaluatorClass new 
  			compiledMethodFor: self selectionAsStream
  			in: ctxt
  			to: rcvr
  			notifying: self
+ 			ifFail: [self flash. ^self]
- 			ifFail: [^ #failedDoit]
  			logged: false.
  		Time millisecondsToRun: 
  			[v := cm valueWithReceiver: rcvr arguments: #() ].
  	] 
  		on: OutOfScopeNotification 
  		do: [ :ex | ex resume: true].
  
  	"We do not want to have large result displayed"
  	valueAsString := v printString.
  	(valueAsString size > 30) ifTrue: [valueAsString := (valueAsString copyFrom: 1 to: 30), '...'].
  	PopUpMenu 
  		inform: 'Time to compile and execute: ', result printString, 'ms res: ', valueAsString.
  !




More information about the Squeak-dev mailing list