Sha256: c202236c97da2712381d07639aa3a5ef3cb0f89b33cf86c76d674d1434e03928
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
module Steep module TypeInference class ConstantEnv attr_reader :context attr_reader :cache attr_reader :factory attr_reader :table # ConstantEnv receives an Names::Module as a context, not a Namespace, because this is a simulation of Ruby. # Any namespace is a module or class. def initialize(factory:, context:) @cache = {} @factory = factory @context = context @table = Ruby::Signature::ConstantTable.new(builder: factory.definition_builder) end def namespace @namespace ||= if context context.namespace.append(context.name) else AST::Namespace.root end end def lookup(name) cache[name] ||= begin constant = table.resolve_constant_reference( factory.type_name_1(name), context: factory.namespace_1(namespace) ) if constant factory.type(constant.type) end rescue => exn Steep.logger.error "Looking up a constant failed: name=#{name}, context=#{context}, error=#{exn.inspect}" nil end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
steep-0.14.0 | lib/steep/type_inference/constant_env.rb |
steep-0.13.0 | lib/steep/type_inference/constant_env.rb |
steep-0.12.0 | lib/steep/type_inference/constant_env.rb |