Class: Yoda::Typing::Tree::Case
- Inherits:
-
Base
- Object
- Base
- Yoda::Typing::Tree::Case
show all
- Defined in:
- lib/yoda/typing/tree/case.rb
Instance Attribute Summary
Attributes inherited from Base
#context, #node
Instance Method Summary
collapse
Methods inherited from Base
#build_child, #generator, #initialize, #type
Instance Method Details
#children ⇒ Object
11
12
13
|
# File 'lib/yoda/typing/tree/case.rb', line 11
def children
@children ||= [subject, *when_branches, else_branch]
end
|
#else_branch ⇒ Object
23
24
25
|
# File 'lib/yoda/typing/tree/case.rb', line 23
def else_branch
@else_branch ||= build_child(node.children.last)
end
|
#infer_case_node ⇒ [Store::Types::Base, Environment]
6
7
8
9
|
# File 'lib/yoda/typing/tree/case.rb', line 6
def infer_case_node
Types::Union.new([*when_body_nodes, else_node].map { |node| infer(node) })
end
|
#subject ⇒ Object
15
16
17
|
# File 'lib/yoda/typing/tree/case.rb', line 15
def subject
@subject ||= build_child(node.children.first)
end
|
#when_branches ⇒ Object
19
20
21
|
# File 'lib/yoda/typing/tree/case.rb', line 19
def when_branches
@when_branches ||= node.children.slice(1, -2).map(&method(:build_child))
end
|