Class: CodeNullQInstruction

Inherits:
Instruction show all
Defined in:
lib/instructions/code/code_null_q.rb

Overview

pops the top :code item; pushes a new :bool item with value true if the :code is an empty block

needs: 1 :code

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



23
24
25
# File 'lib/instructions/code/code_null_q.rb', line 23

def cleanup
  pushes :bool, @result
end

#deriveObject



19
20
21
# File 'lib/instructions/code/code_null_q.rb', line 19

def derive
  @result = ValuePoint.new("bool", @arg1 == "block {}")
end

#preconditions?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/instructions/code/code_null_q.rb', line 10

def preconditions?
  needs :code, 1
end

#setupObject



14
15
16
17
# File 'lib/instructions/code/code_null_q.rb', line 14

def setup
  arg_blueprint = @context.pop_value(:code)
  @arg1 = NudgeProgram.new(arg_blueprint).blueprint
end