Sha256: f7132df1eab1df7efd5f3805504bc94ca7c00e1b3112e96c0d5862b73cd6d2b1

Contents?: true

Size: 424 Bytes

Versions: 3

Compression:

Stored size: 424 Bytes

Contents

# pops the top +:int+ item;
# pushes a new +:bool+ item,
# with value +false+ when the +:int+ is 0, otherwise +true
#
# *needs:* 1 +:int+
#
# *pushes:* 1 +:bool+
#

class BoolFromIntInstruction < Instruction
  def preconditions?
    needs :int, 1
  end
  def setup
    @arg = @context.pop_value(:int)
  end
  def derive
    @result = ValuePoint.new("bool", @arg != 0)
  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/conversion/bool_from_int.rb
nudge-0.2.8 lib/instructions/conversion/bool_from_int.rb
nudge-0.2.7 lib/instructions/conversion/bool_from_int.rb