ObjectFileHandle.st
author Claus Gittinger <cg@exept.de>
Fri, 12 Jul 1996 15:54:39 +0200
changeset 299 33a154508328
parent 263 3b21d0991eff
child 302 e5c0efc943e6
permissions -rw-r--r--
additional support for non-ST object files (function modules)
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
claus
parents:
diff changeset
    13
Object subclass:#ObjectFileHandle
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
    14
	instanceVariableNames:'sysHandle1 sysHandle2 pathName moduleID handleType weakMethodRef
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    15
		weakClassRefs weakFunctionRefs'
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
    16
	classVariableNames:''
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
    17
	poolDictionaries:''
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
    18
	category:'System-Compiler'
120
claus
parents: 114
diff changeset
    19
!
claus
parents: 114
diff changeset
    20
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    21
!ObjectFileHandle  class methodsFor:'documentation'!
120
claus
parents: 114
diff changeset
    22
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    23
copyright
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    24
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    25
 COPYRIGHT (c) 1995 by Claus Gittinger
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    26
	      All Rights Reserved
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    27
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    28
 This software is furnished under a license and may be used
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    29
 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
    30
 inclusion of the above copyright notice.   This software may not
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    31
 be provided or otherwise made available to, or used by, any
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    32
 other person.  No title to or ownership of the software is
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    33
 hereby transferred.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    34
"
114
claus
parents:
diff changeset
    35
!
claus
parents:
diff changeset
    36
120
claus
parents: 114
diff changeset
    37
documentation
claus
parents: 114
diff changeset
    38
"
123
claus
parents: 122
diff changeset
    39
    not for public use - used by ObjectFileLoader to keep track of loaded modules,
claus
parents: 122
diff changeset
    40
    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
    41
    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
    42
    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
    43
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    44
    [see also:]
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    45
        ExternalFunction
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    46
        ObjectFileLoader
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    47
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    48
    [author:]
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    49
        Claus Gittinger
120
claus
parents: 114
diff changeset
    50
"
claus
parents: 114
diff changeset
    51
!
114
claus
parents:
diff changeset
    52
120
claus
parents: 114
diff changeset
    53
history
claus
parents: 114
diff changeset
    54
claus
parents: 114
diff changeset
    55
    "Created: 14.9.1995 / 21:10:55 / claus"
claus
parents: 114
diff changeset
    56
    "Modified: 14.9.1995 / 21:10:55 / claus"
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    57
    "Modified: 12.7.1996 / 15:20:15 / cg"
114
claus
parents:
diff changeset
    58
! !
claus
parents:
diff changeset
    59
claus
parents:
diff changeset
    60
!ObjectFileHandle methodsFor:'accessing'!
claus
parents:
diff changeset
    61
122
claus
parents: 120
diff changeset
    62
classes
claus
parents: 120
diff changeset
    63
    "return the classes"
claus
parents: 120
diff changeset
    64
125
Claus Gittinger <cg@exept.de>
parents: 123
diff changeset
    65
    weakClassRefs isNil ifTrue:[^nil].
122
claus
parents: 120
diff changeset
    66
    ^ weakClassRefs asArray 
claus
parents: 120
diff changeset
    67
claus
parents: 120
diff changeset
    68
    "Created: 14.9.1995 / 21:13:13 / claus"
claus
parents: 120
diff changeset
    69
!
claus
parents: 120
diff changeset
    70
claus
parents: 120
diff changeset
    71
classes:aCollectionOfClasses 
claus
parents: 120
diff changeset
    72
    "set the classes collection"
claus
parents: 120
diff changeset
    73
claus
parents: 120
diff changeset
    74
    weakClassRefs := WeakArray withAll:aCollectionOfClasses.
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    75
    weakClassRefs addDependent:self.
122
claus
parents: 120
diff changeset
    76
    handleType := #classLibraryObject 
claus
parents: 120
diff changeset
    77
claus
parents: 120
diff changeset
    78
    "Created: 14.9.1995 / 21:13:13 / claus"
claus
parents: 120
diff changeset
    79
!
claus
parents: 120
diff changeset
    80
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    81
functions
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    82
    "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
    83
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    84
    weakFunctionRefs isNil ifTrue:[^nil].
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    85
    ^ weakFunctionRefs asArray select:[:f | f notNil]
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    86
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    87
    "Created: 12.7.1996 / 15:33:09 / cg"
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    88
    "Modified: 12.7.1996 / 15:38:00 / cg"
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
120
claus
parents: 114
diff changeset
    91
method
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    92
    "return the method"
