class Apricot::OverloadScope

Attributes

block_arg[RW]
splat[RW]
splat?[RW]

Public Class Methods

new(parent_fn) click to toggle source
Calls superclass method Apricot::Scope::new
# File lib/apricot/scopes.rb, line 97
def initialize(parent_fn)
  super(parent_fn)
end

Public Instance Methods

find_recur_target() click to toggle source

A (recur) is looking for a recursion target. This, being a fn overload, is one.

# File lib/apricot/scopes.rb, line 122
def find_recur_target
  self
end
find_var(name, depth = 0) click to toggle source

An identifier or a nested scope is looking up a variable. If the variable is found here, return a reference to it. Otherwise look it up on the parent (a fn). Don’t increase the depth, the lookup on the fn will do that, and if we do it twice then the generated push_local_depth instructions look up too many scopes.

# File lib/apricot/scopes.rb, line 106
def find_var(name, depth = 0)
  if slot = @variables[name]
    LocalReference.new(slot, depth)
  else
    @parent.find_var(name, depth)
  end
end
new_local(name) click to toggle source

Create a new local on the current level.

# File lib/apricot/scopes.rb, line 115
def new_local(name)
  name = name.name if name.is_a? Identifier
  @variables[name] = store_new_local(name)
end