
# fileIn("s8/library/scripting/ScriptSteps.st")
smalltalk.bind(smalltalk.CompiledScript,"compiledScript",0
,smalltalk.__f__("""(self):
	#CompiledScript>>#compiledScript
	return self 
""","CompiledScript_compiledScript")
,"ScriptSteps-simulating","""compiledScript
	" Returns the (compiled)script to execute when simulating the receiver. "

	^self """,nil)

smalltalk.bind(smalltalk.Script,"stepsFor:entering:withArguments:",0
,smalltalk.__f__("""(self,aReceiver,aMethod,array):
	#Script>>#stepsFor:entering:withArguments:
	__0__=smalltalk.newContext()
	def __blk1__(each):
		return smalltalk.SimulationStep.for_doing_in_(self,each,__0__.ctx) 
	__0__.ctx=nil
	__0__.ctx=self.contextFor_binding_to_(aReceiver,self.argsIn_(aMethod),array) 
	return self.actionsIn_(__0__.ctx).collect_(smalltalk.blk(__blk1__,1)) 
""","Script_stepsFor_entering_withArguments_")
,"ScriptSteps-simulating","""stepsFor: aReceiver entering: aMethod withArguments: array
	" Returns the steps to evaluate execution of the receiver activating aMethod. "

	| ctx |
	ctx := self contextFor: aReceiver binding: (self argsIn: aMethod) to: array.
	^(self actionsIn: ctx) collect: [:each|
		SimulationStep for: self doing: each in: ctx
	]""",nil)

smalltalk.bind(smalltalk.ParseNode,"actionsIn:",0
,smalltalk.__f__("""(self,aContext):
	#ParseNode>>#actionsIn:
	def __blk1__():
		return self.evaluateIn_(aContext) 
	return smalltalk.Array.with_(smalltalk.blk(__blk1__,0)) 
""","ParseNode_actionsIn_")
,"ScriptSteps-simulating","""actionsIn: aContext
	" Returns the steps to evaluate while simulating execution of the receiver in aContext.
	The default implementation will evaluate the receiver in a single step.
	This method can be refined by the subclasses.
	"

	^Array with: [ self evaluateIn: aContext ] """,nil)

smalltalk.bind(smalltalk.Script,"actionsIn:",0
,smalltalk.__f__("""(self,aContext):
	#Script>>#actionsIn:
	__0__=smalltalk.newContext()
	def __blk1__(simulator):
		def __blk2__(value):
			return simulator.exit_(value) 
		return self.exitBlock_(smalltalk.blk(__blk2__,1)) 
	__0__.result=nil
	__0__.result=smalltalk.superReceiver(smalltalk.Script,self).actionsIn_(aContext) 
	__0__.result.addFirst_(smalltalk.blk(__blk1__,1)) 
	return __0__.result 
""","Script_actionsIn_")
,"ScriptSteps-simulating","""actionsIn: aContext
	" Returns the steps to evaluate while simulating execution of the receiver in aContext. "

	| result |
	result := super actionsIn: aContext.
	result addFirst: [:simulator|
		self exitBlock: [:value| simulator exit: value ]
	].
	^result """,nil)

smalltalk.bind(smalltalk.ParseStatements,"inject:in:",0
,smalltalk.__f__("""(self,simulator,aContext):
	#ParseStatements>>#inject:in:
	return self.inject_in_catch_curtail_finally_(simulator,aContext,nil,nil,nil) 
""","ParseStatements_inject_in_")
,"ScriptSteps-internal","""inject: simulator in: aContext
	" Private - Add the steps for evaluation of contents of the receiver in aContext. "

	^self	inject: simulator in: aContext
		catch: nil curtail: nil finally: nil """,nil)

