author | Claus Gittinger <cg@exept.de> |
Mon, 16 Feb 2009 14:10:39 +0100 | |
changeset 2165 | 4dde25bad190 |
parent 1928 | 0953c60fe418 |
child 2347 | 31415085bf93 |
permissions | -rw-r--r-- |
141 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1080 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
114 | 14 |
Object subclass:#ObjectFileHandle |
259 | 15 |
instanceVariableNames:'sysHandle1 sysHandle2 pathName moduleID handleType weakMethodRef |
1163
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
16 |
weakClassRefs weakFunctionRefs snapshot' |
259 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'System-Compiler' |
|
120 | 20 |
! |
21 |
||
368 | 22 |
!ObjectFileHandle class methodsFor:'documentation'! |
120 | 23 |
|
141 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
114 | 36 |
! |
37 |
||
120 | 38 |
documentation |
39 |
" |
|
123 | 40 |
not for public use - used by ObjectFileLoader to keep track of loaded modules, |
41 |
associating objectFile names and moduleIDs to classes/methods. |
|
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
42 |
This is required to be able to fixup classes, methods and function references |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
43 |
when an image is restarted and the dynamic objects are reloaded. |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
44 |
|
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
45 |
[see also:] |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
46 |
ExternalFunction |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
47 |
ObjectFileLoader |
263 | 48 |
|
49 |
[author:] |
|
50 |
Claus Gittinger |
|
120 | 51 |
" |
114 | 52 |
! ! |
53 |
||
1163
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
54 |
!ObjectFileHandle class methodsFor:'change & update'! |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
55 |
|
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
56 |
preSnapshot |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
57 |
"about to write a snapshot. |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
58 |
Mark all the current instances as beeing snapshotted" |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
59 |
|
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
60 |
self allInstancesDo:[:i| i snapshot:true]. |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
61 |
! ! |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
62 |
|
114 | 63 |
!ObjectFileHandle methodsFor:'accessing'! |
64 |
||
122 | 65 |
classes |
66 |
"return the classes" |
|
67 |
||
963
efa3aeb6859c
always return a collection from #functions and #classes
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
68 |
weakClassRefs isNil ifTrue:[^ #()]. |
122 | 69 |
^ weakClassRefs asArray |
70 |
||
71 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
72 |
! |
|
73 |
||
74 |
classes:aCollectionOfClasses |
|
75 |
"set the classes collection" |
|
76 |
||
77 |
weakClassRefs := WeakArray withAll:aCollectionOfClasses. |
|
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
78 |
weakClassRefs addDependent:self. |
122 | 79 |
handleType := #classLibraryObject |
80 |
||
81 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
82 |
! |
|
83 |
||
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
84 |
functions |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
85 |
"return the functions which were already extracted from the module." |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
86 |
|
963
efa3aeb6859c
always return a collection from #functions and #classes
Claus Gittinger <cg@exept.de>
parents:
490
diff
changeset
|
87 |
weakFunctionRefs isNil ifTrue:[^ #()]. |
490
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
88 |
^ weakFunctionRefs asArray select:[:f | f notNil and:[f ~~ 0]] |
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
89 |
|
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
90 |
"Created: 12.7.1996 / 15:33:09 / cg" |
490
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
91 |
"Modified: 30.1.1997 / 20:54:54 / cg" |
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
92 |
! |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
93 |
|
967
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
94 |
makeClassLibHandle |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
95 |
"make this a classLibHandle - must be done manually when init failed for proper de-registration |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
96 |
later." |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
97 |
|
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
98 |
handleType notNil ifTrue:[ |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
99 |
self error:'should not happen'. |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
100 |
]. |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
101 |
handleType := #classLibraryObject |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
102 |
! |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
103 |
|
120 | 104 |
method |
976 | 105 |
"return the method (or nil, if I am not a method-file handle)" |
120 | 106 |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
107 |
weakMethodRef isNil ifTrue:[^ nil]. |
120 | 108 |
^ weakMethodRef at:1 |
109 |
||
110 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
111 |
! |
|
112 |
||
113 |
method:something |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
114 |
"set the method" |
120 | 115 |
|
116 |
weakMethodRef := WeakArray with:something. |
|
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
117 |
weakMethodRef addDependent:self. |
122 | 118 |
handleType := #methodObject. |
120 | 119 |
|
120 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
141 | 121 |
! |
122 |
||
976 | 123 |
methods |
124 |
"return the collection of methods (or an empty collection, |
|
125 |
if I am not a method-file handle)" |
|
126 |
||
127 |
|m| |
|
128 |
||
129 |
(m := self method) isNil ifTrue:[^ #()]. |
|
130 |
"/ TODO: this will return a real collection, when method-only |
|
131 |
"/ binaries remember that relevant information ... |
|
132 |
^ Array with:m |
|
133 |
! |
|
134 |
||
141 | 135 |
moduleID |
136 |
"return moduleID" |
|
137 |
||
138 |
^ moduleID |
|
139 |
||
140 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
141 |
! |
|
142 |
||
143 |
moduleID:something |
|
144 |
"set moduleID" |
|
145 |
||
146 |
moduleID := something. |
|
147 |
||
148 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
149 |
! |
|
150 |
||
151 |
pathName |
|
152 |
"return pathName" |
|
153 |
||
154 |
^ pathName |
|
155 |
||
156 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
157 |
! |
|
158 |
||
159 |
pathName:something |
|
160 |
"set pathName" |
|
161 |
||
162 |
pathName := something. |
|
163 |
||
164 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
165 |
! |
|
166 |
||
1163
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
167 |
snapshot |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
168 |
"return the value of the instance variable 'snapshot' (automatically generated)" |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
169 |
|
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
170 |
^ snapshot |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
171 |
! |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
172 |
|
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
173 |
snapshot:something |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
174 |
"set the value of the instance variable 'snapshot' (automatically generated)" |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
175 |
|
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
176 |
snapshot := something. |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
177 |
! |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
178 |
|
141 | 179 |
sysHandle1 |
180 |
"return sysHandle1" |
|
181 |
||
182 |
^ sysHandle1 |
|
183 |
||
184 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
185 |
! |
|
186 |
||
187 |
sysHandle1:something |
|
188 |
"set sysHandle1" |
|
189 |
||
190 |
sysHandle1 := something. |
|
191 |
||
192 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
193 |
! |
|
194 |
||
195 |
sysHandle2 |
|
196 |
"return sysHandle2" |
|
197 |
||
198 |
^ sysHandle2 |
|
199 |
||
200 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
201 |
! |
|
202 |
||
203 |
sysHandle2:something |
|
204 |
"set sysHandle2" |
|
205 |
||
206 |
sysHandle2 := something. |
|
207 |
||
208 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
114 | 209 |
! ! |
141 | 210 |
|
1554 | 211 |
!ObjectFileHandle methodsFor:'actions'! |
212 |
||
213 |
unload |
|
214 |
"unload the object file represented by me" |
|
215 |
||
216 |
ObjectFileLoader unloadDynamicObject:self |
|
217 |
! ! |
|
218 |
||
259 | 219 |
!ObjectFileHandle methodsFor:'change & update'! |
220 |
||
221 |
update:something with:aParameter from:changedObject |
|
222 |
"my method/class object was collected - unload the underlying objectfile" |
|
223 |
||
490
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
224 |
changedObject == weakMethodRef ifTrue:[ |
474 | 225 |
weakMethodRef nilAllCorpsesAndDo:[:idx |]. |
367
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
226 |
]. |
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
227 |
|
490
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
228 |
changedObject == weakClassRefs ifTrue:[ |
474 | 229 |
weakClassRefs nilAllCorpsesAndDo:[:idx |]. |
367
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
230 |
]. |
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
231 |
|
259 | 232 |
self isObsolete ifTrue:[ |
490
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
233 |
weakFunctionRefs notNil ifTrue:[ |
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
234 |
weakFunctionRefs removeDependent:self. |
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
235 |
weakFunctionRefs := nil. |
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
236 |
]. |
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
237 |
weakClassRefs notNil ifTrue:[ |
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
238 |
weakClassRefs removeDependent:self. |
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
239 |
weakClassRefs := nil. |
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
240 |
]. |
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
241 |
weakMethodRef notNil ifTrue:[ |
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
242 |
weakMethodRef removeDependent:self. |
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
243 |
weakMethodRef := nil. |
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
244 |
]. |
474 | 245 |
('ObjectFileHandle [info]: unloading ' , pathName , ' (method/classes were garbageCollected)') infoPrintCR. |
1163
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
246 |
ObjectFileLoader unloadObjectFile:pathName. |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
247 |
snapshot == true ifFalse:[ |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
248 |
"This object file has never been saved in a snapshot, |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
249 |
so it can be savely removed" |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
250 |
|
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
251 |
pathName asFilename remove. |
242ec57c2f27
Remove object files that have been collected and not been used
Stefan Vogel <sv@exept.de>
parents:
1080
diff
changeset
|
252 |
]. |
259 | 253 |
]. |
254 |
||
255 |
"Created: 5.12.1995 / 18:05:08 / cg" |
|
490
621a7283b926
oops - changeArg is #ElementExpired; changedObject is the one we have to
Claus Gittinger <cg@exept.de>
parents:
474
diff
changeset
|
256 |
"Modified: 30.1.1997 / 20:57:56 / cg" |
259 | 257 |
! ! |
258 |
||
259 |
!ObjectFileHandle methodsFor:'copying'! |
|
260 |
||
261 |
postCopy |
|
262 |
"flush module handles of the copy" |
|
263 |
||
264 |
sysHandle1 := sysHandle2 := moduleID := nil |
|
265 |
||
266 |
"Created: 5.12.1995 / 21:10:49 / cg" |
|
267 |
"Modified: 25.4.1996 / 09:43:53 / cg" |
|
1614 | 268 |
! |
269 |
||
270 |
postDeepCopy |
|
271 |
sysHandle1 := sysHandle2 := moduleID := nil |
|
259 | 272 |
! ! |
273 |
||
1080 | 274 |
!ObjectFileHandle methodsFor:'printing & storing'! |
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
275 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
276 |
printOn:aStream |
259 | 277 |
"append a printed representation of the receiver to aStream" |
278 |
||
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
279 |
aStream nextPutAll:self class name; nextPutAll:'(handle=<'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
280 |
sysHandle1 printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
281 |
aStream nextPutAll:' '. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
282 |
sysHandle2 printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
283 |
aStream nextPutAll:'> path='''. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
284 |
pathName printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
285 |
aStream nextPutAll:''' id='. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
286 |
moduleID printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
287 |
aStream nextPutAll:' type='. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
288 |
handleType printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
289 |
aStream nextPutAll:' method=<'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
290 |
self method printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
291 |
aStream nextPutAll:'> classes=<'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
292 |
self classes printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
293 |
aStream nextPutAll:'>'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
294 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
295 |
aStream nextPutAll:')'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
296 |
|
259 | 297 |
"Modified: 25.4.1996 / 09:44:08 / cg" |
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
298 |
! ! |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
299 |
|
141 | 300 |
!ObjectFileHandle methodsFor:'queries'! |
301 |
||
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
302 |
getFunction:aString |
1767 | 303 |
"return a function object for an entry in the module represented by the receiver." |
304 |
||
305 |
|f| |
|
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
306 |
|
1767 | 307 |
f := ExternalFunction basicNew. |
308 |
(self getFunctionAddress:aString into:f) isNil ifTrue:[ |
|
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
309 |
^ nil |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
310 |
]. |
1769 | 311 |
f setName:aString moduleHandle:self. |
1767 | 312 |
^ f. |
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
313 |
! |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
314 |
|
1603
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
315 |
getFunctionAddress:aString into:anExternalFunction |
1743 | 316 |
"fill the code address of the external function named aString into anExternalFunction. |
317 |
Returns the address, or nil." |
|
1603
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
318 |
|
1767 | 319 |
|address slot sz nW| |
1603
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
320 |
|
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
321 |
address := ObjectFileLoader getFunction:aString from:self. |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
322 |
address isNil ifTrue:[ |
1767 | 323 |
anExternalFunction code:0. |
1603
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
324 |
^ nil |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
325 |
]. |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
326 |
|
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
327 |
anExternalFunction code:address. |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
328 |
weakFunctionRefs isNil ifTrue:[ |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
329 |
handleType := #functionObject. |
1767 | 330 |
weakFunctionRefs := WeakArray with:anExternalFunction. |
1603
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
331 |
^ address. |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
332 |
]. |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
333 |
|
1767 | 334 |
(weakFunctionRefs includesIdentical:anExternalFunction) ifTrue:[ |
335 |
^ address |
|
1603
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
336 |
]. |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
337 |
|
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
338 |
slot := weakFunctionRefs identityIndexOf:nil. |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
339 |
slot ~~ 0 ifTrue:[ |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
340 |
weakFunctionRefs at:slot put:anExternalFunction. |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
341 |
^ address. |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
342 |
]. |
1767 | 343 |
weakFunctionRefs := weakFunctionRefs copyWith:anExternalFunction. |
1603
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
344 |
|
1767 | 345 |
"/ sz := weakFunctionRefs size. |
346 |
"/ nW := WeakArray new:(sz + 1). |
|
347 |
"/ nW replaceFrom:1 to:sz with:weakFunctionRefs startingAt:1. |
|
348 |
"/ nW at:sz+1 put:anExternalFunction. |
|
349 |
"/ |
|
350 |
"/ weakFunctionRefs := nW. |
|
1603
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
351 |
^ address |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
352 |
! |
4243be479e4f
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
1554
diff
changeset
|
353 |
|
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
354 |
hasUndefinedSymbols |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
355 |
"return true, if the module has any undefined symbols. |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
356 |
The only system, which allows modules with undefined symbols to be |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
357 |
loaded is (currently) the linux a.out version." |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
358 |
|
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
359 |
^ ObjectFileLoader hasUndefinedSymbolsIn:self |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
360 |
|
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
361 |
"Created: 12.7.1996 / 14:59:09 / cg" |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
362 |
! |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
363 |
|
141 | 364 |
isClassLibHandle |
365 |
"return true, if I am a handle for a class library" |
|
366 |
||
367 |
^ handleType == #classLibraryObject |
|
368 |
! |
|
369 |
||
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
370 |
isForCollectedObject |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
371 |
"return true, if my clases/method has already been garbage collected" |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
372 |
|
367
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
373 |
|ref| |
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
374 |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
375 |
handleType == #classLibraryObject ifTrue:[ |
367
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
376 |
^ (weakClassRefs findFirst:[:x | x notNil and:[x ~~ 0]]) == 0 |
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
377 |
]. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
378 |
handleType == #methodObject ifTrue:[ |
1038 | 379 |
weakMethodRef isNil ifTrue:[^ true]. |
380 |
ref := weakMethodRef at:1. |
|
367
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
381 |
^ ref isNil or:[ref == 0] |
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
382 |
]. |
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
383 |
handleType == #functionObject ifTrue:[ |
367
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
384 |
^ (weakFunctionRefs findFirst:[:x | x notNil and:[x ~~ 0]]) == 0 |
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
385 |
]. |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
386 |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
387 |
^ false |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
388 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
389 |
"Created: 6.12.1995 / 17:46:58 / cg" |
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
390 |
"Modified: 12.7.1996 / 15:42:38 / cg" |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
391 |
! |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
392 |
|
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
393 |
isFunctionObjectHandle |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
394 |
"return true, if I am a handle for a c-code (or other) function object file" |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
395 |
|
304 | 396 |
^ handleType == #functionObject |
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
397 |
|
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
398 |
"Created: 12.7.1996 / 15:35:33 / cg" |
304 | 399 |
"Modified: 12.7.1996 / 17:25:31 / cg" |
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
400 |
! |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
401 |
|
259 | 402 |
isMethodHandle |
403 |
"return true, if I am a handle for a single compiled method" |
|
404 |
||
405 |
^ handleType == #methodObject |
|
406 |
! |
|
407 |
||
141 | 408 |
isObsolete |
409 |
"return true, if my clases/method has already been removed from |
|
410 |
the image. I.e. if the object file can be unloaded without danger." |
|
411 |
||
367
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
412 |
|ref| |
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
413 |
|
154 | 414 |
moduleID notNil ifTrue:[ |
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
415 |
handleType == #classLibraryObject ifTrue:[ |
367
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
416 |
^ (weakClassRefs findFirst:[:x | x notNil and:[x ~~ 0]]) == 0 |
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
417 |
]. |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
418 |
handleType == #methodObject ifTrue:[ |
367
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
419 |
ref := weakMethodRef at:1. |
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
420 |
^ (ref isNil or:[ref == 0]) |
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
421 |
]. |
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
422 |
handleType == #functionObject ifTrue:[ |
367
87d4673fbd06
changed WeakArray to set emptied slots to zero
Claus Gittinger <cg@exept.de>
parents:
304
diff
changeset
|
423 |
^ (weakFunctionRefs findFirst:[:x | x notNil and:[x ~~ 0]]) == 0 |
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
424 |
]. |
141 | 425 |
]. |
426 |
^ false |
|
299
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
427 |
|
33a154508328
additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
428 |
"Modified: 12.7.1996 / 15:42:21 / cg" |
967
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
429 |
! |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
430 |
|
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
431 |
isUnknownHandle |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
432 |
"return true, if it is not (yet) known, what type of |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
433 |
file is represented by the handle. (i.e. when loaded, but not yet |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
434 |
registered/initialized)" |
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
435 |
|
160ab002eed1
support proper unregistration, when a classLib fails to load
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
436 |
^ handleType isNil |
973 | 437 |
! |
438 |
||
439 |
package |
|
440 |
"retrieve the packageID of the class-library handle" |
|
441 |
||
1928 | 442 |
|classes methods| |
973 | 443 |
|
444 |
"/ sigh - for now, the package must be extracted from the first classes/methods |
|
445 |
"/ package. |
|
446 |
||
447 |
self isClassLibHandle ifTrue:[ |
|
1928 | 448 |
(classes := self classes) notEmpty ifTrue:[ |
449 |
^ classes first package |
|
450 |
]. |
|
451 |
^ nil |
|
973 | 452 |
]. |
453 |
self isMethodHandle ifTrue:[ |
|
1928 | 454 |
(methods := self methods) notEmpty ifTrue:[ |
455 |
^ methods first package |
|
456 |
]. |
|
457 |
^ nil |
|
973 | 458 |
]. |
459 |
^ nil |
|
1928 | 460 |
|
461 |
"Modified: / 12-10-2006 / 20:00:15 / cg" |
|
141 | 462 |
! ! |
463 |
||
368 | 464 |
!ObjectFileHandle class methodsFor:'documentation'! |
148 | 465 |
|
466 |
version |
|
1928 | 467 |
^ '$Header: /cvs/stx/stx/libcomp/ObjectFileHandle.st,v 1.36 2006-10-12 18:15:21 cg Exp $' |
148 | 468 |
! ! |