Class: Nydp::SymbolLookup

Inherits:
Object show all
Extended by:
Helper
Defined in:
lib/nydp/symbol_lookup.rb

Class Method Summary collapse

Methods included from Helper

cons, list, literal?, pair?, sig, sym, sym?

Methods included from Converter

#n2r, #r2n, #rubify

Class Method Details

.build(name, original_bindings, ns) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/nydp/symbol_lookup.rb', line 14

def self.build name, original_bindings, ns
  effective_bindings = skip_empty original_bindings
  depth    = 0
  while NIL != effective_bindings
    here = effective_bindings.car
    if here.key? name
      binding_index = here[name]
      return ContextSymbol.build(depth, name, binding_index, original_bindings.index_of(here))
    else
      depth += 1
      effective_bindings = skip_empty effective_bindings.cdr
    end
  end

  Nydp::Symbol.new name.to_s.to_sym
end

.skip_empty(bindings) ⇒ Object



7
8
9
10
11
12
# File 'lib/nydp/symbol_lookup.rb', line 7

def self.skip_empty bindings
  while (NIL != bindings) && bindings.car.empty?
    bindings = bindings.cdr
  end
  bindings
end