Class: AdLint::Cc1::FunctionDefinition
- Inherits:
-
Definition
- Object
- SyntaxNode
- Definition
- AdLint::Cc1::FunctionDefinition
- Includes:
- SyntaxNodeCollector, SymbolicElement
- Defined in:
- lib/adlint/cc1/syntax.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#declarator ⇒ Object
readonly
Returns the value of attribute declarator.
-
#function_body ⇒ Object
readonly
Returns the value of attribute function_body.
-
#parameter_definitions ⇒ Object
readonly
Returns the value of attribute parameter_definitions.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
-
#type_declaration ⇒ Object
readonly
Returns the value of attribute type_declaration.
Attributes inherited from Definition
#declaration_specifiers, #type
Attributes inherited from SyntaxNode
#head_token, #subsequent_sequence_point, #tail_token
Instance Method Summary collapse
- #function_declarator ⇒ Object
- #identifier ⇒ Object
-
#initialize(dcl_specs, dcr, param_defs, compound_stmt, sym_tbl) ⇒ FunctionDefinition
constructor
A new instance of FunctionDefinition.
- #inspect(indent = 0) ⇒ Object
- #lines ⇒ Object
- #location ⇒ Object
- #signature ⇒ Object
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
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
Methods included from Visitable
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
#declarator ⇒ Object (readonly)
Returns the value of attribute declarator.
4002 4003 4004 |
# File 'lib/adlint/cc1/syntax.rb', line 4002 def declarator @declarator end |
#function_body ⇒ Object (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_definitions ⇒ Object (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 |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
4005 4006 4007 |
# File 'lib/adlint/cc1/syntax.rb', line 4005 def symbol @symbol end |
#type_declaration ⇒ Object (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_declarator ⇒ Object
4016 4017 4018 |
# File 'lib/adlint/cc1/syntax.rb', line 4016 def function_declarator collect_function_declarators(@declarator).first end |
#identifier ⇒ Object
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 |
#lines ⇒ Object
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 |
#location ⇒ Object
4026 4027 4028 |
# File 'lib/adlint/cc1/syntax.rb', line 4026 def location identifier.location end |
#signature ⇒ Object
4012 4013 4014 |
# File 'lib/adlint/cc1/syntax.rb', line 4012 def signature FunctionSignature.new(identifier.value, @type) end |