Module: IfInstruction

Included in:
ExecIfInstruction, FloatIfInstruction, IntIfInstruction
Defined in:
lib/instructions/infrastructure.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#target_stackObject (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

#cleanupObject



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

#deriveObject



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

Returns:

  • (Boolean)


105
106
107
108
# File 'lib/instructions/infrastructure.rb', line 105

def preconditions?
  needs @target_stack, 2
  needs :bool, 1
end

#setupObject



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