'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 13 May 2009 at 11:36:49 am'!

!WeakMessageSend methodsFor: 'private' stamp: 'jmv 5/13/2009 10:25'!
withEnsuredReceiverAndArgumentsDo: aBlock
	"Grab real references to receiver and arguments. If they still exist, evaluate aBlock."

	"Return if my receiver has gone away"
	| r a |
	r := self receiver.
	r ifNil: [ ^nil ].

	
	"Make sure that my arguments haven't gone away"
	a := Array withAll: arguments.
	a with: shouldBeNil do: [ :arg :flag |
		arg ifNil: [ flag ifFalse: [ ^nil ]]
	].

	^aBlock value: r value: a! !

!WeakMessageSend methodsFor: 'private' stamp: 'jmv 5/13/2009 10:25'!
withEnsuredReceiverDo: aBlock
	"Grab a real reference to receive. If still there, evaluate aBlock."

	"Return if my receiver has gone away"
	| r |
	r := self receiver.
	r ifNil: [ ^nil ].

	^aBlock value: r! !

