Module: ShoveInstruction
- Included in:
- BoolShoveInstruction, CodeShoveInstruction, ExecShoveInstruction, FloatShoveInstruction, IntShoveInstruction, NameShoveInstruction
- 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.
260 261 262 |
# File 'lib/instructions/infrastructure.rb', line 260 def target_stack @target_stack end |
Instance Method Details
#cleanup ⇒ Object
293 294 295 |
# File 'lib/instructions/infrastructure.rb', line 293 def cleanup @context.stacks[@target_stack].entries.insert(@new_depth,@result) end |
#derive ⇒ Object
281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/instructions/infrastructure.rb', line 281 def derive max = @context.stacks[@target_stack].depth case when @how_far <= 0 @new_depth = max when @how_far > max @new_depth = 0 else @new_depth = max - @how_far end end |
#initialize(context, target_stack) ⇒ Object
262 263 264 265 |
# File 'lib/instructions/infrastructure.rb', line 262 def initialize(context, target_stack) @target_stack = target_stack super(context) end |
#preconditions? ⇒ Boolean
267 268 269 270 271 272 273 274 |
# File 'lib/instructions/infrastructure.rb', line 267 def preconditions? if @target_stack != :int needs :int, 1 needs @target_stack, 1 else needs :int, 2 end end |
#setup ⇒ Object
276 277 278 279 |
# File 'lib/instructions/infrastructure.rb', line 276 def setup @how_far = @context.pop_value(:int) @result = @context.pop(@target_stack) end |