Class: FloatMaxInstruction
- Inherits:
-
Instruction
- Object
- Instruction
- FloatMaxInstruction
- Defined in:
- lib/instructions/float/float_max.rb
Overview
pops the top 2 items of the :float
stack; pushes a new ValuePoint onto the :float
stack with the largest of the two values
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
20 21 22 |
# File 'lib/instructions/float/float_max.rb', line 20 def cleanup pushes :float, @result end |
#derive ⇒ Object
17 18 19 |
# File 'lib/instructions/float/float_max.rb', line 17 def derive @result = ValuePoint.new("float", [@arg1, @arg2].max) end |
#preconditions? ⇒ Boolean
10 11 12 |
# File 'lib/instructions/float/float_max.rb', line 10 def preconditions? needs :float, 2 end |
#setup ⇒ Object
13 14 15 16 |
# File 'lib/instructions/float/float_max.rb', line 13 def setup @arg2 = @context.pop_value(:float) @arg1 = @context.pop_value(:float) end |