Class: AdLint::Cc1::FunctionDefinition

Inherits:
Definition show all
Includes:
SyntaxNodeCollector, SymbolicElement
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 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 SymbolicElement

#mark_as_referred_by

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, param_defs, compound_stmt, sym_tbl) ⇒ FunctionDefinition

Returns a new instance of FunctionDefinition.



3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
# File 'lib/adlint/cc1/syntax.rb', line 3991

def initialize(dcl_specs, dcr, param_defs, compound_stmt, sym_tbl)
  super(dcl_specs)

  @declarator = dcr
  @parameter_definitions = param_defs
  @function_body = compound_stmt
  @symbol = sym_tbl.create_new_symbol(ObjectName, identifier)
  @type_declaration = build_type_declaration(dcl_specs, sym_tbl)
  build_label_references(compound_stmt)
end

Instance Attribute Details

#declaratorObject (readonly)

Returns the value of attribute declarator.



4002
4003
4004
# File 'lib/adlint/cc1/syntax.rb', line 4002

def declarator
  @declarator
end

#function_bodyObject (readonly)

Returns the value of attribute function_body.



4004
4005
4006
# File 'lib/adlint/cc1/syntax.rb', line 4004

def function_body
  @function_body
end

#parameter_definitionsObject (readonly)

Returns the value of attribute parameter_definitions.



4003
4004
4005
# File 'lib/adlint/cc1/syntax.rb', line 4003

def parameter_definitions
  @parameter_definitions
end

#symbolObject (readonly)

Returns the value of attribute symbol.



4005
4006
4007
# File 'lib/adlint/cc1/syntax.rb', line 4005

def symbol
  @symbol
end

#type_declarationObject (readonly)

Returns the value of attribute type_declaration.



4006
4007
4008
# File 'lib/adlint/cc1/syntax.rb', line 4006

def type_declaration
  @type_declaration
end

Instance Method Details

#function_declaratorObject



4016
4017
4018
# File 'lib/adlint/cc1/syntax.rb', line 4016

def function_declarator
  collect_function_declarators(@declarator).first
end

#identifierObject



4008
4009
4010
# File 'lib/adlint/cc1/syntax.rb', line 4008

def identifier
  @declarator.identifier
end

#inspect(indent = 0) ⇒ Object



4030
4031
4032
4033
4034
4035
4036
4037
# File 'lib/adlint/cc1/syntax.rb', line 4030

def inspect(indent = 0)
  " " * indent + "#{short_class_name} (#{location.inspect}) " +
    (storage_class_specifier ? "#{storage_class_specifier.value} " : "") +
    (function_specifier ? "#{function_specifier.value} " : "") +
    "#{identifier.value}\n" +
    @parameter_definitions.map { |p| p.inspect(indent + 1) }.join("\n") +
    "\n#{@function_body.inspect(indent + 1)}"
end

#linesObject



4020
4021
4022
4023
4024
# File 'lib/adlint/cc1/syntax.rb', line 4020

def lines
  start_line = identifier.location.line_no
  end_line = @function_body.tail_location.line_no
  end_line - start_line + 1
end

#locationObject



4026
4027
4028
# File 'lib/adlint/cc1/syntax.rb', line 4026

def location
  identifier.location
end

#signatureObject



4012
4013
4014
# File 'lib/adlint/cc1/syntax.rb', line 4012

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