Sha256: e53519e0ab504f5076370fe6e977f3fad53519ae586ead4e63d5b03138eb6058

Contents?: true

Size: 478 Bytes

Versions: 3

Compression:

Stored size: 478 Bytes

Contents

# pops the top +:code+ item;
# pushes a new +:int+ with the number of program points in the +:code+
#
# *needs:* 1 +:code+
#
# *pushes:* 1 +:int+
#

class CodePointsInstruction < Instruction
  
  def preconditions?
    needs :code, 1
  end
  
  def setup
    arg_blueprint = @context.pop_value(:code)
    @parsed = NudgeProgram.new(arg_blueprint)
  end
  
  def derive
    @result = ValuePoint.new("int",@parsed.points)
  end
  
  def cleanup
    pushes :int, @result
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nudge-0.2.9 lib/instructions/code/code_points.rb
nudge-0.2.8 lib/instructions/code/code_points.rb
nudge-0.2.7 lib/instructions/code/code_points.rb