Sha256: 036483b8e2a847855fa0f6a850a9eb9c20f7420e24aad08aa550ccf7a3fd0efe

Contents?: true

Size: 535 Bytes

Versions: 3

Compression:

Stored size: 535 Bytes

Contents

# pops the top item from the +:code+ stack;
# pushes it onto the +:exec+ stack so it is executed
#
# *needs:* 1 +:code+
#
# *pushes:* 1 +:exec+

class CodeExecuteInstruction < Instruction
  def preconditions?
    needs :code, 1
  end
  def setup
    @arg = @context.pop_value(:code)
  end
  def derive
    that_becomes = NudgeProgram.new(@arg)
    if that_becomes.parses?
      @result = NudgeProgram.new(@arg).linked_code
    else
      @result = CodeblockPoint.new([])
    end
  end
  def cleanup
    pushes :exec, @result
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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