Sha256: 7ed5b61e1365386f1627cefbcc72309d4257477f668c069d474a45b60b26ce03

Contents?: true

Size: 775 Bytes

Versions: 1

Compression:

Stored size: 775 Bytes

Contents

require 'nydp/context_symbol'

module Nydp
  class SymbolLookup
    extend Helper

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

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nydp-0.6.0 lib/nydp/symbol_lookup.rb