Class: AdLint::Cc1::ParameterDefinition

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

Instance Attribute Summary collapse

Attributes inherited from Definition

#declaration_specifiers, #type

Attributes inherited from SyntaxNode

#head_token, #subsequent_sequence_point, #tail_token

Instance Method Summary collapse

Methods included from DeclarationSpecifiersHolder

#explicitly_typed?, #function_specifier, #implicitly_typed?, #storage_class_specifier, #type_qualifiers, #type_specifiers

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(dcl_specs, dcr) ⇒ ParameterDefinition

Returns a new instance of ParameterDefinition.



4162
4163
4164
4165
# File 'lib/adlint/cc1/syntax.rb', line 4162

def initialize(dcl_specs, dcr)
  super(dcl_specs)
  @declarator = dcr
end

Instance Attribute Details

#declaratorObject (readonly)

Returns the value of attribute declarator.



4167
4168
4169
# File 'lib/adlint/cc1/syntax.rb', line 4167

def declarator
  @declarator
end

Instance Method Details

#identifierObject



4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
# File 'lib/adlint/cc1/syntax.rb', line 4169

def identifier
  if @declarator
    if @declarator.abstract?
      nil
    else
      @declarator.identifier
    end
  else
    nil
  end
end

#inspect(indent = 0) ⇒ Object



4198
4199
4200
4201
4202
# File 'lib/adlint/cc1/syntax.rb', line 4198

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

#locationObject



4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
# File 'lib/adlint/cc1/syntax.rb', line 4181

def location
  case
  when identifier
    identifier.location
  when declaration_specifiers
    declaration_specifiers.location
  else
    Location.new
  end
end

#to_variable_definitionObject



4192
4193
4194
4195
4196
# File 'lib/adlint/cc1/syntax.rb', line 4192

def to_variable_definition
  PseudoVariableDefinition.new(declaration_specifiers,
                               InitDeclarator.new(@declarator, nil, nil),
                               type)
end