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