smalltalk.bind(smalltalk.ParseStatements,"inject:in:catch:curtail:finally:",0
,smalltalk.__f__("""(self,simulator,aContext,catcher,curtail,final):
	#ParseStatements>>#inject:in:catch:curtail:finally:
	simulator.addBlock_contents_in_catch_curtail_finally_(self,self.statements(),aContext,catcher,curtail,final) 
	if smalltalk.b(self.isEmpty()):
		def __blk1__():
			return simulator.value_(nil) 
		return simulator.add_step_in_(self,smalltalk.blk(__blk1__,0),aContext) 
	 
	return self 
""","ParseStatements_inject_in_catch_curtail_finally_")
,"ScriptSteps-internal","""inject: simulator in: aContext catch: catcher curtail: curtail finally: final
	" Private - Add the steps for evaluation of contents of the receiver in aContext. "

	simulator
		addBlock: self contents: self statements in: aContext
		catch: catcher curtail: curtail finally: final.
	self isEmpty ifTrue: [
		^simulator add: self step: [ simulator value: nil ] in: aContext
	].""",nil)

smalltalk.bind(smalltalk.ParseStatements,"content:actionsIn:",0
,smalltalk.__f__("""(self,simulator,aContext):
	#ParseStatements>>#content:actionsIn:
	return self.inject_in_(simulator,aContext) 
""","ParseStatements_content_actionsIn_")
,"ScriptSteps-internal","""content: simulator actionsIn: aContext
	" Private - Add the steps for evaluation of contents of the receiver in aContext. "

	^self inject: simulator in: aContext """,nil)

smalltalk.bind(smalltalk.ParseStatements,"actionsIn:",0
,smalltalk.__f__("""(self,aContext):
	#ParseStatements>>#actionsIn:
	def __blk1__(simulator):
		def __blk2__(ctx):
			return self.content_actionsIn_(simulator,ctx) 
		return smalltalk.S8Context.in_clear_do_(aContext,self.contextVariables(),smalltalk.blk(__blk2__,1)) 
	if smalltalk.b(self.isEmpty()):
		def __blk3__(simulator):
			return self.content_actionsIn_(simulator,aContext) 
		return smalltalk.Array.with_(smalltalk.blk(__blk3__,1)) 
	 
	return smalltalk.Array.with_(smalltalk.blk(__blk1__,1)) 
""","ParseStatements_actionsIn_")
,"ScriptSteps-simulating","""actionsIn: aContext
	" Returns the steps to evaluate while simulating execution of the receiver in aContext. "

	self isEmpty ifTrue: [
		^Array with: [:simulator| self content: simulator actionsIn: aContext ]
	].
	^Array	with: [:simulator|
			S8Context
				in: aContext clear: self contextVariables
				do: [:ctx| self content: simulator actionsIn: ctx ]
		] """,nil)

smalltalk.bind(smalltalk.BlockClosureNode,"content:actionsIn:",0
,smalltalk.__f__("""(self,simulator,aContext):
	#BlockClosureNode>>#content:actionsIn:
	__0__=smalltalk.newContext()
	def __blk1__():
		__0__.block.simulator_(simulator) 
		return simulator.value_(__0__.block) 
	__0__.block=nil
	__0__.block=smalltalk.SimulationBlock.for_in_(self,aContext) 
	return simulator.add_step_in_(self,smalltalk.blk(__blk1__,0),aContext) 
""","BlockClosureNode_content_actionsIn_")
,"ScriptSteps-internal","""content: simulator actionsIn: aContext
	" Private - Add the steps for evaluation of contents of the receiver in aContext. "

	| block |
	block := SimulationBlock for: self in: aContext.
	^simulator add: self step: [
		block simulator: simulator.		
		simulator value: block
	] in: aContext """,nil)

