1498 ! ! |
1496 ! ! |
1499 |
1497 |
1500 !Context methodsFor:'printing & storing'! |
1498 !Context methodsFor:'printing & storing'! |
1501 |
1499 |
1502 argStringFor:someObject |
1500 argStringFor:someObject |
1503 |name s| |
1501 |s| |
1504 %{ |
1502 %{ |
1505 /* |
1503 /* |
1506 * special handling for (invalid) free objects. |
1504 * special handling for (invalid) free objects. |
1507 * these only appear if some primitiveCode does not correctly use SEND macros, |
1505 * these only appear if some primitiveCode does not correctly use SEND macros, |
1508 * which may lead to sends to free objects. In normal operation, this 'cannot' happen. |
1506 * which may lead to sends to free objects. In normal operation, this 'cannot' happen. |
1509 * However, these print methods are also invoked for low-level pointer errors, so better be prepared... |
1507 * However, these print methods are also invoked for low-level pointer errors, so better be prepared... |
1510 */ |
1508 */ |
1511 if (__isNonNilObject(someObject) && (__qClass(someObject)==nil)) { |
1509 if (__isNonNilObject(someObject) && (__qClass(someObject)==nil)) { |
1512 name = __MKSTRING("FreeObject"); |
1510 s = __MKSTRING("FreeObject"); |
1513 } |
1511 } |
1514 %}. |
1512 %}. |
1515 name notNil ifTrue:[^ name]. |
|
1516 s := someObject displayString. |
|
1517 s isNil ifTrue:[ |
1513 s isNil ifTrue:[ |
1518 ^ '**************** nil displayString of ',(someObject class name ? '??') |
1514 s := someObject displayString. |
1519 ]. |
1515 s isNil ifTrue:[ |
1520 s isWideString ifTrue:[ |
1516 ^ '**************** nil displayString of ',(someObject class name ? '??') |
1521 "make sure that the object really returns something we can stream into a string" |
1517 ]. |
1522 s := someObject storeString. |
1518 ]. |
1523 ]. |
1519 "/ JV@2013-04-26: Following is rubbish, the callers must handle string output correctly. |
|
1520 "/ moreover storeString does not work on self-referencing structures, but that doesn't matter |
|
1521 "/ for wide strings. |
|
1522 "/ SV@2013-08-19: I checked/fixed the callers to use CharacterWriteStreams. |
|
1523 "/ s isWideString ifTrue:[ |
|
1524 "/ "make sure that the object really returns something we can stream into a string" |
|
1525 "/ s := someObject storeString. |
|
1526 "/ ]. |
1524 ^ s |
1527 ^ s |
1525 |
|
1526 "Modified: / 07-03-2012 / 13:14:17 / cg" |
|
1527 ! |
1528 ! |
1528 |
1529 |
1529 argsDisplayString |
1530 argsDisplayString |
1530 ^ String streamContents:[:s | self displayArgsOn:s ]. |
1531 ^ String streamContents:[:s | self displayArgsOn:s ]. |
1531 |
1532 |
2186 !Context methodsFor:'special accessing'! |
2179 !Context methodsFor:'special accessing'! |
2187 |
2180 |
2188 argAndVarNames |
2181 argAndVarNames |
2189 "helper: given a context, return a collection of arg&var names" |
2182 "helper: given a context, return a collection of arg&var names" |
2190 |
2183 |
2191 |homeContext method block numArgs numVars m src |
2184 |homeContext homeMethod block numArgs numVars m src |
2192 sel isDoIt blocksLineNr extractFromBlock sender| |
2185 sel isDoIt blocksLineNr extractFromBlock sender| |
2193 |
2186 |
2194 numArgs := self numArgs. |
2187 numArgs := self numArgs. |
2195 numVars := self numVars. |
2188 numVars := self numVars. |
2196 (numArgs == 0 and:[numVars == 0]) ifTrue:[^ #()]. |
2189 (numArgs == 0 and:[numVars == 0]) ifTrue:[^ #()]. |
2197 |
2190 |
2198 homeContext := self methodHome. |
2191 homeContext := self methodHome. |
2199 homeContext notNil ifTrue:[ |
2192 homeContext notNil ifTrue:[ |
2200 sel := homeContext selector. |
2193 sel := homeContext selector. |
2201 method := homeContext method. |
2194 homeMethod := homeContext method. |
2202 ]. |
2195 ]. |
2203 |
2196 |
2204 extractFromBlock := |
2197 extractFromBlock := |
2205 [ |
2198 [ |
2206 |blockNode argNames varNames vars args blocksHome| |
2199 |blockNode argNames varNames vars args blocksHome| |
2227 argNames := #(). |
2220 argNames := #(). |
2228 varNames := #(). |
2221 varNames := #(). |
2229 |
2222 |
2230 numArgs > 0 ifTrue:[ |
2223 numArgs > 0 ifTrue:[ |
2231 vars := blockNode arguments. |
2224 vars := blockNode arguments. |
2232 vars size > 0 ifTrue:[ |
2225 vars notEmptyOrNil ifTrue:[ |
2233 argNames := vars collect:[:var | var name] |
2226 argNames := vars collect:[:var | var name] |
2234 ] |
2227 ] |
2235 ]. |
2228 ]. |
2236 numVars > 0 ifTrue:[ |
2229 numVars > 0 ifTrue:[ |
2237 vars := blockNode variables. |
2230 vars := blockNode variablesIncludingInlined: (homeMethod code notNil and:[homeMethod byteCode isNil]). |
2238 vars size > 0 ifTrue:[ |
2231 vars notEmptyOrNil ifTrue:[ |
2239 varNames := vars collect:[:var | var name]. |
2232 varNames := vars collect:[:var | var name]. |
2240 ] |
2233 ] |
2241 ]. |
2234 ]. |
2242 ^ argNames , varNames |
2235 ^ argNames , varNames |
2243 ]. |
2236 ]. |
2245 |
2238 |
2246 "/ #doIt needs special handling below |
2239 "/ #doIt needs special handling below |
2247 isDoIt := (sel == #'doIt') or:[sel == #'doIt:']. |
2240 isDoIt := (sel == #'doIt') or:[sel == #'doIt:']. |
2248 self isBlockContext ifFalse:[ |
2241 self isBlockContext ifFalse:[ |
2249 isDoIt ifTrue:[ |
2242 isDoIt ifTrue:[ |
2250 method notNil ifTrue:[ |
2243 homeMethod notNil ifTrue:[ |
2251 "/ special for #doIt |
2244 "/ special for #doIt |
2252 m := nil. |
2245 m := nil. |
2253 src := ('[' , method source , '\]') withCRs. |
2246 src := ('[' , homeMethod source , '\]') withCRs. |
2254 "/ blocksLineNr := self lineNumber. |
2247 "/ blocksLineNr := self lineNumber. |
2255 blocksLineNr := (self home ? self) lineNumber. |
2248 blocksLineNr := (self home ? self) lineNumber. |
2256 extractFromBlock value. |
2249 extractFromBlock value. |
2257 ] |
2250 ] |
2258 ]. |
2251 ]. |
2259 |
2252 |
2260 method notNil ifTrue:[ |
2253 homeMethod notNil ifTrue:[ |
2261 ^ method methodArgAndVarNames. |
2254 ^ homeMethod methodArgAndVarNamesInContext: self. |
2262 ]. |
2255 ]. |
2263 ^ #() |
2256 ^ #() |
2264 ]. |
2257 ]. |
2265 |
2258 |
2266 method notNil ifTrue:[ |
2259 homeMethod notNil ifTrue:[ |
2267 isDoIt ifTrue:[ |
2260 isDoIt ifTrue:[ |
2268 "/ special for #doIt |
2261 "/ special for #doIt |
2269 "/ my source is found in the method. |
2262 "/ my source is found in the method. |
2270 m := nil. |
2263 m := nil. |
2271 src := ('[' , method source , '\]') withCRs. |
2264 src := ('[' , homeMethod source , '\]') withCRs. |
2272 ] ifFalse:[ |
2265 ] ifFalse:[ |
2273 m := method. |
2266 m := homeMethod. |
2274 src := nil. |
2267 src := nil. |
2275 ]. |
2268 ]. |
2276 blocksLineNr := self lineNumber. |
2269 blocksLineNr := self lineNumber. |
2277 extractFromBlock value. |
2270 extractFromBlock value. |
2278 blocksLineNr := self home lineNumber. |
2271 blocksLineNr := self home lineNumber. |
2498 ! ! |
2493 ! ! |
2499 |
2494 |
2500 !Context class methodsFor:'documentation'! |
2495 !Context class methodsFor:'documentation'! |
2501 |
2496 |
2502 version |
2497 version |
2503 ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.186 2013-06-09 20:40:08 cg Exp $' |
2498 ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.187 2013-08-19 15:56:31 stefan Exp $' |
2504 ! |
2499 ! |
2505 |
2500 |
2506 version_CVS |
2501 version_CVS |
2507 ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.186 2013-06-09 20:40:08 cg Exp $' |
2502 ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.187 2013-08-19 15:56:31 stefan Exp $' |
|
2503 ! |
|
2504 |
|
2505 version_HG |
|
2506 |
|
2507 ^ '$Changeset: <not expanded> $' |
2508 ! |
2508 ! |
2509 |
2509 |
2510 version_SVN |
2510 version_SVN |
2511 ^ '$ Id: Context.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
2511 ^ '$ Id: Context.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
2512 ! ! |
2512 ! ! |