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