220 !Method methodsFor:'accessing'! |
220 !Method methodsFor:'accessing'! |
221 |
221 |
222 source |
222 source |
223 "return the sourcestring for the receiver" |
223 "return the sourcestring for the receiver" |
224 |
224 |
225 |aStream fileName junk w myClass mgr| |
225 |aStream fileName junk w myClass mgr className| |
226 |
226 |
227 source notNil ifTrue:[ |
227 source notNil ifTrue:[ |
228 " |
228 " |
229 if sourcePosition is nonNil, its the fileName and |
229 if sourcePosition is nonNil, its the fileName and |
230 sourcePosition is the offset. |
230 sourcePosition is the offset. |
269 w := self who. |
269 w := self who. |
270 w notNil ifTrue:[ |
270 w notNil ifTrue:[ |
271 myClass := w at:1. |
271 myClass := w at:1. |
272 aStream := myClass sourceStream. |
272 aStream := myClass sourceStream. |
273 ]. |
273 ]. |
274 "/ |
274 |
275 "/ nope - look in standard places (if there is a source-code manager) |
|
276 "/ |
|
277 aStream isNil ifTrue:[ |
275 aStream isNil ifTrue:[ |
|
276 "/ |
|
277 "/ nope - look in standard places |
|
278 "/ (if there is a source-code manager - otherwise, we already did that) |
|
279 "/ |
278 mgr notNil ifTrue:[ |
280 mgr notNil ifTrue:[ |
279 fileName := Smalltalk getSourceFileName:source. |
281 fileName := Smalltalk getSourceFileName:source. |
280 fileName notNil ifTrue:[ |
282 fileName notNil ifTrue:[ |
281 aStream := fileName asFilename readStream. |
283 aStream := fileName asFilename readStream. |
282 ] |
284 ] |
286 "/ |
288 "/ |
287 aStream isNil ifTrue:[ |
289 aStream isNil ifTrue:[ |
288 aStream := source asFilename readStream. |
290 aStream := source asFilename readStream. |
289 ] |
291 ] |
290 ]. |
292 ]. |
|
293 |
|
294 (aStream isNil and:[w isNil and:[source notNil]]) ifTrue:[ |
|
295 "/ |
|
296 "/ mhmh - seems to be a method which used to be in some |
|
297 "/ class, but has been overwritten by another or removed. |
|
298 "/ (i.e. it has no containing class anyMore) |
|
299 "/ try to guess the class from the sourceFileName. |
|
300 "/ and retry. |
|
301 "/ |
|
302 className := Smalltalk classNameForFile:source. |
|
303 className knownAsSymbol ifTrue:[ |
|
304 myClass := Smalltalk at:className asSymbol ifAbsent:nil. |
|
305 myClass notNil ifTrue:[ |
|
306 aStream := myClass sourceStream. |
|
307 ] |
|
308 ] |
|
309 ] |
291 ] |
310 ] |
292 ]. |
311 ]. |
293 |
312 |
294 aStream notNil ifTrue:[ |
313 aStream notNil ifTrue:[ |
295 aStream position:sourcePosition. |
314 aStream position:sourcePosition. |
296 junk := aStream nextChunk. |
315 junk := aStream nextChunk. |
297 |
316 |
298 " |
317 " |
299 keep a weak reference - maybe its needed again soon ... |
318 keep a weak reference - it may be needed again soon ... |
300 " |
319 " |
301 LastFileReference isNil ifTrue:[ |
320 LastFileReference isNil ifTrue:[ |
302 LastFileReference := WeakArray new:1 |
321 LastFileReference := WeakArray new:1 |
303 ]. |
322 ]. |
304 LastFileReference at:1 put:aStream. |
323 LastFileReference at:1 put:aStream. |
305 LastSourceFileName := source |
324 LastSourceFileName := source |
306 ] |
325 ] |
307 ]. |
326 ]. |
308 ^ junk |
327 ^ junk |
309 |
328 |
310 "Modified: 7.12.1995 / 13:22:32 / cg" |
329 "Modified: 11.12.1995 / 14:53:40 / cg" |
311 ! |
330 ! |
312 |
331 |
313 source:aString |
332 source:aString |
314 "set the methods sourcestring" |
333 "set the methods sourcestring" |
315 |
334 |