Class: NameRandomBoundInstruction

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

Overview

Creates a new ReferencePoint and pushes it onto the :name stack. The name will be randomly sampled (with uniform probability) from the union of all currently bound variables and names.

needs: at least one bound variable or name

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



20
21
22
# File 'lib/instructions/name/name_random_bound.rb', line 20

def cleanup
  pushes :exec, @result
end

#deriveObject



16
17
18
19
# File 'lib/instructions/name/name_random_bound.rb', line 16

def derive
  @result = ReferencePoint.new("placeholder")
  @result.randomize(@context)
end

#preconditions?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/instructions/name/name_random_bound.rb', line 11

def preconditions?
  @context.references.length > 0
end

#setupObject



14
15
# File 'lib/instructions/name/name_random_bound.rb', line 14

def setup
end