Module: SwapInstruction
- Included in:
- BoolSwapInstruction, CodeSwapInstruction, ExecSwapInstruction, FloatSwapInstruction, IntSwapInstruction, NameSwapInstruction
- Defined in:
- lib/instructions/infrastructure.rb
Instance Attribute Summary collapse
-
#target_stack ⇒ Object
readonly
Returns the value of attribute target_stack.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #derive ⇒ Object
- #initialize(context, target_stack) ⇒ Object
- #preconditions? ⇒ Boolean
- #setup ⇒ Object
Instance Attribute Details
#target_stack ⇒ Object (readonly)
Returns the value of attribute target_stack.
144 145 146 |
# File 'lib/instructions/infrastructure.rb', line 144 def target_stack @target_stack end |
Instance Method Details
#cleanup ⇒ Object
160 161 162 163 |
# File 'lib/instructions/infrastructure.rb', line 160 def cleanup pushes @target_stack, @result1 pushes @target_stack, @result2 end |
#derive ⇒ Object
158 159 |
# File 'lib/instructions/infrastructure.rb', line 158 def derive end |
#initialize(context, target_stack) ⇒ Object
146 147 148 149 |
# File 'lib/instructions/infrastructure.rb', line 146 def initialize(context, target_stack) @target_stack = target_stack super(context) end |
#preconditions? ⇒ Boolean
151 152 153 |
# File 'lib/instructions/infrastructure.rb', line 151 def preconditions? needs @target_stack, 2 end |
#setup ⇒ Object
154 155 156 157 |
# File 'lib/instructions/infrastructure.rb', line 154 def setup @result1 = @context.pop(@target_stack) @result2 = @context.pop(@target_stack) end |