smalltalk.bind(smalltalk.CascadedMessageNode,"content:actionsIn:",0
,smalltalk.__f__("""(self,simulator,aContext):
	#CascadedMessageNode>>#content:actionsIn:
	__0__=smalltalk.newContext()
	def __blk1__(each):
		return each.shallowCopy() 
	def __blk2__():
		return simulator.add_in_(__0__.head,aContext) 
	def __blk3__():
		__1__=smalltalk.newContext()
		def __blk4__(each):
			return each.receiver_(__1__.literal) 
		__1__.value=nil
		__1__.literal=nil
		__1__.value=simulator.value() 
		__1__.literal=smalltalk.ParseLiteral.sourceRange_value_(__0__.head.sourceRange(),__1__.value) 
		__0__.tail.do_(smalltalk.blk(__blk4__,1)) 
		return simulator.addAll_in_(__0__.tail,aContext) 
	__0__.head=nil
	__0__.tail=nil
	__0__.tail=self.statements().collect_(smalltalk.blk(__blk1__,1)) 
	if smalltalk.b(__0__.tail.isEmpty()):
		return self.error_(smalltalk.String("Empty cascade - Should not happen")) 
	 
	__0__.head=__0__.tail.first().receiver() 
	return simulator.add_steps_in_(self,smalltalk.Array.with_with_(smalltalk.blk(__blk2__,0),smalltalk.blk(__blk3__,0)),aContext) 
""","CascadedMessageNode_content_actionsIn_")
,"ScriptSteps-internal","""content: simulator actionsIn: aContext
	" Private - Add the steps for evaluation of contents of the receiver in aContext. "

	| head tail |
	tail := self statements collect: [:each| each shallowCopy ].
	tail isEmpty ifTrue: [
		^self error: 'Empty cascade - Should not happen'
	].
	head := tail first receiver.
	^simulator add: self steps: (Array
		with: [ simulator add: head in: aContext ]
		with: [ | value literal |
			value := simulator value.
			literal := ParseLiteral
				sourceRange: head sourceRange
				value: value.
			tail do: [:each| each receiver: literal ].
			" aContext at: '$rec' put: value. "
			simulator addAll: tail in: aContext
		]) in: aContext """,nil)

smalltalk.bind(smalltalk.ParseVariable,"actionsIn:",0
,smalltalk.__f__("""(self,aContext):
	#ParseVariable>>#actionsIn:
	__0__=smalltalk.newContext()
	def __blk1__(simulator):
		return simulator.value_(self.valueIn_(aContext)) 
	__0__.result=nil
	__0__.result=smalltalk.Array.with_(smalltalk.blk(__blk1__,1)) 
	if smalltalk.b(smalltalk.notNil_(getattr(self,"@indices",nil))):
		def __blk2__(simulator):
			return simulator.value_(self.index_in_(simulator.value(),aContext)) 
		__0__.result.add_(smalltalk.blk(__blk2__,1)) 
	 
	return __0__.result 
""","ParseVariable_actionsIn_")
,"ScriptSteps-simulating","""actionsIn: aContext
	" Returns the steps to evaluate while simulating execution of the receiver in aContext. "

	| result |
	result := Array with: [:simulator| simulator value: (self valueIn: aContext) ].
	indices notNil ifTrue: [
		result add: [:simulator| simulator value: (self index: simulator value in: aContext) ]
	].
	^result """,nil)

smalltalk.bind(smalltalk.MethodReturnNode,"actionsIn:",0
,smalltalk.__f__("""(self,aContext):
	#MethodReturnNode>>#actionsIn:
	def __blk1__(simulator):
		return simulator.add_in_(self.expression(),aContext) 
	def __blk2__(simulator):
		def __blk3__():
			return getattr(self,"@exitBlock",nil).value_(simulator.value()) 
		return simulator.return_in_then_(self,aContext,smalltalk.blk(__blk3__,0)) 
	return smalltalk.Array.with_with_(smalltalk.blk(__blk1__,1),smalltalk.blk(__blk2__,1)) 
""","MethodReturnNode_actionsIn_")
,"ScriptSteps-simulating","""actionsIn: aContext
	" Returns the steps to evaluate while simulating execution of the receiver in aContext. "

	^Array
		with: [:simulator| simulator add: self expression in: aContext ]
		with: [:simulator|
			simulator return: self in: aContext then: [
				exitBlock value: simulator value
			]
		] """,nil)

smalltalk.bind(smalltalk.AssignNode,"actionsIn:",0
,smalltalk.__f__("""(self,aContext):
	#AssignNode>>#actionsIn:
	def __blk1__(simulator):
		return simulator.add_in_(self.expression(),aContext) 
	def __blk2__(simulator):
		return self.variable().bind_in_(simulator.value(),aContext) 
	return smalltalk.Array.with_with_(smalltalk.blk(__blk1__,1),smalltalk.blk(__blk2__,1)) 
""","AssignNode_actionsIn_")
,"ScriptSteps-simulating","""actionsIn: aContext
	" Returns the steps to evaluate while simulating execution of the receiver in aContext. "

	^Array
		with: [:simulator| simulator add: self expression in: aContext ]
		with: [:simulator| self variable bind: simulator value in: aContext ] """,nil)

