Module: SwapInstruction

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#target_stackObject (readonly)

Returns the value of attribute target_stack.



144
145
146
# File 'lib/instructions/infrastructure.rb', line 144

def target_stack
  @target_stack
end

Instance Method Details

#cleanupObject



160
161
162
163
# File 'lib/instructions/infrastructure.rb', line 160

def cleanup
  pushes @target_stack, @result1
  pushes @target_stack, @result2
end

#deriveObject



158
159
# File 'lib/instructions/infrastructure.rb', line 158

def derive
end

#initialize(context, target_stack) ⇒ Object



146
147
148
149
# File 'lib/instructions/infrastructure.rb', line 146

def initialize(context, target_stack)
  @target_stack = target_stack
  super(context)
end

#preconditions?Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/instructions/infrastructure.rb', line 151

def preconditions?
  needs @target_stack, 2
end

#setupObject



154
155
156
157
# File 'lib/instructions/infrastructure.rb', line 154

def setup
  @result1 = @context.pop(@target_stack)
  @result2 = @context.pop(@target_stack)
end