Class: AdLint::Cc1::StructSpecifier

Inherits:
TypeSpecifier show all
Defined in:
lib/adlint/cc1/syntax.rb

Instance Attribute Summary collapse

Attributes inherited from SyntaxNode

#head_token, #subsequent_sequence_point, #tail_token

Instance Method Summary collapse

Methods inherited from SyntaxNode

#head_location, #short_class_name, #tail_location

Methods included from LocationHolder

#analysis_target?

Methods included from Visitable

#accept

Constructor Details

#initialize(id, struct_dcls, anonymous = false) ⇒ StructSpecifier

Returns a new instance of StructSpecifier.



2769
2770
2771
2772
2773
2774
# File 'lib/adlint/cc1/syntax.rb', line 2769

def initialize(id, struct_dcls, anonymous = false)
  super()
  @identifier = id
  @struct_declarations = struct_dcls
  @anonymous = anonymous
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



2776
2777
2778
# File 'lib/adlint/cc1/syntax.rb', line 2776

def identifier
  @identifier
end

#struct_declarationsObject (readonly)

Returns the value of attribute struct_declarations.



2777
2778
2779
# File 'lib/adlint/cc1/syntax.rb', line 2777

def struct_declarations
  @struct_declarations
end

Instance Method Details

#anonymous?Boolean

Returns:

  • (Boolean)


2783
2784
2785
# File 'lib/adlint/cc1/syntax.rb', line 2783

def anonymous?
  @anonymous
end

#inspect(indent = 0) ⇒ Object



2800
2801
2802
# File 'lib/adlint/cc1/syntax.rb', line 2800

def inspect(indent = 0)
  " " * indent + short_class_name
end

#locationObject



2779
2780
2781
# File 'lib/adlint/cc1/syntax.rb', line 2779

def location
  @identifier.location
end

#to_sObject



2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
# File 'lib/adlint/cc1/syntax.rb', line 2787

def to_s
  if @struct_declarations
    if @struct_declarations.empty?
      "struct #{identifier.value} {}"
    else
      "struct #{identifier.value} { " +
        @struct_declarations.map { |dcl| dcl.to_s }.join(" ") + " }"
    end
  else
    "struct #{identifier.value}"
  end
end