Class: Atomy::LocalState

Inherits:
Object show all
Includes:
CodeTools::Compiler::LocalVariables
Defined in:
lib/atomy/locals.rb

Direct Known Subclasses

EvalLocalState

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



7
8
9
# File 'lib/atomy/locals.rb', line 7

def parent
  @parent
end

Instance Method Details

#new_local(name) ⇒ Object



18
19
20
21
# File 'lib/atomy/locals.rb', line 18

def new_local(name)
  variable = CodeTools::Compiler::LocalVariable.new(allocate_slot)
  variables[name] = variable
end

#search_local(name) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/atomy/locals.rb', line 9

def search_local(name)
  if variable = variables[name]
    variable.nested_reference
  elsif @parent && reference = @parent.search_local(name)
    reference.depth += 1
    reference
  end
end