ObjectFileHandle.st
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--
automatic checkIn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
     1
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
     3
	      All Rights Reserved
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
     4
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
     5
 This software is furnished under a license and may be used
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
     6
 only in accordance with the terms of that license and with the
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
     8
 be provided or otherwise made available to, or used by, any
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
     9
 other person.  No title to or ownership of the software is
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    10
 hereby transferred.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    11
"
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
    12
"{ Package: 'stx:libcomp' }"
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
    13
114
claus
parents:
diff changeset
    14
Object subclass:#ObjectFileHandle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
    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
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
    17
	classVariableNames:''
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
    18
	poolDictionaries:''
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
    19
	category:'System-Compiler'
120
claus
parents: 114
diff changeset
    20
!
claus
parents: 114
diff changeset
    21
368
26e9268bde0f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
    22
!ObjectFileHandle class methodsFor:'documentation'!
120
claus
parents: 114
diff changeset
    23
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    24
copyright
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    25
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    26
 COPYRIGHT (c) 1995 by Claus Gittinger
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    27
	      All Rights Reserved
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    28
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    29
 This software is furnished under a license and may be used
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    30
 only in accordance with the terms of that license and with the
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    32
 be provided or otherwise made available to, or used by, any
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    33
 other person.  No title to or ownership of the software is
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    34
 hereby transferred.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    35
"
114
claus
parents:
diff changeset
    36
!
claus
parents:
diff changeset
    37
120
claus
parents: 114
diff changeset
    38
documentation
claus
parents: 114
diff changeset
    39
"
123
claus
parents: 122
diff changeset
    40
    not for public use - used by ObjectFileLoader to keep track of loaded modules,
claus
parents: 122
diff changeset
    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
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    48
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    49
    [author:]
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    50
        Claus Gittinger
120
claus
parents: 114
diff changeset
    51
"
114
claus
parents:
diff changeset
    52
! !
claus
parents:
diff changeset
    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
claus
parents:
diff changeset
    63
!ObjectFileHandle methodsFor:'accessing'!
claus
parents:
diff changeset
    64
122
claus
parents: 120
diff changeset
    65
classes
claus
parents: 120
diff changeset
    66
    "return the classes"
claus
parents: 120
diff changeset
    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
claus
parents: 120
diff changeset
    69
    ^ weakClassRefs asArray 
claus
parents: 120
diff changeset
    70
claus
parents: 120
diff changeset
    71
    "Created: 14.9.1995 / 21:13:13 / claus"
claus
parents: 120
diff changeset
    72
!
claus
parents: 120
diff changeset
    73
claus
parents: 120
diff changeset
    74
classes:aCollectionOfClasses 
claus
parents: 120
diff changeset
    75
    "set the classes collection"
claus
parents: 120
diff changeset
    76
claus
parents: 120
diff changeset
    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
claus
parents: 120
diff changeset
    79
    handleType := #classLibraryObject 
claus
parents: 120
diff changeset
    80
claus
parents: 120
diff changeset
    81
    "Created: 14.9.1995 / 21:13:13 / claus"
claus
parents: 120
diff changeset
    82
!
claus
parents: 120
diff changeset
    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
claus
parents: 114
diff changeset
   104
method
976
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   105
    "return the method (or nil, if I am not a method-file handle)"
120
claus
parents: 114
diff changeset
   106
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   107
    weakMethodRef isNil ifTrue:[^ nil].
120
claus
parents: 114
diff changeset
   108
    ^ weakMethodRef at:1 
claus
parents: 114
diff changeset
   109
claus
parents: 114
diff changeset
   110
    "Created: 14.9.1995 / 21:13:13 / claus"
claus
parents: 114
diff changeset
   111
!
claus
parents: 114
diff changeset
   112
claus
parents: 114
diff changeset
   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
claus
parents: 114
diff changeset
   115
claus
parents: 114
diff changeset
   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
claus
parents: 120
diff changeset
   118
    handleType := #methodObject.
120
claus
parents: 114
diff changeset
   119
