Sha256: 0974f04dc698978aed670434e4bf7db860e3e28ca69fbc060093f3630b68f3d7

Contents?: true

Size: 494 Bytes

Versions: 3

Compression:

Stored size: 494 Bytes

Contents

# 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+
#

class IntMinInstruction < Instruction
  def preconditions?
    needs :int, 2
  end
  def setup
    @arg2 = @context.pop_value(:int)
    @arg1 = @context.pop_value(:int)
  end
  def derive
      @min = [@arg1,@arg2].min
      @result = ValuePoint.new("int", @min)
  end
  def cleanup
    pushes :int, @result
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nudge-0.2.9 lib/instructions/int/int_min.rb
nudge-0.2.8 lib/instructions/int/int_min.rb
nudge-0.2.7 lib/instructions/int/int_min.rb