class Apricot::FnScope
Attributes
name[R]
self_reference[R]
Public Class Methods
new(parent, name)
click to toggle source
Calls superclass method
Apricot::Scope::new
# File lib/apricot/scopes.rb, line 62 def initialize(parent, name) super(parent) if name @name = name name_slot = @parent.store_new_local(name) @self_reference = LocalReference.new(name_slot, 1) end end
Public Instance Methods
find_recur_target()
click to toggle source
A (recur) is looking for a recursion target (ie. a loop or a fn overload scope).
# File lib/apricot/scopes.rb, line 84 def find_recur_target @parent.find_recur_target 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 and increment its depth because it is beyond the bounds of the current block of code (fn).
# File lib/apricot/scopes.rb, line 76 def find_var(name, depth = 0) return @self_reference if name == @name @parent.find_var(name, depth + 1) end