BlockContext.st
changeset 357 82091a50055d
parent 293 31df3850e98c
child 360 90c3608b92a3
equal deleted inserted replaced
356:6c5ce0e1e7a8 357:82091a50055d
    19 
    19 
    20 BlockContext comment:'
    20 BlockContext comment:'
    21 COPYRIGHT (c) 1993 by Claus Gittinger
    21 COPYRIGHT (c) 1993 by Claus Gittinger
    22 	      All Rights Reserved
    22 	      All Rights Reserved
    23 
    23 
    24 $Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.13 1995-03-06 19:14:53 claus Exp $
    24 $Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.14 1995-06-06 03:52:58 claus Exp $
    25 '!
    25 '!
    26 
    26 
    27 !BlockContext class methodsFor:'documentation'!
    27 !BlockContext class methodsFor:'documentation'!
    28 
    28 
    29 copyright
    29 copyright
    40 "
    40 "
    41 !
    41 !
    42 
    42 
    43 version
    43 version
    44 "
    44 "
    45 $Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.13 1995-03-06 19:14:53 claus Exp $
    45 $Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.14 1995-06-06 03:52:58 claus Exp $
    46 "
    46 "
    47 !
    47 !
    48 
    48 
    49 documentation
    49 documentation
    50 "
    50 "
   117 
   117 
   118 !BlockContext methodsFor:'printing & storing'!
   118 !BlockContext methodsFor:'printing & storing'!
   119 
   119 
   120 receiverPrintString
   120 receiverPrintString
   121     "return a printString describing the contexts receiver.
   121     "return a printString describing the contexts receiver.
   122      Since this is called from the debugger, be very careful to
   122 
       
   123      Since this is also used by the debugger(s), be very careful to
   123      return something useful, even in case internals of the system
   124      return something useful, even in case internals of the system
   124      got corrupted ... (i.e. avoid messageNotUnderstood here)"
   125      got corrupted ... (i.e. avoid messageNotUnderstood here)"
   125 
   126 
   126     |cls who mHome m className|
   127     |cls who mHome m className 
   127 
   128      sender selSender tryVars possibleBlocks method mWho|
   128     home isNil ifTrue:[
   129 
       
   130     (home isNil or:[home isContext not]) ifTrue:[
       
   131 	"
       
   132 	 mhmh - an optimized blocks context
       
   133 	 should get the block here, and get the method from
       
   134 	 that one ...
       
   135 	 ... but in 2.10.x, there is no easy way to get to the block
       
   136 	 since that one is not in the context.
       
   137 	 Starting with 2.11, the new block calling scheme will fix this.
       
   138 	"
       
   139 
       
   140 	"temporary kludge - peek into the sender context.
       
   141 	 If its a do-like method and there is a single block variable 
       
   142 	 in the args or temporaries, that must be the one.
       
   143 	 This helps in some cases.
       
   144 	"
       
   145 	(sender := self sender) notNil ifTrue:[
       
   146 	    tryVars := false.
       
   147 	    (selSender := sender selector) notNil ifTrue:[
       
   148 		(selSender endsWith:'do:') ifTrue:[
       
   149 		    tryVars := true.
       
   150 		] ifFalse:[
       
   151 		    (selSender endsWith:'Do:') ifTrue:[
       
   152 			tryVars := true.
       
   153 		    ]
       
   154 		]
       
   155 	    ].
       
   156 	    tryVars ifTrue:[
       
   157 		possibleBlocks := sender argsAndVars select:[:v | v isBlock].
       
   158 		possibleBlocks := possibleBlocks select:[:b | b home isNil].
       
   159 
       
   160 		possibleBlocks size == 1 ifTrue:[
       
   161 		    method := possibleBlocks first method.
       
   162 		    "
       
   163 		     change the line in the upper-listview
       
   164 		     according the information we have now
       
   165 		    "
       
   166 		    mWho := method who.
       
   167 		    ^ '[] (optimized) in ' , 
       
   168 		      (mWho at:1) name , '-' , (mWho at:2).
       
   169 		].
       
   170 	    ]
       
   171 	].
       
   172 
   129 	^ '[] optimized'
   173 	^ '[] optimized'
   130     ].
   174     ].
   131     home isContext ifFalse:[
   175 
   132 	"a copying block"
       
   133 
       
   134 	"/ receiverClassName := home selfValue class name.
       
   135 	^ '[] optimized'
       
   136     ].
       
   137     mHome := self methodHome.
   176     mHome := self methodHome.
   138     mHome isNil ifTrue:[
   177     mHome isNil ifTrue:[
   139 	'BCONTEXT: no methodHome' errorPrintNL.
   178 	'BCONTEXT: no methodHome' errorPrintNL.
   140 	^ '[] in ???'
   179 	^ '[] in ???'
   141     ].
   180     ].