Sha256: faaf9e4e5d05c8974f250faf16730a242803c4ac78dc829125e8dd84f5871424

Contents?: true

Size: 476 Bytes

Versions: 3

Compression:

Stored size: 476 Bytes

Contents

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

class BoolXorInstruction < Instruction
  
  def preconditions?
    needs :bool, 2
  end
  
  def setup
    @arg1 = @context.pop_value(:bool)
    @arg2 = @context.pop_value(:bool)
  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/bool/bool_xor.rb
nudge-0.2.8 lib/instructions/bool/bool_xor.rb
nudge-0.2.7 lib/instructions/bool/bool_xor.rb