BlockContext.st
changeset 15382 5a8665b2765a
parent 15267 47d41a3d1cbf
child 15454 fd304e6048f0
child 18066 89d51443ba6f
--- a/BlockContext.st	Fri Jun 07 14:18:34 2013 +0200
+++ b/BlockContext.st	Fri Jun 07 15:32:46 2013 +0200
@@ -160,16 +160,16 @@
 
 !BlockContext methodsFor:'printing & storing'!
 
-receiverPrintString
-    "return a printString describing the contexts receiver.
+printReceiverOn:aStream
+    "print a string describing the receiver of the context on aStream
 
      Since this is also used by the debugger(s), be very careful to
      return something useful, even in case internals of the system
      got corrupted ... (i.e. avoid messageNotUnderstood here)"
 
-    |cls who mHome m className sel homeSel|
+    |cls who mHome m className homeSel|
 
-    (home isNil or:[home isContext not]) ifTrue:[
+    home isContext ifFalse:[
         "
          mhmh - an optimized blocks context
          should get the block here, and get the method from
@@ -186,29 +186,34 @@
         "
         m := self method.
         m isNil ifTrue:[
-            ^ '[] (optimized) in ???'.
+            aStream nextPutAll:'[] (optimized) in ???'.
+        ] ifFalse:[
+            aStream nextPutAll:'[] in '.
+            m mclass name printOn:aStream.
+            aStream nextPutAll:'>>'.
+            m selector printOn:aStream.
         ].
-        ^ '[] in ' , m mclass name , ' >> ' , m selector.
+        ^ self.
     ].
 
     mHome := self methodHome.
     mHome isNil ifTrue:[
-        'BlockContext [warning]: no methodHome' errorPrintCR.
-        ^ '[] in ???'
+        aStream nextPutAll:'[] (no methodHome!!) in ???'.
+        ^ self.
     ].
 
     "
      kludge to avoid slow search for containing class
     "
-    ((homeSel := mHome selector) == #doIt
-    or:[homeSel == #doIt:]) ifTrue:[
-        sel := #doIt.
+    homeSel := mHome selector.
+    (homeSel == #doIt or:[homeSel == #doIt:]) ifTrue:[
         cls := mHome receiver class.
+        homeSel := #doIt.
     ] ifFalse:[
         m := mHome method.
         m isNil ifTrue:[
-            'BlockContext [warning]: no method' errorPrintCR.
-            ^ '[] in ???'
+            aStream nextPutAll:'[] (no method!!) in ???'.
+            ^ self.
         ].
         who := m who.
         who notNil ifTrue:[
@@ -216,20 +221,18 @@
         ] ifFalse:[
             cls := receiver class.
         ].
-        sel := homeSel printString.
     ].
 
     cls isNil ifTrue:[
-        'BlockContext [warning]: no home class' errorPrintCR.
-        className := '???'
+        className := '???(no home class!!)'
     ] ifFalse:[
         className := cls name.
-        className isNil ifTrue:[
-            'BlockContext [warning]: nameless class' errorPrintCR.
-            className := '???'
+        className isEmptyOrNil ifTrue:[
+            className := '???(nameless class!!)'
         ]
     ].
-    ^ '[] in ' , className , ' >> ' , sel
+    aStream nextPutAll:'[] in '; nextPutAll:className; nextPutAll:'>>'.
+    homeSel printOn:aStream.
 
     "Modified: / 19-07-2012 / 11:02:41 / cg"
 ! !
@@ -254,10 +257,10 @@
 !BlockContext class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.37 2013-05-24 17:11:15 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.38 2013-06-07 13:32:46 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.37 2013-05-24 17:11:15 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.38 2013-06-07 13:32:46 stefan Exp $'
 ! !