Class: NameEqualQInstruction

Inherits:
Instruction show all
Defined in:
lib/instructions/name/name_equal_q.rb

Overview

pops the top 2 items of the :name stack; pushes a new ValuePoint onto the :bool stack, with value true if the names are identical

needs: 2 :name

pushes: 1 :bool

Instance Attribute Summary

Attributes inherited from Instruction

#context

Instance Method Summary collapse

Methods inherited from Instruction

all_instructions, #go, inherited, #initialize, #needs, #pushes, to_nudgecode

Constructor Details

This class inherits a constructor from Instruction

Instance Method Details

#cleanupObject



20
21
22
# File 'lib/instructions/name/name_equal_q.rb', line 20

def cleanup
  pushes :bool, @result
end

#deriveObject



17
18
19
# File 'lib/instructions/name/name_equal_q.rb', line 17

def derive
  @result = ValuePoint.new("bool", @arg1 == @arg2)
end

#preconditions?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/instructions/name/name_equal_q.rb', line 10

def preconditions?
  needs :name, 2
end

#setupObject



13
14
15
16
# File 'lib/instructions/name/name_equal_q.rb', line 13

def setup
  @arg2 = @context.pop_value(:name)
  @arg1 = @context.pop_value(:name)
end