claus
parents: 114
diff changeset
   120
    "Created: 14.9.1995 / 21:13:13 / claus"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   121
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   122
976
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   123
methods
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   124
    "return the collection of methods (or an empty collection,
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   125
     if I am not a method-file handle)"
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   126
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   127
    |m|
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   128
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   129
    (m := self method) isNil ifTrue:[^ #()].
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   130
    "/ TODO: this will return a real collection, when method-only
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   131
    "/ binaries remember that relevant information ...
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   132
    ^ Array with:m
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   133
!
9078108d2af4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 973
diff changeset
   134
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   135
moduleID
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   136
    "return moduleID"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   137
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   138
    ^ moduleID
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   139
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   140
    "Created: 14.9.1995 / 21:13:12 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   141
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   142
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   143
moduleID:something
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   144
    "set moduleID"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   145
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   146
    moduleID := something.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   147
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   148
    "Created: 14.9.1995 / 21:13:12 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   149
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   150
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   151
pathName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   152
    "return pathName"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   153
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   154
    ^ pathName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   155
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   156
    "Created: 14.9.1995 / 21:13:12 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   157
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   158
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   159
pathName:something
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   160
    "set pathName"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   161
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   162
    pathName := something.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   163
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   164
    "Created: 14.9.1995 / 21:13:12 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   165
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   179
sysHandle1
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   180
    "return sysHandle1"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   181
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   182
    ^ sysHandle1
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   183
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   184
    "Created: 14.9.1995 / 21:13:12 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   185
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   186
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   187
sysHandle1:something
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   188
    "set sysHandle1"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   189
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   190
    sysHandle1 := something.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   191
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   192
    "Created: 14.9.1995 / 21:13:12 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   193
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   194
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   195
sysHandle2
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   196
    "return sysHandle2"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   197
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   198
    ^ sysHandle2
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   199
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   200
    "Created: 14.9.1995 / 21:13:12 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   201
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   202
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   203
sysHandle2:something
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   204
    "set sysHandle2"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   205
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   206
    sysHandle2 := something.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   207
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   208
    "Created: 14.9.1995 / 21:13:12 / claus"
114
claus
parents:
diff changeset
   209
! !
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   210
1554
8e923008be65 New: #unload
Stefan Vogel <sv@exept.de>
parents: 1163
diff changeset
   211
!ObjectFileHandle methodsFor:'actions'!
8e923008be65 New: #unload
Stefan Vogel <sv@exept.de>
parents: 1163
diff changeset
   212
8e923008be65 New: #unload
Stefan Vogel <sv@exept.de>
parents: 1163
diff changeset
   213
unload
8e923008be65 New: #unload
Stefan Vogel <sv@exept.de>
parents: 1163
diff changeset
   214
    "unload the object file represented by me"
8e923008be65 New: #unload
Stefan Vogel <sv@exept.de>
parents: 1163
diff changeset
   215
8e923008be65 New: #unload
Stefan Vogel <sv@exept.de>
parents: 1163
diff changeset
   216
    ObjectFileLoader unloadDynamicObject:self
8e923008be65 New: #unload
Stefan Vogel <sv@exept.de>
parents: 1163
diff changeset
   217
! !
8e923008be65 New: #unload
Stefan Vogel <sv@exept.de>
parents: 1163
diff changeset
   218
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   219
!ObjectFileHandle methodsFor:'change & update'!
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   220
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   221
update:something with:aParameter from:changedObject
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   222
    "my method/class object was collected - unload the underlying objectfile"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   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
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   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
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   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
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   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
bf2345df4093 new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 388
diff changeset
   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
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   253
    ].
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   254
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   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
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   257
! !
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   258
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   259
!ObjectFileHandle methodsFor:'copying'!
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   260
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   261
postCopy
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   262
    "flush module handles of the copy"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   263
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   264
    sysHandle1 := sysHandle2 := moduleID := nil
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   265
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   266
    "Created: 5.12.1995 / 21:10:49 / cg"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   267
    "Modified: 25.4.1996 / 09:43:53 / cg"
