Class: ExecSInstruction
- Inherits:
-
Instruction
- Object
- Instruction
- ExecSInstruction
- Defined in:
- lib/instructions/exec/exec_s.rb
Overview
Implements the S Combinator on the :exec
stack: if the top three items on the stack are A, B, C (in top-to-bottom order), this pushes
-
a CodeBlock containing B and C (in that order)
-
C
-
A
needs: 3 :exec
items
pushes: 3 :exec
items
Instance Attribute Summary
Attributes inherited from Instruction
Instance Method Summary collapse
Methods inherited from Instruction
all_instructions, #go, inherited, #initialize, #needs, #pushes, to_nudgecode
Constructor Details
This class inherits a constructor from Instruction
Instance Method Details
#cleanup ⇒ Object
24 25 26 27 28 |
# File 'lib/instructions/exec/exec_s.rb', line 24 def cleanup pushes :exec, @s_result pushes :exec, @argC pushes :exec, @argA end |
#derive ⇒ Object
21 22 23 |
# File 'lib/instructions/exec/exec_s.rb', line 21 def derive @s_result = CodeblockPoint.new([@argB,@argC]) end |
#preconditions? ⇒ Boolean
13 14 15 |
# File 'lib/instructions/exec/exec_s.rb', line 13 def preconditions? needs :exec, 3 end |
#setup ⇒ Object
16 17 18 19 20 |
# File 'lib/instructions/exec/exec_s.rb', line 16 def setup @argA = @context.pop(:exec) @argB = @context.pop(:exec) @argC = @context.pop(:exec) end |