Context.st
changeset 15644 6302ce0150b4
parent 15388 1b0f7426a7bb
child 15650 6fb6c451391f
--- a/Context.st	Mon Aug 19 12:02:34 2013 +0200
+++ b/Context.st	Mon Aug 19 17:56:31 2013 +0200
@@ -275,9 +275,7 @@
 !Context methodsFor:'Compatibility-Squeak'!
 
 longStack
-    ^ String streamContents:[:s |
-            self fullPrintAllOn:s
-    ]
+    ^ self fullPrintAllString
 ! !
 
 !Context methodsFor:'Compatibility-VW'!
@@ -1500,7 +1498,7 @@
 !Context methodsFor:'printing & storing'!
 
 argStringFor:someObject
-    |name s|
+    |s|
 %{
     /*
      * special handling for (invalid) free objects.
@@ -1509,21 +1507,24 @@
      * However, these print methods are also invoked for low-level pointer errors, so better be prepared...
      */
     if (__isNonNilObject(someObject) && (__qClass(someObject)==nil)) {
-        name = __MKSTRING("FreeObject");
+        s = __MKSTRING("FreeObject");
     }
 %}.
-    name notNil ifTrue:[^ name].
-    s := someObject displayString.
     s isNil ifTrue:[
-        ^ '**************** nil displayString of ',(someObject class name ? '??')
+        s := someObject displayString.
+        s isNil ifTrue:[
+            ^ '**************** nil displayString of ',(someObject class name ? '??')
+        ].
     ].
-    s isWideString ifTrue:[
-        "make sure that the object really returns something we can stream into a string"
-        s := someObject storeString.
-    ].
+"/    JV@2013-04-26: Following is rubbish, the callers must handle string output correctly. 
+"/    moreover storeString does not work on self-referencing structures, but that doesn't matter
+"/    for wide strings.
+"/    SV@2013-08-19: I checked/fixed the callers to use CharacterWriteStreams.
+"/    s isWideString ifTrue:[
+"/        "make sure that the object really returns something we can stream into a string"
+"/        s := someObject storeString.
+"/    ].
     ^ s
-
-    "Modified: / 07-03-2012 / 13:14:17 / cg"
 !
 
 argsDisplayString
@@ -1541,7 +1542,7 @@
         Error handle:[:ex |
             s := 'Error in argString'.
         ] do:[
-            s := (self argStringFor:(self at:index)).
+            s := self argStringFor:(self at:index).
         ].
 
         aStream nextPutAll:(s contractTo:100).
@@ -1582,11 +1583,7 @@
 fullPrintAllString
     "return a string containing the full walkback (incl. arguments)"
 
-    |s|
-
-    s := WriteStream on:''.
-    self fullPrintAllOn:s.
-    ^ s contents
+    ^ String streamContents:[:s | self fullPrintAllOn:s]
 
     "
      thisContext fullPrintAllString
@@ -1627,11 +1624,7 @@
     "return a string describing the context - this includes the linenumber,
      receiver printString and argument printString"
 
-    |s|
-
-    s := WriteStream on:''.
-    self fullPrintOn:s.
-    ^ s contents
+    ^ String streamContents:[:s | self fullPrintOn:s]
 
     "
      thisContext fullPrintString
@@ -2188,7 +2181,7 @@
 argAndVarNames
     "helper: given a context, return a collection of arg&var names"
 
-    |homeContext method block numArgs numVars m src
+    |homeContext homeMethod block numArgs numVars m src
      sel isDoIt blocksLineNr extractFromBlock sender|
 
     numArgs := self numArgs.
@@ -2198,7 +2191,7 @@
     homeContext := self methodHome.
     homeContext notNil ifTrue:[
         sel := homeContext selector.
-        method := homeContext method.
+        homeMethod := homeContext method.
     ].
 
     extractFromBlock :=
@@ -2229,13 +2222,13 @@
 
                 numArgs > 0 ifTrue:[
                     vars := blockNode arguments.
-                    vars size > 0 ifTrue:[
+                    vars notEmptyOrNil ifTrue:[
                         argNames := vars collect:[:var | var name]
                     ]
                 ].
                 numVars > 0 ifTrue:[
-                    vars := blockNode variables.
-                    vars size > 0 ifTrue:[
+                    vars := blockNode variablesIncludingInlined: (homeMethod code notNil and:[homeMethod byteCode isNil]).
+                    vars notEmptyOrNil ifTrue:[
                         varNames := vars collect:[:var | var name].
                     ]
                 ].
@@ -2247,30 +2240,30 @@
     isDoIt := (sel == #'doIt') or:[sel == #'doIt:'].
     self isBlockContext ifFalse:[
         isDoIt ifTrue:[
-            method notNil ifTrue:[
+            homeMethod notNil ifTrue:[
                 "/ special for #doIt
                 m := nil.
-                src := ('[' , method source , '\]') withCRs.
+                src := ('[' , homeMethod source , '\]') withCRs.
                 "/ blocksLineNr := self lineNumber.
                 blocksLineNr := (self home ? self) lineNumber.
                 extractFromBlock value.
             ]
         ].
 
-        method notNil ifTrue:[
-            ^ method methodArgAndVarNames.
+        homeMethod notNil ifTrue:[
+            ^ homeMethod methodArgAndVarNamesInContext: self.
         ].
         ^ #()
     ].
 
-    method notNil ifTrue:[
+    homeMethod notNil ifTrue:[
         isDoIt ifTrue:[
             "/ special for #doIt
             "/ my source is found in the method.
             m := nil.
-            src := ('[' , method source , '\]') withCRs.
+            src := ('[' , homeMethod source , '\]') withCRs.
         ] ifFalse:[
-            m := method.
+            m := homeMethod.
             src := nil.
         ].
         blocksLineNr := self lineNumber.
@@ -2299,6 +2292,8 @@
     ].
 
     ^ #()
+
+    "Modified: / 19-08-2013 / 12:13:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 canResume
@@ -2500,11 +2495,16 @@
 !Context class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.186 2013-06-09 20:40:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.187 2013-08-19 15:56:31 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.186 2013-06-09 20:40:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.187 2013-08-19 15:56:31 stefan Exp $'
+!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
 !
 
 version_SVN