--- a/BlockContext.st Wed Aug 16 14:06:22 2000 +0200
+++ b/BlockContext.st Wed Aug 16 17:01:57 2000 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libbasic' }"
+
Context variableSubclass:#BlockContext
instanceVariableNames:''
classVariableNames:''
@@ -62,6 +64,38 @@
^ false
!
+guessedHome
+ "a temporary kludge: optimized block contexts do (currently) not provide
+ any home info. The code below tries to guess the home."
+
+ |sender tryVars selSender possibleBlocks method mWho|
+
+ (home isNil or:[home isContext not]) ifTrue:[
+ (sender := self sender) notNil ifTrue:[
+ tryVars := false.
+ (selSender := sender selector) notNil ifTrue:[
+ (selSender endsWith:'do:') ifTrue:[
+ tryVars := true.
+ ] ifFalse:[
+ (selSender endsWith:'Do:') ifTrue:[
+ tryVars := true.
+ ]
+ ]
+ ].
+ tryVars ifTrue:[
+ possibleBlocks := sender argsAndVars select:[:v | v isBlock].
+ possibleBlocks := possibleBlocks select:[:b | b home isNil].
+
+ possibleBlocks size == 1 ifTrue:[
+ method := possibleBlocks first method.
+ ^ method.
+ ].
+ ]
+ ].
+ ].
+ ^ nil
+!
+
home
"return the immediate home of the receiver.
normally this is the methodcontext, where the block was created,
@@ -154,38 +188,10 @@
in the args or temporaries, that must be the one.
This helps in some cases.
"
- (sender := self sender) notNil ifTrue:[
- tryVars := false.
- (selSender := sender selector) notNil ifTrue:[
- (selSender endsWith:'do:') ifTrue:[
- tryVars := true.
- ] ifFalse:[
- (selSender endsWith:'Do:') ifTrue:[
- tryVars := true.
- ]
- ]
- ].
- tryVars ifTrue:[
- possibleBlocks := sender argsAndVars select:[:v | v isBlock].
- possibleBlocks := possibleBlocks select:[:b | b home isNil].
-
- possibleBlocks size == 1 ifTrue:[
- method := possibleBlocks first method.
- "
- change the line in the upper-listview
- according the information we have now
- "
- (method isNil
- or:[(mWho := method who) isNil]) ifTrue:[
- ^ '[] (optimized) in ???'.
- ].
- ^ '[] (optimized) in ' ,
- mWho methodClass name , '-' , mWho methodSelector.
- ].
- ]
+ m isNil ifTrue:[
+ ^ '[] (optimized) in ???'.
].
-
- ^ '[] (optimized)'
+ ^ '[] (optimized) in ' , m mclass name , '-' , m selector.
].
mHome := self methodHome.
@@ -234,5 +240,5 @@
!BlockContext class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.28 1999-08-23 17:59:22 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.29 2000-08-16 15:01:57 cg Exp $'
! !