The Trunk: Kernel-nice.483.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-nice.483.mcz

commits-2
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.483.mcz

==================== Summary ====================

Name: Kernel-nice.483
Author: nice
Time: 22 August 2010, 9:41:03.176 pm
UUID: 3fb5df26-bcfa-4958-8ee6-79cf603bb3fa
Ancestors: Kernel-nice.482

Fix WeakMessageSends Part 3.
Thanks to Juan, see http://bugs.squeak.org/view.php?id=7352

Clean-up, but preserve WeakMessageSend>>valueWithEnoughArguments: though it is not used with such receiver (who knows a package might need it).

=============== Diff against Kernel-nice.482 ===============

Item was changed:
  ----- Method: WeakMessageSend>>valueWithEnoughArguments: (in category 'evaluating') -----
  valueWithEnoughArguments: anArray
  "call the selector with enough arguments from arguments and anArray"
+ ^self
+ withEnsuredReceiverAndArgumentsDo: [ :r :a |
+ r
+ perform: selector
+ withArguments: a ]
+ withEnoughArguments: anArray
+ otherwise: [ ]!
- | args |
- self ensureReceiverAndArguments ifFalse: [ ^nil ].
- args := Array new: selector numArgs.
- args replaceFrom: 1
- to: ( arguments size min: args size)
- with: arguments
- startingAt: 1.
- args size > arguments size ifTrue: [
- args replaceFrom: arguments size + 1
- to: (arguments size + anArray size min: args size)
- with: anArray
- startingAt: 1.
- ].
- ^ self receiver perform: selector withArguments: args
- !

Item was added:
+ ----- Method: WeakMessageSend>>withEnsuredReceiverAndArgumentsDo:withEnoughArguments:otherwise: (in category 'private') -----
+ withEnsuredReceiverAndArgumentsDo: aBlock withEnoughArguments: anArray otherwise: altBlock
+ "call the selector with enough arguments from arguments and anArray"
+ | r selfArgs enoughArgs |
+ r := self receiver.
+ r ifNil: [ ^altBlock value ].
+
+ selfArgs := self arguments.
+ selfArgs with: shouldBeNil do: [ :arg :flag |
+ arg ifNil: [ flag ifFalse: [ ^altBlock value ]]
+ ].
+
+ enoughArgs := Array new: selector numArgs.
+ enoughArgs replaceFrom: 1
+ to: ( selfArgs size min: enoughArgs size)
+ with: selfArgs
+ startingAt: 1.
+ enoughArgs size > selfArgs size ifTrue: [
+ enoughArgs replaceFrom: selfArgs size + 1
+ to: (selfArgs size + anArray size min: enoughArgs size)
+ with: anArray
+ startingAt: 1.
+ ].
+ ^aBlock value: r value: enoughArgs!

Item was removed:
- ----- Method: WeakMessageSend>>ensureArguments (in category 'private') -----
- ensureArguments
- "Return true if my arguments haven't gone away"
- arguments ifNotNil: [
- arguments with: shouldBeNil do: [ :arg :flag |
- arg ifNil: [ flag ifFalse: [ ^false ]]
- ]
- ].
- ^true
- !

Item was removed:
- ----- Method: MessageSend>>isValid (in category 'testing') -----
- isValid
- ^true!

Item was removed:
- ----- Method: WeakMessageSend>>ensureReceiverAndArguments (in category 'private') -----
- ensureReceiverAndArguments
-
- "Return true if my receiver hasn't gone away"
- self receiver ifNil: [ ^false ].
-
- "Make sure that my arguments haven't gone away"
- arguments ifNotNil: [
- arguments with: shouldBeNil do: [ :arg :flag |
- arg ifNil: [ flag ifFalse: [ ^false ]]
- ]
- ].
-
- ^true
- !

Item was removed:
- ----- Method: WeakMessageSend>>isValid (in category 'testing') -----
- isValid
- ^self isReceiverOrAnyArgumentGarbage not
- !

Item was removed:
- ----- Method: WeakMessageSend>>ensureReceiver (in category 'private') -----
- ensureReceiver
- "Return true if my receiver hasn't gone away"
- ^self receiver notNil
- !