BlockContext.st
changeset 15382 5a8665b2765a
parent 15267 47d41a3d1cbf
child 15454 fd304e6048f0
child 18066 89d51443ba6f
equal deleted inserted replaced
15381:a353b2ca4d08 15382:5a8665b2765a
   158     ^ nil
   158     ^ nil
   159 ! !
   159 ! !
   160 
   160 
   161 !BlockContext methodsFor:'printing & storing'!
   161 !BlockContext methodsFor:'printing & storing'!
   162 
   162 
   163 receiverPrintString
   163 printReceiverOn:aStream
   164     "return a printString describing the contexts receiver.
   164     "print a string describing the receiver of the context on aStream
   165 
   165 
   166      Since this is also used by the debugger(s), be very careful to
   166      Since this is also used by the debugger(s), be very careful to
   167      return something useful, even in case internals of the system
   167      return something useful, even in case internals of the system
   168      got corrupted ... (i.e. avoid messageNotUnderstood here)"
   168      got corrupted ... (i.e. avoid messageNotUnderstood here)"
   169 
   169 
   170     |cls who mHome m className sel homeSel|
   170     |cls who mHome m className homeSel|
   171 
   171 
   172     (home isNil or:[home isContext not]) ifTrue:[
   172     home isContext ifFalse:[
   173         "
   173         "
   174          mhmh - an optimized blocks context
   174          mhmh - an optimized blocks context
   175          should get the block here, and get the method from
   175          should get the block here, and get the method from
   176          that one ...
   176          that one ...
   177          ... but in 2.x, there is no easy way to get to the block
   177          ... but in 2.x, there is no easy way to get to the block
   184          in the args or temporaries, that must be the one.
   184          in the args or temporaries, that must be the one.
   185          This helps in some cases.
   185          This helps in some cases.
   186         "
   186         "
   187         m := self method.
   187         m := self method.
   188         m isNil ifTrue:[
   188         m isNil ifTrue:[
   189             ^ '[] (optimized) in ???'.
   189             aStream nextPutAll:'[] (optimized) in ???'.
       
   190         ] ifFalse:[
       
   191             aStream nextPutAll:'[] in '.
       
   192             m mclass name printOn:aStream.
       
   193             aStream nextPutAll:'>>'.
       
   194             m selector printOn:aStream.
   190         ].
   195         ].
   191         ^ '[] in ' , m mclass name , ' >> ' , m selector.
   196         ^ self.
   192     ].
   197     ].
   193 
   198 
   194     mHome := self methodHome.
   199     mHome := self methodHome.
   195     mHome isNil ifTrue:[
   200     mHome isNil ifTrue:[
   196         'BlockContext [warning]: no methodHome' errorPrintCR.
   201         aStream nextPutAll:'[] (no methodHome!!) in ???'.
   197         ^ '[] in ???'
   202         ^ self.
   198     ].
   203     ].
   199 
   204 
   200     "
   205     "
   201      kludge to avoid slow search for containing class
   206      kludge to avoid slow search for containing class
   202     "
   207     "
   203     ((homeSel := mHome selector) == #doIt
   208     homeSel := mHome selector.
   204     or:[homeSel == #doIt:]) ifTrue:[
   209     (homeSel == #doIt or:[homeSel == #doIt:]) ifTrue:[
   205         sel := #doIt.
       
   206         cls := mHome receiver class.
   210         cls := mHome receiver class.
       
   211         homeSel := #doIt.
   207     ] ifFalse:[
   212     ] ifFalse:[
   208         m := mHome method.
   213         m := mHome method.
   209         m isNil ifTrue:[
   214         m isNil ifTrue:[
   210             'BlockContext [warning]: no method' errorPrintCR.
   215             aStream nextPutAll:'[] (no method!!) in ???'.
   211             ^ '[] in ???'
   216             ^ self.
   212         ].
   217         ].
   213         who := m who.
   218         who := m who.
   214         who notNil ifTrue:[
   219         who notNil ifTrue:[
   215             cls := who methodClass
   220             cls := who methodClass
   216         ] ifFalse:[
   221         ] ifFalse:[
   217             cls := receiver class.
   222             cls := receiver class.
   218         ].
   223         ].
   219         sel := homeSel printString.
       
   220     ].
   224     ].
   221 
   225 
   222     cls isNil ifTrue:[
   226     cls isNil ifTrue:[
   223         'BlockContext [warning]: no home class' errorPrintCR.
   227         className := '???(no home class!!)'
   224         className := '???'
       
   225     ] ifFalse:[
   228     ] ifFalse:[
   226         className := cls name.
   229         className := cls name.
   227         className isNil ifTrue:[
   230         className isEmptyOrNil ifTrue:[
   228             'BlockContext [warning]: nameless class' errorPrintCR.
   231             className := '???(nameless class!!)'
   229             className := '???'
       
   230         ]
   232         ]
   231     ].
   233     ].
   232     ^ '[] in ' , className , ' >> ' , sel
   234     aStream nextPutAll:'[] in '; nextPutAll:className; nextPutAll:'>>'.
       
   235     homeSel printOn:aStream.
   233 
   236 
   234     "Modified: / 19-07-2012 / 11:02:41 / cg"
   237     "Modified: / 19-07-2012 / 11:02:41 / cg"
   235 ! !
   238 ! !
   236 
   239 
   237 !BlockContext methodsFor:'testing'!
   240 !BlockContext methodsFor:'testing'!
   252 ! !
   255 ! !
   253 
   256 
   254 !BlockContext class methodsFor:'documentation'!
   257 !BlockContext class methodsFor:'documentation'!
   255 
   258 
   256 version
   259 version
   257     ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.37 2013-05-24 17:11:15 cg Exp $'
   260     ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.38 2013-06-07 13:32:46 stefan Exp $'
   258 !
   261 !
   259 
   262 
   260 version_CVS
   263 version_CVS
   261     ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.37 2013-05-24 17:11:15 cg Exp $'
   264     ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.38 2013-06-07 13:32:46 stefan Exp $'
   262 ! !
   265 ! !
   263 
   266