1614
894cf7de352c +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 1603
diff changeset
   268
!
894cf7de352c +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 1603
diff changeset
   269
894cf7de352c +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 1603
diff changeset
   270
postDeepCopy
894cf7de352c +postDeepCopy
Claus Gittinger <cg@exept.de>
parents: 1603
diff changeset
   271
    sysHandle1 := sysHandle2 := moduleID := nil
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   272
! !
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   273
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1038
diff changeset
   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
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   277
    "append a printed representation of the receiver to aStream"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   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
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   300
!ObjectFileHandle methodsFor:'queries'!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   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
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   303
    "return a function object for an entry in the module represented by the receiver."
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   304
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   305
    |f|
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   306
1767
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   307
    f := ExternalFunction basicNew.
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   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
bb88e5aab773 *** empty log message ***
ca
parents: 1767
diff changeset
   311
    f setName:aString moduleHandle:self.
1767
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   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
7cd4c5cd0510 comment
Claus Gittinger <cg@exept.de>
parents: 1614
diff changeset
   316
    "fill the code address of the external function named aString into anExternalFunction.
7cd4c5cd0510 comment
Claus Gittinger <cg@exept.de>
parents: 1614
diff changeset
   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
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   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
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   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
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   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
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   334
    (weakFunctionRefs includesIdentical:anExternalFunction) ifTrue:[
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   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
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   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
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   345
"/    sz := weakFunctionRefs size.
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   346
"/    nW := WeakArray new:(sz + 1).
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   347
"/    nW replaceFrom:1 to:sz with:weakFunctionRefs startingAt:1.
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   348
"/    nW at:sz+1 put:anExternalFunction.
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   349
"/
0ed1d952d4dc function registration handling
ca
parents: 1743
diff changeset
   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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   364
isClassLibHandle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   365
    "return true, if I am a handle for a class library"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   366
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   367
    ^ handleType == #classLibraryObject 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   368
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   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
faf50ed50034 checkin from browser
ps
parents: 976
diff changeset
   379
        weakMethodRef isNil ifTrue:[^ true].
faf50ed50034 checkin from browser
ps
parents: 976
diff changeset
   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
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   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
Claus Gittinger <cg@exept.de>
parents: 302
diff changeset
   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
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   402
isMethodHandle
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   403
    "return true, if I am a handle for a single compiled method"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   404
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   405
    ^ handleType == #methodObject
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   406
!
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   407
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   408
isObsolete
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   409
    "return true, if my clases/method has already been removed from
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   410
     the image. I.e. if the object file can be unloaded without danger."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   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
04716b86ad29 reloading compiled methods
Claus Gittinger <cg@exept.de>
parents: 152
diff changeset
   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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   425
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   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
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   437
!
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   438
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   439
package
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   440
    "retrieve the packageID of the class-library handle"
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   441
1928
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   442
    |classes methods|
973
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   443
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   444
    "/ sigh - for now, the package must be extracted from the first classes/methods
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   445
    "/ package.
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   446
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   447
    self isClassLibHandle ifTrue:[
1928
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   448
        (classes := self classes) notEmpty ifTrue:[
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   449
            ^ classes first package
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   450
        ].
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   451
        ^ nil
973
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   452
    ].
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   453
    self isMethodHandle ifTrue:[
1928
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   454
        (methods := self methods) notEmpty ifTrue:[
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   455
            ^ methods first package
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   456
        ].
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   457
        ^ nil
973
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   458
    ].
67ea50ac2f99 added package access
Claus Gittinger <cg@exept.de>
parents: 967
diff changeset
   459
    ^ nil
1928
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   460
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   461
    "Modified: / 12-10-2006 / 20:00:15 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   462
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   463
368
26e9268bde0f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 367
diff changeset
   464
!ObjectFileHandle class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   465
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   466
version
1928
0953c60fe418 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   467
    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileHandle.st,v 1.36 2006-10-12 18:15:21 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   468
! !