Sha256: 34a0dbff634733871edd1729499041dc7bf054646257059e1142f164e56165c3

Contents?: true

Size: 454 Bytes

Versions: 3

Compression:

Stored size: 454 Bytes

Contents

# pops the top 2 items of the +:int+ stack;
# pushes a ValuePoint with their product onto the +:int+ stack
#
# *needs:* 2 +:int+
#
# *pushes:* 1 +:int+
#

class IntMultiplyInstruction < Instruction
  def preconditions?
    needs :int, 2
  end
  def setup
    @arg1 = @context.pop_value(:int)
    @arg2 = @context.pop_value(:int)
  end
  def derive
    @result = ValuePoint.new("int", @arg1 * @arg2)
  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_multiply.rb
nudge-0.2.8 lib/instructions/int/int_multiply.rb
nudge-0.2.7 lib/instructions/int/int_multiply.rb