smalltalk.bind(smalltalk.MessageNode,"actionsIn:",0
,smalltalk.__f__("""(self,aContext):
	#MessageNode>>#actionsIn:
	def __blk1__(simulator):
		return simulator.add_in_(self.receiver(),aContext) 
	def __blk2__(simulator):
		return simulator.add_steps_in_(self,self.steps_in_(simulator.value(),aContext),aContext) 
	return smalltalk.Array.with_with_(smalltalk.blk(__blk1__,1),smalltalk.blk(__blk2__,1)) 
""","MessageNode_actionsIn_")
,"ScriptSteps-simulating","""actionsIn: aContext
	" Returns the steps to evaluate while simulating execution of the receiver in aContext. "

	^Array
		with: [:simulator| simulator add: self receiver in: aContext ]
		with: [:simulator| simulator add: self steps: (self steps: simulator value in: aContext) in: aContext ] """,nil)

smalltalk.bind(smalltalk.MessageNode,"steps:in:",0
,smalltalk.__f__("""(self,anObject,aContext):
	#MessageNode>>#steps:in:
	__0__=smalltalk.newContext()
	def __blk1__():
		return smalltalk.booleanNot_(self.receiver().isOO()) 
	def __blk2__():
		return self.receiver() 
	def __blk3__():
		return self 
	def __blk4__(simulator):
		return simulator.collect_all_in_(self,self.args(),aContext) 
	def __blk5__(simulator):
		__1__=smalltalk.newContext()
		__1__.send=nil
		__1__.send=__0__.sender.stepsToSend_to_withArguments_in_(self.selector(),anObject,simulator.value(),aContext) 
		return simulator.add_steps_in_(self,__1__.send,aContext) 
	__0__.sender=nil
	__0__.sender=smalltalk.if_true_false_(smalltalk.boolean_or_(self.receiver().isSuper(),smalltalk.blk(__blk1__,0)),smalltalk.blk(__blk2__,0),smalltalk.blk(__blk3__,0)) 
	return smalltalk.Array.with_with_(smalltalk.blk(__blk4__,1),smalltalk.blk(__blk5__,1)) 
""","MessageNode_steps_in_")
,"ScriptSteps-simulating","""steps: anObject in: aContext
	" Private - Returns the steps to simulate message sent to anObject in aContext. "

	| sender |
	sender := (self receiver isSuper or: [ self receiver isOO not ])
		ifTrue: [ self receiver ] ifFalse: [ self ].
	^Array	with: [:simulator| simulator collect: self all: self args in: aContext ]
		with: [:simulator| | send |
			send := sender
				stepsToSend: self selector
				to: anObject withArguments: simulator value
				in: aContext.
			simulator add: self steps: send in: aContext 
		] """,nil)

smalltalk.bind(smalltalk.MessageNode,"stepsToSend:to:withArguments:in:",0
,smalltalk.__f__("""(self,msg,anObject,objects,aContext):
	#MessageNode>>#stepsToSend:to:withArguments:in:
	def __blk1__():
		nil 
	def __blk2__(simulator):
		return simulator.activate_message_for_withArguments_((anObject).__class__,msg,anObject,objects) 
	if smalltalk.b(smalltalk.notNil_((self).__class__.actionToSend_ifAbsent_(msg,smalltalk.blk(__blk1__,0)))):
		def __blk3__(simulator):
			return simulator.value_(self.send_to_withArguments_in_(msg,anObject,objects,aContext)) 
		return smalltalk.Array.with_(smalltalk.blk(__blk3__,1)) 
	 
	return smalltalk.Array.with_(smalltalk.blk(__blk2__,1)) 
""","MessageNode_stepsToSend_to_withArguments_in_")
,"ScriptSteps-simulating","""stepsToSend: msg to: anObject withArguments: objects in: aContext
	" Private - Returns the steps to simulate message sent to anObject in aContext. "

	(self class actionToSend: msg ifAbsent: []) notNil ifTrue: [ "optimized/native message sent"
		^Array with: [:simulator|
			simulator value: (self send: msg to: anObject withArguments: objects in: aContext)
		]
	].
	^Array with: [:simulator|
		simulator
			activate: anObject class message: msg
			for: anObject withArguments: objects
	] """,nil)

