Module: Carbon::Compiler::Visitor::Preparation::Struct

Included in:
Carbon::Compiler::Visitor::Preparation
Defined in:
lib/carbon/compiler/visitor/preparation/struct.rb

Instance Method Summary collapse

Instance Method Details

#visit_struct(node) ⇒ Object



10
11
12
13
14
15
# File 'lib/carbon/compiler/visitor/preparation/struct.rb', line 10

def visit_struct(node)
  error_multiple_data(node) if @_data
  @_data = node
  names = {}
  node.attributes!([directives_pop]).map! { |c| accept(c, names) }
end

#visit_struct_element(node, names) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/carbon/compiler/visitor/preparation/struct.rb', line 19

def visit_struct_element(node, names)
  name = node.name.value
  error_struct_duplicate(node, name, names) if names.key?(name)
  names[name] = node
  type = accept(node.type)
  node.merge(type: type)
end