class AdLint::Cc1::FunctionDefinition
Attributes
declarator[R]
function_body[R]
parameter_definitions[R]
symbol[R]
type_declaration[R]
Public Class Methods
new(dcl_specs, dcr, param_defs, compound_stmt, sym_tbl)
click to toggle source
Calls superclass method
AdLint::Cc1::Definition::new
# File lib/adlint/cc1/syntax.rb, line 4010 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
Public Instance Methods
function_declarator()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 4035 def function_declarator collect_function_declarators(@declarator).first end
identifier()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 4027 def identifier @declarator.identifier end
inspect(indent = 0)
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 4049 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
lines()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 4039 def lines start_line = identifier.location.line_no end_line = @function_body.tail_location.line_no end_line - start_line + 1 end
location()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 4045 def location identifier.location end
signature()
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 4031 def signature FunctionSignature.new(identifier.value, @type) end
Private Instance Methods
build_label_references(compound_stmt)
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 4071 def build_label_references(compound_stmt) labels = collect_generic_labeled_statements(compound_stmt) gotos = collect_goto_statements(compound_stmt) labels.each do |generic_labeled_stmt| label_name = generic_labeled_stmt.label.value gotos.select { |goto_stmt| goto_stmt.identifier.value == label_name }.each do |goto_stmt| generic_labeled_stmt.referrers.push(goto_stmt) end end end
build_type_declaration(dcl_specs, sym_tbl)
click to toggle source
# File lib/adlint/cc1/syntax.rb, line 4059 def build_type_declaration(dcl_specs, sym_tbl) return nil unless dcl_specs dcl_specs.type_specifiers.each do |type_spec| builder = TypeDeclarationBuilder.new(sym_tbl) type_spec.accept(builder) unless builder.type_declarations.empty? return builder.type_declarations.first end end nil end