1416
|
1 |
"{ Package: 'cg:private' }"
|
|
2 |
|
|
3 |
Object subclass:#SnapShotImageMemory
|
1417
|
4 |
instanceVariableNames:'image stream msb ptrSize intSize intTag spaceInfos symbolEntries
|
1416
|
5 |
globalEntries addrToObjectMapping'
|
|
6 |
classVariableNames:''
|
|
7 |
poolDictionaries:''
|
|
8 |
category:'System-Support'
|
|
9 |
!
|
|
10 |
|
1417
|
11 |
Object subclass:#ImageHeader
|
|
12 |
instanceVariableNames:'memory classRef bits byteSize'
|
|
13 |
classVariableNames:''
|
|
14 |
poolDictionaries:''
|
|
15 |
privateIn:SnapShotImageMemory
|
|
16 |
!
|
|
17 |
|
1419
|
18 |
SnapShotImageMemory::ImageHeader variableByteSubclass:#ImageByteObject
|
|
19 |
instanceVariableNames:''
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
|
22 |
privateIn:SnapShotImageMemory
|
|
23 |
!
|
|
24 |
|
1416
|
25 |
Object subclass:#SpaceInfo
|
|
26 |
instanceVariableNames:'start end size flags imageBase'
|
|
27 |
classVariableNames:''
|
|
28 |
poolDictionaries:''
|
|
29 |
privateIn:SnapShotImageMemory
|
|
30 |
!
|
|
31 |
|
1417
|
32 |
SnapShotImageMemory::ImageHeader variableSubclass:#ImageObject
|
1419
|
33 |
instanceVariableNames:'cachedContents'
|
1416
|
34 |
classVariableNames:''
|
|
35 |
poolDictionaries:''
|
|
36 |
privateIn:SnapShotImageMemory
|
|
37 |
!
|
|
38 |
|
|
39 |
SnapShotImageMemory::ImageObject variableSubclass:#ImageClassObject
|
|
40 |
instanceVariableNames:''
|
|
41 |
classVariableNames:''
|
|
42 |
poolDictionaries:''
|
|
43 |
privateIn:SnapShotImageMemory
|
|
44 |
!
|
|
45 |
|
|
46 |
|
|
47 |
!SnapShotImageMemory class methodsFor:'instance creation'!
|
|
48 |
|
|
49 |
for:aFilename
|
|
50 |
^ self new for:aFilename
|
|
51 |
! !
|
|
52 |
|
|
53 |
!SnapShotImageMemory class methodsFor:'private'!
|
|
54 |
|
|
55 |
isNilOOP:anOOP
|
|
56 |
^ anOOP == 0
|
|
57 |
!
|
|
58 |
|
|
59 |
isPointerOOP:anOOP
|
|
60 |
^ (anOOP bitTest:1) not
|
|
61 |
!
|
|
62 |
|
|
63 |
isSmallIntegerOOP:anOOP
|
|
64 |
^ anOOP bitTest:1
|
|
65 |
! !
|
|
66 |
|
|
67 |
!SnapShotImageMemory methodsFor:'accessing'!
|
|
68 |
|
|
69 |
globalEntries
|
|
70 |
"return the value of the instance variable 'globalEntries' (automatically generated)"
|
|
71 |
|
|
72 |
^ globalEntries!
|
|
73 |
|
|
74 |
globalEntries:something
|
|
75 |
"set the value of the instance variable 'globalEntries' (automatically generated)"
|
|
76 |
|
1417
|
77 |
globalEntries := something.!
|
|
78 |
|
|
79 |
image
|
|
80 |
|
|
81 |
^ image
|
|
82 |
!
|
|
83 |
|
|
84 |
image:something
|
|
85 |
|
|
86 |
image := something.
|
|
87 |
!
|
|
88 |
|
|
89 |
ptrSize
|
|
90 |
"return the value of the instance variable 'ptrSize' (automatically generated)"
|
|
91 |
|
|
92 |
^ ptrSize!
|
|
93 |
|
|
94 |
ptrSize:something
|
|
95 |
"set the value of the instance variable 'ptrSize' (automatically generated)"
|
|
96 |
|
|
97 |
ptrSize := something.! !
|
1416
|
98 |
|
|
99 |
!SnapShotImageMemory methodsFor:'object access'!
|
|
100 |
|
1417
|
101 |
fetchByteAt:addr
|
|
102 |
|byte imgAddr|
|
|
103 |
|
|
104 |
imgAddr := self imageAddressOf:addr.
|
|
105 |
stream position:imgAddr.
|
|
106 |
byte := stream next.
|
|
107 |
^ byte
|
|
108 |
!
|
|
109 |
|
1416
|
110 |
fetchClassObjectAt:baseAddr
|
1417
|
111 |
|addr classPtr size bits o classRef nInsts|
|
|
112 |
|
|
113 |
(baseAddr bitAnd:3) ~~ 0 ifTrue:[self halt].
|
1416
|
114 |
|
|
115 |
o := addrToObjectMapping at:baseAddr ifAbsent:nil.
|
|
116 |
o notNil ifTrue:[^ o].
|
|
117 |
|
|
118 |
addr := baseAddr.
|
|
119 |
classPtr := self fetchPointerAt:addr.
|
|
120 |
addr := addr + ptrSize.
|
|
121 |
size := self fetchUnboxedIntegerAt:addr.
|
|
122 |
addr := addr + ptrSize.
|
|
123 |
bits := self fetchUnboxedIntegerAt:addr.
|
|
124 |
addr := addr + ptrSize.
|
|
125 |
|
1417
|
126 |
nInsts := (size - (intSize *3)) // intSize.
|
|
127 |
o := ImageClassObject new:nInsts.
|
|
128 |
addrToObjectMapping at:baseAddr put:o.
|
|
129 |
|
|
130 |
(self class isPointerOOP:classPtr) ifFalse:[
|
|
131 |
self halt
|
|
132 |
].
|
|
133 |
|
|
134 |
classRef := self fetchClassObjectAt:classPtr.
|
|
135 |
|
|
136 |
o classRef:classRef.
|
|
137 |
size > 8000 ifTrue:[self halt].
|
|
138 |
o byteSize:size.
|
1416
|
139 |
o bits:bits.
|
|
140 |
|
1417
|
141 |
1 to:nInsts do:[:idx |
|
1416
|
142 |
o at:idx put:(self fetchUnboxedIntegerAt:addr).
|
1417
|
143 |
"/ o at:idx put:(self fetchObjectAt:(self fetchUnboxedIntegerAt:addr)).
|
|
144 |
addr := addr + ptrSize.
|
1416
|
145 |
].
|
1417
|
146 |
o memory:self.
|
1416
|
147 |
^ o
|
|
148 |
!
|
|
149 |
|
|
150 |
fetchObjectAt:baseAddr
|
1417
|
151 |
|addr classPtr classRef size bits o nBytes nInsts flags imgAddr|
|
|
152 |
|
|
153 |
baseAddr == 0 ifTrue:[^ nil].
|
|
154 |
(baseAddr bitAnd:1) == 1 ifTrue:[(baseAddr bitTest:16r80000000) ifTrue:[
|
|
155 |
^ (baseAddr - 16r100000000) bitShift32:-1
|
|
156 |
] ifFalse:[
|
|
157 |
^ baseAddr bitShift32:-1
|
|
158 |
]
|
|
159 |
].
|
|
160 |
(baseAddr bitAnd:3) ~~ 0 ifTrue:[self halt].
|
1416
|
161 |
|
|
162 |
o := addrToObjectMapping at:baseAddr ifAbsent:nil.
|
|
163 |
o notNil ifTrue:[^ o].
|
|
164 |
|
|
165 |
addr := baseAddr.
|
|
166 |
classPtr := self fetchPointerAt:addr.
|
|
167 |
addr := addr + ptrSize.
|
|
168 |
size := self fetchUnboxedIntegerAt:addr.
|
|
169 |
addr := addr + ptrSize.
|
|
170 |
bits := self fetchUnboxedIntegerAt:addr.
|
|
171 |
addr := addr + ptrSize.
|
|
172 |
|
|
173 |
(self class isPointerOOP:classPtr) ifFalse:[
|
|
174 |
self halt
|
|
175 |
].
|
|
176 |
|
|
177 |
classRef := self fetchClassObjectAt:classPtr.
|
1417
|
178 |
|
|
179 |
flags := classRef flags bitAnd:Behavior maskIndexType.
|
|
180 |
(flags = Behavior flagBytes) ifTrue:[
|
|
181 |
nBytes := (size - (intSize * 3)).
|
|
182 |
o := ImageByteObject new:nBytes.
|
|
183 |
o classRef:classRef.
|
|
184 |
size > 8000 ifTrue:[self halt].
|
|
185 |
o byteSize:size.
|
|
186 |
o bits:bits.
|
1416
|
187 |
|
1417
|
188 |
imgAddr := self imageAddressOf:addr.
|
|
189 |
stream position:imgAddr.
|
1416
|
190 |
|
1417
|
191 |
1 to:nBytes do:[:idx |
|
|
192 |
o at:idx put:(stream next).
|
|
193 |
addr := addr + 1.
|
|
194 |
].
|
|
195 |
|
|
196 |
"/Transcript show:'#'.
|
|
197 |
"/Transcript show:((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:o startingAt:1) asString.
|
|
198 |
"/Transcript cr.
|
1416
|
199 |
|
1417
|
200 |
] ifFalse:[
|
|
201 |
(flags = Behavior flagNotIndexed) ifFalse:[
|
|
202 |
(flags ~= Behavior flagPointers) ifTrue:[
|
|
203 |
(flags ~= Behavior flagWeakPointers) ifTrue:[
|
|
204 |
self halt
|
|
205 |
]
|
|
206 |
].
|
|
207 |
].
|
1416
|
208 |
|
1417
|
209 |
nInsts := (size - (intSize * 3)) // intSize.
|
|
210 |
(classRef flags bitTest:Behavior flagBehavior)
|
|
211 |
"/ classRef isImageBehavior
|
|
212 |
ifTrue:[
|
|
213 |
o := ImageClassObject new:nInsts.
|
|
214 |
] ifFalse:[
|
|
215 |
o := ImageObject new:nInsts.
|
|
216 |
].
|
|
217 |
o classRef:classRef.
|
|
218 |
size > 8000 ifTrue:[self halt].
|
|
219 |
o byteSize:size.
|
|
220 |
o bits:bits.
|
|
221 |
addrToObjectMapping at:baseAddr put:o.
|
1416
|
222 |
|
1417
|
223 |
1 to:nInsts do:[:idx |
|
|
224 |
o at:idx put:(self fetchUnboxedIntegerAt:addr).
|
|
225 |
"/ o at:idx put:(self fetchObjectAt:(self fetchUnboxedIntegerAt:addr)).
|
|
226 |
addr := addr + ptrSize.
|
|
227 |
]
|
|
228 |
].
|
|
229 |
o memory:self.
|
|
230 |
^ o
|
1416
|
231 |
!
|
|
232 |
|
|
233 |
fetchPointerAt:addr
|
|
234 |
^ self fetchUnboxedIntegerAt:addr
|
|
235 |
!
|
|
236 |
|
|
237 |
fetchUnboxedIntegerAt:addr
|
1417
|
238 |
|ptr imgAddr|
|
|
239 |
|
|
240 |
(addr bitAnd:3) ~~ 0 ifTrue:[self halt].
|
|
241 |
|
|
242 |
imgAddr := self imageAddressOf:addr.
|
|
243 |
stream position:imgAddr.
|
|
244 |
ptr := stream nextUnsignedLongMSB:msb.
|
|
245 |
^ ptr
|
|
246 |
!
|
|
247 |
|
|
248 |
imageAddressOf:addr
|
1416
|
249 |
spaceInfos do:[:eachSpace |
|
1417
|
250 |
|byte imgAddr|
|
1416
|
251 |
|
|
252 |
addr >= eachSpace start ifTrue:[
|
|
253 |
addr <= eachSpace end ifTrue:[
|
|
254 |
imgAddr := eachSpace imageBase + (addr - eachSpace start).
|
1417
|
255 |
^ imgAddr
|
1416
|
256 |
]
|
|
257 |
].
|
|
258 |
].
|
1417
|
259 |
self halt:'image address error'.
|
1416
|
260 |
! !
|
|
261 |
|
|
262 |
!SnapShotImageMemory methodsFor:'private'!
|
|
263 |
|
|
264 |
allClassesDo:aBlock
|
|
265 |
self allGlobalKeysDo:[:eachKey |
|
|
266 |
|val|
|
|
267 |
|
|
268 |
val := self at:eachKey.
|
|
269 |
val isBehavior ifTrue:[
|
|
270 |
aBlock value:val
|
1417
|
271 |
] ifFalse:[
|
|
272 |
self halt.
|
|
273 |
].
|
1416
|
274 |
].
|
|
275 |
!
|
|
276 |
|
|
277 |
allGlobalKeysDo:aBlock
|
1417
|
278 |
globalEntries isNil ifTrue:[
|
1416
|
279 |
self readHeader.
|
|
280 |
self readGlobals.
|
|
281 |
].
|
|
282 |
!
|
|
283 |
|
1419
|
284 |
fetchByteArrayFor:aByteArrayRef
|
|
285 |
|nBytes|
|
|
286 |
|
|
287 |
(aByteArrayRef isImageBytes) ifFalse:[self halt].
|
|
288 |
|
|
289 |
nBytes := aByteArrayRef byteSize - (intSize * 3).
|
|
290 |
^ ((ByteArray new:nBytes) replaceFrom:1 to:nBytes-1 with:aByteArrayRef startingAt:1).!
|
|
291 |
|
1417
|
292 |
fetchStringFor:aStringRef
|
|
293 |
|nBytes|
|
|
294 |
|
|
295 |
(aStringRef isImageBytes) ifFalse:[self halt].
|
|
296 |
|
|
297 |
nBytes := aStringRef byteSize - (intSize * 3).
|
|
298 |
^ ((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:aStringRef startingAt:1) asString.
|
|
299 |
!
|
|
300 |
|
1416
|
301 |
for:aFilename
|
|
302 |
stream := aFilename asFilename readStream binary.
|
|
303 |
addrToObjectMapping := IdentityDictionary new.
|
1417
|
304 |
|
|
305 |
addrToObjectMapping at:(ObjectMemory addressOf:false) put:false.
|
|
306 |
addrToObjectMapping at:(ObjectMemory addressOf:true) put:true.
|
|
307 |
!
|
|
308 |
|
|
309 |
printStringOfClass:aClassRef
|
|
310 |
|nameSlot|
|
|
311 |
|
|
312 |
(aClassRef isImageBehavior) ifFalse:[self halt].
|
|
313 |
((aClassRef byteSize // intSize) - 3) < Class instSize ifTrue:[self halt.].
|
|
314 |
|
|
315 |
nameSlot := aClassRef at:7.
|
|
316 |
nameSlot isInteger ifTrue:[
|
|
317 |
nameSlot := self fetchObjectAt:nameSlot
|
|
318 |
].
|
|
319 |
nameSlot isImageSymbol ifFalse:[self halt].
|
|
320 |
^ 'Class: ' , (self printStringOfSymbol:nameSlot)
|
|
321 |
!
|
|
322 |
|
|
323 |
printStringOfObject:anObjectRef
|
|
324 |
|s nBytes|
|
|
325 |
|
|
326 |
anObjectRef isNil ifTrue:[^ 'nil'].
|
|
327 |
(anObjectRef isInteger) ifTrue:[^ anObjectRef printString].
|
|
328 |
(anObjectRef == true ) ifTrue:[^ anObjectRef printString].
|
|
329 |
(anObjectRef == false) ifTrue:[^ anObjectRef printString].
|
|
330 |
|
|
331 |
(anObjectRef isImageSymbol) ifTrue:[^ self printStringOfSymbol:anObjectRef].
|
|
332 |
(anObjectRef isImageBehavior) ifTrue:[^ self printStringOfClass:anObjectRef].
|
|
333 |
|
|
334 |
^ 'obj(' , anObjectRef printString , ')'
|
|
335 |
!
|
|
336 |
|
|
337 |
printStringOfString:aStringRef
|
|
338 |
|nBytes|
|
|
339 |
|
|
340 |
(aStringRef isString) ifFalse:[self halt].
|
|
341 |
^ self fetchStringFor:aStringRef.
|
|
342 |
!
|
|
343 |
|
|
344 |
printStringOfSymbol:aSymbolRef
|
|
345 |
|nBytes|
|
|
346 |
|
|
347 |
(aSymbolRef isImageSymbol) ifFalse:[self halt].
|
|
348 |
^ self fetchStringFor:aSymbolRef.
|
|
349 |
"/ nBytes := aSymbolRef size - (intSize * 3).
|
|
350 |
"/ ^ ((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:aSymbolRef startingAt:1) asString.
|
1416
|
351 |
!
|
|
352 |
|
|
353 |
readGlobalEntries
|
1417
|
354 |
|refPointer theSymbolPtr theSymbolRef theValuePtr theValueRef pos|
|
1416
|
355 |
|
|
356 |
globalEntries := OrderedCollection new.
|
|
357 |
[
|
|
358 |
refPointer := stream nextUnsignedLongMSB:msb.
|
1417
|
359 |
theSymbolPtr := stream nextUnsignedLongMSB:msb.
|
|
360 |
theValuePtr := stream nextUnsignedLongMSB:msb.
|
|
361 |
theSymbolPtr ~~ 0
|
1416
|
362 |
] whileTrue:[
|
1417
|
363 |
globalEntries add:(theSymbolPtr -> theValuePtr).
|
1416
|
364 |
].
|
1417
|
365 |
globalEntries := globalEntries asArray.
|
|
366 |
|
|
367 |
"/ globalEntries inspect.
|
|
368 |
pos := stream position.
|
|
369 |
globalEntries do:[:item |
|
|
370 |
theSymbolPtr := item key.
|
|
371 |
theValuePtr := item value.
|
|
372 |
theSymbolRef := self fetchObjectAt:theSymbolPtr.
|
|
373 |
|
|
374 |
"/ Transcript show:(self printStringOfSymbol:theSymbolRef).
|
|
375 |
"/ Transcript show:'->'.
|
|
376 |
|
|
377 |
theValueRef := self fetchObjectAt:theValuePtr.
|
|
378 |
"/ Transcript show:(self printStringOfObject:theValueRef).
|
|
379 |
"/ Transcript cr.
|
|
380 |
|
|
381 |
item key:theSymbolRef.
|
|
382 |
item value:theValueRef.
|
|
383 |
].
|
|
384 |
stream position:pos.
|
1416
|
385 |
!
|
|
386 |
|
|
387 |
readHeader
|
|
388 |
"
|
|
389 |
(self for:'stmeas.img') readHeader
|
|
390 |
"
|
|
391 |
|
|
392 |
|order magic version timeStamp snapID last_util_addr hiText_addr flags
|
|
393 |
lowData hiData charSlots charTableSlots fixMemStart fixMemEnd
|
|
394 |
symMemStart symMemEnd vmDataAddr sharedMethodCode sharedBlockCode
|
|
395 |
nContexts contextSpace nRegistered symbolsSeqNr nSpaces
|
1417
|
396 |
classNameSize spaceSize|
|
1416
|
397 |
|
|
398 |
stream next:256. "/ skip execCmd
|
|
399 |
|
|
400 |
msb := false.
|
|
401 |
order := stream nextUnsignedLongMSB:msb.
|
|
402 |
order = 16r076543210 ifTrue:[
|
|
403 |
] ifFalse:[
|
|
404 |
order = 16r01234567 ifTrue:[
|
|
405 |
msb := true.
|
|
406 |
] ifFalse:[
|
|
407 |
self error:'unhandled byteorder'
|
|
408 |
].
|
|
409 |
].
|
|
410 |
magic := (stream next:8) asString.
|
|
411 |
magic ~= 'ST/X-IMG' ifTrue:[
|
|
412 |
self error:'not an st/x image'
|
|
413 |
].
|
|
414 |
version := stream nextUnsignedLongMSB:msb.
|
|
415 |
timeStamp := stream nextUnsignedLongMSB:msb.
|
|
416 |
ptrSize := stream nextByte.
|
|
417 |
ptrSize ~~ 4 ifTrue:[
|
|
418 |
self error:'unhandled ptr format'
|
|
419 |
].
|
|
420 |
stream next:7. "/ filler
|
|
421 |
intSize := stream nextUnsignedLongMSB:msb.
|
|
422 |
intSize == 9 ifTrue:[
|
|
423 |
intSize := 4.
|
|
424 |
intTag := 1.
|
|
425 |
] ifFalse:[
|
|
426 |
self error:'unhandled int format'
|
|
427 |
].
|
|
428 |
|
|
429 |
snapID := stream nextUnsignedLongMSB:msb.
|
|
430 |
last_util_addr := stream next:intSize.
|
|
431 |
hiText_addr := stream next:intSize.
|
|
432 |
flags := stream next:intSize.
|
|
433 |
stream next:8. "/ info, debug & filler
|
|
434 |
|
|
435 |
lowData := stream nextUnsignedLongMSB:msb.
|
|
436 |
hiData := stream nextUnsignedLongMSB:msb.
|
|
437 |
|
|
438 |
charSlots := stream nextUnsignedLongMSB:msb.
|
|
439 |
charTableSlots := stream nextUnsignedLongMSB:msb.
|
|
440 |
|
|
441 |
version >= 8 ifTrue:[
|
|
442 |
fixMemStart := stream nextUnsignedLongMSB:msb.
|
|
443 |
fixMemEnd := stream nextUnsignedLongMSB:msb.
|
|
444 |
symMemStart := stream nextUnsignedLongMSB:msb.
|
|
445 |
symMemEnd := stream nextUnsignedLongMSB:msb.
|
|
446 |
vmDataAddr := stream nextUnsignedLongMSB:msb.
|
|
447 |
].
|
|
448 |
stream next:(128 * intSize). "/ skip sharedMethodCode ptrs
|
|
449 |
stream next:(128 * intSize). "/ skip sharedBlockCode ptrs
|
|
450 |
|
|
451 |
nContexts := stream nextUnsignedLongMSB:msb.
|
|
452 |
contextSpace := stream nextUnsignedLongMSB:msb.
|
|
453 |
nRegistered := stream nextUnsignedLongMSB:msb.
|
|
454 |
|
|
455 |
version >= 8 ifTrue:[
|
|
456 |
version >= 9 ifTrue:[
|
|
457 |
symbolsSeqNr := stream nextUnsignedLongMSB:msb.
|
|
458 |
stream next:(intSize * 31).
|
|
459 |
] ifFalse:[
|
|
460 |
stream next:(intSize * 32).
|
|
461 |
]
|
|
462 |
].
|
|
463 |
|
|
464 |
nSpaces := stream nextUnsignedLongMSB:msb.
|
|
465 |
spaceInfos := (1 to:nSpaces) collect:[:idx | SpaceInfo new].
|
|
466 |
|
|
467 |
1 to:nSpaces do:[:i |
|
|
468 |
(spaceInfos at:i) flags:(stream nextUnsignedLongMSB:msb).
|
|
469 |
].
|
|
470 |
nSpaces+1 to:32 do:[:i | stream nextUnsignedLongMSB:msb].
|
|
471 |
|
|
472 |
1 to:nSpaces do:[:i |
|
|
473 |
(spaceInfos at:i) start:(stream nextUnsignedLongMSB:msb).
|
|
474 |
].
|
|
475 |
nSpaces+1 to:32 do:[:i | stream nextUnsignedLongMSB:msb].
|
|
476 |
|
|
477 |
1 to:nSpaces do:[:i |
|
|
478 |
(spaceInfos at:i) size:(stream nextUnsignedLongMSB:msb).
|
|
479 |
].
|
|
480 |
nSpaces+1 to:32 do:[:i | stream nextUnsignedLongMSB:msb].
|
|
481 |
|
|
482 |
version >= 8 ifTrue:[
|
1417
|
483 |
stream position:(stream class zeroPosition).
|
|
484 |
stream skip:4096.
|
1416
|
485 |
].
|
|
486 |
|
|
487 |
1 to:nSpaces do:[:i |
|
|
488 |
(spaceInfos at:i) end:((spaceInfos at:i) start + (spaceInfos at:i) size - 1).
|
|
489 |
].
|
|
490 |
1 to:nSpaces do:[:i |
|
|
491 |
(spaceInfos at:i) imageBase:(stream position).
|
1417
|
492 |
spaceSize := (spaceInfos at:i) size.
|
|
493 |
stream skip:spaceSize.
|
1416
|
494 |
].
|
|
495 |
|
|
496 |
"/ registration
|
|
497 |
|
|
498 |
self readRegistrationEntries.
|
1417
|
499 |
Transcript showCR:'reading symbols...'.
|
1416
|
500 |
self readSymbolEntries.
|
1417
|
501 |
self readUGlobalEntries.
|
|
502 |
Transcript showCR:'reading globals...'.
|
1416
|
503 |
self readGlobalEntries.
|
|
504 |
|
|
505 |
|
|
506 |
"/struct basicImageHeader {
|
|
507 |
"/ char h_execCmd[256];
|
|
508 |
"/
|
|
509 |
"/ int h_orderWord;
|
|
510 |
"/ char h_magic[8];
|
|
511 |
"/ int h_version;
|
|
512 |
"/ int h_timeStamp;
|
|
513 |
"/ char h_ptrSize;
|
|
514 |
"/ char h_filler1[7];
|
|
515 |
"/ int h_intSize;
|
|
516 |
"/ int h_snapID;
|
|
517 |
"/ INT h_last_util_addr;
|
|
518 |
"/ INT h_hiText_addr;
|
|
519 |
"/ INT h_flags;
|
|
520 |
"/ char h_infoPrinting;
|
|
521 |
"/ char h_debugPrinting;
|
|
522 |
"/ char h_filler2[6];
|
|
523 |
"/
|
|
524 |
"/ /*
|
|
525 |
"/ * these are to verify compatibility of the image with
|
|
526 |
"/ * myself ...
|
|
527 |
"/ * this is now obsolete.
|
|
528 |
"/ */
|
|
529 |
"/ INT h_lowData, h_hiData;
|
|
530 |
"/
|
|
531 |
"/ /*
|
|
532 |
"/ * base address of character- and characterTable slots
|
|
533 |
"/ */
|
|
534 |
"/ INT h_charSlots;
|
|
535 |
"/ INT h_charTableSlots;
|
|
536 |
"/
|
|
537 |
"/#if HEADER_VERSION >= 8
|
|
538 |
"/ /*
|
|
539 |
"/ * the fixBase (VMDATA address)
|
|
540 |
"/ */
|
|
541 |
"/ INT h_fixMemStart;
|
|
542 |
"/ INT h_fixMemEnd;
|
|
543 |
"/ INT h_symMemStart;
|
|
544 |
"/ INT h_symMemEnd;
|
|
545 |
"/
|
|
546 |
"/ INT h_vmDataAddr;
|
|
547 |
"/#endif
|
|
548 |
"/
|
|
549 |
"/ INT h_sharedMethodCode[128];
|
|
550 |
"/ INT h_sharedBlockCode[128];
|
|
551 |
"/
|
|
552 |
"/ /*
|
|
553 |
"/ * space needed to restore contexts
|
|
554 |
"/ */
|
|
555 |
"/ INT h_nContexts;
|
|
556 |
"/ INT h_contextSpace;
|
|
557 |
"/
|
|
558 |
"/ /*
|
|
559 |
"/ * number of class registration info records
|
|
560 |
"/ */
|
|
561 |
"/ INT h_nRegistered;
|
|
562 |
"/
|
|
563 |
"/#if HEADER_VERSION >= 8
|
|
564 |
"/ /*
|
|
565 |
"/ * reserved slots, for future versions
|
|
566 |
"/ * (can add additional info, without affecting position of following stuff)
|
|
567 |
"/ * If you add slots, you MUST DECREMENT the fillcount.
|
|
568 |
"/ */
|
|
569 |
"/# if HEADER_VERSION >= 9
|
|
570 |
"/ INT h_symbolsSeqNr;
|
|
571 |
"/ INT h_reserved[31];
|
|
572 |
"/# else
|
|
573 |
"/ INT h_reserved[32];
|
|
574 |
"/# endif
|
|
575 |
"/#endif
|
|
576 |
"/
|
|
577 |
"/ /*
|
|
578 |
"/ * number of spaces, base and size of each
|
|
579 |
"/ */
|
|
580 |
"/ INT h_nSpaces;
|
|
581 |
"/ INT h_spaceFlags[MAXSPACES];
|
|
582 |
"/ INT h_spaceBase[MAXSPACES];
|
|
583 |
"/ INT h_spaceSize[MAXSPACES];
|
|
584 |
"/
|
|
585 |
"/ /*
|
|
586 |
"/ * here come nSpaces object spaces
|
|
587 |
"/ */
|
|
588 |
"/
|
|
589 |
"/ /*
|
|
590 |
"/ * here comes registration info
|
|
591 |
"/ */
|
|
592 |
"/
|
|
593 |
"/ /*
|
|
594 |
"/ * here come nSymbols symbolEntries
|
|
595 |
"/ * followed by a zero/zero entry
|
|
596 |
"/ */
|
|
597 |
"/
|
|
598 |
"/ /*
|
|
599 |
"/ * here come nGlobal globalEntries
|
|
600 |
"/ * followed by a zero/zero entry
|
|
601 |
"/ */
|
|
602 |
"/
|
|
603 |
"/ /*
|
|
604 |
"/ * here come nUnnamedGlobal globalEntries
|
|
605 |
"/ * followed by a zero/zero entry
|
|
606 |
"/ */
|
|
607 |
"/
|
|
608 |
"/ /*
|
|
609 |
"/ * here come stack contexts
|
|
610 |
"/ */
|
|
611 |
"/};
|
|
612 |
!
|
|
613 |
|
|
614 |
readRegistrationEntries
|
|
615 |
|classNameSize|
|
|
616 |
|
|
617 |
[
|
|
618 |
classNameSize := stream nextUnsignedLongMSB:msb.
|
|
619 |
classNameSize ~~ 0
|
|
620 |
] whileTrue:[
|
|
621 |
|className flags moduleTimestamp signature nMethods nBlocks oldLitRefs nLitRefs
|
|
622 |
oldConstTable nConsts|
|
|
623 |
|
|
624 |
className := (stream next:classNameSize) asString.
|
|
625 |
stream next. "/ 0-byte
|
|
626 |
flags := stream nextUnsignedLongMSB:msb.
|
|
627 |
moduleTimestamp := stream nextUnsignedLongMSB:msb.
|
|
628 |
signature := stream nextUnsignedLongMSB:msb.
|
|
629 |
nMethods := stream nextUnsignedLongMSB:msb.
|
|
630 |
nMethods timesRepeat:[ stream nextUnsignedLongMSB:msb ].
|
|
631 |
nBlocks := stream nextUnsignedLongMSB:msb.
|
|
632 |
nBlocks timesRepeat:[ stream nextUnsignedLongMSB:msb ].
|
|
633 |
oldLitRefs := stream nextUnsignedLongMSB:msb.
|
|
634 |
nLitRefs := stream nextUnsignedLongMSB:msb.
|
|
635 |
nLitRefs timesRepeat:[ stream nextUnsignedLongMSB:msb ].
|
|
636 |
stream nextUnsignedLongMSB:msb. "/ 0-litRef
|
|
637 |
oldConstTable := stream nextUnsignedLongMSB:msb.
|
|
638 |
nConsts := stream nextUnsignedLongMSB:msb.
|
|
639 |
nConsts timesRepeat:[ stream nextUnsignedLongMSB:msb ].
|
|
640 |
|
|
641 |
Transcript showCR:className.
|
|
642 |
].
|
|
643 |
!
|
|
644 |
|
|
645 |
readSymbolEntries
|
1417
|
646 |
|refPointer theSymbolPtr theSymbolRef pos|
|
1416
|
647 |
|
|
648 |
symbolEntries := OrderedCollection new.
|
|
649 |
|
|
650 |
[
|
|
651 |
refPointer := stream nextUnsignedLongMSB:msb.
|
1417
|
652 |
theSymbolPtr := stream nextUnsignedLongMSB:msb.
|
|
653 |
theSymbolPtr ~~ 0
|
1416
|
654 |
] whileTrue:[
|
1417
|
655 |
symbolEntries add:theSymbolPtr.
|
1416
|
656 |
].
|
1417
|
657 |
symbolEntries := symbolEntries asArray.
|
|
658 |
|
|
659 |
pos := stream position.
|
|
660 |
symbolEntries := symbolEntries collect:[:theSymbolPtr |
|
|
661 |
theSymbolRef := self fetchObjectAt:theSymbolPtr.
|
|
662 |
theSymbolRef isImageSymbol ifFalse:[
|
|
663 |
self halt
|
|
664 |
].
|
|
665 |
].
|
|
666 |
stream position:pos
|
1416
|
667 |
!
|
|
668 |
|
|
669 |
readUGlobalEntries
|
|
670 |
|refPointer theValue|
|
|
671 |
|
|
672 |
[
|
|
673 |
refPointer := stream nextUnsignedLongMSB:msb.
|
|
674 |
theValue := stream nextUnsignedLongMSB:msb.
|
|
675 |
refPointer ~~ 0
|
|
676 |
] whileTrue
|
|
677 |
! !
|
|
678 |
|
1417
|
679 |
!SnapShotImageMemory::ImageHeader methodsFor:'accessing'!
|
|
680 |
|
|
681 |
bits
|
|
682 |
"return the value of the instance variable 'bits' (automatically generated)"
|
|
683 |
|
|
684 |
^ bits!
|
|
685 |
|
|
686 |
bits:something
|
|
687 |
"set the value of the instance variable 'bits' (automatically generated)"
|
|
688 |
|
|
689 |
bits := something.!
|
|
690 |
|
|
691 |
byteSize
|
|
692 |
"return the value of the instance variable 'size' (automatically generated)"
|
|
693 |
|
|
694 |
^ byteSize
|
|
695 |
!
|
|
696 |
|
|
697 |
byteSize:something
|
|
698 |
"set the value of the instance variable 'size' (automatically generated)"
|
|
699 |
|
|
700 |
something > 8000 ifTrue:[self halt].
|
|
701 |
byteSize := something.
|
|
702 |
!
|
|
703 |
|
|
704 |
classRef
|
|
705 |
"return the value of the instance variable 'classRef' (automatically generated)"
|
|
706 |
|
|
707 |
^ classRef!
|
|
708 |
|
|
709 |
classRef:something
|
|
710 |
"set the value of the instance variable 'classRef' (automatically generated)"
|
|
711 |
|
|
712 |
classRef := something.!
|
|
713 |
|
|
714 |
memory
|
|
715 |
"return the value of the instance variable 'memory' (automatically generated)"
|
|
716 |
|
|
717 |
^ memory!
|
|
718 |
|
|
719 |
memory:something
|
|
720 |
"set the value of the instance variable 'memory' (automatically generated)"
|
|
721 |
|
|
722 |
memory := something.! !
|
|
723 |
|
|
724 |
!SnapShotImageMemory::ImageHeader methodsFor:'queries'!
|
|
725 |
|
|
726 |
category
|
|
727 |
|categoryPtr categoryRef category|
|
|
728 |
|
|
729 |
self isMethodOrLazyMethod ifTrue:[
|
|
730 |
categoryPtr := self at:6.
|
|
731 |
categoryRef := memory fetchObjectAt:categoryPtr.
|
|
732 |
category := memory fetchStringFor:categoryRef.
|
|
733 |
^ category
|
|
734 |
].
|
|
735 |
self halt.
|
|
736 |
!
|
|
737 |
|
1419
|
738 |
isBehavior
|
|
739 |
^ self isImageBehavior!
|
|
740 |
|
1417
|
741 |
isImageBehavior
|
|
742 |
|flags|
|
|
743 |
|
|
744 |
flags := classRef flags.
|
|
745 |
^ flags bitTest:Behavior flagBehavior
|
|
746 |
!
|
|
747 |
|
|
748 |
isImageBytes
|
|
749 |
|flags|
|
|
750 |
|
|
751 |
flags := classRef flags bitAnd:Behavior maskIndexType.
|
|
752 |
^ flags = Behavior flagBytes
|
|
753 |
!
|
|
754 |
|
|
755 |
isImageMethod
|
|
756 |
|flags|
|
|
757 |
|
|
758 |
flags := classRef flags.
|
|
759 |
^ flags bitTest:Behavior flagMethod
|
|
760 |
!
|
|
761 |
|
|
762 |
isImageSymbol
|
|
763 |
|flags|
|
|
764 |
|
|
765 |
flags := classRef flags.
|
|
766 |
^ flags bitTest:Behavior flagSymbol
|
|
767 |
!
|
|
768 |
|
1419
|
769 |
isLazyMethod
|
|
770 |
^ classRef name = 'LazyMethod'!
|
|
771 |
|
1417
|
772 |
isMeta
|
|
773 |
^ false
|
|
774 |
!
|
|
775 |
|
|
776 |
isMethod
|
|
777 |
^ classRef name = 'Method'
|
|
778 |
!
|
|
779 |
|
|
780 |
isMethodDictionary
|
|
781 |
^ classRef name = 'MethodDictionary'
|
|
782 |
!
|
|
783 |
|
|
784 |
isMethodOrLazyMethod
|
|
785 |
classRef name = 'LazyMethod' ifTrue:[^ true].
|
|
786 |
^ classRef name = 'Method'
|
|
787 |
!
|
|
788 |
|
|
789 |
isString
|
|
790 |
^ classRef name = 'String'
|
|
791 |
! !
|
|
792 |
|
1419
|
793 |
!SnapShotImageMemory::ImageByteObject methodsFor:'queries'!
|
|
794 |
|
|
795 |
size
|
|
796 |
^ byteSize
|
|
797 |
! !
|
|
798 |
|
1416
|
799 |
!SnapShotImageMemory::SpaceInfo methodsFor:'accessing'!
|
|
800 |
|
|
801 |
end
|
|
802 |
"return the value of the instance variable 'end' (automatically generated)"
|
|
803 |
|
|
804 |
^ end!
|
|
805 |
|
|
806 |
end:something
|
|
807 |
"set the value of the instance variable 'end' (automatically generated)"
|
|
808 |
|
|
809 |
end := something.!
|
|
810 |
|
|
811 |
flags
|
|
812 |
"return the value of the instance variable 'flags' (automatically generated)"
|
|
813 |
|
|
814 |
^ flags!
|
|
815 |
|
|
816 |
flags:something
|
|
817 |
"set the value of the instance variable 'flags' (automatically generated)"
|
|
818 |
|
|
819 |
flags := something.!
|
|
820 |
|
|
821 |
imageBase
|
|
822 |
"return the value of the instance variable 'imageBase' (automatically generated)"
|
|
823 |
|
|
824 |
^ imageBase!
|
|
825 |
|
|
826 |
imageBase:something
|
|
827 |
"set the value of the instance variable 'imageBase' (automatically generated)"
|
|
828 |
|
|
829 |
imageBase := something.!
|
|
830 |
|
|
831 |
size
|
|
832 |
"return the value of the instance variable 'size' (automatically generated)"
|
|
833 |
|
|
834 |
^ size!
|
|
835 |
|
|
836 |
size:something
|
|
837 |
"set the value of the instance variable 'size' (automatically generated)"
|
|
838 |
|
|
839 |
size := something.!
|
|
840 |
|
|
841 |
start
|
|
842 |
"return the value of the instance variable 'start' (automatically generated)"
|
|
843 |
|
|
844 |
^ start!
|
|
845 |
|
|
846 |
start:something
|
|
847 |
"set the value of the instance variable 'start' (automatically generated)"
|
|
848 |
|
|
849 |
start := something.! !
|
|
850 |
|
1419
|
851 |
!SnapShotImageMemory::ImageObject methodsFor:'method protocol'!
|
|
852 |
|
|
853 |
byteCode
|
|
854 |
|byteCodeSlotOffset byteCodePtr byteCodeRef byteCode|
|
|
855 |
|
|
856 |
self isMethod ifTrue:[
|
|
857 |
byteCodeSlotOffset := Method instVarOffsetOf:'byteCode'.
|
|
858 |
].
|
|
859 |
byteCodeSlotOffset notNil ifTrue:[
|
|
860 |
byteCodePtr := self at:byteCodeSlotOffset.
|
|
861 |
byteCodeRef := memory fetchObjectAt:byteCodePtr.
|
|
862 |
byteCodeRef isNil ifTrue:[^ nil].
|
|
863 |
|
|
864 |
byteCode := memory fetchByteArrayFor:byteCodeRef.
|
|
865 |
^ byteCode
|
|
866 |
].
|
|
867 |
|
|
868 |
self halt.
|
|
869 |
!
|
|
870 |
|
|
871 |
comment
|
|
872 |
|src comment comments parser|
|
|
873 |
|
|
874 |
self isMethod ifTrue:[
|
|
875 |
src := self source.
|
|
876 |
src isNil ifTrue:[^ nil].
|
|
877 |
|
|
878 |
parser := Parser for:src in:nil.
|
|
879 |
parser ignoreErrors; ignoreWarnings; saveComments:true.
|
|
880 |
parser parseMethodSpec.
|
|
881 |
comments := parser comments.
|
|
882 |
comments size ~~ 0 ifTrue:[
|
|
883 |
comment := comments first string.
|
|
884 |
(comment withoutSpaces endsWith:'}') ifTrue:[
|
|
885 |
"if first comment is a pragma, take next comment"
|
|
886 |
comment := comments at:2 ifAbsent:nil.
|
|
887 |
comment notNil ifTrue:[
|
|
888 |
comment := comment string.
|
|
889 |
].
|
|
890 |
].
|
1417
|
891 |
].
|
1419
|
892 |
^ comment.
|
1417
|
893 |
].
|
1419
|
894 |
self isLazyMethod ifTrue:[
|
|
895 |
^ ''
|
|
896 |
].
|
|
897 |
|
|
898 |
self halt.
|
1417
|
899 |
!
|
1416
|
900 |
|
1419
|
901 |
containingClass
|
|
902 |
self isMethodOrLazyMethod ifTrue:[
|
|
903 |
^ self mclass
|
1417
|
904 |
].
|
1419
|
905 |
self halt.!
|
|
906 |
|
|
907 |
hasCode
|
|
908 |
^ false!
|
|
909 |
|
|
910 |
isBreakpointed
|
|
911 |
^ false!
|
|
912 |
|
|
913 |
isCounting
|
|
914 |
^ false!
|
|
915 |
|
|
916 |
isCountingMemoryUsage
|
|
917 |
^ false!
|
|
918 |
|
|
919 |
isDynamic
|
|
920 |
^ false!
|
|
921 |
|
|
922 |
isExecutable
|
|
923 |
self isMethod ifTrue:[
|
|
924 |
^ false
|
|
925 |
].
|
|
926 |
self halt.!
|
|
927 |
|
|
928 |
isIgnored
|
|
929 |
^ false!
|
|
930 |
|
|
931 |
isJavaMethod
|
|
932 |
^ self class name = 'JavaMethod'!
|
|
933 |
|
|
934 |
isPrivate
|
|
935 |
^ false!
|
|
936 |
|
|
937 |
isProtected
|
|
938 |
^ false!
|
|
939 |
|
|
940 |
isPublic
|
|
941 |
^ true!
|
|
942 |
|
|
943 |
isTimed
|
|
944 |
^ false!
|
|
945 |
|
|
946 |
isTraced
|
|
947 |
^ false!
|
1416
|
948 |
|
1417
|
949 |
isWrapped
|
|
950 |
^ false
|
1416
|
951 |
!
|
|
952 |
|
1419
|
953 |
mclass
|
|
954 |
|mclassSlotOffset mclassPtr mclass|
|
|
955 |
|
|
956 |
self isMethod ifTrue:[
|
|
957 |
mclassSlotOffset := Method instVarOffsetOf:'mclass'.
|
|
958 |
mclassPtr := self at:mclassSlotOffset.
|
|
959 |
mclassPtr ~~ 0 ifTrue:[
|
|
960 |
mclass := memory fetchObjectAt:mclassPtr.
|
|
961 |
mclass isImageBehavior ifFalse:[
|
|
962 |
self halt
|
|
963 |
].
|
|
964 |
^ mclass
|
|
965 |
].
|
|
966 |
|
|
967 |
"/ search my class ...
|
|
968 |
memory image allClassesDo:[:eachClass |
|
|
969 |
eachClass theNonMetaclass methodDictionary keysAndValuesDo:[:sel :mthdRef |
|
|
970 |
mthdRef == self ifTrue:[
|
|
971 |
self at:mclassSlotOffset put:eachClass theNonMetaclass.
|
|
972 |
^ eachClass theNonMetaclass
|
|
973 |
].
|
|
974 |
].
|
|
975 |
eachClass theMetaclass methodDictionary keysAndValuesDo:[:sel :mthdRef |
|
|
976 |
mthdRef == self ifTrue:[
|
|
977 |
self at:mclassSlotOffset put:eachClass theMetaclass.
|
|
978 |
^ eachClass theMetaclass
|
|
979 |
].
|
|
980 |
]
|
1417
|
981 |
].
|
1419
|
982 |
self halt.
|
1417
|
983 |
].
|
1419
|
984 |
self halt.
|
1417
|
985 |
!
|
|
986 |
|
1419
|
987 |
numArgs
|
|
988 |
|flagsSlotOffset flagsPtr flags|
|
|
989 |
|
|
990 |
self isMethod ifTrue:[
|
|
991 |
flagsSlotOffset := Method instVarOffsetOf:'flags'.
|
|
992 |
].
|
|
993 |
flagsSlotOffset notNil ifTrue:[
|
|
994 |
flagsPtr := self at:flagsSlotOffset.
|
|
995 |
flags := memory fetchObjectAt:flagsPtr.
|
|
996 |
^ (flags bitAnd:(Method numArgsMaskInFlags)) bitShift:(Method numArgsShiftInFlags negated)
|
|
997 |
].
|
|
998 |
|
|
999 |
self halt.
|
|
1000 |
!
|
|
1001 |
|
|
1002 |
package
|
|
1003 |
|packageSlotOffset packagePtr packageRef package|
|
|
1004 |
|
|
1005 |
self isImageBehavior ifTrue:[
|
|
1006 |
self isMeta ifTrue:[
|
|
1007 |
^ self theNonMetaclass package
|
|
1008 |
].
|
|
1009 |
packageSlotOffset := Class instVarOffsetOf:'package'.
|
|
1010 |
].
|
|
1011 |
self isMethod ifTrue:[
|
|
1012 |
packageSlotOffset := Method instVarOffsetOf:'package'.
|
|
1013 |
].
|
|
1014 |
packageSlotOffset notNil ifTrue:[
|
|
1015 |
packagePtr := self at:packageSlotOffset.
|
|
1016 |
packageRef := memory fetchObjectAt:packagePtr.
|
|
1017 |
packageRef isNil ifTrue:[^ nil].
|
|
1018 |
|
|
1019 |
packageRef isImageSymbol ifFalse:[
|
|
1020 |
self halt.
|
|
1021 |
].
|
|
1022 |
package := memory fetchStringFor:packageRef.
|
|
1023 |
^ package asSymbol
|
|
1024 |
].
|
|
1025 |
self isMeta ifTrue:[
|
|
1026 |
self halt
|
|
1027 |
].
|
|
1028 |
|
|
1029 |
self halt.
|
|
1030 |
!
|
|
1031 |
|
|
1032 |
previousVersion
|
|
1033 |
^ nil!
|
|
1034 |
|
1417
|
1035 |
printStringForBrowserWithSelector:selector
|
|
1036 |
^ selector
|
|
1037 |
!
|
|
1038 |
|
1419
|
1039 |
privacy
|
|
1040 |
^ #public!
|
|
1041 |
|
1417
|
1042 |
resources
|
|
1043 |
^ nil
|
|
1044 |
!
|
|
1045 |
|
|
1046 |
source
|
1419
|
1047 |
|sourcePosition sourcePositionPtr sourcePtr sourceRef source aStream junk|
|
|
1048 |
|
|
1049 |
self isMethodOrLazyMethod ifTrue:[
|
|
1050 |
sourcePositionPtr := self at:(Method instVarOffsetOf:'sourcePosition').
|
|
1051 |
sourcePtr := self at:(Method instVarOffsetOf:'source').
|
|
1052 |
sourceRef := memory fetchObjectAt:sourcePtr.
|
|
1053 |
sourceRef isString ifFalse:[
|
1417
|
1054 |
self halt.
|
|
1055 |
].
|
1419
|
1056 |
source := memory printStringOfString:sourceRef.
|
|
1057 |
sourcePosition := memory fetchObjectAt:sourcePositionPtr.
|
1417
|
1058 |
sourcePosition isNil ifTrue:[
|
|
1059 |
^ source
|
|
1060 |
].
|
|
1061 |
|
|
1062 |
aStream := self sourceStream.
|
|
1063 |
aStream notNil ifTrue:[
|
|
1064 |
Stream positionErrorSignal handle:[:ex |
|
|
1065 |
^ nil
|
|
1066 |
] do:[
|
|
1067 |
aStream position:sourcePosition abs.
|
|
1068 |
].
|
|
1069 |
junk := aStream nextChunk.
|
|
1070 |
|
|
1071 |
aStream close.
|
|
1072 |
^ junk
|
|
1073 |
].
|
|
1074 |
].
|
1416
|
1075 |
self halt.
|
|
1076 |
!
|
|
1077 |
|
1419
|
1078 |
sourceFilename
|
|
1079 |
"return the sourcefilename if source is extern; nil otherwise"
|
|
1080 |
|
|
1081 |
self isMethodOrLazyMethod ifTrue:[
|
|
1082 |
self sourcePosition notNil ifTrue:[^ self source].
|
|
1083 |
^ nil
|
|
1084 |
].
|
|
1085 |
self halt.!
|
|
1086 |
|
|
1087 |
sourceLineNumber
|
|
1088 |
self isMethodOrLazyMethod ifTrue:[
|
|
1089 |
^ 1
|
|
1090 |
].
|
|
1091 |
self halt.
|
|
1092 |
!
|
|
1093 |
|
|
1094 |
sourcePosition
|
|
1095 |
|sourcePosition|
|
|
1096 |
|
|
1097 |
self isMethodOrLazyMethod ifTrue:[
|
|
1098 |
sourcePosition := self sourcePositionValue.
|
|
1099 |
sourcePosition isNil ifTrue:[^ sourcePosition].
|
|
1100 |
^ sourcePosition abs
|
|
1101 |
].
|
|
1102 |
self halt.!
|
|
1103 |
|
|
1104 |
sourcePositionValue
|
|
1105 |
|sourcePosition sourcePositionPtr|
|
|
1106 |
|
|
1107 |
self isMethodOrLazyMethod ifTrue:[
|
|
1108 |
sourcePositionPtr := self at:(Method instVarOffsetOf:'sourcePosition').
|
|
1109 |
sourcePosition := memory fetchObjectAt:sourcePositionPtr.
|
|
1110 |
^ sourcePosition
|
|
1111 |
].
|
|
1112 |
self halt.!
|
|
1113 |
|
1417
|
1114 |
sourceStream
|
|
1115 |
|sourcePosition source aStream fileName junk who
|
|
1116 |
myClass mgr className sep dir mod package|
|
|
1117 |
|
|
1118 |
self isMethod ifTrue:[
|
|
1119 |
sourcePosition := self at:(Method instVarOffsetOf:'sourcePosition').
|
|
1120 |
source := self at:(Method instVarOffsetOf:'source').
|
|
1121 |
source := memory fetchObjectAt:source.
|
|
1122 |
source isString ifTrue:[
|
|
1123 |
source := memory printStringOfString:source.
|
|
1124 |
].
|
|
1125 |
sourcePosition notNil ifTrue:[
|
|
1126 |
sourcePosition := memory fetchObjectAt:sourcePosition.
|
|
1127 |
].
|
|
1128 |
|
|
1129 |
source isNil ifTrue:[^ nil].
|
|
1130 |
sourcePosition isNil ifTrue:[^ source readStream].
|
|
1131 |
|
|
1132 |
sourcePosition < 0 ifTrue:[
|
|
1133 |
aStream := source asFilename readStream.
|
|
1134 |
aStream notNil ifTrue:[
|
|
1135 |
^ aStream
|
|
1136 |
].
|
|
1137 |
|
|
1138 |
fileName := Smalltalk getSourceFileName:source.
|
|
1139 |
fileName notNil ifTrue:[
|
|
1140 |
aStream := fileName asFilename readStream.
|
|
1141 |
aStream notNil ifTrue:[
|
|
1142 |
^ aStream
|
|
1143 |
].
|
|
1144 |
].
|
|
1145 |
].
|
|
1146 |
|
|
1147 |
"/
|
|
1148 |
"/ if there is no SourceManager, look in local standard places first
|
|
1149 |
"/
|
|
1150 |
(mgr := Smalltalk at:#SourceCodeManager) isNil ifTrue:[
|
|
1151 |
aStream := self localSourceStream.
|
|
1152 |
aStream notNil ifTrue:[
|
|
1153 |
^ aStream
|
|
1154 |
].
|
|
1155 |
].
|
|
1156 |
|
|
1157 |
"/
|
|
1158 |
"/ nope - ask my class for the source (this also invokes the SCMgr)
|
|
1159 |
"/
|
|
1160 |
myClass := self mclass.
|
1416
|
1161 |
|
1417
|
1162 |
package := self package.
|
|
1163 |
(package notNil and:[package ~= myClass package]) ifTrue:[
|
|
1164 |
mgr notNil ifTrue:[
|
|
1165 |
"/ try to get the source using my package information ...
|
|
1166 |
sep := package indexOfAny:'/\:'.
|
|
1167 |
sep ~~ 0 ifTrue:[
|
|
1168 |
mod := package copyTo:sep - 1.
|
|
1169 |
dir := package copyFrom:sep + 1.
|
|
1170 |
aStream := mgr streamForClass:nil fileName:source revision:nil directory:dir module:mod cache:true.
|
|
1171 |
aStream notNil ifTrue:[
|
|
1172 |
^ aStream
|
|
1173 |
].
|
|
1174 |
].
|
|
1175 |
].
|
|
1176 |
].
|
|
1177 |
|
|
1178 |
aStream := myClass sourceStreamFor:source.
|
|
1179 |
aStream notNil ifTrue:[
|
|
1180 |
^ aStream
|
|
1181 |
].
|
|
1182 |
|
|
1183 |
"/
|
|
1184 |
"/ nope - look in standard places
|
|
1185 |
"/ (if there is a source-code manager - otherwise, we already did that)
|
|
1186 |
"/
|
|
1187 |
mgr notNil ifTrue:[
|
|
1188 |
aStream := self localSourceStream.
|
|
1189 |
aStream notNil ifTrue:[
|
|
1190 |
^ aStream
|
|
1191 |
].
|
|
1192 |
].
|
|
1193 |
|
|
1194 |
"/
|
|
1195 |
"/ final chance: try current directory
|
|
1196 |
"/
|
|
1197 |
aStream isNil ifTrue:[
|
|
1198 |
aStream := source asFilename readStream.
|
|
1199 |
aStream notNil ifTrue:[
|
|
1200 |
^ aStream
|
|
1201 |
].
|
|
1202 |
].
|
|
1203 |
|
|
1204 |
(who isNil and:[source notNil]) ifTrue:[
|
|
1205 |
"/
|
|
1206 |
"/ mhmh - seems to be a method which used to be in some
|
|
1207 |
"/ class, but has been overwritten by another or removed.
|
|
1208 |
"/ (i.e. it has no containing class anyMore)
|
|
1209 |
"/ try to guess the class from the sourceFileName.
|
|
1210 |
"/ and retry.
|
|
1211 |
"/
|
|
1212 |
className := Smalltalk classNameForFile:source.
|
|
1213 |
className knownAsSymbol ifTrue:[
|
|
1214 |
myClass := Smalltalk at:className asSymbol ifAbsent:nil.
|
|
1215 |
myClass notNil ifTrue:[
|
|
1216 |
aStream := myClass sourceStreamFor:source.
|
|
1217 |
aStream notNil ifTrue:[
|
|
1218 |
^ aStream
|
|
1219 |
].
|
|
1220 |
]
|
|
1221 |
]
|
|
1222 |
].
|
|
1223 |
|
|
1224 |
^ nil
|
|
1225 |
].
|
1416
|
1226 |
self halt.
|
|
1227 |
! !
|
|
1228 |
|
1419
|
1229 |
!SnapShotImageMemory::ImageObject methodsFor:'methodDictionary protocol'!
|
|
1230 |
|
|
1231 |
at:aSelector ifAbsent:exceptionValue
|
|
1232 |
self isMethodDictionary ifTrue:[
|
|
1233 |
cachedContents isNil ifTrue:[
|
|
1234 |
self cacheMethodDictionary.
|
|
1235 |
].
|
|
1236 |
^ cachedContents at:aSelector ifAbsent:exceptionValue
|
|
1237 |
].
|
|
1238 |
self halt.!
|
|
1239 |
|
|
1240 |
cacheMethodDictionary
|
|
1241 |
|symPtr symRef mthdPtr mthdRef s|
|
|
1242 |
|
|
1243 |
cachedContents isNil ifTrue:[
|
|
1244 |
cachedContents := IdentityDictionary new.
|
|
1245 |
|
|
1246 |
1 to:self size by:2 do:[:idx |
|
|
1247 |
symPtr := self at:idx.
|
|
1248 |
symRef := memory fetchObjectAt:symPtr.
|
|
1249 |
symRef isImageSymbol ifFalse:[self halt].
|
|
1250 |
s := memory fetchStringFor:symRef.
|
|
1251 |
mthdPtr := self at:idx + 1.
|
|
1252 |
mthdRef := memory fetchObjectAt:mthdPtr.
|
|
1253 |
cachedContents at:s asSymbol put:mthdRef.
|
|
1254 |
].
|
|
1255 |
].!
|
|
1256 |
|
|
1257 |
do:aBlock
|
|
1258 |
self isMethodDictionary ifTrue:[
|
|
1259 |
cachedContents isNil ifTrue:[
|
|
1260 |
self cacheMethodDictionary.
|
|
1261 |
].
|
|
1262 |
cachedContents do:aBlock.
|
|
1263 |
^ self.
|
|
1264 |
].
|
|
1265 |
self halt.
|
|
1266 |
!
|
|
1267 |
|
|
1268 |
includesKey:aSelector
|
|
1269 |
self isMethodDictionary ifTrue:[
|
|
1270 |
cachedContents isNil ifTrue:[
|
|
1271 |
self cacheMethodDictionary.
|
|
1272 |
].
|
|
1273 |
^ cachedContents includesKey:aSelector
|
|
1274 |
].
|
|
1275 |
self halt.!
|
|
1276 |
|
|
1277 |
keyAtValue:aMethod ifAbsent:exceptionValue
|
|
1278 |
self isMethodDictionary ifTrue:[
|
|
1279 |
cachedContents isNil ifTrue:[
|
|
1280 |
self cacheMethodDictionary.
|
|
1281 |
].
|
|
1282 |
^ cachedContents keyAtValue:aMethod ifAbsent:exceptionValue
|
|
1283 |
].
|
|
1284 |
self halt.!
|
|
1285 |
|
|
1286 |
keysAndValuesDo:aBlock
|
|
1287 |
self isMethodDictionary ifTrue:[
|
|
1288 |
cachedContents isNil ifTrue:[
|
|
1289 |
self cacheMethodDictionary.
|
|
1290 |
].
|
|
1291 |
|
|
1292 |
cachedContents keysAndValuesDo:[:sel :mthdRef |
|
|
1293 |
aBlock value:sel value:mthdRef.
|
|
1294 |
].
|
|
1295 |
^ self
|
|
1296 |
].
|
|
1297 |
self halt.
|
|
1298 |
! !
|
|
1299 |
|
1416
|
1300 |
!SnapShotImageMemory::ImageClassObject methodsFor:'accessing - slots'!
|
|
1301 |
|
1417
|
1302 |
category
|
|
1303 |
|categoryRef category|
|
|
1304 |
|
|
1305 |
categoryRef := self categorySlot.
|
|
1306 |
categoryRef isInteger ifTrue:[
|
|
1307 |
categoryRef := memory fetchObjectAt:categoryRef.
|
|
1308 |
].
|
|
1309 |
categoryRef notNil ifTrue:[
|
|
1310 |
category := memory fetchStringFor:categoryRef.
|
|
1311 |
].
|
|
1312 |
^ category
|
|
1313 |
!
|
|
1314 |
|
1416
|
1315 |
categorySlot
|
1419
|
1316 |
^ self at:(Class instVarOffsetOf:'category')!
|
|
1317 |
|
|
1318 |
classFilename
|
|
1319 |
|classFilenameRef classFilename|
|
|
1320 |
|
|
1321 |
classFilenameRef := self classFilenameSlot.
|
|
1322 |
classFilenameRef isInteger ifTrue:[
|
|
1323 |
classFilenameRef := memory fetchObjectAt:classFilenameRef.
|
|
1324 |
].
|
|
1325 |
classFilenameRef notNil ifTrue:[
|
|
1326 |
classFilename := memory fetchStringFor:classFilenameRef.
|
|
1327 |
].
|
|
1328 |
^ classFilename!
|
1416
|
1329 |
|
|
1330 |
classFilenameSlot
|
1419
|
1331 |
^ self at:(Class instVarOffsetOf:'classFilename')!
|
1416
|
1332 |
|
1417
|
1333 |
classVarNames
|
|
1334 |
|classVarNamesRef classVarNames s|
|
|
1335 |
|
|
1336 |
classVarNamesRef := self classVarsSlot.
|
|
1337 |
classVarNamesRef isInteger ifTrue:[
|
|
1338 |
classVarNamesRef := memory fetchObjectAt:classVarNamesRef.
|
|
1339 |
].
|
|
1340 |
classVarNamesRef notNil ifTrue:[
|
|
1341 |
classVarNamesRef isImageBytes ifTrue:[
|
|
1342 |
"/ a string
|
|
1343 |
classVarNames := memory fetchStringFor:classVarNamesRef.
|
|
1344 |
classVarNames := classVarNames asCollectionOfWords.
|
|
1345 |
] ifFalse:[
|
|
1346 |
classVarNames := Array new:(classVarNamesRef size).
|
|
1347 |
1 to:classVarNames size do:[:idx |
|
|
1348 |
s := classVarNamesRef at:idx.
|
|
1349 |
s := memory fetchObjectAt:s.
|
|
1350 |
s isImageBytes ifFalse:[self halt].
|
|
1351 |
s := memory fetchStringFor:s.
|
|
1352 |
classVarNames at:idx put:s.
|
|
1353 |
].
|
|
1354 |
].
|
|
1355 |
].
|
|
1356 |
^ classVarNames
|
|
1357 |
!
|
|
1358 |
|
1419
|
1359 |
classVariableString
|
|
1360 |
|classVarsPtr classVarsRef classVars|
|
|
1361 |
|
|
1362 |
(classVarsPtr := self classVarsSlot) == 0 ifTrue:[^ ''].
|
|
1363 |
classVarsRef := memory fetchObjectAt:classVarsPtr.
|
|
1364 |
classVarsRef isImageBytes ifTrue:[
|
|
1365 |
"/ a string
|
|
1366 |
classVars := memory fetchStringFor:classVarsRef.
|
|
1367 |
^ classVars
|
|
1368 |
].
|
|
1369 |
^ self classVarNames asStringWith:(Character space)
|
|
1370 |
!
|
|
1371 |
|
1416
|
1372 |
classVarsSlot
|
|
1373 |
^ self at:9
|
|
1374 |
!
|
|
1375 |
|
1417
|
1376 |
comment
|
|
1377 |
|commentRef comment|
|
|
1378 |
|
|
1379 |
commentRef := self commentSlot.
|
|
1380 |
commentRef isInteger ifTrue:[
|
|
1381 |
commentRef := memory fetchObjectAt:commentRef.
|
|
1382 |
].
|
|
1383 |
commentRef notNil ifTrue:[
|
|
1384 |
comment := memory fetchStringFor:commentRef.
|
|
1385 |
].
|
|
1386 |
^ comment
|
|
1387 |
!
|
|
1388 |
|
1416
|
1389 |
commentSlot
|
1419
|
1390 |
^ self at:(Class instVarOffsetOf:'comment')!
|
1416
|
1391 |
|
1417
|
1392 |
flags
|
1416
|
1393 |
|flags|
|
|
1394 |
|
|
1395 |
flags := self flagsSlot.
|
|
1396 |
|
|
1397 |
(SnapShotImageMemory isSmallIntegerOOP:flags) ifFalse:[
|
|
1398 |
self halt
|
|
1399 |
].
|
|
1400 |
^ flags bitShift:-1.
|
|
1401 |
!
|
|
1402 |
|
1417
|
1403 |
flagsSlot
|
1419
|
1404 |
^ self at:(Class instVarOffsetOf:'flags')!
|
|
1405 |
|
|
1406 |
instSize
|
|
1407 |
|instSizeRef|
|
|
1408 |
|
|
1409 |
instSizeRef := self instSizeSlot.
|
|
1410 |
^ memory fetchObjectAt:instSizeRef.!
|
1417
|
1411 |
|
1416
|
1412 |
instSizeSlot
|
1419
|
1413 |
^ self at:(Class instVarOffsetOf:'instSize')!
|
1416
|
1414 |
|
1417
|
1415 |
instVarNames
|
|
1416 |
|instVarNamesRef instVarNames s|
|
|
1417 |
|
|
1418 |
instVarNamesRef := self instVarsSlot.
|
|
1419 |
instVarNamesRef isInteger ifTrue:[
|
|
1420 |
instVarNamesRef := memory fetchObjectAt:instVarNamesRef.
|
|
1421 |
].
|
|
1422 |
instVarNamesRef notNil ifTrue:[
|
|
1423 |
instVarNamesRef isImageBytes ifTrue:[
|
|
1424 |
"/ a string
|
|
1425 |
instVarNames := memory fetchStringFor:instVarNamesRef.
|
|
1426 |
instVarNames := instVarNames asCollectionOfWords.
|
|
1427 |
] ifFalse:[
|
|
1428 |
instVarNames := Array new:(instVarNamesRef size).
|
|
1429 |
1 to:instVarNames size do:[:idx |
|
|
1430 |
s := instVarNamesRef at:idx.
|
|
1431 |
s := memory fetchObjectAt:s.
|
|
1432 |
s isImageBytes ifFalse:[self halt].
|
|
1433 |
s := memory fetchStringFor:s.
|
|
1434 |
instVarNames at:idx put:s.
|
|
1435 |
].
|
|
1436 |
].
|
|
1437 |
].
|
1419
|
1438 |
^ instVarNames ? #()!
|
1417
|
1439 |
|
1416
|
1440 |
instVarsSlot
|
|
1441 |
^ self at:6
|
|
1442 |
!
|
|
1443 |
|
1417
|
1444 |
methodDictionary
|
|
1445 |
|methodDictionaryRef methodDictionary|
|
|
1446 |
|
|
1447 |
methodDictionaryRef := self methodDictionarySlot.
|
|
1448 |
methodDictionaryRef isInteger ifTrue:[
|
|
1449 |
methodDictionaryRef == 0 ifTrue:[^ nil].
|
|
1450 |
methodDictionary := memory fetchObjectAt:methodDictionaryRef.
|
|
1451 |
].
|
|
1452 |
^ methodDictionary
|
|
1453 |
!
|
|
1454 |
|
1416
|
1455 |
methodDictionarySlot
|
1419
|
1456 |
^ self at:(Class instVarOffsetOf:'methodDictionary')!
|
1416
|
1457 |
|
1417
|
1458 |
name
|
|
1459 |
|nameRef name|
|
|
1460 |
|
1419
|
1461 |
self isMeta ifTrue:[
|
|
1462 |
^ self theNonMetaclass name , ' class'
|
|
1463 |
].
|
|
1464 |
|
1417
|
1465 |
nameRef := self nameSlot.
|
|
1466 |
nameRef isInteger ifTrue:[
|
|
1467 |
nameRef := memory fetchObjectAt:nameRef.
|
|
1468 |
].
|
|
1469 |
nameRef notNil ifTrue:[
|
|
1470 |
name := memory fetchStringFor:nameRef.
|
|
1471 |
].
|
|
1472 |
nameRef notNil ifTrue:[
|
|
1473 |
name := name asSymbol.
|
|
1474 |
].
|
|
1475 |
^ name
|
|
1476 |
!
|
|
1477 |
|
1416
|
1478 |
nameSlot
|
1419
|
1479 |
^ self at:(Class instVarOffsetOf:'name')!
|
1416
|
1480 |
|
|
1481 |
packageSlot
|
1419
|
1482 |
^ self at:(Class instVarOffsetOf:'package')!
|
|
1483 |
|
|
1484 |
primitiveSpec
|
|
1485 |
|primitiveSpecRef primitiveSpec|
|
|
1486 |
|
|
1487 |
primitiveSpecRef := self primitiveSpecSlot.
|
|
1488 |
primitiveSpecRef isInteger ifTrue:[
|
|
1489 |
primitiveSpecRef := memory fetchObjectAt:primitiveSpecRef.
|
|
1490 |
].
|
|
1491 |
primitiveSpecRef notNil ifTrue:[
|
|
1492 |
primitiveSpec := memory fetchStringFor:primitiveSpecRef.
|
|
1493 |
].
|
|
1494 |
^ primitiveSpec
|
1416
|
1495 |
!
|
|
1496 |
|
1419
|
1497 |
primitiveSpecSlot
|
|
1498 |
^ self at:(Class instVarOffsetOf:'primitiveSpec')!
|
|
1499 |
|
|
1500 |
revision
|
|
1501 |
|revisionRef revision|
|
|
1502 |
|
|
1503 |
revisionRef := self revisionSlot.
|
|
1504 |
revisionRef isInteger ifTrue:[
|
|
1505 |
revisionRef := memory fetchObjectAt:revisionRef.
|
|
1506 |
].
|
|
1507 |
revisionRef notNil ifTrue:[
|
|
1508 |
revision := memory fetchStringFor:revisionRef.
|
|
1509 |
].
|
|
1510 |
^ revision!
|
|
1511 |
|
1416
|
1512 |
revisionSlot
|
|
1513 |
^ self at:14
|
|
1514 |
!
|
|
1515 |
|
1417
|
1516 |
superclass
|
|
1517 |
|superClassRef superClass|
|
|
1518 |
|
|
1519 |
superClassRef := self superclassSlot.
|
|
1520 |
superClassRef isInteger ifTrue:[
|
|
1521 |
superClass := memory fetchObjectAt:superClassRef.
|
|
1522 |
].
|
|
1523 |
^ superClass
|
|
1524 |
!
|
|
1525 |
|
|
1526 |
superclassSlot
|
1416
|
1527 |
^ self at:1
|
|
1528 |
! !
|
|
1529 |
|
1417
|
1530 |
!SnapShotImageMemory::ImageClassObject methodsFor:'class protocol'!
|
|
1531 |
|
1419
|
1532 |
addAllClassVarNamesTo:aCollection
|
|
1533 |
"helper - add the name-strings of the class variables and of the class-vars
|
|
1534 |
of all superclasses to the argument, aCollection. Return aCollection"
|
|
1535 |
|
|
1536 |
|classvars superclass|
|
|
1537 |
|
|
1538 |
(superclass := self superclass) notNil ifTrue:[
|
|
1539 |
superclass addAllClassVarNamesTo:aCollection
|
|
1540 |
].
|
|
1541 |
(classvars := self classVariableString) notNil ifTrue:[
|
|
1542 |
aCollection addAll:(classvars asCollectionOfWords).
|
|
1543 |
].
|
|
1544 |
^ aCollection!
|
|
1545 |
|
|
1546 |
addAllInstVarNamesTo:aCollection
|
|
1547 |
|superInsts instvars superclass|
|
|
1548 |
|
|
1549 |
(superclass := self superclass) notNil ifTrue:[
|
|
1550 |
self superclass addAllInstVarNamesTo:aCollection
|
|
1551 |
].
|
|
1552 |
aCollection addAll:self instVarNames.
|
|
1553 |
^ aCollection!
|
|
1554 |
|
|
1555 |
addChangeRecordForClassFileOut:aClass!
|
|
1556 |
|
|
1557 |
allClassVarNames
|
|
1558 |
"return a collection of all the class variable name-strings
|
|
1559 |
this includes all superclass-class variables"
|
|
1560 |
|
|
1561 |
^ self addAllClassVarNamesTo:(OrderedCollection new)!
|
|
1562 |
|
|
1563 |
allInstVarNames
|
|
1564 |
self superclass isNil ifTrue:[^ self instVarNames].
|
|
1565 |
^ self addAllInstVarNamesTo:(OrderedCollection new)!
|
|
1566 |
|
|
1567 |
allSubclassesDo:aBlock
|
|
1568 |
"evaluate aBlock for all of my subclasses.
|
|
1569 |
There is no specific order, in which the entries are enumerated.
|
|
1570 |
Warning:
|
|
1571 |
This will only enumerate globally known classes - for anonymous
|
|
1572 |
behaviors, you have to walk over all instances of Behavior."
|
|
1573 |
|
|
1574 |
self isMeta ifTrue:[
|
|
1575 |
"/ metaclasses are not found via Smalltalk allClassesDo:
|
|
1576 |
"/ here, walk over classes and enumerate corresponding metas.
|
|
1577 |
self soleInstance allSubclassesDo:[:aSubClass |
|
|
1578 |
aBlock value:(aSubClass class)
|
|
1579 |
].
|
|
1580 |
] ifFalse:[
|
|
1581 |
Smalltalk allClassesDo:[:aClass |
|
|
1582 |
(aClass isSubclassOf:self) ifTrue:[
|
|
1583 |
aBlock value:aClass
|
|
1584 |
]
|
|
1585 |
]
|
|
1586 |
]
|
|
1587 |
|
|
1588 |
"
|
|
1589 |
Collection allSubclassesDo:[:c | Transcript showCR:(c name)]
|
|
1590 |
Collection class allSubclassesDo:[:c | Transcript showCR:(c name)]
|
|
1591 |
"
|
|
1592 |
|
|
1593 |
"Modified: / 25.10.1997 / 21:17:13 / cg"
|
|
1594 |
!
|
|
1595 |
|
|
1596 |
allSuperclasses
|
|
1597 |
"return a collection of the receivers accumulated superclasses"
|
|
1598 |
|
|
1599 |
|aCollection theSuperClass|
|
|
1600 |
|
|
1601 |
theSuperClass := self superclass.
|
|
1602 |
theSuperClass isNil ifTrue:[
|
|
1603 |
^ #()
|
|
1604 |
].
|
|
1605 |
aCollection := OrderedCollection new.
|
|
1606 |
[theSuperClass notNil] whileTrue:[
|
|
1607 |
aCollection add:theSuperClass.
|
|
1608 |
theSuperClass := theSuperClass superclass
|
|
1609 |
].
|
|
1610 |
^ aCollection
|
|
1611 |
|
|
1612 |
"
|
|
1613 |
String allSuperclasses
|
|
1614 |
"!
|
|
1615 |
|
|
1616 |
allSuperclassesDo:aBlock
|
|
1617 |
"evaluate aBlock for all of my superclasses"
|
|
1618 |
|
|
1619 |
|theClass|
|
|
1620 |
|
|
1621 |
theClass := self superclass.
|
|
1622 |
[theClass notNil] whileTrue:[
|
|
1623 |
aBlock value:theClass.
|
|
1624 |
theClass := theClass superclass
|
|
1625 |
]
|
|
1626 |
|
|
1627 |
"
|
|
1628 |
String allSuperclassesDo:[:c | Transcript showCR:(c name)]
|
|
1629 |
"
|
|
1630 |
!
|
|
1631 |
|
|
1632 |
basicFileOutDefinitionOn:aStream withNameSpace:forceNameSpace
|
|
1633 |
"append an expression on aStream, which defines myself."
|
|
1634 |
|
|
1635 |
self
|
|
1636 |
basicFileOutDefinitionOn:aStream
|
|
1637 |
withNameSpace:forceNameSpace
|
|
1638 |
withPackage:true!
|
|
1639 |
|
1417
|
1640 |
basicFileOutDefinitionOn:aStream withNameSpace:forceNameSpace withPackage:showPackage
|
|
1641 |
"append an expression on aStream, which defines myself."
|
|
1642 |
|
|
1643 |
|s owner ns nsName fullName superName cls topOwner
|
|
1644 |
syntaxHilighting superclass category|
|
|
1645 |
|
|
1646 |
UserPreferences isNil ifTrue:[
|
|
1647 |
syntaxHilighting := false
|
|
1648 |
] ifFalse:[
|
|
1649 |
syntaxHilighting := UserPreferences current syntaxColoring.
|
|
1650 |
].
|
|
1651 |
|
|
1652 |
owner := self owningClass.
|
|
1653 |
|
|
1654 |
owner isNil ifTrue:[
|
|
1655 |
ns := self nameSpace.
|
|
1656 |
] ifFalse:[
|
|
1657 |
ns := self topOwningClass nameSpace
|
|
1658 |
].
|
|
1659 |
fullName := Class fileOutNameSpaceQuerySignal query == true.
|
|
1660 |
|
|
1661 |
(showPackage and:[owner isNil]) ifTrue:[
|
|
1662 |
aStream nextPutAll:'"{ Package: '''.
|
|
1663 |
aStream nextPutAll:self package asString.
|
|
1664 |
aStream nextPutAll:''' }"'; cr; cr.
|
|
1665 |
].
|
|
1666 |
|
|
1667 |
((owner isNil and:[fullName not])
|
|
1668 |
or:[owner notNil and:[forceNameSpace and:[fullName not]]]) ifTrue:[
|
|
1669 |
(ns notNil and:[ns ~~ Smalltalk]) ifTrue:[
|
|
1670 |
nsName := ns name.
|
|
1671 |
(nsName includes:$:) ifTrue:[
|
|
1672 |
nsName := '''' , nsName , ''''
|
|
1673 |
].
|
|
1674 |
"/ aStream nextPutLine:'"{ NameSpace: ' , nsName , ' }"'; cr.
|
|
1675 |
aStream nextPutAll:'"{ NameSpace: '.
|
|
1676 |
syntaxHilighting ifTrue:[aStream bold].
|
|
1677 |
aStream nextPutAll:nsName.
|
|
1678 |
syntaxHilighting ifTrue:[aStream normal].
|
|
1679 |
aStream nextPutAll:' }"'; cr; cr.
|
|
1680 |
]
|
|
1681 |
].
|
|
1682 |
|
1419
|
1683 |
superclass := self superclass.
|
|
1684 |
category := self category.
|
|
1685 |
|
1417
|
1686 |
"take care of nil-superclass"
|
|
1687 |
superclass isNil ifTrue:[
|
|
1688 |
s := 'nil'
|
|
1689 |
] ifFalse:[
|
|
1690 |
fullName ifTrue:[
|
|
1691 |
superclass == owner ifTrue:[
|
|
1692 |
s := superclass nameWithoutNameSpacePrefix
|
|
1693 |
] ifFalse:[
|
|
1694 |
s := superclass name
|
|
1695 |
]
|
|
1696 |
] ifFalse:[
|
|
1697 |
(ns == superclass nameSpace
|
|
1698 |
and:[superclass owningClass isNil]) ifTrue:[
|
|
1699 |
"/ superclass is in the same namespace;
|
|
1700 |
"/ still prepend namespace prefix, to avoid
|
|
1701 |
"/ confusing stc, which needs that information ...
|
|
1702 |
s := superclass nameWithoutPrefix
|
|
1703 |
] ifFalse:[
|
|
1704 |
"/ a very special (rare) situation:
|
|
1705 |
"/ my superclass resides in another nameSpace,
|
|
1706 |
"/ but there is something else named like this
|
|
1707 |
"/ to be found in my nameSpace (or a private class)
|
|
1708 |
|
|
1709 |
superName := superclass nameWithoutNameSpacePrefix asSymbol.
|
|
1710 |
cls := self privateClassesAt:superName.
|
|
1711 |
cls isNil ifTrue:[
|
|
1712 |
(topOwner := self topOwningClass) isNil ifTrue:[
|
|
1713 |
ns := self nameSpace.
|
|
1714 |
ns notNil ifTrue:[
|
|
1715 |
cls := ns privateClassesAt:superName
|
|
1716 |
] ifFalse:[
|
|
1717 |
"/ self error:'unexpected nil namespace'
|
|
1718 |
]
|
|
1719 |
] ifFalse:[
|
|
1720 |
cls := topOwner nameSpace at:superName.
|
|
1721 |
]
|
|
1722 |
].
|
|
1723 |
(cls notNil and:[cls ~~ superclass]) ifTrue:[
|
|
1724 |
s := superclass nameSpace name , '::' , superName
|
|
1725 |
] ifFalse:[
|
|
1726 |
"/ no class with that name found in my namespace ...
|
|
1727 |
"/ if the superclass resides in Smalltalk,
|
|
1728 |
"/ suppress prefix; otherwise, use full prefix.
|
|
1729 |
(superclass nameSpace notNil
|
|
1730 |
and:[superclass nameSpace ~~ Smalltalk]) ifTrue:[
|
|
1731 |
(owner notNil
|
|
1732 |
and:[owner nameSpace == superclass owningClass nameSpace])
|
|
1733 |
ifTrue:[
|
|
1734 |
s := superclass nameWithoutNameSpacePrefix
|
|
1735 |
] ifFalse:[
|
|
1736 |
s := superclass name
|
|
1737 |
]
|
|
1738 |
] ifFalse:[
|
|
1739 |
s := superName
|
|
1740 |
]
|
|
1741 |
]
|
|
1742 |
]
|
|
1743 |
]
|
|
1744 |
].
|
|
1745 |
|
|
1746 |
syntaxHilighting ifTrue:[aStream bold].
|
|
1747 |
aStream nextPutAll:s. "/ superclass
|
|
1748 |
syntaxHilighting ifTrue:[aStream normal].
|
|
1749 |
aStream space.
|
|
1750 |
self basicFileOutInstvarTypeKeywordOn:aStream.
|
|
1751 |
|
|
1752 |
(fullName and:[owner isNil]) ifTrue:[
|
|
1753 |
aStream nextPutAll:'#'''.
|
|
1754 |
syntaxHilighting ifTrue:[aStream bold].
|
|
1755 |
aStream nextPutAll:(self name).
|
|
1756 |
syntaxHilighting ifTrue:[aStream normal].
|
|
1757 |
aStream nextPutAll:''''.
|
|
1758 |
] ifFalse:[
|
|
1759 |
aStream nextPut:$#.
|
|
1760 |
syntaxHilighting ifTrue:[aStream bold].
|
|
1761 |
aStream nextPutAll:(self nameWithoutPrefix).
|
|
1762 |
syntaxHilighting ifTrue:[aStream normal].
|
|
1763 |
].
|
|
1764 |
|
|
1765 |
aStream crtab.
|
|
1766 |
aStream nextPutAll:'instanceVariableNames:'''.
|
|
1767 |
syntaxHilighting ifTrue:[aStream bold].
|
|
1768 |
self printInstVarNamesOn:aStream indent:16.
|
|
1769 |
syntaxHilighting ifTrue:[aStream normal].
|
|
1770 |
aStream nextPutAll:''''.
|
|
1771 |
|
|
1772 |
aStream crtab.
|
|
1773 |
aStream nextPutAll:'classVariableNames:'''.
|
|
1774 |
syntaxHilighting ifTrue:[aStream bold].
|
|
1775 |
self printClassVarNamesOn:aStream indent:16.
|
|
1776 |
syntaxHilighting ifTrue:[aStream normal].
|
|
1777 |
aStream nextPutAll:''''.
|
|
1778 |
|
|
1779 |
aStream crtab.
|
|
1780 |
aStream nextPutAll:'poolDictionaries:'''''.
|
|
1781 |
|
|
1782 |
aStream crtab.
|
|
1783 |
owner isNil ifTrue:[
|
|
1784 |
"/ a public class
|
|
1785 |
aStream nextPutAll:'category:'.
|
|
1786 |
category isNil ifTrue:[
|
|
1787 |
s := ''''''
|
|
1788 |
] ifFalse:[
|
|
1789 |
s := category asString storeString
|
|
1790 |
].
|
|
1791 |
aStream nextPutAll:s.
|
|
1792 |
] ifFalse:[
|
|
1793 |
"/ a private class
|
|
1794 |
aStream nextPutAll:'privateIn:'.
|
|
1795 |
syntaxHilighting ifTrue:[aStream bold].
|
|
1796 |
"/ fullName ifTrue:[
|
|
1797 |
"/ s := owner name.
|
|
1798 |
"/ ] ifFalse:[
|
|
1799 |
"/ s := owner nameWithoutNameSpacePrefix.
|
|
1800 |
"/ ].
|
|
1801 |
s := owner nameWithoutNameSpacePrefix.
|
|
1802 |
aStream nextPutAll:s.
|
|
1803 |
syntaxHilighting ifTrue:[aStream normal].
|
|
1804 |
].
|
|
1805 |
aStream cr
|
|
1806 |
|
|
1807 |
"Created: / 4.1.1997 / 20:38:16 / cg"
|
|
1808 |
"Modified: / 8.8.1997 / 10:59:50 / cg"
|
1419
|
1809 |
"Modified: / 18.3.1999 / 18:15:46 / stefan"!
|
1417
|
1810 |
|
|
1811 |
basicFileOutInstvarTypeKeywordOn:aStream
|
|
1812 |
"a helper for fileOutDefinition"
|
|
1813 |
|
|
1814 |
|isVar s superclass|
|
|
1815 |
|
|
1816 |
superclass := self superclass.
|
|
1817 |
superclass isNil ifTrue:[
|
|
1818 |
isVar := self isVariable
|
|
1819 |
] ifFalse:[
|
|
1820 |
"I cant remember what this is for ?"
|
|
1821 |
isVar := (self isVariable and:[superclass isVariable not])
|
|
1822 |
].
|
|
1823 |
|
|
1824 |
aStream nextPutAll:(self firstDefinitionSelectorPart).
|
|
1825 |
|
|
1826 |
"Created: 11.10.1996 / 18:57:29 / cg"
|
|
1827 |
!
|
|
1828 |
|
1419
|
1829 |
binaryRevision
|
|
1830 |
"return the revision-ID from which the class was stc-compiled;
|
|
1831 |
nil if its an autoloaded or filedIn class.
|
|
1832 |
If a classes binary is up-to-date w.r.t. the source repository,
|
|
1833 |
the returned string is the same as the one returned by #revision."
|
|
1834 |
|
|
1835 |
|owner info c revision|
|
|
1836 |
|
|
1837 |
revision := self revision.
|
|
1838 |
|
|
1839 |
(owner := self owningClass) notNil ifTrue:[^ owner binaryRevision].
|
|
1840 |
revision notNil ifTrue:[
|
|
1841 |
c := revision first.
|
|
1842 |
c == $$ ifTrue:[
|
|
1843 |
info := Class revisionInfoFromString:revision.
|
|
1844 |
info isNil ifTrue:[^ '0'].
|
|
1845 |
^ info at:#revision ifAbsent:'0'.
|
|
1846 |
].
|
|
1847 |
c isDigit ifFalse:[
|
|
1848 |
^ '0'
|
|
1849 |
].
|
|
1850 |
].
|
|
1851 |
|
|
1852 |
^ revision
|
|
1853 |
|
|
1854 |
"
|
|
1855 |
Object binaryRevision
|
|
1856 |
Object class binaryRevision
|
|
1857 |
"
|
|
1858 |
|
|
1859 |
"
|
|
1860 |
to find all classes which are not up-to-date:
|
|
1861 |
|
|
1862 |
|classes|
|
|
1863 |
|
|
1864 |
classes := Smalltalk allClasses
|
|
1865 |
select:[:cls | cls binaryRevision notNil and:[cls binaryRevision ~= cls revision]].
|
|
1866 |
SystemBrowser browseClasses:classes title:'classes which are not up-to-date'
|
|
1867 |
"
|
|
1868 |
|
|
1869 |
"Created: 7.12.1995 / 10:58:47 / cg"
|
|
1870 |
"Modified: 1.4.1997 / 23:33:01 / stefan"
|
|
1871 |
"Modified: 9.9.1997 / 12:05:41 / cg"!
|
|
1872 |
|
1417
|
1873 |
compiledMethodAt:aSelector
|
|
1874 |
|
|
1875 |
^ self compiledMethodAt:aSelector ifAbsent:nil
|
|
1876 |
!
|
|
1877 |
|
|
1878 |
compiledMethodAt:aSelector ifAbsent:exceptionValue
|
|
1879 |
|dict|
|
|
1880 |
|
|
1881 |
dict := self methodDictionary.
|
|
1882 |
dict isNil ifTrue:[
|
|
1883 |
('Behavior [warning]: nil methodDictionary in ' , self name printString) errorPrintCR.
|
|
1884 |
^ exceptionValue value
|
|
1885 |
].
|
|
1886 |
|
|
1887 |
^ dict at:aSelector ifAbsent:exceptionValue
|
|
1888 |
!
|
|
1889 |
|
|
1890 |
evaluatorClass
|
|
1891 |
^ Object evaluatorClass
|
|
1892 |
!
|
|
1893 |
|
1419
|
1894 |
fileOut
|
|
1895 |
|baseName dirName nm fileName|
|
|
1896 |
|
|
1897 |
baseName := (Smalltalk fileNameForClass:self name).
|
|
1898 |
nm := baseName asFilename withSuffix:'st'.
|
|
1899 |
|
|
1900 |
"
|
|
1901 |
this test allows a smalltalk to be built without Projects/ChangeSets
|
|
1902 |
"
|
|
1903 |
Project notNil ifTrue:[
|
|
1904 |
dirName := Project currentProjectDirectory
|
|
1905 |
] ifFalse:[
|
|
1906 |
dirName := Filename currentDirectory
|
|
1907 |
].
|
|
1908 |
fileName := (dirName asFilename construct:nm).
|
|
1909 |
fileName makeLegalFilename.
|
|
1910 |
|
|
1911 |
self fileOutAs:fileName name.
|
|
1912 |
|
|
1913 |
"/ "
|
|
1914 |
"/ add a change record; that way, administration is much easier,
|
|
1915 |
"/ since we can see in that changeBrowser, which changes have
|
|
1916 |
"/ already found their way into a sourceFile and which must be
|
|
1917 |
"/ applied again
|
|
1918 |
"/ "
|
|
1919 |
"/ self addChangeRecordForClassFileOut:self
|
|
1920 |
|
|
1921 |
"Modified: / 7.6.1996 / 09:14:43 / stefan"
|
|
1922 |
"Modified: / 27.8.1998 / 02:02:57 / cg"!
|
|
1923 |
|
|
1924 |
fileOutAllDefinitionsOn:aStream
|
|
1925 |
"append expressions on aStream, which defines myself and all of my private classes."
|
|
1926 |
|
|
1927 |
self fileOutDefinitionOn:aStream.
|
|
1928 |
aStream nextPutChunkSeparator.
|
|
1929 |
aStream cr; cr.
|
|
1930 |
|
|
1931 |
"/
|
|
1932 |
"/ optional classInstanceVariables
|
|
1933 |
"/
|
|
1934 |
self classRef instanceVariableString isBlank ifFalse:[
|
|
1935 |
self fileOutClassInstVarDefinitionOn:aStream.
|
|
1936 |
aStream nextPutChunkSeparator.
|
|
1937 |
aStream cr; cr
|
|
1938 |
].
|
|
1939 |
|
|
1940 |
"/ here, the full nameSpace prefixes are output,
|
|
1941 |
"/ to avoid confusing stc
|
|
1942 |
"/ (which otherwise could not find the correct superclass)
|
|
1943 |
"/
|
|
1944 |
Class fileOutNameSpaceQuerySignal answer:true do:[
|
|
1945 |
self privateClassesSorted do:[:aClass |
|
|
1946 |
aClass fileOutAllDefinitionsOn:aStream
|
|
1947 |
]
|
|
1948 |
].
|
|
1949 |
|
|
1950 |
"Created: 15.10.1996 / 11:15:19 / cg"
|
|
1951 |
"Modified: 22.3.1997 / 16:11:56 / cg"!
|
|
1952 |
|
|
1953 |
fileOutAs:fileNameString
|
|
1954 |
"create a file consisting of all methods in myself in
|
|
1955 |
sourceForm, from which the class can be reconstructed (by filing in).
|
|
1956 |
The given fileName should be a full path, including suffix.
|
|
1957 |
Care is taken, to not clobber any existing file in
|
|
1958 |
case of errors (for example: disk full).
|
|
1959 |
Also, since the classes methods need a valid sourcefile, the current
|
|
1960 |
sourceFile may not be rewritten."
|
|
1961 |
|
|
1962 |
|aStream fileName newFileName savFilename needRename
|
|
1963 |
mySourceFileName sameFile s mySourceFileID anySourceRef|
|
|
1964 |
|
|
1965 |
self isLoaded ifFalse:[
|
|
1966 |
^ Class fileOutErrorSignal
|
|
1967 |
raiseRequestWith:self
|
|
1968 |
errorString:'will not fileOut unloaded classes'
|
|
1969 |
].
|
|
1970 |
|
|
1971 |
fileName := fileNameString asFilename.
|
|
1972 |
|
|
1973 |
"
|
|
1974 |
if file exists, copy the existing to a .sav-file,
|
|
1975 |
create the new file as XXX.new-file,
|
|
1976 |
and, if that worked rename afterwards ...
|
|
1977 |
"
|
|
1978 |
(fileName exists) ifTrue:[
|
|
1979 |
sameFile := false.
|
|
1980 |
|
|
1981 |
"/ check carefully - maybe, my source does not really come from that
|
|
1982 |
"/ file (i.e. all of my methods have their source as string)
|
|
1983 |
|
|
1984 |
anySourceRef := false.
|
|
1985 |
self methodDictionary do:[:m|
|
|
1986 |
m sourcePosition notNil ifTrue:[
|
|
1987 |
anySourceRef := true
|
|
1988 |
]
|
|
1989 |
].
|
|
1990 |
self classRef methodDictionary do:[:m|
|
|
1991 |
m sourcePosition notNil ifTrue:[
|
|
1992 |
anySourceRef := true
|
|
1993 |
]
|
|
1994 |
].
|
|
1995 |
|
|
1996 |
anySourceRef ifTrue:[
|
|
1997 |
s := self sourceStream.
|
|
1998 |
s notNil ifTrue:[
|
|
1999 |
mySourceFileID := s pathName asFilename info id.
|
|
2000 |
sameFile := (fileName info id) == mySourceFileID.
|
|
2001 |
s close.
|
|
2002 |
] ifFalse:[
|
|
2003 |
self classFilename notNil ifTrue:[
|
|
2004 |
"
|
|
2005 |
check for overwriting my current source file
|
|
2006 |
this is not allowed, since it would clobber my methods source
|
|
2007 |
file ... you have to save it to some other place.
|
|
2008 |
This happens if you ask for a fileOut into the source-directory
|
|
2009 |
(from which my methods get their source)
|
|
2010 |
"
|
|
2011 |
mySourceFileName := Smalltalk getSourceFileName:self classFilename.
|
|
2012 |
sameFile := (fileNameString = mySourceFileName).
|
|
2013 |
sameFile ifFalse:[
|
|
2014 |
mySourceFileName notNil ifTrue:[
|
|
2015 |
sameFile := (fileName info id) == (mySourceFileName asFilename info id)
|
|
2016 |
]
|
|
2017 |
].
|
|
2018 |
]
|
|
2019 |
].
|
|
2020 |
].
|
|
2021 |
|
|
2022 |
sameFile ifTrue:[
|
|
2023 |
^ Class fileOutErrorSignal
|
|
2024 |
raiseRequestWith:fileNameString
|
|
2025 |
errorString:('may not overwrite sourcefile:', fileNameString)
|
|
2026 |
].
|
|
2027 |
|
|
2028 |
savFilename := Filename newTemporary.
|
|
2029 |
fileName copyTo:savFilename.
|
|
2030 |
newFileName := fileName withSuffix:'new'.
|
|
2031 |
needRename := true
|
|
2032 |
] ifFalse:[
|
|
2033 |
"/ another possible trap: if my sourceFileName is
|
|
2034 |
"/ the same as the written one AND the new files directory
|
|
2035 |
"/ is along the sourcePath, we also need a temporary file
|
|
2036 |
"/ first, to avoid accessing the newly written file.
|
|
2037 |
|
|
2038 |
anySourceRef := false.
|
|
2039 |
self methodDictionary do:[:m|
|
|
2040 |
|mSrc|
|
|
2041 |
|
|
2042 |
(mSrc := m sourceFilename) notNil ifTrue:[
|
|
2043 |
mSrc asFilename baseName = fileName baseName ifTrue:[
|
|
2044 |
anySourceRef := true
|
|
2045 |
]
|
|
2046 |
]
|
|
2047 |
].
|
|
2048 |
self classRef methodDictionary do:[:m|
|
|
2049 |
|mSrc|
|
|
2050 |
|
|
2051 |
(mSrc := m sourceFilename) notNil ifTrue:[
|
|
2052 |
mSrc asFilename baseName = fileName baseName ifTrue:[
|
|
2053 |
anySourceRef := true
|
|
2054 |
]
|
|
2055 |
]
|
|
2056 |
].
|
|
2057 |
anySourceRef ifTrue:[
|
|
2058 |
newFileName := fileName withSuffix:'new'.
|
|
2059 |
needRename := true
|
|
2060 |
] ifFalse:[
|
|
2061 |
newFileName := fileName.
|
|
2062 |
needRename := false
|
|
2063 |
]
|
|
2064 |
].
|
|
2065 |
|
|
2066 |
aStream := newFileName writeStream.
|
|
2067 |
aStream isNil ifTrue:[
|
|
2068 |
savFilename notNil ifTrue:[
|
|
2069 |
savFilename delete
|
|
2070 |
].
|
|
2071 |
^ Class fileOutErrorSignal
|
|
2072 |
raiseRequestWith:newFileName
|
|
2073 |
errorString:('cannot create file:', newFileName name)
|
|
2074 |
].
|
|
2075 |
self fileOutOn:aStream.
|
|
2076 |
aStream close.
|
|
2077 |
|
|
2078 |
"
|
|
2079 |
finally, replace the old-file
|
|
2080 |
be careful, if the old one is a symbolic link; in this case,
|
|
2081 |
we have to do a copy ...
|
|
2082 |
"
|
|
2083 |
needRename ifTrue:[
|
|
2084 |
newFileName copyTo:fileName.
|
|
2085 |
newFileName delete
|
|
2086 |
].
|
|
2087 |
savFilename notNil ifTrue:[
|
|
2088 |
savFilename delete
|
|
2089 |
].
|
|
2090 |
|
|
2091 |
"
|
|
2092 |
add a change record; that way, administration is much easier,
|
|
2093 |
since we can see in that changeBrowser, which changes have
|
|
2094 |
already found their way into a sourceFile and which must be
|
|
2095 |
applied again
|
|
2096 |
"
|
|
2097 |
self addChangeRecordForClassFileOut:self
|
|
2098 |
|
|
2099 |
"Modified: / 7.6.1996 / 09:14:43 / stefan"
|
|
2100 |
"Created: / 16.4.1997 / 20:44:05 / cg"
|
|
2101 |
"Modified: / 12.8.1998 / 11:14:56 / cg"!
|
|
2102 |
|
|
2103 |
fileOutCategory:aCategory
|
|
2104 |
"create a file 'class-category.st' consisting of all methods in aCategory.
|
|
2105 |
If the current project is not nil, create the file in the projects
|
|
2106 |
directory."
|
|
2107 |
|
|
2108 |
|aStream fileName|
|
|
2109 |
|
|
2110 |
fileName := (self name , '-' , aCategory , '.st') asFilename.
|
|
2111 |
fileName makeLegalFilename.
|
|
2112 |
|
|
2113 |
"/
|
|
2114 |
"/ this test allows a smalltalk to be built without Projects/ChangeSets
|
|
2115 |
"/
|
|
2116 |
Project notNil ifTrue:[
|
|
2117 |
fileName := Project currentProjectDirectory asFilename construct:(fileName name).
|
|
2118 |
].
|
|
2119 |
|
|
2120 |
"/
|
|
2121 |
"/ if the file exists, save original in a .sav file
|
|
2122 |
"/
|
|
2123 |
fileName exists ifTrue:[
|
|
2124 |
fileName copyTo:(fileName withSuffix:'sav')
|
|
2125 |
].
|
|
2126 |
aStream := FileStream newFileNamed:fileName.
|
|
2127 |
aStream isNil ifTrue:[
|
|
2128 |
^ Class fileOutErrorSignal
|
|
2129 |
raiseRequestWith:fileName
|
|
2130 |
errorString:('cannot create file:', fileName pathName)
|
|
2131 |
].
|
|
2132 |
|
|
2133 |
self fileOutCategory:aCategory on:aStream.
|
|
2134 |
aStream close
|
|
2135 |
|
|
2136 |
"Modified: / 1.4.1997 / 16:00:24 / stefan"
|
|
2137 |
"Created: / 1.4.1997 / 16:04:18 / stefan"
|
|
2138 |
"Modified: / 28.10.1997 / 14:40:28 / cg"!
|
|
2139 |
|
|
2140 |
fileOutCategory:aCategory except:skippedMethods only:savedMethods methodFilter:methodFilter on:aStream
|
|
2141 |
|dict source sortedSelectors first privacy interestingMethods cat|
|
|
2142 |
|
|
2143 |
dict := self methodDictionary.
|
|
2144 |
dict notNil ifTrue:[
|
|
2145 |
interestingMethods := OrderedCollection new.
|
|
2146 |
dict do:[:aMethod |
|
|
2147 |
|wanted|
|
|
2148 |
|
|
2149 |
(methodFilter isNil
|
|
2150 |
or:[methodFilter value:aMethod]) ifTrue:[
|
|
2151 |
(aCategory = aMethod category) ifTrue:[
|
|
2152 |
skippedMethods notNil ifTrue:[
|
|
2153 |
wanted := (skippedMethods includesIdentical:aMethod) not
|
|
2154 |
] ifFalse:[
|
|
2155 |
savedMethods notNil ifTrue:[
|
|
2156 |
wanted := (savedMethods includesIdentical:aMethod).
|
|
2157 |
] ifFalse:[
|
|
2158 |
wanted := true
|
|
2159 |
]
|
|
2160 |
].
|
|
2161 |
wanted ifTrue:[interestingMethods add:aMethod].
|
|
2162 |
]
|
|
2163 |
]
|
|
2164 |
].
|
|
2165 |
interestingMethods notEmpty ifTrue:[
|
|
2166 |
first := true.
|
|
2167 |
privacy := nil.
|
|
2168 |
|
|
2169 |
"/
|
|
2170 |
"/ sort by selector
|
|
2171 |
"/
|
|
2172 |
sortedSelectors := interestingMethods collect:[:m | self selectorAtMethod:m].
|
|
2173 |
sortedSelectors sortWith:interestingMethods.
|
|
2174 |
|
|
2175 |
interestingMethods do:[:aMethod |
|
|
2176 |
first ifFalse:[
|
|
2177 |
privacy ~~ aMethod privacy ifTrue:[
|
|
2178 |
first := true.
|
|
2179 |
aStream space.
|
|
2180 |
aStream nextPutChunkSeparator.
|
|
2181 |
].
|
|
2182 |
aStream cr; cr
|
|
2183 |
].
|
|
2184 |
|
|
2185 |
privacy := aMethod privacy.
|
|
2186 |
|
|
2187 |
first ifTrue:[
|
|
2188 |
aStream nextPutChunkSeparator.
|
|
2189 |
self printClassNameOn:aStream.
|
|
2190 |
privacy ~~ #public ifTrue:[
|
|
2191 |
aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'.
|
|
2192 |
] ifFalse:[
|
|
2193 |
aStream nextPutAll:' methodsFor:'.
|
|
2194 |
].
|
|
2195 |
cat := aCategory.
|
|
2196 |
cat isNil ifTrue:[ cat := '' ].
|
|
2197 |
aStream nextPutAll:aCategory asString storeString.
|
|
2198 |
aStream nextPutChunkSeparator; cr; cr.
|
|
2199 |
first := false.
|
|
2200 |
].
|
|
2201 |
source := aMethod source.
|
|
2202 |
source isNil ifTrue:[
|
|
2203 |
Class fileOutErrorSignal
|
|
2204 |
raiseRequestWith:self
|
|
2205 |
errorString:'no source for method: ', (aMethod displayString)
|
|
2206 |
] ifFalse:[
|
|
2207 |
aStream nextChunkPut:source.
|
|
2208 |
].
|
|
2209 |
].
|
|
2210 |
aStream space.
|
|
2211 |
aStream nextPutChunkSeparator.
|
|
2212 |
aStream cr
|
|
2213 |
]
|
|
2214 |
]
|
|
2215 |
|
|
2216 |
"Modified: 28.8.1995 / 14:30:41 / claus"
|
|
2217 |
"Modified: 12.6.1996 / 11:37:33 / stefan"
|
|
2218 |
"Modified: 15.11.1996 / 11:32:21 / cg"
|
|
2219 |
"Created: 1.4.1997 / 16:04:33 / stefan"!
|
|
2220 |
|
|
2221 |
fileOutCategory:aCategory methodFilter:methodFilter on:aStream
|
|
2222 |
"file out all methods belonging to aCategory, aString onto aStream"
|
|
2223 |
|
|
2224 |
self fileOutCategory:aCategory except:nil only:nil methodFilter:methodFilter on:aStream!
|
|
2225 |
|
|
2226 |
fileOutCategory:aCategory on:aStream
|
|
2227 |
Class fileOutNameSpaceQuerySignal answer:true do:[
|
|
2228 |
self fileOutCategory:aCategory except:nil only:nil methodFilter:nil on:aStream
|
|
2229 |
]!
|
|
2230 |
|
|
2231 |
fileOutClassInstVarDefinitionOn:aStream withNameSpace:withNameSpace
|
|
2232 |
"append an expression to define my classInstanceVariables on aStream"
|
|
2233 |
|
|
2234 |
|anySuperClassInstVar|
|
|
2235 |
|
|
2236 |
self isLoaded ifFalse:[
|
|
2237 |
^ self basicFileOutDefinitionOn:aStream withNameSpace:withNameSpace
|
|
2238 |
].
|
|
2239 |
|
|
2240 |
withNameSpace ifTrue:[
|
|
2241 |
self name printOn:aStream.
|
|
2242 |
] ifFalse:[
|
|
2243 |
self printClassNameOn:aStream.
|
|
2244 |
].
|
|
2245 |
aStream nextPutAll:' class instanceVariableNames:'''.
|
|
2246 |
self class printInstVarNamesOn:aStream indent:8.
|
|
2247 |
aStream nextPutAll:''''.
|
|
2248 |
|
|
2249 |
"mhmh - good idea; saw this in SmallDraw sourcecode ..."
|
|
2250 |
|
|
2251 |
anySuperClassInstVar := false.
|
|
2252 |
self allSuperclassesDo:[:aSuperClass |
|
|
2253 |
aSuperClass class instVarNames do:[:ignored | anySuperClassInstVar := true].
|
|
2254 |
].
|
|
2255 |
|
|
2256 |
aStream cr; cr; nextPut:(Character doubleQuote); cr; space.
|
|
2257 |
anySuperClassInstVar ifFalse:[
|
|
2258 |
aStream
|
|
2259 |
nextPutLine:'No other class instance variables are inherited by this class.'.
|
|
2260 |
] ifTrue:[
|
|
2261 |
aStream
|
|
2262 |
nextPutLine:'The following class instance variables are inherited by this class:'.
|
|
2263 |
aStream cr.
|
|
2264 |
self allSuperclassesDo:[:aSuperClass |
|
|
2265 |
aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '.
|
|
2266 |
aStream nextPutLine:(aSuperClass class instanceVariableString).
|
|
2267 |
].
|
|
2268 |
|
|
2269 |
].
|
|
2270 |
aStream nextPut:(Character doubleQuote); cr.
|
|
2271 |
|
|
2272 |
"Created: / 10.12.1995 / 16:31:25 / cg"
|
|
2273 |
"Modified: / 1.4.1997 / 16:00:33 / stefan"
|
|
2274 |
"Modified: / 3.2.2000 / 23:05:28 / cg"
|
|
2275 |
!
|
|
2276 |
|
|
2277 |
fileOutDefinitionOn:aStream
|
|
2278 |
"append an expression on aStream, which defines myself."
|
|
2279 |
|
|
2280 |
^ self basicFileOutDefinitionOn:aStream withNameSpace:false!
|
|
2281 |
|
|
2282 |
fileOutMethod:aMethod
|
|
2283 |
|aStream fileName selector|
|
|
2284 |
|
|
2285 |
selector := self selectorAtMethod:aMethod.
|
|
2286 |
selector notNil ifTrue:[
|
|
2287 |
fileName := (self name , '-' , selector, '.st') asFilename.
|
|
2288 |
fileName makeLegalFilename.
|
|
2289 |
|
|
2290 |
"
|
|
2291 |
this test allows a smalltalk to be built without Projects/ChangeSets
|
|
2292 |
"
|
|
2293 |
Project notNil ifTrue:[
|
|
2294 |
fileName := Project currentProjectDirectory asFilename construct:fileName name.
|
|
2295 |
].
|
|
2296 |
|
|
2297 |
"
|
|
2298 |
if file exists, save original in a .sav file
|
|
2299 |
"
|
|
2300 |
fileName exists ifTrue:[
|
|
2301 |
fileName copyTo:(fileName withSuffix: 'sav')
|
|
2302 |
].
|
|
2303 |
|
|
2304 |
fileName := fileName name.
|
|
2305 |
|
|
2306 |
aStream := FileStream newFileNamed:fileName.
|
|
2307 |
aStream isNil ifTrue:[
|
|
2308 |
^ Class fileOutErrorSignal
|
|
2309 |
raiseRequestWith:fileName
|
|
2310 |
errorString:('cannot create file:', fileName)
|
|
2311 |
].
|
|
2312 |
self fileOutMethod:aMethod on:aStream.
|
|
2313 |
aStream close
|
|
2314 |
]
|
|
2315 |
|
|
2316 |
"Modified: / 1.4.1997 / 16:00:57 / stefan"
|
|
2317 |
"Created: / 2.4.1997 / 00:24:28 / stefan"
|
|
2318 |
"Modified: / 28.10.1997 / 14:40:34 / cg"!
|
|
2319 |
|
|
2320 |
fileOutMethod:aMethod on:aStream
|
|
2321 |
|dict cat source privacy|
|
|
2322 |
|
|
2323 |
dict := self methodDictionary.
|
|
2324 |
dict notNil ifTrue:[
|
|
2325 |
aStream nextPutChunkSeparator.
|
|
2326 |
self name printOn:aStream.
|
|
2327 |
"/ self printClassNameOn:aStream.
|
|
2328 |
|
|
2329 |
(privacy := aMethod privacy) ~~ #public ifTrue:[
|
|
2330 |
aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'.
|
|
2331 |
] ifFalse:[
|
|
2332 |
aStream nextPutAll:' methodsFor:'.
|
|
2333 |
].
|
|
2334 |
cat := aMethod category.
|
|
2335 |
cat isNil ifTrue:[
|
|
2336 |
cat := ''
|
|
2337 |
].
|
|
2338 |
aStream nextPutAll:cat asString storeString.
|
|
2339 |
aStream nextPutChunkSeparator; cr; cr.
|
|
2340 |
source := aMethod source.
|
|
2341 |
source isNil ifTrue:[
|
|
2342 |
Class fileOutErrorSignal
|
|
2343 |
raiseRequestWith:self
|
|
2344 |
errorString:('no source for method: ' ,
|
|
2345 |
self name , '>>' ,
|
|
2346 |
(self selectorAtMethod:aMethod))
|
|
2347 |
] ifFalse:[
|
|
2348 |
aStream nextChunkPut:source.
|
|
2349 |
].
|
|
2350 |
aStream space.
|
|
2351 |
aStream nextPutChunkSeparator.
|
|
2352 |
aStream cr
|
|
2353 |
]
|
|
2354 |
|
|
2355 |
"Modified: 27.8.1995 / 01:23:19 / claus"
|
|
2356 |
"Modified: 12.6.1996 / 11:44:41 / stefan"
|
|
2357 |
"Modified: 15.11.1996 / 11:32:43 / cg"
|
|
2358 |
"Created: 2.4.1997 / 00:24:33 / stefan"!
|
|
2359 |
|
|
2360 |
fileOutOn:aStream
|
|
2361 |
|
|
2362 |
^ self fileOutOn:aStream withTimeStamp:true!
|
|
2363 |
|
|
2364 |
fileOutOn:aStream withTimeStamp:stampIt
|
|
2365 |
"file out my definition and all methods onto aStream.
|
|
2366 |
If stampIt is true, a timeStamp comment is prepended."
|
|
2367 |
|
|
2368 |
self fileOutOn:aStream withTimeStamp:stampIt withInitialize:true!
|
|
2369 |
|
|
2370 |
fileOutOn:aStream withTimeStamp:stampIt withInitialize:initIt
|
|
2371 |
"file out my definition and all methods onto aStream.
|
|
2372 |
If stampIt is true, a timeStamp comment is prepended.
|
|
2373 |
If initIt is true, and the class implements a class-initialize method,
|
|
2374 |
append a corresponding doIt expression for initialization."
|
|
2375 |
|
|
2376 |
self
|
|
2377 |
fileOutOn:aStream
|
|
2378 |
withTimeStamp:stampIt
|
|
2379 |
withInitialize:initIt
|
|
2380 |
withDefinition:true
|
|
2381 |
methodFilter:nil!
|
|
2382 |
|
|
2383 |
fileOutOn:aStream withTimeStamp:stampIt withInitialize:initIt withDefinition:withDefinition methodFilter:methodFilter
|
|
2384 |
"file out my definition and all methods onto aStream.
|
|
2385 |
If stampIt is true, a timeStamp comment is prepended.
|
|
2386 |
If initIt is true, and the class implements a class-initialize method,
|
|
2387 |
append a corresponding doIt expression for initialization.
|
|
2388 |
The order by which the fileOut is done is used to put the version string at the end.
|
|
2389 |
Thus, if the version string is expanded (by CVS), the characterPositions of methods should not move"
|
|
2390 |
|
|
2391 |
|collectionOfCategories copyrightMethod copyrightText comment versionMethod skippedMethods
|
|
2392 |
meta|
|
|
2393 |
|
|
2394 |
self isLoaded ifFalse:[
|
|
2395 |
^ Class fileOutErrorSignal
|
|
2396 |
raiseRequestWith:self
|
|
2397 |
errorString:'will not fileOut unloaded classes'
|
|
2398 |
].
|
|
2399 |
|
|
2400 |
meta := self classRef.
|
|
2401 |
|
|
2402 |
"
|
|
2403 |
if there is a copyright method, add a copyright comment
|
|
2404 |
at the beginning, taking the string from the copyright method.
|
|
2405 |
We cannot do this unconditionally - that would lead to my copyrights
|
|
2406 |
being put on your code ;-).
|
|
2407 |
On the other hand: I want every file created by myself to have the
|
|
2408 |
copyright string at the beginning be preserved .... even if the
|
|
2409 |
code was edited in the browser and filedOut.
|
|
2410 |
"
|
|
2411 |
(copyrightMethod := meta compiledMethodAt:#copyright) notNil ifTrue:[
|
|
2412 |
"
|
|
2413 |
get the copyright methods source,
|
|
2414 |
and insert at beginning.
|
|
2415 |
"
|
|
2416 |
copyrightText := copyrightMethod source.
|
|
2417 |
copyrightText isNil ifTrue:[
|
|
2418 |
"
|
|
2419 |
no source available - trigger an error
|
|
2420 |
"
|
|
2421 |
Class fileOutErrorSignal
|
|
2422 |
raiseRequestWith:'no source for class ' , self name , ' available. Cannot fileOut'.
|
|
2423 |
^ self
|
|
2424 |
].
|
|
2425 |
"
|
|
2426 |
strip off the selector-line
|
|
2427 |
"
|
|
2428 |
copyrightText := copyrightText asCollectionOfLines asStringCollection.
|
|
2429 |
copyrightText := copyrightText copyFrom:2 to:(copyrightText size).
|
|
2430 |
"/ copyrightText do:[:line | aStream nextPutAll:line. aStream cr.].
|
|
2431 |
copyrightText := copyrightText asString.
|
|
2432 |
aStream nextPutAllAsChunk:copyrightText.
|
|
2433 |
].
|
|
2434 |
|
|
2435 |
stampIt ifTrue:[
|
|
2436 |
"/
|
|
2437 |
"/ first, a timestamp
|
|
2438 |
"/
|
|
2439 |
aStream nextPutAll:(Smalltalk timeStamp).
|
|
2440 |
aStream nextPutChunkSeparator.
|
|
2441 |
aStream cr; cr.
|
|
2442 |
].
|
|
2443 |
|
|
2444 |
withDefinition ifTrue:[
|
|
2445 |
"/
|
|
2446 |
"/ then the definition
|
|
2447 |
"/
|
|
2448 |
self fileOutAllDefinitionsOn:aStream.
|
|
2449 |
"/
|
|
2450 |
"/ a comment - if any
|
|
2451 |
"/
|
|
2452 |
(comment := self comment) notNil ifTrue:[
|
|
2453 |
self fileOutCommentOn:aStream.
|
|
2454 |
aStream cr.
|
|
2455 |
].
|
|
2456 |
"/
|
|
2457 |
"/ primitive definitions - if any
|
|
2458 |
"/
|
|
2459 |
self fileOutPrimitiveSpecsOn:aStream.
|
|
2460 |
].
|
|
2461 |
|
|
2462 |
"/
|
|
2463 |
"/ methods from all categories in metaclass (i.e. class methods)
|
|
2464 |
"/ EXCEPT: the version method is placed at the very end, to
|
|
2465 |
"/ avoid sourcePosition-shifts when checked out later.
|
|
2466 |
"/ (RCS expands this string, so its size is not constant)
|
|
2467 |
"/
|
|
2468 |
collectionOfCategories := meta categories asSortedCollection.
|
|
2469 |
collectionOfCategories notNil ifTrue:[
|
|
2470 |
"/
|
|
2471 |
"/ documentation first (if any), but not the version method
|
|
2472 |
"/
|
|
2473 |
(collectionOfCategories includes:'documentation') ifTrue:[
|
|
2474 |
versionMethod := meta compiledMethodAt:#version.
|
|
2475 |
versionMethod notNil ifTrue:[
|
|
2476 |
skippedMethods := Array with:versionMethod
|
|
2477 |
].
|
|
2478 |
meta fileOutCategory:'documentation' except:skippedMethods only:nil methodFilter:methodFilter on:aStream.
|
|
2479 |
aStream cr.
|
|
2480 |
].
|
|
2481 |
|
|
2482 |
"/
|
|
2483 |
"/ initialization next (if any)
|
|
2484 |
"/
|
|
2485 |
(collectionOfCategories includes:'initialization') ifTrue:[
|
|
2486 |
meta fileOutCategory:'initialization' methodFilter:methodFilter on:aStream.
|
|
2487 |
aStream cr.
|
|
2488 |
].
|
|
2489 |
|
|
2490 |
"/
|
|
2491 |
"/ instance creation next (if any)
|
|
2492 |
"/
|
|
2493 |
(collectionOfCategories includes:'instance creation') ifTrue:[
|
|
2494 |
meta fileOutCategory:'instance creation' methodFilter:methodFilter on:aStream.
|
|
2495 |
aStream cr.
|
|
2496 |
].
|
|
2497 |
collectionOfCategories do:[:aCategory |
|
|
2498 |
((aCategory ~= 'documentation')
|
|
2499 |
and:[(aCategory ~= 'initialization')
|
|
2500 |
and:[aCategory ~= 'instance creation']]) ifTrue:[
|
|
2501 |
meta fileOutCategory:aCategory methodFilter:methodFilter on:aStream.
|
|
2502 |
aStream cr
|
|
2503 |
]
|
|
2504 |
]
|
|
2505 |
].
|
|
2506 |
|
|
2507 |
"/
|
|
2508 |
"/ methods from all categories in myself
|
|
2509 |
"/
|
|
2510 |
collectionOfCategories := self categories asSortedCollection.
|
|
2511 |
collectionOfCategories notNil ifTrue:[
|
|
2512 |
collectionOfCategories do:[:aCategory |
|
|
2513 |
self fileOutCategory:aCategory methodFilter:methodFilter on:aStream.
|
|
2514 |
aStream cr
|
|
2515 |
]
|
|
2516 |
].
|
|
2517 |
|
|
2518 |
"/
|
|
2519 |
"/ any private classes' methods
|
|
2520 |
"/
|
|
2521 |
self privateClassesSorted do:[:aClass |
|
|
2522 |
aClass fileOutAllMethodsOn:aStream methodFilter:methodFilter
|
|
2523 |
].
|
|
2524 |
|
|
2525 |
|
|
2526 |
"/
|
|
2527 |
"/ finally, the previously skipped version method
|
|
2528 |
"/
|
|
2529 |
versionMethod notNil ifTrue:[
|
|
2530 |
meta fileOutCategory:'documentation' except:nil only:skippedMethods methodFilter:methodFilter on:aStream.
|
|
2531 |
].
|
|
2532 |
|
|
2533 |
initIt ifTrue:[
|
|
2534 |
"/
|
|
2535 |
"/ optionally an initialize message
|
|
2536 |
"/
|
|
2537 |
(meta implements:#initialize) ifTrue:[
|
|
2538 |
self printClassNameOn:aStream. aStream nextPutAll:' initialize'.
|
|
2539 |
aStream nextPutChunkSeparator.
|
|
2540 |
aStream cr
|
|
2541 |
]
|
|
2542 |
]
|
|
2543 |
|
|
2544 |
"Created: / 15.11.1995 / 12:53:06 / cg"
|
|
2545 |
"Modified: / 1.4.1997 / 16:01:05 / stefan"
|
|
2546 |
"Modified: / 13.3.1998 / 12:23:59 / cg"!
|
|
2547 |
|
|
2548 |
fileOutPrimitiveDefinitionsOn:aStream
|
|
2549 |
"append primitive defs (if any) to aStream."
|
|
2550 |
|
|
2551 |
|s|
|
|
2552 |
|
|
2553 |
"
|
|
2554 |
primitive definitions - if any
|
|
2555 |
"
|
|
2556 |
(s := self primitiveDefinitionsString) notNil ifTrue:[
|
|
2557 |
aStream nextPutChunkSeparator.
|
|
2558 |
self printClassNameOn:aStream.
|
|
2559 |
aStream nextPutAll:' primitiveDefinitions';
|
|
2560 |
nextPutChunkSeparator;
|
|
2561 |
cr.
|
|
2562 |
aStream nextPutAll:s.
|
|
2563 |
aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr
|
|
2564 |
].
|
|
2565 |
(s := self primitiveVariablesString) notNil ifTrue:[
|
|
2566 |
aStream nextPutChunkSeparator.
|
|
2567 |
self printClassNameOn:aStream.
|
|
2568 |
aStream nextPutAll:' primitiveVariables';
|
|
2569 |
nextPutChunkSeparator;
|
|
2570 |
cr.
|
|
2571 |
aStream nextPutAll:s.
|
|
2572 |
aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr
|
|
2573 |
].
|
|
2574 |
|
|
2575 |
"Modified: 8.1.1997 / 17:45:40 / cg"!
|
|
2576 |
|
|
2577 |
fileOutPrimitiveSpecsOn:aStream
|
|
2578 |
"append primitive defs (if any) to aStream."
|
|
2579 |
|
|
2580 |
|s|
|
|
2581 |
|
|
2582 |
"
|
|
2583 |
primitive definitions - if any
|
|
2584 |
"
|
|
2585 |
self fileOutPrimitiveDefinitionsOn:aStream.
|
|
2586 |
"
|
|
2587 |
primitive functions - if any
|
|
2588 |
"
|
|
2589 |
(s := self primitiveFunctionsString) notNil ifTrue:[
|
|
2590 |
aStream nextPutChunkSeparator.
|
|
2591 |
self printClassNameOn:aStream.
|
|
2592 |
aStream nextPutAll:' primitiveFunctions';
|
|
2593 |
nextPutChunkSeparator;
|
|
2594 |
cr.
|
|
2595 |
aStream nextPutAll:s.
|
|
2596 |
aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr
|
|
2597 |
].
|
|
2598 |
|
|
2599 |
"Modified: 8.1.1997 / 17:45:51 / cg"!
|
|
2600 |
|
1417
|
2601 |
firstDefinitionSelectorPart
|
|
2602 |
"return the first part of the selector with which I was (can be) defined in my superclass"
|
|
2603 |
|
|
2604 |
self isVariable ifFalse:[
|
|
2605 |
^ #'subclass:'
|
|
2606 |
].
|
|
2607 |
self isBytes ifTrue:[
|
|
2608 |
^ #'variableByteSubclass:'
|
|
2609 |
].
|
|
2610 |
self isLongs ifTrue:[
|
|
2611 |
^ #'variableLongSubclass:'
|
|
2612 |
].
|
|
2613 |
self isFloats ifTrue:[
|
|
2614 |
^ #'variableFloatSubclass:'
|
|
2615 |
].
|
|
2616 |
self isDoubles ifTrue:[
|
|
2617 |
^ #'variableDoubleSubclass:'
|
|
2618 |
].
|
|
2619 |
self isWords ifTrue:[
|
|
2620 |
^ #'variableWordSubclass:'
|
|
2621 |
].
|
|
2622 |
self isSignedWords ifTrue:[
|
|
2623 |
^ #'variableSignedWordSubclass:'
|
|
2624 |
].
|
|
2625 |
self isSignedLongs ifTrue:[
|
|
2626 |
^ #'variableSignedLongSubclass:'
|
|
2627 |
].
|
|
2628 |
self isSignedLongLongs ifTrue:[
|
|
2629 |
^ #'variableSignedLongLongSubclass:'
|
|
2630 |
].
|
|
2631 |
self isLongLongs ifTrue:[
|
|
2632 |
^ #'variableLongLongSubclass:'
|
|
2633 |
].
|
|
2634 |
^ #'variableSubclass:'
|
|
2635 |
!
|
|
2636 |
|
1419
|
2637 |
getPrimitiveSpecsAt:index
|
|
2638 |
"{ Pragma: +optSpace }"
|
|
2639 |
|
|
2640 |
"return a primitiveSpecification component as string or nil"
|
|
2641 |
|
|
2642 |
|owner pos stream string primitiveSpec classFilename|
|
|
2643 |
|
|
2644 |
(owner := self owningClass) notNil ifTrue:[^ owner getPrimitiveSpecsAt:index].
|
|
2645 |
|
|
2646 |
primitiveSpec := self primitiveSpec.
|
|
2647 |
|
|
2648 |
primitiveSpec isNil ifTrue:[^ nil].
|
|
2649 |
pos := primitiveSpec at:index.
|
|
2650 |
pos isNil ifTrue:[^ nil].
|
|
2651 |
|
|
2652 |
"the primitiveSpec is either a string, or an integer specifying the
|
|
2653 |
position within the classes sourcefile ...
|
|
2654 |
"
|
|
2655 |
pos isNumber ifTrue:[
|
|
2656 |
classFilename := self classFilename.
|
|
2657 |
classFilename notNil ifTrue:[
|
|
2658 |
stream := self sourceStream.
|
|
2659 |
stream notNil ifTrue:[
|
|
2660 |
stream position:pos+1.
|
|
2661 |
string := stream nextChunk.
|
|
2662 |
stream close.
|
|
2663 |
^ string
|
|
2664 |
]
|
|
2665 |
].
|
|
2666 |
^ nil
|
|
2667 |
].
|
|
2668 |
^ pos
|
|
2669 |
|
|
2670 |
"Modified: 15.1.1997 / 15:29:30 / stefan"!
|
|
2671 |
|
|
2672 |
hasMethods
|
|
2673 |
"return true, if there are any (local) methods in this class"
|
|
2674 |
|
|
2675 |
^ (self methodDictionary size ~~ 0)!
|
|
2676 |
|
|
2677 |
implements:aSelector
|
|
2678 |
^ self includesSelector:aSelector!
|
|
2679 |
|
|
2680 |
includesSelector:aSelector
|
|
2681 |
^ self methodDictionary includesKey:aSelector!
|
|
2682 |
|
|
2683 |
instanceVariableString
|
|
2684 |
"return a string of the instance variable names"
|
|
2685 |
|
|
2686 |
|instvars|
|
|
2687 |
|
|
2688 |
instvars := self instVarNames.
|
|
2689 |
instvars isNil ifTrue:[^ ''].
|
|
2690 |
instvars isString ifTrue:[
|
|
2691 |
^ instvars
|
|
2692 |
].
|
|
2693 |
|
|
2694 |
^ instvars asStringWith:(Character space)
|
|
2695 |
|
|
2696 |
"
|
|
2697 |
Point instanceVariableString
|
|
2698 |
"
|
|
2699 |
|
|
2700 |
"Modified: 22.8.1997 / 14:59:14 / cg"
|
|
2701 |
!
|
|
2702 |
|
|
2703 |
isObsolete
|
|
2704 |
^ false
|
|
2705 |
!
|
|
2706 |
|
|
2707 |
isSubclassOf:aClass
|
|
2708 |
"return true, if I am a subclass of the argument, aClass"
|
|
2709 |
|
|
2710 |
|theClass|
|
|
2711 |
|
|
2712 |
theClass := self superclass.
|
|
2713 |
[theClass notNil] whileTrue:[
|
|
2714 |
(theClass == aClass) ifTrue:[^ true].
|
|
2715 |
theClass := theClass superclass.
|
|
2716 |
].
|
|
2717 |
^ false
|
|
2718 |
!
|
|
2719 |
|
1417
|
2720 |
nameWithoutNameSpacePrefix
|
|
2721 |
|nm owner|
|
|
2722 |
|
|
2723 |
nm := self nameWithoutPrefix.
|
|
2724 |
(owner := self owningClass) isNil ifTrue:[
|
|
2725 |
^ nm
|
|
2726 |
].
|
|
2727 |
|
|
2728 |
^ (owner nameWithoutNameSpacePrefix , '::' , nm)
|
|
2729 |
!
|
|
2730 |
|
|
2731 |
nameWithoutPrefix
|
|
2732 |
|nm idx|
|
|
2733 |
|
|
2734 |
nm := self name.
|
|
2735 |
idx := nm lastIndexOf:$:.
|
|
2736 |
idx == 0 ifTrue:[
|
|
2737 |
^ nm
|
|
2738 |
].
|
|
2739 |
^ nm copyFrom:idx+1.
|
|
2740 |
!
|
|
2741 |
|
1419
|
2742 |
packageSourceCodeInfo
|
|
2743 |
"{ Pragma: +optSpace }"
|
|
2744 |
|
|
2745 |
"return the sourceCodeInfo, which defines the module and the subdirectory
|
|
2746 |
in which the receiver class was built.
|
|
2747 |
This info is extracted from the package id (which is added to stc-compiled classes).
|
|
2748 |
This method is to be obsoleted soon, since the same info is now found
|
|
2749 |
in the versionString.
|
|
2750 |
|
|
2751 |
The info returned consists of a dictionary
|
|
2752 |
filled with (at least) values at: #module, #directory and #library.
|
|
2753 |
If no such info is present in the class, nil is returned.
|
|
2754 |
(this happens with autoloaded and filed-in classes)
|
|
2755 |
Auotloaded classes set their package from the revisionInfo, if present.
|
|
2756 |
|
|
2757 |
By convention, this info is encoded in the classes package
|
|
2758 |
string (which is given as argument to stc) as the last word in parenthesis.
|
|
2759 |
The info consists of 1 to 3 subcomponents, separated by colons.
|
|
2760 |
The first defines the classes module (i.e. some application identifier),
|
|
2761 |
the second defines the subdirectory within that module, the third
|
|
2762 |
defines the name of the class library.
|
|
2763 |
If left blank, the module info defaults to 'stx',
|
|
2764 |
the directory info defaults to library name.
|
|
2765 |
The library name may not be left blank.
|
|
2766 |
(this is done for backward compatibility,)
|
|
2767 |
|
|
2768 |
For example:
|
|
2769 |
'....(libbasic)' -> module: stx directory: libbasic library: libbasic
|
|
2770 |
'....(stx:libbasic)' -> module: stx directory: libbasic library: libbasic
|
|
2771 |
'....(stx:foo:libbfoo)' -> module: stx directory: foo library: libfoo
|
|
2772 |
'....(aeg:libIECInterface)' -> module: aeg directory: libIECInterface library:libIECInterface
|
|
2773 |
'....(stx:goodies/persistency:libdbase)' -> module: stx directory: goodies/persistency library:libdbase
|
|
2774 |
|
|
2775 |
The way how the sourceCodeManager uses this to find the source location
|
|
2776 |
depends on the scheme used. For CVS, the module is taken as the -d arg,
|
|
2777 |
while the directory is prepended to the file name.
|
|
2778 |
Other schemes may do things differently - these are not yet specified.
|
|
2779 |
|
|
2780 |
Caveat:
|
|
2781 |
Encoding this info in the package string seems somewhat kludgy.
|
|
2782 |
"
|
|
2783 |
|
|
2784 |
|owner sourceInfo packageString idx1 idx2
|
|
2785 |
moduleString directoryString libraryString components component1 component2 dirComponents mgr
|
|
2786 |
package|
|
|
2787 |
|
|
2788 |
(owner := self owningClass) notNil ifTrue:[^ owner packageSourceCodeInfo].
|
|
2789 |
|
|
2790 |
package := self package.
|
|
2791 |
package isNil ifTrue:[^ nil].
|
|
2792 |
|
|
2793 |
packageString := package asString.
|
|
2794 |
idx1 := packageString lastIndexOf:$(.
|
|
2795 |
idx1 ~~ 0 ifTrue:[
|
|
2796 |
idx2 := packageString indexOf:$) startingAt:idx1+1.
|
|
2797 |
idx2 ~~ 0 ifTrue:[
|
|
2798 |
sourceInfo := packageString copyFrom:idx1 + 1 to:idx2 - 1
|
|
2799 |
]
|
|
2800 |
] ifFalse:[
|
|
2801 |
sourceInfo := packageString
|
|
2802 |
].
|
|
2803 |
|
|
2804 |
sourceInfo isNil ifTrue:[^ nil].
|
|
2805 |
components := sourceInfo asCollectionOfSubstringsSeparatedBy:$:.
|
|
2806 |
components size == 0 ifTrue:[
|
|
2807 |
"/ moduleString := 'stx'.
|
|
2808 |
"/ directoryString := libraryString := ''.
|
|
2809 |
^ nil
|
|
2810 |
].
|
|
2811 |
|
|
2812 |
component1 := components at:1.
|
|
2813 |
components size == 1 ifTrue:[
|
|
2814 |
"/ a single name given - the module becomes 'stx' or
|
|
2815 |
"/ the very first directory component (if such a module exists).
|
|
2816 |
"/ If the component includes slashes, its the directory
|
|
2817 |
"/ otherwise the library.
|
|
2818 |
"/
|
|
2819 |
dirComponents := Filename concreteClass components:component1.
|
|
2820 |
(dirComponents size > 1
|
|
2821 |
and:[(mgr := self sourceCodeManager) notNil
|
|
2822 |
and:[mgr checkForExistingModule:dirComponents first]]) ifTrue:[
|
|
2823 |
moduleString := dirComponents first.
|
|
2824 |
directoryString := libraryString := (Filename fromComponents:(dirComponents copyFrom:2)) asString.
|
|
2825 |
] ifFalse:[
|
|
2826 |
"/ non-existing; assume directory under the stx package.
|
|
2827 |
moduleString := 'stx'.
|
|
2828 |
(component1 startsWith:'stx/') ifTrue:[
|
|
2829 |
component1 := component1 copyFrom:5
|
|
2830 |
].
|
|
2831 |
directoryString := libraryString := component1.
|
|
2832 |
].
|
|
2833 |
|
|
2834 |
(libraryString includes:$/) ifTrue:[
|
|
2835 |
libraryString := libraryString asFilename baseName
|
|
2836 |
]
|
|
2837 |
] ifFalse:[
|
|
2838 |
component2 := components at:2.
|
|
2839 |
components size == 2 ifTrue:[
|
|
2840 |
"/ two components - assume its the module and the directory;
|
|
2841 |
"/ the library is assumed to be named after the directory
|
|
2842 |
"/ except, if slashes are in the name; then the libraryname
|
|
2843 |
"/ is the last component.
|
|
2844 |
"/
|
|
2845 |
moduleString := component1.
|
|
2846 |
directoryString := libraryString := component2.
|
|
2847 |
(libraryString includes:$/) ifTrue:[
|
|
2848 |
libraryString := libraryString asFilename baseName
|
|
2849 |
]
|
|
2850 |
] ifFalse:[
|
|
2851 |
"/ all components given
|
|
2852 |
moduleString := component1.
|
|
2853 |
directoryString := component2.
|
|
2854 |
libraryString := components at:3.
|
|
2855 |
]
|
|
2856 |
].
|
|
2857 |
|
|
2858 |
libraryString isEmpty ifTrue:[
|
|
2859 |
directoryString notEmpty ifTrue:[
|
|
2860 |
libraryString := directoryString asFilename baseName
|
|
2861 |
].
|
|
2862 |
libraryString isEmpty ifTrue:[
|
|
2863 |
"/ lets extract the library from the liblist file ...
|
|
2864 |
libraryString := Smalltalk libraryFileNameOfClass:self.
|
|
2865 |
libraryString isNil ifTrue:[^ nil].
|
|
2866 |
]
|
|
2867 |
].
|
|
2868 |
|
|
2869 |
moduleString isEmpty ifTrue:[
|
|
2870 |
moduleString := 'stx'.
|
|
2871 |
].
|
|
2872 |
directoryString isEmpty ifTrue:[
|
|
2873 |
directoryString := libraryString.
|
|
2874 |
].
|
|
2875 |
|
|
2876 |
^ IdentityDictionary
|
|
2877 |
with:(#module->moduleString)
|
|
2878 |
with:(#directory->directoryString)
|
|
2879 |
with:(#library->libraryString)
|
|
2880 |
|
|
2881 |
"
|
|
2882 |
Object packageSourceCodeInfo
|
|
2883 |
View packageSourceCodeInfo
|
|
2884 |
Model packageSourceCodeInfo
|
|
2885 |
BinaryObjectStorage packageSourceCodeInfo
|
|
2886 |
MemoryMonitor packageSourceCodeInfo
|
|
2887 |
ClockView packageSourceCodeInfo
|
|
2888 |
"
|
|
2889 |
|
|
2890 |
"Created: 4.11.1995 / 20:36:53 / cg"
|
|
2891 |
"Modified: 19.9.1997 / 10:42:25 / cg"!
|
|
2892 |
|
|
2893 |
primitiveDefinitionsString
|
|
2894 |
"{ Pragma: +optSpace }"
|
|
2895 |
|
|
2896 |
"return the primitiveDefinition string or nil"
|
|
2897 |
|
|
2898 |
^ self getPrimitiveSpecsAt:1
|
|
2899 |
|
|
2900 |
"
|
|
2901 |
Object primitiveDefinitionsString
|
|
2902 |
String primitiveDefinitionsString
|
|
2903 |
"!
|
|
2904 |
|
|
2905 |
primitiveFunctionsString
|
|
2906 |
"{ Pragma: +optSpace }"
|
|
2907 |
|
|
2908 |
"return the primitiveFunctions string or nil"
|
|
2909 |
|
|
2910 |
^ self getPrimitiveSpecsAt:3!
|
|
2911 |
|
|
2912 |
primitiveVariablesString
|
|
2913 |
"{ Pragma: +optSpace }"
|
|
2914 |
|
|
2915 |
"return the primitiveVariables string or nil"
|
|
2916 |
|
|
2917 |
^ self getPrimitiveSpecsAt:2!
|
|
2918 |
|
|
2919 |
printClassNameOn:aStream
|
|
2920 |
|nm|
|
|
2921 |
|
|
2922 |
Class fileOutNameSpaceQuerySignal query == false ifTrue:[
|
|
2923 |
nm := self nameWithoutNameSpacePrefix
|
|
2924 |
] ifFalse:[
|
|
2925 |
nm := self name.
|
|
2926 |
].
|
|
2927 |
|
|
2928 |
aStream nextPutAll:nm.!
|
|
2929 |
|
1417
|
2930 |
printClassVarNamesOn:aStream indent:indent
|
|
2931 |
"print the class variable names indented and breaking at line end"
|
|
2932 |
|
|
2933 |
self printNameArray:(self classVarNames) on:aStream indent:indent
|
|
2934 |
!
|
|
2935 |
|
|
2936 |
printHierarchyAnswerIndentOn:aStream
|
|
2937 |
"print my class hierarchy on aStream - return indent
|
|
2938 |
recursively calls itself to print superclass and use returned indent
|
|
2939 |
for my description - used in the browser"
|
|
2940 |
|
|
2941 |
|indent nm superclass|
|
|
2942 |
|
|
2943 |
superclass := self superclass.
|
|
2944 |
indent := 0.
|
|
2945 |
(superclass notNil) ifTrue:[
|
|
2946 |
indent := (superclass printHierarchyAnswerIndentOn:aStream) + 2
|
|
2947 |
].
|
|
2948 |
aStream spaces:indent.
|
|
2949 |
nm := self printNameInHierarchy.
|
|
2950 |
aStream nextPutAll:nm; nextPutAll:' ('.
|
|
2951 |
self printInstVarNamesOn:aStream indent:(indent + nm size + 2).
|
|
2952 |
aStream nextPutLine:')'.
|
|
2953 |
^ indent
|
|
2954 |
!
|
|
2955 |
|
|
2956 |
printHierarchyOn:aStream
|
|
2957 |
self printHierarchyAnswerIndentOn:aStream
|
|
2958 |
!
|
|
2959 |
|
|
2960 |
printInstVarNamesOn:aStream indent:indent
|
|
2961 |
"print the instance variable names indented and breaking at line end"
|
|
2962 |
|
|
2963 |
self printNameArray:(self instVarNames) on:aStream indent:indent
|
|
2964 |
|
|
2965 |
"Created: 22.3.1997 / 14:12:00 / cg"
|
|
2966 |
!
|
|
2967 |
|
|
2968 |
printNameArray:anArray on:aStream indent:indent
|
|
2969 |
"print an array of strings separated by spaces; when the stream
|
|
2970 |
defines a lineLength, break when this limit is reached; indent
|
|
2971 |
every line; used to printOut instance variable names"
|
|
2972 |
|
|
2973 |
|thisName nextName arraySize lenMax pos mustBreak line spaces|
|
|
2974 |
|
|
2975 |
arraySize := anArray size.
|
|
2976 |
arraySize ~~ 0 ifTrue:[
|
|
2977 |
pos := indent.
|
|
2978 |
lenMax := aStream lineLength.
|
|
2979 |
thisName := anArray at:1.
|
|
2980 |
line := ''.
|
|
2981 |
1 to:arraySize do:[:index |
|
|
2982 |
line := line , thisName.
|
|
2983 |
pos := pos + thisName size.
|
|
2984 |
(index == arraySize) ifFalse:[
|
|
2985 |
nextName := anArray at:(index + 1).
|
|
2986 |
mustBreak := false.
|
|
2987 |
(lenMax > 0) ifTrue:[
|
|
2988 |
((pos + nextName size) > lenMax) ifTrue:[
|
|
2989 |
mustBreak := true
|
|
2990 |
]
|
|
2991 |
].
|
|
2992 |
mustBreak ifTrue:[
|
|
2993 |
aStream nextPutLine:line withTabs.
|
|
2994 |
spaces isNil ifTrue:[
|
|
2995 |
spaces := String new:indent
|
|
2996 |
].
|
|
2997 |
line := spaces.
|
|
2998 |
pos := indent
|
|
2999 |
] ifFalse:[
|
|
3000 |
line := line , ' '.
|
|
3001 |
pos := pos + 1
|
|
3002 |
].
|
|
3003 |
thisName := nextName
|
|
3004 |
]
|
|
3005 |
].
|
|
3006 |
aStream nextPutAll:line withTabs
|
|
3007 |
]
|
|
3008 |
|
|
3009 |
"Modified: 9.11.1996 / 00:12:06 / cg"
|
|
3010 |
"Created: 22.3.1997 / 14:12:12 / cg"
|
|
3011 |
!
|
|
3012 |
|
|
3013 |
printNameInHierarchy
|
|
3014 |
^ self name
|
|
3015 |
!
|
|
3016 |
|
1419
|
3017 |
privateClasses
|
|
3018 |
"{ Pragma: +optSpace }"
|
|
3019 |
|
|
3020 |
"return a collection of my private classes (if any).
|
|
3021 |
The classes are in any order."
|
|
3022 |
|
|
3023 |
^ self privateClassesOrAll:false!
|
|
3024 |
|
1417
|
3025 |
privateClassesAt:aClassNameStringOrSymbol
|
|
3026 |
|nmSym|
|
|
3027 |
|
|
3028 |
nmSym := (self name , '::' , aClassNameStringOrSymbol) asSymbolIfInterned.
|
|
3029 |
nmSym isNil ifTrue:[
|
|
3030 |
"/ no such symbol - there cannot be a corresponding private class
|
|
3031 |
^ nil
|
|
3032 |
].
|
|
3033 |
|
|
3034 |
^ memory at:nmSym.
|
|
3035 |
!
|
|
3036 |
|
1419
|
3037 |
privateClassesOrAll:allOfThem
|
|
3038 |
"{ Pragma: +optSpace }"
|
|
3039 |
|
|
3040 |
"return a collection of my direct private classes (if any)
|
|
3041 |
or direct plus indirect private classes (if allOfThem).
|
|
3042 |
An empty collection if there are none.
|
|
3043 |
The classes are in any order."
|
|
3044 |
|
|
3045 |
|classes myName myNamePrefix myNamePrefixLen|
|
|
3046 |
|
|
3047 |
myName := self name.
|
|
3048 |
myNamePrefix := myName , '::'.
|
|
3049 |
myNamePrefixLen := myNamePrefix size.
|
|
3050 |
|
|
3051 |
Smalltalk keysDo:[:nm |
|
|
3052 |
|cls|
|
|
3053 |
|
|
3054 |
(nm startsWith:myNamePrefix) ifTrue:[
|
|
3055 |
(allOfThem
|
|
3056 |
or:[(nm indexOf:$: startingAt:myNamePrefixLen + 1) == 0]) ifTrue:[
|
|
3057 |
cls := Smalltalk at:nm.
|
|
3058 |
|
|
3059 |
(cls isBehavior and:[cls isMeta not]) ifTrue:[
|
|
3060 |
classes isNil ifTrue:[
|
|
3061 |
classes := IdentitySet new:10.
|
|
3062 |
].
|
|
3063 |
classes add:cls.
|
|
3064 |
]
|
|
3065 |
]
|
|
3066 |
]
|
|
3067 |
].
|
|
3068 |
|
|
3069 |
^ classes ? #()
|
|
3070 |
|
|
3071 |
"
|
|
3072 |
UILayoutTool privateClassesOrAll:true
|
|
3073 |
UILayoutTool privateClassesOrAll:false
|
|
3074 |
"
|
|
3075 |
|
|
3076 |
"Modified: / 29.5.1998 / 23:23:18 / cg"!
|
|
3077 |
|
|
3078 |
privateClassesSorted
|
|
3079 |
"{ Pragma: +optSpace }"
|
|
3080 |
|
|
3081 |
"return a collection of my private classes (if any).
|
|
3082 |
The classes are sorted by inheritance."
|
|
3083 |
|
|
3084 |
|classes|
|
|
3085 |
|
|
3086 |
classes := self privateClasses.
|
|
3087 |
(classes size > 0) ifTrue:[
|
|
3088 |
classes := classes asOrderedCollection topologicalSort:[:a :b | b isSubclassOf:a].
|
|
3089 |
].
|
|
3090 |
^ classes.
|
|
3091 |
|
|
3092 |
"
|
|
3093 |
Object privateClassesSorted
|
|
3094 |
"
|
|
3095 |
|
|
3096 |
"Created: 22.3.1997 / 16:10:42 / cg"
|
|
3097 |
"Modified: 22.3.1997 / 16:11:20 / cg"!
|
|
3098 |
|
|
3099 |
revisionInfo
|
|
3100 |
"return a dictionary filled with revision info.
|
|
3101 |
This extracts the relevant info from the revisionString.
|
|
3102 |
The revisionInfo contains all or a subset of:
|
|
3103 |
#binaryRevision - the revision upon which the binary of this class is based
|
|
3104 |
#revision - the revision upon which the class is based logically
|
|
3105 |
(different, if a changed class was checked in, but not yet recompiled)
|
|
3106 |
#user - the user who checked in the logical revision
|
|
3107 |
#date - the date when the logical revision was checked in
|
|
3108 |
#time - the time when the logical revision was checked in
|
|
3109 |
#fileName - the classes source file name
|
|
3110 |
#repositoryPath - the classes source container
|
|
3111 |
"
|
|
3112 |
|
|
3113 |
|vsnString info mgr|
|
|
3114 |
|
|
3115 |
vsnString := self revisionString.
|
|
3116 |
vsnString notNil ifTrue:[
|
|
3117 |
mgr := self sourceCodeManager.
|
|
3118 |
mgr notNil ifTrue:[
|
|
3119 |
info := mgr revisionInfoFromString:vsnString
|
|
3120 |
] ifFalse:[
|
|
3121 |
info := Class revisionInfoFromString:vsnString.
|
|
3122 |
].
|
|
3123 |
info notNil ifTrue:[
|
|
3124 |
info at:#binaryRevision put:self binaryRevision.
|
|
3125 |
]
|
|
3126 |
].
|
|
3127 |
^ info!
|
|
3128 |
|
|
3129 |
revisionString
|
|
3130 |
"{ Pragma: +optSpace }"
|
|
3131 |
|
|
3132 |
"return my revision string; that one is extracted from the
|
|
3133 |
classes #version method. Either this is a method returning that string,
|
|
3134 |
or its a comment-only method and the comment defines the version.
|
|
3135 |
If the source is not accessable or no such method exists,
|
|
3136 |
nil is returned."
|
|
3137 |
|
|
3138 |
|owner cls meta m src val|
|
|
3139 |
|
|
3140 |
(owner := self owningClass) notNil ifTrue:[^ owner revisionString].
|
|
3141 |
|
|
3142 |
thisContext isRecursive ifTrue:[^ nil ].
|
|
3143 |
|
|
3144 |
self isMeta ifTrue:[
|
|
3145 |
meta := self. cls := self soleInstance
|
|
3146 |
] ifFalse:[
|
|
3147 |
cls := self. meta := self classRef
|
|
3148 |
].
|
|
3149 |
|
|
3150 |
m := meta compiledMethodAt:#version.
|
|
3151 |
m isNil ifTrue:[
|
|
3152 |
m := cls compiledMethodAt:#version.
|
|
3153 |
m isNil ifTrue:[^ nil].
|
|
3154 |
].
|
|
3155 |
|
|
3156 |
m isExecutable ifTrue:[
|
|
3157 |
"/
|
|
3158 |
"/ if its a method returning the string,
|
|
3159 |
"/ thats the returned value
|
|
3160 |
"/
|
|
3161 |
val := cls version.
|
|
3162 |
val isString ifTrue:[^ val].
|
|
3163 |
].
|
|
3164 |
|
|
3165 |
"/
|
|
3166 |
"/ if its a method consisting of a comment only
|
|
3167 |
"/ extract it - this may lead to a recursive call
|
|
3168 |
"/ to myself (thats what the #isRecursive is for)
|
|
3169 |
"/ in case we need to access the source code manager
|
|
3170 |
"/ for the source ...
|
|
3171 |
"/
|
|
3172 |
src := m source.
|
|
3173 |
src isNil ifTrue:[^ nil].
|
|
3174 |
^ Class revisionStringFromSource:src
|
|
3175 |
|
|
3176 |
"
|
|
3177 |
Smalltalk allClassesDo:[:cls |
|
|
3178 |
Transcript showCR:cls revisionString
|
|
3179 |
].
|
|
3180 |
|
|
3181 |
Number revisionString
|
|
3182 |
FileDirectory revisionString
|
|
3183 |
Metaclass revisionString
|
|
3184 |
"
|
|
3185 |
|
|
3186 |
"Created: 29.10.1995 / 19:28:03 / cg"
|
|
3187 |
"Modified: 23.10.1996 / 18:23:56 / cg"
|
|
3188 |
"Modified: 1.4.1997 / 23:37:25 / stefan"!
|
|
3189 |
|
|
3190 |
selectorAtMethod:aMethod
|
|
3191 |
^ self selectorAtMethod:aMethod ifAbsent:[nil]!
|
|
3192 |
|
|
3193 |
selectorAtMethod:aMethod ifAbsent:failBlock
|
|
3194 |
|md|
|
|
3195 |
|
|
3196 |
md := self methodDictionary.
|
|
3197 |
md isNil ifTrue:[
|
|
3198 |
'OOPS - nil methodDictionary' errorPrintCR.
|
|
3199 |
^ nil
|
|
3200 |
].
|
|
3201 |
^ md keyAtValue:aMethod ifAbsent:failBlock.!
|
|
3202 |
|
|
3203 |
soleInstance
|
|
3204 |
self isMeta ifFalse:[self halt].
|
|
3205 |
^ self theNonMetaclass.
|
|
3206 |
!
|
|
3207 |
|
1417
|
3208 |
sourceCodeManager
|
|
3209 |
^ SourceCodeManager
|
|
3210 |
!
|
|
3211 |
|
1419
|
3212 |
sourceStreamFor:source
|
|
3213 |
"return an open stream on a sourcefile, nil if that is not available"
|
|
3214 |
|
|
3215 |
|owner fileName aStream mgr validated guessedFileName sep mod dir classFilename package name|
|
|
3216 |
|
|
3217 |
self isMeta ifTrue:[
|
|
3218 |
^ self theNonMetaclass sourceStreamFor:source
|
|
3219 |
].
|
|
3220 |
|
|
3221 |
(owner := self owningClass) notNil ifTrue:[^ owner sourceStreamFor:source].
|
|
3222 |
validated := false.
|
|
3223 |
|
|
3224 |
classFilename := self classFilename.
|
|
3225 |
package := self package.
|
|
3226 |
name := self name.
|
|
3227 |
|
|
3228 |
"/
|
|
3229 |
"/ if there is no SourceCodeManager,
|
|
3230 |
"/ or TryLocalSourceFirst is true,
|
|
3231 |
"/ look in standard places first
|
|
3232 |
"/
|
|
3233 |
((mgr := self sourceCodeManager) isNil
|
|
3234 |
or:[Class tryLocalSourceFirst == true]) ifTrue:[
|
|
3235 |
aStream := self localSourceStreamFor:source.
|
|
3236 |
].
|
|
3237 |
|
|
3238 |
aStream isNil ifTrue:[
|
|
3239 |
"/ mhmh - still no source file.
|
|
3240 |
"/ If there is a SourceCodeManager, ask it to aquire the
|
|
3241 |
"/ the source for my class, and return an open stream on it.
|
|
3242 |
"/ if that one does not know about the source, look in
|
|
3243 |
"/ standard places
|
|
3244 |
|
|
3245 |
mgr notNil ifTrue:[
|
|
3246 |
self classFilename ~= source ifTrue:[
|
|
3247 |
sep := self package indexOfAny:'/\:'.
|
|
3248 |
sep ~~ 0 ifTrue:[
|
|
3249 |
mod := package copyTo:sep - 1.
|
|
3250 |
dir := package copyFrom:sep + 1.
|
|
3251 |
aStream := mgr streamForClass:nil fileName:source revision:nil directory:dir module:mod cache:true.
|
|
3252 |
].
|
|
3253 |
].
|
|
3254 |
aStream isNil ifTrue:[
|
|
3255 |
classFilename isNil ifTrue:[
|
|
3256 |
classFilename := guessedFileName := (Smalltalk fileNameForClass:self) , '.st'.
|
|
3257 |
].
|
|
3258 |
source asFilename baseName = classFilename asFilename baseName ifTrue:[
|
|
3259 |
aStream := mgr getSourceStreamFor:self.
|
|
3260 |
]
|
|
3261 |
].
|
|
3262 |
aStream notNil ifTrue:[
|
|
3263 |
(self validateSourceStream:aStream) ifFalse:[
|
|
3264 |
('Class [info]: repositories source for `'
|
|
3265 |
, (self isMeta ifTrue:[self soleInstance name]
|
|
3266 |
ifFalse:[name])
|
|
3267 |
, ''' is invalid.') infoPrintCR.
|
|
3268 |
aStream close.
|
|
3269 |
aStream := nil
|
|
3270 |
] ifTrue:[
|
|
3271 |
validated := true.
|
|
3272 |
].
|
|
3273 |
].
|
|
3274 |
]
|
|
3275 |
].
|
|
3276 |
|
|
3277 |
aStream isNil ifTrue:[
|
|
3278 |
"/
|
|
3279 |
"/ hard case - there is no source file for this class
|
|
3280 |
"/ (in the source-dir-path).
|
|
3281 |
"/
|
|
3282 |
|
|
3283 |
"/
|
|
3284 |
"/ look if my binary is from a dynamically loaded module,
|
|
3285 |
"/ and, if so, look in the modules directory for the
|
|
3286 |
"/ source file.
|
|
3287 |
"/
|
|
3288 |
ObjectFileLoader notNil ifTrue:[
|
|
3289 |
ObjectFileLoader loadedObjectHandlesDo:[:h |
|
|
3290 |
|f classes|
|
|
3291 |
|
|
3292 |
aStream isNil ifTrue:[
|
|
3293 |
(classes := h classes) size > 0 ifTrue:[
|
|
3294 |
(classes includes:self) ifTrue:[
|
|
3295 |
f := h pathName.
|
|
3296 |
f := f asFilename directory.
|
|
3297 |
f := f construct:source.
|
|
3298 |
f exists ifTrue:[
|
|
3299 |
aStream := f readStream.
|
|
3300 |
].
|
|
3301 |
].
|
|
3302 |
].
|
|
3303 |
]
|
|
3304 |
].
|
|
3305 |
].
|
|
3306 |
].
|
|
3307 |
|
|
3308 |
"/
|
|
3309 |
"/ try along sourcePath
|
|
3310 |
"/
|
|
3311 |
aStream isNil ifTrue:[
|
|
3312 |
aStream := self localSourceStreamFor:source.
|
|
3313 |
].
|
|
3314 |
|
|
3315 |
"/
|
|
3316 |
"/ final chance: try current directory
|
|
3317 |
"/
|
|
3318 |
aStream isNil ifTrue:[
|
|
3319 |
aStream := source asFilename readStream.
|
|
3320 |
].
|
|
3321 |
|
|
3322 |
(aStream notNil and:[validated not]) ifTrue:[
|
|
3323 |
(self validateSourceStream:aStream) ifFalse:[
|
|
3324 |
(Smalltalk releaseIdentification = 'ST/X_free_demo_vsn') ifTrue:[
|
|
3325 |
"/ ('Class [info]: source for ''' , self name , ''' is not available in the demo version.') infoPrintCR
|
|
3326 |
] ifFalse:[
|
|
3327 |
('Class [warning]: source for ''' , self name , ''' is invalid or stripped. Take care.') errorPrintCR
|
|
3328 |
]
|
|
3329 |
].
|
|
3330 |
].
|
|
3331 |
(aStream notNil and:[aStream isFileStream]) ifTrue:[
|
|
3332 |
guessedFileName notNil ifTrue:[
|
|
3333 |
classFilename := aStream pathName asFilename baseName.
|
|
3334 |
]
|
|
3335 |
].
|
|
3336 |
^ aStream
|
|
3337 |
|
|
3338 |
"
|
|
3339 |
Object sourceStream
|
|
3340 |
Clock sourceStream
|
|
3341 |
Autoload sourceStream
|
|
3342 |
"
|
|
3343 |
|
|
3344 |
"Created: / 10.11.1995 / 21:05:13 / cg"
|
|
3345 |
"Modified: / 22.4.1998 / 19:20:50 / ca"
|
|
3346 |
"Modified: / 23.4.1998 / 15:53:54 / cg"
|
|
3347 |
!
|
|
3348 |
|
|
3349 |
subclasses
|
|
3350 |
"return a collection of the direct subclasses of the receiver"
|
|
3351 |
|
|
3352 |
|newColl|
|
|
3353 |
|
|
3354 |
"/ "/ use cached information (avoid class hierarchy search)
|
|
3355 |
"/ "/ if possible
|
|
3356 |
"/
|
|
3357 |
"/ SubclassInfo notNil ifTrue:[
|
|
3358 |
"/ newColl := SubclassInfo at:self ifAbsent:nil.
|
|
3359 |
"/ newColl notNil ifTrue:[^ newColl asOrderedCollection]
|
|
3360 |
"/ ].
|
|
3361 |
|
|
3362 |
newColl := OrderedCollection new.
|
|
3363 |
self subclassesDo:[:aClass |
|
|
3364 |
newColl add:aClass
|
|
3365 |
].
|
|
3366 |
"/ SubclassInfo notNil ifTrue:[
|
|
3367 |
"/ SubclassInfo at:self put:newColl.
|
|
3368 |
"/ ].
|
|
3369 |
^ newColl
|
|
3370 |
!
|
|
3371 |
|
|
3372 |
subclassesDo:aBlock
|
|
3373 |
"evaluate the argument, aBlock for all immediate subclasses.
|
|
3374 |
This will only enumerate globally known classes - for anonymous
|
|
3375 |
behaviors, you have to walk over all instances of Behavior."
|
|
3376 |
|
|
3377 |
|coll|
|
|
3378 |
|
|
3379 |
self isMeta ifTrue:[
|
|
3380 |
self halt.
|
|
3381 |
"/ metaclasses are not found via Smalltalk allClassesDo:
|
|
3382 |
"/ here, walk over classes and enumerate corresponding metas.
|
|
3383 |
self soleInstance subclassesDo:[:aSubClass |
|
|
3384 |
aBlock value:(aSubClass class)
|
|
3385 |
].
|
|
3386 |
^ self
|
|
3387 |
].
|
|
3388 |
|
|
3389 |
"/ use cached information (avoid class hierarchy search)
|
|
3390 |
"/ if possible
|
|
3391 |
|
|
3392 |
"/ SubclassInfo isNil ifTrue:[
|
|
3393 |
"/ Behavior subclassInfo
|
|
3394 |
"/ ].
|
|
3395 |
"/ SubclassInfo notNil ifTrue:[
|
|
3396 |
"/ coll := SubclassInfo at:self ifAbsent:nil.
|
|
3397 |
"/ coll notNil ifTrue:[
|
|
3398 |
"/ coll do:aBlock.
|
|
3399 |
"/ ].
|
|
3400 |
"/ ^ self
|
|
3401 |
"/ ].
|
|
3402 |
|
|
3403 |
Smalltalk allClassesDo:[:aClass |
|
|
3404 |
(aClass superclass == self) ifTrue:[
|
|
3405 |
aBlock value:aClass
|
|
3406 |
]
|
|
3407 |
]
|
|
3408 |
|
|
3409 |
"
|
|
3410 |
Collection subclassesDo:[:c | Transcript showCR:(c name)]
|
|
3411 |
"
|
|
3412 |
|
|
3413 |
"Modified: 22.1.1997 / 18:44:01 / cg"
|
|
3414 |
!
|
|
3415 |
|
1417
|
3416 |
syntaxHighlighterClass
|
|
3417 |
^ Object syntaxHighlighterClass
|
|
3418 |
!
|
|
3419 |
|
1419
|
3420 |
theMetaclass
|
|
3421 |
self isMeta ifTrue:[^ self].
|
|
3422 |
^ self classRef.!
|
|
3423 |
|
|
3424 |
theNonMetaclass
|
|
3425 |
|instSlotOffs clsPtr|
|
|
3426 |
|
|
3427 |
self isMeta ifFalse:[^ self].
|
|
3428 |
instSlotOffs := Metaclass instVarOffsetOf:'myClass'.
|
|
3429 |
clsPtr := self at:instSlotOffs.
|
|
3430 |
^ memory fetchObjectAt:clsPtr.
|
|
3431 |
!
|
|
3432 |
|
|
3433 |
validateSourceStream:aStream
|
|
3434 |
"check if aStream really contains my source.
|
|
3435 |
This is done by checking the version methods return value
|
|
3436 |
against the version string as contained in the version method"
|
|
3437 |
|
|
3438 |
^ true!
|
|
3439 |
|
|
3440 |
withAllSuperclasses
|
|
3441 |
"return a collection containing the receiver and all
|
|
3442 |
of the receivers accumulated superclasses"
|
|
3443 |
|
|
3444 |
|aCollection theSuperClass|
|
|
3445 |
|
|
3446 |
aCollection := OrderedCollection with:self.
|
|
3447 |
theSuperClass := self superclass.
|
|
3448 |
[theSuperClass notNil] whileTrue:[
|
|
3449 |
aCollection add:theSuperClass.
|
|
3450 |
theSuperClass := theSuperClass superclass
|
|
3451 |
].
|
|
3452 |
^ aCollection
|
|
3453 |
|
|
3454 |
"
|
|
3455 |
String withAllSuperclasses
|
|
3456 |
"!
|
|
3457 |
|
1417
|
3458 |
withAllSuperclassesDo:aBlock
|
|
3459 |
|sc|
|
|
3460 |
|
|
3461 |
aBlock value:self.
|
|
3462 |
sc := self superclass.
|
|
3463 |
sc notNil ifTrue:[
|
|
3464 |
sc withAllSuperclassesDo:aBlock.
|
|
3465 |
]
|
|
3466 |
! !
|
|
3467 |
|
|
3468 |
!SnapShotImageMemory::ImageClassObject methodsFor:'queries'!
|
|
3469 |
|
|
3470 |
categories
|
|
3471 |
|newList|
|
|
3472 |
|
|
3473 |
newList := Set new.
|
|
3474 |
self methodDictionary do:[:aMethod |
|
|
3475 |
|cat|
|
|
3476 |
|
|
3477 |
cat := aMethod category.
|
|
3478 |
cat isNil ifTrue:[
|
|
3479 |
cat := '* no category *'
|
|
3480 |
].
|
|
3481 |
newList add:cat
|
|
3482 |
].
|
|
3483 |
^ newList
|
|
3484 |
!
|
|
3485 |
|
|
3486 |
isBytes
|
|
3487 |
^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagBytes.
|
|
3488 |
!
|
|
3489 |
|
|
3490 |
isDoubles
|
|
3491 |
^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagDoubles.
|
|
3492 |
!
|
|
3493 |
|
|
3494 |
isFloats
|
|
3495 |
^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagFloats.
|
|
3496 |
!
|
|
3497 |
|
|
3498 |
isLoaded
|
|
3499 |
^ self superclass name ~= 'Autoload'
|
|
3500 |
!
|
|
3501 |
|
|
3502 |
isLongLongs
|
|
3503 |
^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagLongLongs.
|
|
3504 |
!
|
|
3505 |
|
|
3506 |
isLongs
|
|
3507 |
^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagLongs.
|
|
3508 |
!
|
|
3509 |
|
|
3510 |
isMeta
|
1419
|
3511 |
^ self size == (Metaclass instSize).
|
|
3512 |
"/ ^ classRef classRef name = 'Metaclass'!
|
1417
|
3513 |
|
|
3514 |
isPrivate
|
|
3515 |
^ classRef isPrivateMeta
|
|
3516 |
!
|
|
3517 |
|
|
3518 |
isPrivateMeta
|
|
3519 |
^ classRef name = 'PrivateMetaclass'
|
|
3520 |
!
|
|
3521 |
|
|
3522 |
isSignedLongLongs
|
|
3523 |
^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagSignedLongLongs.
|
|
3524 |
!
|
|
3525 |
|
|
3526 |
isSignedLongs
|
|
3527 |
^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagSignedLongs.
|
|
3528 |
!
|
|
3529 |
|
|
3530 |
isSignedWords
|
|
3531 |
^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagSignedWords.
|
|
3532 |
!
|
|
3533 |
|
|
3534 |
isVariable
|
|
3535 |
^ (self flags bitAnd:Behavior maskIndexType) ~= 0.
|
|
3536 |
!
|
|
3537 |
|
|
3538 |
isWords
|
|
3539 |
^ (self flags bitAnd:Behavior maskIndexType) == Behavior flagWords.
|
|
3540 |
!
|
|
3541 |
|
|
3542 |
nameSpace
|
|
3543 |
|env name idx nsName|
|
|
3544 |
|
|
3545 |
"/ (env := self environment) notNil ifTrue:[^ env].
|
1419
|
3546 |
env := Smalltalk. "/ default
|
1417
|
3547 |
name := self name.
|
|
3548 |
idx := name lastIndexOf:$:.
|
|
3549 |
idx ~~ 0 ifTrue:[
|
|
3550 |
(name at:idx-1) == $: ifTrue:[
|
|
3551 |
nsName := name copyTo:(idx - 2).
|
|
3552 |
env := Smalltalk at:nsName asSymbol.
|
|
3553 |
]
|
|
3554 |
].
|
|
3555 |
^ env
|
|
3556 |
!
|
|
3557 |
|
|
3558 |
owningClass
|
|
3559 |
|ownerPtr owner|
|
|
3560 |
|
|
3561 |
classRef isPrivateMeta ifFalse:[^ nil].
|
|
3562 |
ownerPtr := classRef at:8.
|
|
3563 |
owner := memory fetchClassObjectAt:ownerPtr.
|
|
3564 |
^ owner
|
|
3565 |
!
|
|
3566 |
|
|
3567 |
supportsMethodCategories
|
|
3568 |
^ true
|
|
3569 |
!
|
|
3570 |
|
|
3571 |
topOwningClass
|
|
3572 |
|owner|
|
|
3573 |
|
|
3574 |
classRef isPrivateMeta ifTrue:[
|
|
3575 |
owner := self owningClass.
|
|
3576 |
[owner classRef isPrivateMeta] whileTrue:[
|
|
3577 |
owner := owner owningClass
|
|
3578 |
].
|
|
3579 |
^ owner
|
|
3580 |
] ifFalse:[
|
|
3581 |
^ nil
|
|
3582 |
].
|
|
3583 |
^ self halt.
|
|
3584 |
!
|
|
3585 |
|
|
3586 |
wasAutoloaded
|
|
3587 |
^ false
|
|
3588 |
! !
|
|
3589 |
|
1416
|
3590 |
!SnapShotImageMemory class methodsFor:'documentation'!
|
|
3591 |
|
|
3592 |
version
|
|
3593 |
^ '$Header$'
|
|
3594 |
! !
|