1422
|
1 |
"{ Package: 'stx:libtool' }"
|
1415
|
2 |
|
|
3 |
Object subclass:#SnapShotImage
|
|
4 |
instanceVariableNames:'memory globals'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'System-Support'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!SnapShotImage class methodsFor:'instance creation'!
|
|
12 |
|
|
13 |
for:aFilename
|
|
14 |
^ self new for:aFilename
|
|
15 |
! !
|
|
16 |
|
|
17 |
!SnapShotImage methodsFor:'private'!
|
|
18 |
|
|
19 |
fetchGlobals
|
1417
|
20 |
globals := IdentityDictionary new.
|
1415
|
21 |
memory globalEntries do:[:eachEntry |
|
1417
|
22 |
|nameSymRef valRef nameSym value|
|
1415
|
23 |
|
1417
|
24 |
nameSymRef := eachEntry key.
|
|
25 |
valRef := eachEntry value.
|
|
26 |
nameSymRef isImageSymbol ifFalse:[self halt].
|
1415
|
27 |
|
1417
|
28 |
nameSym := (memory printStringOfSymbol:nameSymRef) asSymbol.
|
|
29 |
globals at:nameSym put:valRef
|
1415
|
30 |
].
|
|
31 |
!
|
|
32 |
|
|
33 |
for:aFilename
|
|
34 |
memory := SnapShotImageMemory for:aFilename.
|
1418
|
35 |
memory image:self.
|
|
36 |
memory readHeader! !
|
1415
|
37 |
|
|
38 |
!SnapShotImage methodsFor:'smalltalk protocol'!
|
|
39 |
|
|
40 |
allClassesDo:aBlock
|
1417
|
41 |
self keysAndValuesDo:[:key :valRef |
|
|
42 |
valRef isInteger ifFalse:[
|
|
43 |
valRef ~~ true ifTrue:[
|
|
44 |
valRef ~~ false ifTrue:[
|
|
45 |
valRef notNil ifTrue:[
|
|
46 |
valRef isImageBehavior ifTrue:[
|
|
47 |
aBlock value:valRef
|
|
48 |
]
|
|
49 |
]
|
|
50 |
]
|
|
51 |
]
|
1415
|
52 |
]
|
|
53 |
].
|
|
54 |
!
|
|
55 |
|
1418
|
56 |
allClassesInCategory:aCategory
|
|
57 |
|coll|
|
|
58 |
|
|
59 |
coll := OrderedCollection new.
|
|
60 |
self allClassesInCategory:aCategory do:[:aClass |
|
|
61 |
coll add:aClass
|
|
62 |
].
|
|
63 |
^ coll!
|
|
64 |
|
|
65 |
allClassesInCategory:aCategory do:aBlock
|
|
66 |
"evaluate the argument, aBlock for all classes in the aCategory;
|
|
67 |
The order of the classes is not defined."
|
|
68 |
|
|
69 |
aCategory notNil ifTrue:[
|
|
70 |
self allClassesDo:[:aClass |
|
|
71 |
aClass isMeta ifFalse:[
|
|
72 |
(aClass category = aCategory) ifTrue:[
|
|
73 |
aBlock value:aClass
|
|
74 |
]
|
|
75 |
]
|
|
76 |
]
|
|
77 |
]!
|
|
78 |
|
1417
|
79 |
at:aKey
|
|
80 |
globals isNil ifTrue:[
|
|
81 |
self fetchGlobals
|
|
82 |
].
|
|
83 |
^ globals at:aKey
|
|
84 |
!
|
|
85 |
|
1418
|
86 |
at:aKey ifAbsent:exceptionValue
|
|
87 |
globals isNil ifTrue:[
|
|
88 |
self fetchGlobals
|
|
89 |
].
|
|
90 |
^ globals at:aKey ifAbsent:exceptionValue!
|
|
91 |
|
1415
|
92 |
keysAndValuesDo:aTwoArgBlock
|
|
93 |
globals isNil ifTrue:[
|
|
94 |
self fetchGlobals
|
|
95 |
].
|
|
96 |
globals keysAndValuesDo:aTwoArgBlock
|
|
97 |
! !
|
|
98 |
|
|
99 |
!SnapShotImage class methodsFor:'documentation'!
|
|
100 |
|
|
101 |
version
|
|
102 |
^ '$Header$'
|
|
103 |
! !
|