Class: AdLint::Cc1::MemberDeclaration

Inherits:
SyntaxNode
  • Object
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(spec_qual_list, struct_dcl) ⇒ MemberDeclaration

Returns a new instance of MemberDeclaration.



2883
2884
2885
2886
2887
2888
# File 'lib/adlint/cc1/syntax.rb', line 2883

def initialize(spec_qual_list, struct_dcl)
  super()
  @specifier_qualifier_list = spec_qual_list
  @struct_declarator = struct_dcl
  @type = nil
end

Instance Attribute Details

#specifier_qualifier_listObject (readonly)

Returns the value of attribute specifier_qualifier_list.



2890
2891
2892
# File 'lib/adlint/cc1/syntax.rb', line 2890

def specifier_qualifier_list
  @specifier_qualifier_list
end

#struct_declaratorObject (readonly)

Returns the value of attribute struct_declarator.



2891
2892
2893
# File 'lib/adlint/cc1/syntax.rb', line 2891

def struct_declarator
  @struct_declarator
end

#typeObject

Returns the value of attribute type.



2892
2893
2894
# File 'lib/adlint/cc1/syntax.rb', line 2892

def type
  @type
end

Instance Method Details

#identifierObject



2894
2895
2896
2897
2898
2899
2900
# File 'lib/adlint/cc1/syntax.rb', line 2894

def identifier
  if @struct_declarator && @struct_declarator.declarator
    @struct_declarator.declarator.identifier
  else
    nil
  end
end

#inspect(indent = 0) ⇒ Object



2921
2922
2923
2924
# File 'lib/adlint/cc1/syntax.rb', line 2921

def inspect(indent = 0)
  " " * indent + "#{short_class_name} (#{location.inspect}) " +
    ((id = identifier) ? id.value : "")
end

#locationObject



2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
# File 'lib/adlint/cc1/syntax.rb', line 2902

def location
  case
  when @struct_declarator && @struct_declarator.declarator
    @struct_declarator.declarator.identifier.location
  when @struct_declarator
    @struct_declarator.head_location
  else
    @specifier_qualifier_list.head_location
  end
end

#to_sObject



2913
2914
2915
2916
2917
2918
2919
# File 'lib/adlint/cc1/syntax.rb', line 2913

def to_s
  if id = identifier
    "#{type.brief_image} #{id.value}"
  else
    type.brief_image
  end
end