Class: CodeExecuteInstruction

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

Overview

pops the top item from the :code stack; pushes it onto the :exec stack so it is executed

needs: 1 :code

pushes: 1 :exec

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_execute.rb', line 23

def cleanup
  pushes :exec, @result
end

#deriveObject



15
16
17
18
19
20
21
22
# File 'lib/instructions/code/code_execute.rb', line 15

def derive
  that_becomes = NudgeProgram.new(@arg)
  if that_becomes.parses?
    @result = NudgeProgram.new(@arg).linked_code
  else
    @result = CodeblockPoint.new([])
  end
end

#preconditions?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/instructions/code/code_execute.rb', line 9

def preconditions?
  needs :code, 1
end

#setupObject



12
13
14
# File 'lib/instructions/code/code_execute.rb', line 12

def setup
  @arg = @context.pop_value(:code)
end