120
claus
parents: 114
diff changeset
    93
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
    94
    weakMethodRef isNil ifTrue:[^ nil].
120
claus
parents: 114
diff changeset
    95
    ^ weakMethodRef at:1 
claus
parents: 114
diff changeset
    96
claus
parents: 114
diff changeset
    97
    "Created: 14.9.1995 / 21:13:13 / claus"
claus
parents: 114
diff changeset
    98
!
claus
parents: 114
diff changeset
    99
claus
parents: 114
diff changeset
   100
method:something
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   101
    "set the method"
120
claus
parents: 114
diff changeset
   102
claus
parents: 114
diff changeset
   103
    weakMethodRef := WeakArray with:something.
151
7f46f760ba45 automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   104
    weakMethodRef addDependent:self.
122
claus
parents: 120
diff changeset
   105
    handleType := #methodObject.
120
claus
parents: 114
diff changeset
   106
claus
parents: 114
diff changeset
   107
    "Created: 14.9.1995 / 21:13:13 / claus"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   108
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   109
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   110
moduleID
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   111
    "return moduleID"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   112
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   113
    ^ moduleID
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   114
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   115
    "Created: 14.9.1995 / 21:13:12 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   116
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   117
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   118
moduleID:something
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   119
    "set moduleID"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   120
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   121
    moduleID := something.
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
    "Created: 14.9.1995 / 21:13:12 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   124
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   125
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   126
pathName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   127
    "return pathName"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   128
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   129
    ^ pathName
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   130
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   131
    "Created: 14.9.1995 / 21:13:12 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   132
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   133
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   134
pathName:something
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   135
    "set pathName"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   136
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   137
    pathName := something.
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
    "Created: 14.9.1995 / 21:13:12 / claus"
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   142
sysHandle1
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   143
    "return sysHandle1"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   144
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   145
    ^ sysHandle1
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
    "Created: 14.9.1995 / 21:13:12 / claus"
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   150
sysHandle1:something
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   151
    "set sysHandle1"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   152
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   153
    sysHandle1 := something.
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
    "Created: 14.9.1995 / 21:13:12 / claus"
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   158
sysHandle2
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   159
    "return sysHandle2"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   160
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   161
    ^ sysHandle2
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
    "Created: 14.9.1995 / 21:13:12 / claus"
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
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   166
sysHandle2:something
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   167
    "set sysHandle2"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   168
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   169
    sysHandle2 := something.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   170
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   171
    "Created: 14.9.1995 / 21:13:12 / claus"
114
claus
parents:
diff changeset
   172
! !
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   173
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   174
!ObjectFileHandle methodsFor:'change & update'!
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   175
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   176
update:something with:aParameter from:changedObject
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   177
    "my method/class object was collected - unload the underlying objectfile"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   178
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   179
    self isObsolete ifTrue:[
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   180
	('OBJFLOADER: unloading ' , pathName , '  (method/classes were garbageCollected)') infoPrintNL.
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   181
	ObjectFileLoader unloadObjectFile:pathName
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   182
    ].
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   183
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   184
    "Created: 5.12.1995 / 18:05:08 / cg"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   185
! !
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   186
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   187
!ObjectFileHandle methodsFor:'copying'!
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   188
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   189
postCopy
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   190
    "flush module handles of the copy"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   191
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   192
    sysHandle1 := sysHandle2 := moduleID := nil
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   193
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   194
    "Created: 5.12.1995 / 21:10:49 / cg"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   195
    "Modified: 25.4.1996 / 09:43:53 / cg"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   196
