class R2CEnvironment
Constants
- TYPE
- VALUE
Attributes
env[R]
Public Instance Methods
_get(name)
click to toggle source
# File lib/r2cenvironment.rb, line 52 def _get(name) @env.each do |closure| return closure[name] if closure.has_key? name end raise NameError, "Unbound var: #{name.inspect} in #{@env.inspect}" end
add(id, type, depth = 0)
click to toggle source
# File lib/r2cenvironment.rb, line 10 def add(id, type, depth = 0) raise "Adding illegal identifier #{id.inspect}" unless Symbol === id raise ArgumentError, "type must be a valid Type instance: #{type.inspect}" unless CType === type @env[depth][id.to_s.sub(/^\*/, '').intern][TYPE] = type end
depth()
click to toggle source
# File lib/r2cenvironment.rb, line 19 def depth @env.length end
extend()
click to toggle source
# File lib/r2cenvironment.rb, line 24 def extend # override @env.unshift(Hash.new { |h,k| h[k] = [] }) end
Also aliased as: old_extend
get_val(name)
click to toggle source
# File lib/r2cenvironment.rb, line 28 def get_val(name) self._get(name)[VALUE] end
lookup(name)
click to toggle source
# File lib/r2cenvironment.rb, line 32 def lookup(name) # HACK: if name is :self, cheat for now until we have full defn remapping return CType.fucked if name == :self return self._get(name)[TYPE] end
scope()
click to toggle source
# File lib/r2cenvironment.rb, line 43 def scope self.extend begin yield ensure self.unextend end end
set_val(name, val)
click to toggle source
# File lib/r2cenvironment.rb, line 39 def set_val(name, val) self._get(name)[VALUE] = val end