Sha256: c77fa3b4cbfbc59e485481063944827d1edd776872f8728cf076d26efd82c136

Contents?: true

Size: 595 Bytes

Versions: 3

Compression:

Stored size: 595 Bytes

Contents

# 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+
#

class CodeAtomQInstruction < Instruction
  def preconditions?
    needs :code, 1
  end
  def setup
    arg_blueprint = @context.pop_value(:code)
    @arg1 = NudgeProgram.new(arg_blueprint)
  end
  def derive
    atomQ = @arg1.parses? && @arg1.points == 1
    @result = ValuePoint.new("bool", atomQ)
  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_atom_q.rb
nudge-0.2.8 lib/instructions/code/code_atom_q.rb
nudge-0.2.7 lib/instructions/code/code_atom_q.rb