! !
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   197
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   198
!ObjectFileHandle methodsFor:'printing'!
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   199
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   200
printOn:aStream
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   201
    "append a printed representation of the receiver to aStream"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   202
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   203
    aStream nextPutAll:self class name; nextPutAll:'(handle=<'. 
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   204
    sysHandle1 printOn:aStream. 
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   205
    aStream nextPutAll:' '. 
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   206
    sysHandle2 printOn:aStream. 
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   207
    aStream nextPutAll:'> path='''. 
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   208
    pathName printOn:aStream. 
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   209
    aStream nextPutAll:''' id='. 
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   210
    moduleID printOn:aStream. 
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   211
    aStream nextPutAll:' type='. 
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   212
    handleType printOn:aStream.
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   213
    aStream nextPutAll:' method=<'.
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   214
    self method printOn:aStream.
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   215
    aStream nextPutAll:'> classes=<'.
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   216
    self classes printOn:aStream.
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   217
    aStream nextPutAll:'>'.
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   218
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   219
    aStream nextPutAll:')'.
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   220
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   221
    "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
   222
! !
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   223
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   224
!ObjectFileHandle methodsFor:'queries'!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   225
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   226
getFunction:aString
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   227
    "return a function object for an entry in the module represented by
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   228
     the receiver."
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   229
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   230
    |address f slot sz nW|
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   231
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   232
    address := ObjectFileLoader getFunction:aString from:self.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   233
    address isNil ifTrue:[
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   234
        ^ nil
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   235
    ].
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   236
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   237
    weakFunctionRefs isNil ifTrue:[
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   238
        handleType := #functionObject.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   239
        f := ExternalFunction basicNew code:address.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   240
        f setName:aString moduleHandle:self.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   241
        weakFunctionRefs := WeakArray with:f.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   242
        ^ f.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   243
    ].
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   244
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   245
    weakFunctionRefs nonNilElementsDo:[:anExternalFunction |
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   246
        anExternalFunction code = address ifTrue:[
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   247
            ^ anExternalFunction
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   248
        ]
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   249
    ].
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   250
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   251
    f := ExternalFunction basicNew code:address.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   252
    f setName:aString moduleHandle:self.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   253
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   254
    slot := weakFunctionRefs identityIndexOf:nil.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   255
    slot ~~ 0 ifTrue:[
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   256
        weakFunctionRefs at:slot put:f.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   257
        ^ f.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   258
    ].
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   259
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   260
    sz := weakFunctionRefs size.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   261
    nW := WeakArray new:(sz + 2).
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   262
    nW replaceFrom:1 to:sz with:weakFunctionRefs startingAt:1.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   263
    nW at:sz+1 put:f.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   264
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   265
    weakFunctionRefs := nW.
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   266
    ^ f
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   267
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   268
    "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
   269
    "Modified: 12.7.1996 / 15:52:07 / cg"
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   270
!
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   271
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   272
hasUndefinedSymbols
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   273
    "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
   274
     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
   275
     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
   276
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   277
    ^ ObjectFileLoader hasUndefinedSymbolsIn:self
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   278
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   279
    "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
   280
!
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   281
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   282
isClassLibHandle
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   283
    "return true, if I am a handle for a class library"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   284
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   285
    ^ handleType == #classLibraryObject 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   286
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   287
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   288
isForCollectedObject
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   289
    "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
   290
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   291
    handleType == #classLibraryObject ifTrue:[
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   292
        ^ (weakClassRefs findFirst:[:x | x notNil]) == 0
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   293
    ].
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   294
    handleType == #methodObject ifTrue:[
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   295
        ^ (weakMethodRef at:1) isNil
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   296
    ].
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   297
    handleType == #functionObject ifTrue:[
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   298
        ^ (weakFunctionRefs findFirst:[:x | x notNil]) == 0
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   299
    ].
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   300
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   301
    ^ false
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   302
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   303
    "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
   304
    "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
   305
!
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   306
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   307
isFunctionObjectHandle
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   308
    "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
   309
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   310
    handleType := #functionObject
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   311
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   312
    "Modified: 12.7.1996 / 15:34:29 / cg"
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   313
    "Created: 12.7.1996 / 15:35:33 / cg"
157
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   314
!
d7f68808a258 reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents: 154
diff changeset
   315
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   316
isMethodHandle
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   317
    "return true, if I am a handle for a single compiled method"
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   318
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   319
    ^ handleType == #methodObject
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   320
!
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 157
diff changeset
   321
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   322
isObsolete
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   323
    "return true, if my clases/method has already been removed from
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   324
     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
   325
154
04716b86ad29 reloading compiled methods
Claus Gittinger <cg@exept.de>
parents: 152
diff changeset
   326
    moduleID notNil ifTrue:[
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   327
        handleType == #classLibraryObject ifTrue:[
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   328
            ^ (weakClassRefs findFirst:[:x | x notNil]) == 0
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   329
        ].
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   330
        handleType == #methodObject ifTrue:[
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   331
            ^ (weakMethodRef at:1) isNil
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   332
        ].
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   333
        handleType == #functionObject ifTrue:[
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   334
            ^ (weakFunctionRefs findFirst:[:x | x notNil]) == 0
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   335
        ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   336
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   337
    ^ false
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   338
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   339
    "Modified: 12.7.1996 / 15:42:21 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   340
! !
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   341
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   342
!ObjectFileHandle  class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   343
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   344
version
299
33a154508328 additional support for non-ST object files (function modules)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   345
    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileHandle.st,v 1.15 1996-07-12 13:54:39 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
   346
! !