class SyntaxTree::YARV::LocalTable
This represents every local variable associated with an instruction sequence. There are two kinds of locals: plain locals that are what you expect, and block proxy locals, which represent local variables associated with blocks that were passed into the current instruction sequence.
Attributes
Public Class Methods
Public Instance Methods
Source
# File lib/syntax_tree/yarv/local_table.rb, line 73 def block(name) locals << BlockLocal.new(name) unless has?(name) end
Add a BlockLocal
to the local table.
Source
# File lib/syntax_tree/yarv/local_table.rb, line 51 def find(name, level = 0) index = locals.index { |local| local.name == name } Lookup.new(locals[index], index, level) if index end
Source
# File lib/syntax_tree/yarv/local_table.rb, line 56 def has?(name) locals.any? { |local| local.name == name } end
Source
# File lib/syntax_tree/yarv/local_table.rb, line 64 def name_at(index) locals[index].name end
Source
# File lib/syntax_tree/yarv/local_table.rb, line 60 def names locals.map(&:name) end
Source
# File lib/syntax_tree/yarv/local_table.rb, line 84 def offset(index) size - (index - 3) - 1 end
This is the offset from the top of the stack where this local variable lives.
Source
# File lib/syntax_tree/yarv/local_table.rb, line 78 def plain(name) locals << PlainLocal.new(name) unless has?(name) end
Add a PlainLocal
to the local table.