Sha256: 4858c78645d7c0f3d6a92cd7171ff3b80fa724c2ca93be5a3346ff453dd31cb4

Contents?: true

Size: 414 Bytes

Versions: 3

Compression:

Stored size: 414 Bytes

Contents

# pops the top item of the +:int+ stack;
# pushes a ValuePoint with its absolute value onto the +:int+ stack
#
# *needs:* 1 +:int+
#
# *pushes:* 1 +:int+
#

class IntAbsInstruction < Instruction  
  def preconditions?
    needs :int, 1
  end
  def setup
    @arg1 = @context.pop_value(:int)
  end
  def derive
      @result = ValuePoint.new("int", @arg1.abs)
  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_abs.rb
nudge-0.2.8 lib/instructions/int/int_abs.rb
nudge-0.2.7 lib/instructions/int/int_abs.rb