Class: Yoda::Typing::Inferencer
- Inherits:
-
Object
- Object
- Yoda::Typing::Inferencer
show all
- Defined in:
- lib/yoda/typing/inferencer.rb,
lib/yoda/typing/inferencer/tracer.rb,
lib/yoda/typing/inferencer/arguments.rb,
lib/yoda/typing/inferencer/type_binding.rb,
lib/yoda/typing/inferencer/load_resolver.rb,
lib/yoda/typing/inferencer/method_resolver.rb,
lib/yoda/typing/inferencer/object_resolver.rb,
lib/yoda/typing/inferencer/arguments_binder.rb,
lib/yoda/typing/inferencer/parameter_binder.rb
Defined Under Namespace
Classes: Arguments, ArgumentsBinder, LoadResolver, MethodResolver, ObjectResolver, ParameterBinder, Tracer, TypeBinding
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(context:, tracer: nil) ⇒ Inferencer
Returns a new instance of Inferencer.
28
29
30
31
|
# File 'lib/yoda/typing/inferencer.rb', line 28
def initialize(context:, tracer: nil)
@context = context
@tracer = tracer || Tracer.new(environment: context.environment, generator: context.generator)
end
|
Instance Attribute Details
14
15
16
|
# File 'lib/yoda/typing/inferencer.rb', line 14
def context
@context
end
|
17
18
19
|
# File 'lib/yoda/typing/inferencer.rb', line 17
def tracer
@tracer
end
|
Class Method Details
.create_for_root(environment:) ⇒ Inferencer
21
22
23
24
|
# File 'lib/yoda/typing/inferencer.rb', line 21
def self.create_for_root(environment:)
context = Contexts.root_scope(environment: environment)
new(context: context)
end
|
Instance Method Details
#infer(node) ⇒ Store::Types::Base
35
36
37
38
|
# File 'lib/yoda/typing/inferencer.rb', line 35
def infer(node)
Tree.build(node, context: context, tracer: tracer).type
end
|
#pretty_print(pp) ⇒ Object
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/yoda/typing/inferencer.rb', line 41
def pretty_print(pp)
pp.object_group(self) do
pp.breakable
pp.text "@context="
pp.pp context
pp.comma_breakable
pp.text "@tracer="
pp.pp tracer
end
end
|