Class: CodeIfInstruction
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
#cleanup ⇒ Object
19
20
21
|
# File 'lib/instructions/code/code_if.rb', line 19
def cleanup
pushes :exec, @result
end
|
#derive ⇒ Object
14
15
16
17
|
# File 'lib/instructions/code/code_if.rb', line 14
def derive
which = @stay ? @ifTrue : @ifFalse
@result = NudgeProgram.new(which).linked_code
end
|
#preconditions? ⇒ Boolean
3
4
5
6
|
# File 'lib/instructions/code/code_if.rb', line 3
def preconditions?
needs :code, 2
needs :bool, 1
end
|
#setup ⇒ Object
8
9
10
11
12
|
# File 'lib/instructions/code/code_if.rb', line 8
def setup
@stay = @context.pop_value(:bool)
@ifFalse = @context.pop_value(:code)
@ifTrue = @context.pop_value(:code)
end
|