smalltalk.bind(smalltalk.NativeMessageNode,"stepsToSend:to:withArguments:in:",0
,smalltalk.__f__("""(self,msg,anObject,values,aContext):
	#NativeMessageNode>>#stepsToSend:to:withArguments:in:
	def __blk1__(simulator):
		return simulator.value_(self.send_to_withArguments_in_(msg,anObject,values,aContext)) 
	return smalltalk.Array.with_(smalltalk.blk(__blk1__,1)) 
""","NativeMessageNode_stepsToSend_to_withArguments_in_")
,"ScriptSteps-simulating","""stepsToSend: msg to: anObject withArguments: values in: aContext
	" Private - Returns the steps to simulate message sent to anObject in aContext. "

	^Array with: [:simulator|
		simulator value: (self
			send: msg to: anObject
			withArguments: values in: aContext)
	] """,nil)

smalltalk.bind(smalltalk.ParseSuper,"stepsToSend:to:withArguments:in:",0
,smalltalk.__f__("""(self,msg,anObject,values,aContext):
	#ParseSuper>>#stepsToSend:to:withArguments:in:
	def __blk1__(simulator):
		__1__=smalltalk.newContext()
		def __blk2__():
			return simulator.activate_message_for_withArguments_((getattr(self,"@implementor",nil)).__class__,smalltalk.String("missingImplementorFor:"),getattr(self,"@implementor",nil),smalltalk.Array.with_(msg)) 
		def __blk3__():
			return simulator.activate_message_for_withArguments_(__1__.cls,msg,anObject,values) 
		__1__.mth=nil
		__1__.cls=nil
		__1__.cls=getattr(self,"@implementor",nil).superclass() 
		if smalltalk.b(smalltalk.notNil_(__1__.cls)):
			__1__.mth=__1__.cls._gt_gt_gt(msg) 
		 
		return smalltalk.if_true_false_(smalltalk.isNil_(__1__.mth),smalltalk.blk(__blk2__,0),smalltalk.blk(__blk3__,0)) 
	return smalltalk.Array.with_(smalltalk.blk(__blk1__,1)) 
""","ParseSuper_stepsToSend_to_withArguments_in_")
,"ScriptSteps-simulating","""stepsToSend: msg to: anObject withArguments: values in: aContext
	" Private - Returns the steps to simulate message sent to anObject in aContext. "

	^Array with: [:simulator| | mth cls |
		cls := implementor superclass.
		cls notNil ifTrue: [ mth := cls >>> msg ].
		mth isNil ifTrue: [
			simulator
				activate: implementor class message: #missingImplementorFor:
				for: implementor withArguments: (Array with: msg)
		] ifFalse: [
			simulator
				activate: cls message: msg
				for: anObject withArguments: values
		]
	] """,nil)

smalltalk.bind(smalltalk.ParseNoReceiver,"stepsToSend:to:withArguments:in:",0
,smalltalk.__f__("""(self,msg,anObject,values,aContext):
	#ParseNoReceiver>>#stepsToSend:to:withArguments:in:
	def __blk1__(simulator):
		return simulator.value_(self.send_to_withArguments_in_(msg,anObject,values,aContext)) 
	return smalltalk.Array.with_(smalltalk.blk(__blk1__,1)) 
""","ParseNoReceiver_stepsToSend_to_withArguments_in_")
,"ScriptSteps-simulating","""stepsToSend: msg to: anObject withArguments: values in: aContext
	" Private - Returns the steps to simulate message sent to anObject in aContext. "

	^Array with: [:simulator|
		simulator value: (self send: msg to: anObject withArguments: values in: aContext)
	] """,nil)
