[Pkg] The Trunk: Kernel-ct.1491.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Nov 7 19:52:00 UTC 2022


Christoph Thiede uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ct.1491.mcz

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

Name: Kernel-ct.1491
Author: ct
Time: 7 November 2022, 8:51:11.997226 pm
UUID: 78f3b27b-1a68-4d42-b796-c7edbe07870c
Ancestors: Kernel-ct.1489, Kernel-ct.1294

Merges Kernel-ct.1294:
	Add #haltOnceIf: to Object, which combines the strengths of #haltOnce and #haltIf:. Especially useful in performance-critical situations: It HaltOnce is disabled, the condition will not be evaluated at all.

Revision:
	Minor refactoring. Argument renaming, make use of #findContextSuchThat:.

=============== Diff against Kernel-ct.1489 ===============

Item was changed:
  ----- Method: Object>>haltIf: (in category 'debugging') -----
+ haltIf: aBooleanOrBlockOrSelector
+ 	"This is the typical message to use for inserting breakpoints during debugging. Param can be a boolean block or value, halt if true.
+ 	If the block has one arg, the receiver is bound to that.
+  	If the argument is a selector, we look up in the callchain. Halt if any method's selector equals selector."
- haltIf: condition
- 	"This is the typical message to use for inserting breakpoints during 
- 	debugging.  Param can be a block or expression, halt if true.
- 	If the Block has one arg, the receiver is bound to that.
-  	If the condition is a selector, we look up in the callchain. Halt if
-       any method's selector equals selector."
- 	| cntxt |
  
+ 	^ (self meetsHaltCondition: aBooleanOrBlockOrSelector)
+ 		ifTrue: [self halt]!
- 	condition isSymbol ifTrue:[
- 		"only halt if a method with selector symbol is in callchain"
- 		cntxt := thisContext.
- 		[cntxt sender isNil] whileFalse: [
- 			cntxt := cntxt sender. 
- 			(cntxt selector = condition) ifTrue: [Halt signal].
- 			].
- 		^self.
- 	].
- 	(condition isBlock 
- 			ifTrue: [condition cull: self] 
- 			ifFalse: [condition] 
- 	) ifTrue: [
- 		Halt signal
- 	].!

Item was added:
+ ----- Method: Object>>haltOnceIf: (in category 'debugging') -----
+ haltOnceIf: aBooleanOrBlockOrSelector
+ 	"Check aBooleanOrBlockOrSelector and halt, unless we have already done it once. See #meetsHaltCondition:."
+ 	
+ 	self haltOnceEnabled ifFalse: [^ self].
+ 	^ (self meetsHaltCondition: aBooleanOrBlockOrSelector)
+ 		ifTrue:
+ 			[self clearHaltOnce; halt]!

Item was added:
+ ----- Method: Object>>meetsHaltCondition: (in category 'debugging') -----
+ meetsHaltCondition: aBooleanOrBlockOrSelector
+ 	"If the condition block has one arg, the receiver is bound to that.
+  	If the condition is a selector, we look up in the callchain. Halt if any method's selector equals selector."
+ 	
+ 	aBooleanOrBlockOrSelector isSymbol ifTrue:
+ 		[^ (thisContext home sender findContextSuchThat: [:ctxt |
+ 			ctxt selector = aBooleanOrBlockOrSelector])
+ 				notNil].
+ 	^ aBooleanOrBlockOrSelector isBlock 
+ 		ifTrue: [aBooleanOrBlockOrSelector cull: self] 
+ 		ifFalse: [aBooleanOrBlockOrSelector value]!



More information about the Packages mailing list