Class: Steep::TypeInference::ConstantEnv
- Defined in:
- lib/steep/type_inference/constant_env.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#factory ⇒ Object
readonly
Returns the value of attribute factory.
-
#resolver ⇒ Object
readonly
Returns the value of attribute resolver.
Instance Method Summary collapse
- #children(module_name) ⇒ Object
- #constants ⇒ Object
- #decompose_constant(constant) ⇒ Object
- #decompose_constant!(constant) ⇒ Object
-
#initialize(factory:, context:, resolver:) ⇒ ConstantEnv
constructor
A new instance of ConstantEnv.
- #resolve(name) ⇒ Object
- #resolve_child(module_name, constant_name) ⇒ Object
- #toplevel(name) ⇒ Object
Constructor Details
#initialize(factory:, context:, resolver:) ⇒ ConstantEnv
Returns a new instance of ConstantEnv.
8 9 10 11 12 |
# File 'lib/steep/type_inference/constant_env.rb', line 8 def initialize(factory:, context:, resolver:) @factory = factory @context = context @resolver = resolver end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/steep/type_inference/constant_env.rb', line 4 def context @context end |
#factory ⇒ Object (readonly)
Returns the value of attribute factory.
5 6 7 |
# File 'lib/steep/type_inference/constant_env.rb', line 5 def factory @factory end |
#resolver ⇒ Object (readonly)
Returns the value of attribute resolver.
6 7 8 |
# File 'lib/steep/type_inference/constant_env.rb', line 6 def resolver @resolver end |
Instance Method Details
#children(module_name) ⇒ Object
37 38 39 |
# File 'lib/steep/type_inference/constant_env.rb', line 37 def children(module_name) resolver.children(module_name).transform_values {|c| decompose_constant!(c) } end |
#constants ⇒ Object
26 27 28 29 |
# File 'lib/steep/type_inference/constant_env.rb', line 26 def constants cs = resolver.constants(context) or raise cs.transform_values {|c| decompose_constant!(c) } end |
#decompose_constant(constant) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/steep/type_inference/constant_env.rb', line 45 def decompose_constant(constant) if constant [ factory.type(constant.type), constant.name, constant.entry ] end end |
#decompose_constant!(constant) ⇒ Object
41 42 43 |
# File 'lib/steep/type_inference/constant_env.rb', line 41 def decompose_constant!(constant) decompose_constant(constant) || raise end |
#resolve(name) ⇒ Object
14 15 16 17 18 |
# File 'lib/steep/type_inference/constant_env.rb', line 14 def resolve(name) decompose_constant( resolver.resolve(name, context: context) ) end |
#resolve_child(module_name, constant_name) ⇒ Object
31 32 33 34 35 |
# File 'lib/steep/type_inference/constant_env.rb', line 31 def resolve_child(module_name, constant_name) decompose_constant( resolver.resolve_child(module_name, constant_name) ) end |
#toplevel(name) ⇒ Object
20 21 22 23 24 |
# File 'lib/steep/type_inference/constant_env.rb', line 20 def toplevel(name) decompose_constant( resolver.table.toplevel[name] ) end |