Class: CodeNameLookupInstruction
- Inherits:
-
Instruction
- Object
- Instruction
- CodeNameLookupInstruction
- Defined in:
- lib/instructions/code/code_name_lookup.rb
Overview
pops the top :name
item; pushes a new :code
item that has a value equal to the current context binding
note: if there is no binding, the resulting :code
value will be an empty string
needs: 1 :name
pushes: 1 :code
Instance Attribute Summary
Attributes inherited from Instruction
Instance Method Summary collapse
- #cleanup ⇒ Object
- #derive ⇒ Object
-
#preconditions? ⇒ Boolean
was Push3 CODE.DEFINITION.
- #setup ⇒ Object
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
#cleanup ⇒ Object
26 27 28 |
# File 'lib/instructions/code/code_name_lookup.rb', line 26 def cleanup pushes :code, @result end |
#derive ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/instructions/code/code_name_lookup.rb', line 18 def derive bound_value = @context.variables[@the_reference] || @context.names[@the_reference] || nil if bound_value != nil @result = ValuePoint.new("code", bound_value.blueprint) else @result = ValuePoint.new("code", "") end end |
#preconditions? ⇒ Boolean
was Push3 CODE.DEFINITION
12 13 14 |
# File 'lib/instructions/code/code_name_lookup.rb', line 12 def preconditions? needs :name, 1 end |
#setup ⇒ Object
15 16 17 |
# File 'lib/instructions/code/code_name_lookup.rb', line 15 def setup @the_reference = @context.pop_value(:name) end |