--- a/ObjectFileHandle.st Thu Jun 22 17:25:31 2006 +0200
+++ b/ObjectFileHandle.st Thu Jun 22 18:13:48 2006 +0200
@@ -301,73 +301,39 @@
!ObjectFileHandle methodsFor:'queries'!
getFunction:aString
- "return a function object for an entry in the module represented by
- the receiver."
+ "return a function object for an entry in the module represented by the receiver."
+
+ |f|
- |address f slot sz nW|
-
- address := ObjectFileLoader getFunction:aString from:self.
- address isNil ifTrue:[
+ f := ExternalFunction basicNew.
+ f setName:aString moduleHandle:self.
+ (self getFunctionAddress:aString into:f) isNil ifTrue:[
^ nil
].
-
- weakFunctionRefs isNil ifTrue:[
- handleType := #functionObject.
- f := ExternalFunction basicNew code:address.
- f setName:aString moduleHandle:self.
- weakFunctionRefs := WeakArray with:f.
- ^ f.
- ].
-
- weakFunctionRefs nonNilElementsDo:[:anExternalFunction |
- anExternalFunction code = address ifTrue:[
- ^ anExternalFunction
- ]
- ].
-
- f := ExternalFunction basicNew code:address.
- f setName:aString moduleHandle:self.
-
- slot := weakFunctionRefs identityIndexOf:nil.
- slot ~~ 0 ifTrue:[
- weakFunctionRefs at:slot put:f.
- ^ f.
- ].
-
- sz := weakFunctionRefs size.
- nW := WeakArray new:(sz + 2).
- nW replaceFrom:1 to:sz with:weakFunctionRefs startingAt:1.
- nW at:sz+1 put:f.
-
- weakFunctionRefs := nW.
- ^ f
-
- "Created: 12.7.1996 / 14:59:09 / cg"
- "Modified: 18.10.1996 / 20:59:54 / cg"
+ ^ f.
!
getFunctionAddress:aString into:anExternalFunction
"fill the code address of the external function named aString into anExternalFunction.
Returns the address, or nil."
- |address f slot sz nW|
+ |address slot sz nW|
address := ObjectFileLoader getFunction:aString from:self.
address isNil ifTrue:[
+ anExternalFunction code:0.
^ nil
].
anExternalFunction code:address.
weakFunctionRefs isNil ifTrue:[
handleType := #functionObject.
- weakFunctionRefs := WeakArray with:f.
+ weakFunctionRefs := WeakArray with:anExternalFunction.
^ address.
].
- weakFunctionRefs nonNilElementsDo:[:eachExternalFunction |
- eachExternalFunction == anExternalFunction ifTrue:[
- ^ address
- ]
+ (weakFunctionRefs includesIdentical:anExternalFunction) ifTrue:[
+ ^ address
].
slot := weakFunctionRefs identityIndexOf:nil.
@@ -375,13 +341,14 @@
weakFunctionRefs at:slot put:anExternalFunction.
^ address.
].
+ weakFunctionRefs := weakFunctionRefs copyWith:anExternalFunction.
- sz := weakFunctionRefs size.
- nW := WeakArray new:(sz + 2).
- nW replaceFrom:1 to:sz with:weakFunctionRefs startingAt:1.
- nW at:sz+1 put:anExternalFunction.
-
- weakFunctionRefs := nW.
+"/ sz := weakFunctionRefs size.
+"/ nW := WeakArray new:(sz + 1).
+"/ nW replaceFrom:1 to:sz with:weakFunctionRefs startingAt:1.
+"/ nW at:sz+1 put:anExternalFunction.
+"/
+"/ weakFunctionRefs := nW.
^ address
!
@@ -492,5 +459,5 @@
!ObjectFileHandle class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileHandle.st,v 1.33 2006-04-26 11:26:08 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileHandle.st,v 1.34 2006-06-22 16:13:48 ca Exp $'
! !