Module: IfInstruction
- Included in:
- ExecIfInstruction, FloatIfInstruction, IntIfInstruction
- Defined in:
- lib/instructions/infrastructure.rb
Instance Attribute Summary collapse
-
#target_stack ⇒ Object
readonly
Returns the value of attribute target_stack.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #derive ⇒ Object
- #initialize(context, target_stack) ⇒ Object
- #preconditions? ⇒ Boolean
- #setup ⇒ Object
Instance Attribute Details
#target_stack ⇒ Object (readonly)
Returns the value of attribute target_stack.
98 99 100 |
# File 'lib/instructions/infrastructure.rb', line 98 def target_stack @target_stack end |
Instance Method Details
#cleanup ⇒ Object
116 117 118 |
# File 'lib/instructions/infrastructure.rb', line 116 def cleanup @stay ? @context.stacks[@target_stack].push(@ifTrue) : @context.stacks[@target_stack].push(@ifFalse) end |
#derive ⇒ Object
114 115 |
# File 'lib/instructions/infrastructure.rb', line 114 def derive end |
#initialize(context, target_stack) ⇒ Object
100 101 102 103 |
# File 'lib/instructions/infrastructure.rb', line 100 def initialize(context, target_stack) @target_stack = target_stack super(context) end |
#preconditions? ⇒ Boolean
105 106 107 108 |
# File 'lib/instructions/infrastructure.rb', line 105 def preconditions? needs @target_stack, 2 needs :bool, 1 end |
#setup ⇒ Object
109 110 111 112 113 |
# File 'lib/instructions/infrastructure.rb', line 109 def setup @stay = @context.pop_value(:bool) @ifFalse = @context.pop(@target_stack) @ifTrue = @context.pop(@target_stack) end |