Class: CodeExecuteThenPopInstruction
- Inherits:
- 
      Instruction
      
        - Object
- Instruction
- CodeExecuteThenPopInstruction
 
- Defined in:
- lib/instructions/code/code_execute_then_pop.rb
Overview
peeks at the top item from the :code stack (without popping it!); pushes a new block containing that code value and “do code_pop” onto the :exec stack, so the item is executed, then removed from the :code stack
needs: 1 :code
pushes: 1 :exec
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
| 26 27 28 | # File 'lib/instructions/code/code_execute_then_pop.rb', line 26 def cleanup pushes :exec, @result end | 
#derive ⇒ Object
| 18 19 20 21 22 23 24 25 | # File 'lib/instructions/code/code_execute_then_pop.rb', line 18 def derive that_becomes = NudgeProgram.new(@arg) if that_becomes.parses? @result = CodeblockPoint.new([NudgeProgram.new(@arg).linked_code,InstructionPoint.new("code_pop")]) else @result = CodeblockPoint.new([InstructionPoint.new("code_pop")]) end end | 
#preconditions? ⇒ Boolean
| 11 12 13 14 | # File 'lib/instructions/code/code_execute_then_pop.rb', line 11 def preconditions? needs CodePopInstruction needs :code, 1 end | 
#setup ⇒ Object
| 15 16 17 | # File 'lib/instructions/code/code_execute_then_pop.rb', line 15 def setup @arg = @context.peek_value(:code) # does not pop the stack initially! end |