Sha256: 0b2f091f851959a5630b47b43dcc2841d1447762d1376728fa3dec6491730d89

Contents?: true

Size: 599 Bytes

Versions: 3

Compression:

Stored size: 599 Bytes

Contents

# pops the top 2 items of the +:code+ stack;
# pushes a new ValuePoint onto the +:bool+ stack, with value +true+ if the
# two items' blueprint strings are identical
#
# *needs:* 2 +:code+
#
# *pushes:* 1 +:bool+
#

class CodeEqualQInstruction < Instruction
  def preconditions?
    needs :code, 2
  end
  def setup
    @arg2 = @context.pop_value(:code)
    @arg1 = @context.pop_value(:code)
  end
  def derive
    c1 = NudgeProgram.new(@arg1).blueprint
    c2 = NudgeProgram.new(@arg2).blueprint
    @result = ValuePoint.new("bool", c1 == c2)
  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/code/code_equal_q.rb
nudge-0.2.8 lib/instructions/code/code_equal_q.rb
nudge-0.2.7 lib/instructions/code/code_equal_q.rb