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