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 |
"
|
1470
|
25 |
!
|
|
26 |
|
|
27 |
examples
|
|
28 |
"
|
|
29 |
|i m|
|
|
30 |
|
|
31 |
i := self for:'st.img'.
|
|
32 |
m := i memory.
|
|
33 |
m fetchObjectAt:16r38000000
|
|
34 |
"
|
1448
|
35 |
! !
|
1415
|
36 |
|
|
37 |
!SnapShotImage class methodsFor:'instance creation'!
|
|
38 |
|
|
39 |
for:aFilename
|
|
40 |
^ self new for:aFilename
|
|
41 |
! !
|
|
42 |
|
1470
|
43 |
!SnapShotImage methodsFor:'accessing'!
|
|
44 |
|
|
45 |
memory
|
|
46 |
^ memory
|
|
47 |
! !
|
|
48 |
|
1415
|
49 |
!SnapShotImage methodsFor:'private'!
|
|
50 |
|
|
51 |
fetchGlobals
|
1417
|
52 |
globals := IdentityDictionary new.
|
1415
|
53 |
memory globalEntries do:[:eachEntry |
|
1417
|
54 |
|nameSymRef valRef nameSym value|
|
1415
|
55 |
|
1417
|
56 |
nameSymRef := eachEntry key.
|
|
57 |
valRef := eachEntry value.
|
|
58 |
nameSymRef isImageSymbol ifFalse:[self halt].
|
1415
|
59 |
|
1417
|
60 |
nameSym := (memory printStringOfSymbol:nameSymRef) asSymbol.
|
|
61 |
globals at:nameSym put:valRef
|
1415
|
62 |
].
|
|
63 |
!
|
|
64 |
|
|
65 |
for:aFilename
|
|
66 |
memory := SnapShotImageMemory for:aFilename.
|
1418
|
67 |
memory image:self.
|
1448
|
68 |
memory readHeader
|
|
69 |
! !
|
1415
|
70 |
|
|
71 |
!SnapShotImage methodsFor:'smalltalk protocol'!
|
|
72 |
|
|
73 |
allClassesDo:aBlock
|
1417
|
74 |
self keysAndValuesDo:[:key :valRef |
|
|
75 |
valRef isInteger ifFalse:[
|
|
76 |
valRef ~~ true ifTrue:[
|
|
77 |
valRef ~~ false ifTrue:[
|
|
78 |
valRef notNil ifTrue:[
|
|
79 |
valRef isImageBehavior ifTrue:[
|
|
80 |
aBlock value:valRef
|
|
81 |
]
|
|
82 |
]
|
|
83 |
]
|
|
84 |
]
|
1415
|
85 |
]
|
|
86 |
].
|
|
87 |
!
|
|
88 |
|
1418
|
89 |
allClassesInCategory:aCategory
|
|
90 |
|coll|
|
|
91 |
|
|
92 |
coll := OrderedCollection new.
|
|
93 |
self allClassesInCategory:aCategory do:[:aClass |
|
|
94 |
coll add:aClass
|
|
95 |
].
|
1448
|
96 |
^ coll
|
|
97 |
!
|
1418
|
98 |
|
|
99 |
allClassesInCategory:aCategory do:aBlock
|
|
100 |
"evaluate the argument, aBlock for all classes in the aCategory;
|
|
101 |
The order of the classes is not defined."
|
|
102 |
|
|
103 |
aCategory notNil ifTrue:[
|
|
104 |
self allClassesDo:[:aClass |
|
|
105 |
aClass isMeta ifFalse:[
|
|
106 |
(aClass category = aCategory) ifTrue:[
|
|
107 |
aBlock value:aClass
|
|
108 |
]
|
|
109 |
]
|
|
110 |
]
|
1448
|
111 |
]
|
|
112 |
!
|
1418
|
113 |
|
1417
|
114 |
at:aKey
|
|
115 |
globals isNil ifTrue:[
|
|
116 |
self fetchGlobals
|
|
117 |
].
|
|
118 |
^ globals at:aKey
|
|
119 |
!
|
|
120 |
|
1418
|
121 |
at:aKey ifAbsent:exceptionValue
|
|
122 |
globals isNil ifTrue:[
|
|
123 |
self fetchGlobals
|
|
124 |
].
|
1448
|
125 |
^ globals at:aKey ifAbsent:exceptionValue
|
|
126 |
!
|
1418
|
127 |
|
1415
|
128 |
keysAndValuesDo:aTwoArgBlock
|
|
129 |
globals isNil ifTrue:[
|
|
130 |
self fetchGlobals
|
|
131 |
].
|
|
132 |
globals keysAndValuesDo:aTwoArgBlock
|
|
133 |
! !
|
|
134 |
|
|
135 |
!SnapShotImage class methodsFor:'documentation'!
|
|
136 |
|
|
137 |
version
|
|
138 |
^ '$Header$'
|
|
139 |
! !
|