Class: CodeFromBoolInstruction

Inherits:
Instruction show all
Defined in:
lib/instructions/conversion/code_from_bool.rb

Overview

pops the top :bool item; pushes a new :code item, with value equal to the :bool item’s blueprint

needs: 1 :bool

pushes: 1 :code

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



21
22
23
# File 'lib/instructions/conversion/code_from_bool.rb', line 21

def cleanup
  pushes :code, @result
end

#deriveObject



18
19
20
# File 'lib/instructions/conversion/code_from_bool.rb', line 18

def derive
  @result = ValuePoint.new("code", "value «bool»\n«bool» #{@arg}")
end

#preconditions?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/instructions/conversion/code_from_bool.rb', line 12

def preconditions?
  needs :bool, 1
end

#setupObject



15
16
17
# File 'lib/instructions/conversion/code_from_bool.rb', line 15

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