class SyntaxTree::YARV::InstructionSequence::Stack

This object is used to track the size of the stack at any given time. It is effectively a mini symbolic interpreter. It’s necessary because when instruction sequences get serialized they include a :stack_max field on them. This field is used to determine how much stack space to allocate for the instruction sequence.

Attributes

current_size[R]
maximum_size[R]

Public Class Methods

new() click to toggle source
# File lib/syntax_tree/yarv/instruction_sequence.rb, line 93
def initialize
  @current_size = 0
  @maximum_size = 0
end

Public Instance Methods

change_by(value) click to toggle source
# File lib/syntax_tree/yarv/instruction_sequence.rb, line 98
def change_by(value)
  @current_size += value
  @maximum_size = @current_size if @current_size > @maximum_size
end