Class: Carbon::Compiler::Node::EType
- Inherits:
-
Base
- Object
- Base
- Carbon::Compiler::Node::EType
show all
- Defined in:
- lib/carbon/compiler/node/etype.rb,
lib/carbon/compiler/node/etype/star.rb,
lib/carbon/compiler/node/etype/option.rb
Defined Under Namespace
Classes: Option, Star
Instance Attribute Summary
Attributes inherited from Base
#children, #location
Instance Method Summary
collapse
Methods inherited from Base
#[], #accept, #attributes!, #behavior?, #data, #data?, #each, #identity?, #initialize, #map!, mapping, #merge!, #type!, #update!
Instance Method Details
#clean? ⇒ Boolean
29
30
31
|
# File 'lib/carbon/compiler/node/etype.rb', line 29
def clean?
children.none? { |c| c.is_a?(Base) }
end
|
#expand(file, typify = true) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/carbon/compiler/node/etype.rb', line 11
def expand(file, typify = true)
catch(:invalid) { check_valid_parts(file) } or return {}
return blank_mapping if clean?
children[-1].expand(file).map do |key, value|
value = children[0..-2].concat(value)
if typify
{ Concrete::Type.new(Concrete::Type::Name.new([key], nil)) =>
Concrete::Type.new(Concrete::Type::Name.new(value, nil)) }
else
{ key => value }
end
end.inject(:merge)
end
|
#to_type ⇒ Object
33
34
35
36
37
|
# File 'lib/carbon/compiler/node/etype.rb', line 33
def to_type
return unless clean?
Concrete::Type.new(Concrete::Type::Name.new(children, nil),
location: location)
end
|