Class: CodeAtomQInstruction

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

Overview

pops the top item of the :code stack; pushes a ValuePoint onto the :bool stack that is false only if the :code item was a CodeBlockPoint, (that is, a multi-line Nudge program)

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



22
23
24
# File 'lib/instructions/code/code_atom_q.rb', line 22

def cleanup
  pushes :bool, @result
end

#deriveObject



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

def derive
  atomQ = @arg1.parses? && @arg1.points == 1
  @result = ValuePoint.new("bool", atomQ)
end

#preconditions?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/instructions/code/code_atom_q.rb', line 11

def preconditions?
  needs :code, 1
end

#setupObject



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

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