Class: IntSubtractInstruction
- Inherits:
-
Instruction
- Object
- Instruction
- IntSubtractInstruction
- Defined in:
- lib/instructions/int/int_subtract.rb
Overview
pops the top 2 items of the :int
stack; pushes a ValuePoint with their difference onto the :int
stack
note: the top item is the value subtracted from the second stack item’s value
needs: 2 :int
pushes: 1 :int
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
23 24 25 |
# File 'lib/instructions/int/int_subtract.rb', line 23 def cleanup pushes :int, @result end |
#derive ⇒ Object
19 20 21 22 |
# File 'lib/instructions/int/int_subtract.rb', line 19 def derive @diff = @arg1-@arg2 @result = ValuePoint.new("int", @diff) end |
#preconditions? ⇒ Boolean
12 13 14 |
# File 'lib/instructions/int/int_subtract.rb', line 12 def preconditions? needs :int, 2 end |
#setup ⇒ Object
15 16 17 18 |
# File 'lib/instructions/int/int_subtract.rb', line 15 def setup @arg2 = @context.pop_value(:int) @arg1 = @context.pop_value(:int) end |