Class: AdLint::Cc1::FunctionDeclaration

Inherits:
SyntaxNode
  • Object
show all
Includes:
DeclarationSpecifiersHolder, SyntaxNodeCollector, SymbolicElement
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 included from SyntaxNodeCollector

collect_additive_expressions, collect_array_declarators, collect_compound_assignment_expressions, collect_constant_specifiers, collect_equality_expressions, collect_function_declarators, collect_generic_labeled_statements, collect_goto_statements, collect_identifier_declarators, collect_if_else_statements, collect_if_statements, collect_logical_and_expressions, collect_logical_or_expressions, collect_object_specifiers, collect_postfix_decrement_expressions, collect_postfix_increment_expressions, collect_prefix_decrement_expressions, collect_prefix_increment_expressions, collect_relational_expressions, collect_simple_assignment_expressions, collect_typedef_type_specifiers

Methods included from DeclarationSpecifiersHolder

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

Methods included from SymbolicElement

#mark_as_referred_by

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, init_dcr, sym) ⇒ FunctionDeclaration

Returns a new instance of FunctionDeclaration.



2405
2406
2407
2408
2409
2410
2411
# File 'lib/adlint/cc1/syntax.rb', line 2405

def initialize(dcl_specs, init_dcr, sym)
  super()
  @declaration_specifiers = dcl_specs
  @init_declarator = init_dcr
  @symbol = sym
  @type = nil
end

Instance Attribute Details

#declaration_specifiersObject (readonly)

Returns the value of attribute declaration_specifiers.



2413
2414
2415
# File 'lib/adlint/cc1/syntax.rb', line 2413

def declaration_specifiers
  @declaration_specifiers
end

#init_declaratorObject (readonly)

Returns the value of attribute init_declarator.



2414
2415
2416
# File 'lib/adlint/cc1/syntax.rb', line 2414

def init_declarator
  @init_declarator
end

#symbolObject (readonly)

Returns the value of attribute symbol.



2415
2416
2417
# File 'lib/adlint/cc1/syntax.rb', line 2415

def symbol
  @symbol
end

#typeObject

Returns the value of attribute type.



2416
2417
2418
# File 'lib/adlint/cc1/syntax.rb', line 2416

def type
  @type
end

Instance Method Details

#function_declaratorObject



2426
2427
2428
# File 'lib/adlint/cc1/syntax.rb', line 2426

def function_declarator
  collect_function_declarators(@init_declarator).first
end

#identifierObject



2418
2419
2420
# File 'lib/adlint/cc1/syntax.rb', line 2418

def identifier
  @init_declarator.declarator.identifier
end

#inspect(indent = 0) ⇒ Object



2434
2435
2436
2437
# File 'lib/adlint/cc1/syntax.rb', line 2434

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

#locationObject



2430
2431
2432
# File 'lib/adlint/cc1/syntax.rb', line 2430

def location
  identifier.location
end

#signatureObject



2422
2423
2424
# File 'lib/adlint/cc1/syntax.rb', line 2422

def signature
  FunctionSignature.new(identifier.value, @type)
end