Sha256: ca1144f66be9f462a72e471647ff24043d2c7401f91e619f6b524bfc203e862e

Contents?: true

Size: 493 Bytes

Versions: 3

Compression:

Stored size: 493 Bytes

Contents

# pops the top 2 items of the +:int+ stack;
# pushes a new ValuePoint onto the +:bool+ stack, with value +true+ if the integers are identical
#
# *needs:* 2 +:int+
#
# *pushes:* 1 +:bool+
#

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

Version data entries

3 entries across 3 versions & 1 rubygems

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