1448
|
1 |
"{ Package: 'stx:libtool2' }"
|
1415
|
2 |
|
|
3 |
Object subclass:#SnapShotImage
|
|
4 |
instanceVariableNames:'memory globals'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'System-Support'
|
|
8 |
!
|
|
9 |
|
1448
|
10 |
!SnapShotImage class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
documentation
|
|
13 |
"
|
|
14 |
I simulate a Smalltalk environment as present in a snapshot image.
|
|
15 |
My protocol mimics the NameSpace (i.e. class-environment) protocol,
|
|
16 |
and I can be used as a Browsers environment, in order to open a
|
|
17 |
browser into an old snapShot image (st.img - file).
|
|
18 |
|
|
19 |
I am not used directly; instead, via the SystemBrowsers entry:
|
|
20 |
SystemBrowser openOnSnapShotImage:'/export/home/cg/work/stx/projects/smalltalk/st.img'
|
|
21 |
|
|
22 |
[author:]
|
|
23 |
Claus Gittinger
|
|
24 |
"
|
|
25 |
! !
|
1415
|
26 |
|
|
27 |
!SnapShotImage class methodsFor:'instance creation'!
|
|
28 |
|
|
29 |
for:aFilename
|
|
30 |
^ self new for:aFilename
|
|
31 |
! !
|
|
32 |
|
|
33 |
!SnapShotImage methodsFor:'private'!
|
|
34 |
|
|
35 |
fetchGlobals
|
1417
|
36 |
globals := IdentityDictionary new.
|
1415
|
37 |
memory globalEntries do:[:eachEntry |
|
1417
|
38 |
|nameSymRef valRef nameSym value|
|
1415
|
39 |
|
1417
|
40 |
nameSymRef := eachEntry key.
|
|
41 |
valRef := eachEntry value.
|
|
42 |
nameSymRef isImageSymbol ifFalse:[self halt].
|
1415
|
43 |
|
1417
|
44 |
nameSym := (memory printStringOfSymbol:nameSymRef) asSymbol.
|
|
45 |
globals at:nameSym put:valRef
|
1415
|
46 |
].
|
|
47 |
!
|
|
48 |
|
|
49 |
for:aFilename
|
|
50 |
memory := SnapShotImageMemory for:aFilename.
|
1418
|
51 |
memory image:self.
|
1448
|
52 |
memory readHeader
|
|
53 |
! !
|
1415
|
54 |
|
|
55 |
!SnapShotImage methodsFor:'smalltalk protocol'!
|
|
56 |
|
|
57 |
allClassesDo:aBlock
|
1417
|
58 |
self keysAndValuesDo:[:key :valRef |
|
|
59 |
valRef isInteger ifFalse:[
|
|
60 |
valRef ~~ true ifTrue:[
|
|
61 |
valRef ~~ false ifTrue:[
|
|
62 |
valRef notNil ifTrue:[
|
|
63 |
valRef isImageBehavior ifTrue:[
|
|
64 |
aBlock value:valRef
|
|
65 |
]
|
|
66 |
]
|
|
67 |
]
|
|
68 |
]
|
1415
|
69 |
]
|
|
70 |
].
|
|
71 |
!
|
|
72 |
|
1418
|
73 |
allClassesInCategory:aCategory
|
|
74 |
|coll|
|
|
75 |
|
|
76 |
coll := OrderedCollection new.
|
|
77 |
self allClassesInCategory:aCategory do:[:aClass |
|
|
78 |
coll add:aClass
|
|
79 |
].
|
1448
|
80 |
^ coll
|
|
81 |
!
|
1418
|
82 |
|
|
83 |
allClassesInCategory:aCategory do:aBlock
|
|
84 |
"evaluate the argument, aBlock for all classes in the aCategory;
|
|
85 |
The order of the classes is not defined."
|
|
86 |
|
|
87 |
aCategory notNil ifTrue:[
|
|
88 |
self allClassesDo:[:aClass |
|
|
89 |
aClass isMeta ifFalse:[
|
|
90 |
(aClass category = aCategory) ifTrue:[
|
|
91 |
aBlock value:aClass
|
|
92 |
]
|
|
93 |
]
|
|
94 |
]
|
1448
|
95 |
]
|
|
96 |
!
|
1418
|
97 |
|
1417
|
98 |
at:aKey
|
|
99 |
globals isNil ifTrue:[
|
|
100 |
self fetchGlobals
|
|
101 |
].
|
|
102 |
^ globals at:aKey
|
|
103 |
!
|
|
104 |
|
1418
|
105 |
at:aKey ifAbsent:exceptionValue
|
|
106 |
globals isNil ifTrue:[
|
|
107 |
self fetchGlobals
|
|
108 |
].
|
1448
|
109 |
^ globals at:aKey ifAbsent:exceptionValue
|
|
110 |
!
|
1418
|
111 |
|
1415
|
112 |
keysAndValuesDo:aTwoArgBlock
|
|
113 |
globals isNil ifTrue:[
|
|
114 |
self fetchGlobals
|
|
115 |
].
|
|
116 |
globals keysAndValuesDo:aTwoArgBlock
|
|
117 |
! !
|
|
118 |
|
|
119 |
!SnapShotImage class methodsFor:'documentation'!
|
|
120 |
|
|
121 |
version
|
|
122 |
^ '$Header$'
|
|
123 |
! !
|