Class: Yoda::Typing::Tree::Base
Abstract
- Inherits:
-
Object
- Object
- Yoda::Typing::Tree::Base
show all
- Extended by:
- Forwardable
- Defined in:
- lib/yoda/typing/tree/base.rb
Overview
Direct Known Subclasses
AskDefined, Begin, BlockCall, Case, ClassTree, ConditionalLoop, Constant, ConstantAssignment, Ensure, For, HashTree, If, InterpolationText, Literal, LocalExit, LogicalAssignment, LogicalOperator, MethodDef, ModuleTree, MultipleAssignment, Rescue, RescueClause, Self, Send, SingletonClassTree, SingletonMethodDef, Super, Variable, VariableAssignment, Yield
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(node:, tracer:, context:, parent: nil) ⇒ Base
Returns a new instance of Base.
29
30
31
32
33
34
|
# File 'lib/yoda/typing/tree/base.rb', line 29
def initialize(node:, tracer:, context:, parent: nil)
@node = node
@tracer = tracer
@context = context
@parent = parent
end
|
Instance Attribute Details
18
19
20
|
# File 'lib/yoda/typing/tree/base.rb', line 18
def context
@context
end
|
12
13
14
|
# File 'lib/yoda/typing/tree/base.rb', line 12
def node
@node
end
|
15
16
17
|
# File 'lib/yoda/typing/tree/base.rb', line 15
def tracer
@tracer
end
|
Instance Method Details
#build_child(node, context: self.context) ⇒ Base
52
53
54
|
# File 'lib/yoda/typing/tree/base.rb', line 52
def build_child(node, context: self.context)
Tree.build(node, context: context, tracer: tracer, parent: self)
end
|
23
|
# File 'lib/yoda/typing/tree/base.rb', line 23
delegate [:generator] => :context
|
#infer_child(node, **kwargs) ⇒ Types::Type
59
60
61
|
# File 'lib/yoda/typing/tree/base.rb', line 59
def infer_child(node, **kwargs)
build_child(node, **kwargs).type
end
|
#inspect ⇒ Object
77
78
79
|
# File 'lib/yoda/typing/tree/base.rb', line 77
def inspect
pretty_print_inspect
end
|
#pretty_print(pp) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/yoda/typing/tree/base.rb', line 64
def pretty_print(pp)
pp.object_group(self) do
pp.breakable
pp.text "@node="
pp.pp node
pp.text "@context="
pp.pp context
pp.comma_breakable
pp.text "@tracer="
pp.pp tracer
end
end
|
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/yoda/typing/tree/base.rb', line 37
def type
@type ||= begin
bind_tree(node: node, tree: self)
bind_context(node: node, context: context)
Logger.trace("Traversing #{node}")
type = infer_type
Logger.trace("Traversed #{node} -> #{type.to_s}")
bind_type(node: node, type: type, context: context)
type
end
end
|