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