Class: NameNextInstruction

Inherits:
Instruction show all
Defined in:
lib/instructions/name/name_next.rb

Overview

Creates and pushes a new ReferencePoint onto the :name stack. The name itself will be a new string, obtained by invoking the context’s Interpreter#next_name method.

needs: nothing

pushes: 1 :name

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



18
19
20
# File 'lib/instructions/name/name_next.rb', line 18

def cleanup
  pushes :exec, @result
end

#deriveObject



15
16
17
# File 'lib/instructions/name/name_next.rb', line 15

def derive
  @result = ReferencePoint.new(@new_name)
end

#preconditions?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/instructions/name/name_next.rb', line 9

def preconditions?
  true
end

#setupObject



12
13
14
# File 'lib/instructions/name/name_next.rb', line 12

def setup
  @new_name = @context.next_name
end