Module: YankInstruction
- Included in:
- BoolYankInstruction, CodeYankInstruction, ExecYankInstruction, FloatYankInstruction, IntYankInstruction, NameYankInstruction
- 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.
300 301 302 |
# File 'lib/instructions/infrastructure.rb', line 300 def target_stack @target_stack end |
Instance Method Details
#cleanup ⇒ Object
332 333 334 335 |
# File 'lib/instructions/infrastructure.rb', line 332 def cleanup moved_value = @context.stacks[@target_stack].entries.delete_at(@which) @context.stacks[@target_stack].push(moved_value) end |
#derive ⇒ Object
320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/instructions/infrastructure.rb', line 320 def derive max = @context.stacks[@target_stack].depth-1 case when @from_where < 0 @which = max when @from_where > max @which = 0 else @which = max - @from_where end end |
#initialize(context, target_stack) ⇒ Object
302 303 304 305 |
# File 'lib/instructions/infrastructure.rb', line 302 def initialize(context, target_stack) @target_stack = target_stack super(context) end |
#preconditions? ⇒ Boolean
307 308 309 310 311 312 313 314 |
# File 'lib/instructions/infrastructure.rb', line 307 def preconditions? if @target_stack != :int needs :int, 1 needs @target_stack, 1 else needs :int, 2 end end |
#setup ⇒ Object
316 317 318 |
# File 'lib/instructions/infrastructure.rb', line 316 def setup @from_where = @context.pop_value(:int) end |