﻿'From Squeak6.1alpha of 18 September 2022 [latest update: #22216] on 19 September 2022 at 10:35:49 pm'!

!Context methodsFor: 'closure support' stamp: 'jar 9/19/2022 22:32'!
asContextWithSender: aContext
	self sender: aContext.
	^ self! !

!Context methodsFor: 'private' stamp: 'jar 9/19/2022 22:32'!
insertSender: aContext
	"Insert aContext and its sender chain between me and my sender.  Return new callee of my original sender."

	| ctxt |
	ctxt := aContext bottomContext.
	ctxt sender: sender.
	self sender: aContext.
	^ ctxt! !

!Context methodsFor: 'private' stamp: 'jar 9/19/2022 22:30'!
sender: aContextOrNil 

	sender := aContextOrNil ifNotNil: [aContextOrNil asContext]! !

!Context methodsFor: 'private' stamp: 'jar 9/19/2022 22:31'!
setSender: s receiver: r arguments: args 
	"Initialize the receiver's initial state."

	pc := method initialPC.
	self stackp: method numTemps.
	self sender: s.
	receiver := r.
	closureOrNil := nil.
	1 to: args size do: [:i | self at: i put: (args at: i)]! !

!Context methodsFor: 'private' stamp: 'jar 9/19/2022 22:31'!
setSender: s receiver: r closure: c startpc: startpc
	"Create the receiver's initial state."

	self sender: s.
	receiver := r.
	closureOrNil := c.
	pc := startpc.
	stackp := 0! !

!Context methodsFor: 'debugger access' stamp: 'jar 9/19/2022 22:31'!
swapSender: coroutine 
	"Replace the receiver's sender with coroutine and answer the receiver's 
	previous sender. For use in coroutining."

	| oldSender |
	oldSender := sender.
	self sender: coroutine.
	^oldSender! !

