Module dev.civl.abc

Interface DeclarationNode

All Superinterfaces:
ASTNode
All Known Subinterfaces:
AbstractFunctionDefinitionNode, EnumerationTypeNode, EnumeratorDeclarationNode, FieldDeclarationNode, FunctionDeclarationNode, FunctionDefinitionNode, OrdinaryDeclarationNode, OrdinaryLabelNode, PredicateNode, ScopeParameterizedDeclarationNode, StructureOrUnionTypeNode, TypedefDeclarationNode, VariableDeclarationNode

public interface DeclarationNode extends ASTNode

The root of the declaration node type hierarchy. According to C11, "A declaration specifies the interpretation and attributes of a set of identifiers." An object of this type specifies a declaration for exactly one identifier.

A DeclarationNode does not correspond exactly to the notion of "declaration" in the C Standard. For example, in the C Standard, a static assertion is a kind of declaration. This seems more like a grammatical convenience (since a static assertion can appear almost anywhere a declaration can) than a logical organization of the concepts, as a static assertion does not specify "the interpretation and attributes of a set of identifiers".

Every declaration node has at least one child: an identifier node for the identifier being declared. It is possible for that identifier node to be null, for example, in an anonymous struct or enum.

Furthermore, every declaration node declares some abstract thing, called an Entity. This class provides a method to get and set that entity.

See Also:
  • Method Details

    • getIdentifier

      IdentifierNode getIdentifier()
      Gets the identifier node which contains the name of the entity being declared. May be null.
      Returns:
      the identifier for the name of the entity being declared
    • getName

      String getName()
      The name of the identifier being declared as a string. Could be null. If the identifier is not null, this method returns the same string returned by getIdentifier().name(). It is provided for convenience.
      Returns:
      name of identifier being declared, or null if the declaration is anonymous
    • setIdentifier

      void setIdentifier(IdentifierNode identifier)
      Sets the identifier node.
      Parameters:
      identifier - the identifier node
    • isDefinition

      boolean isDefinition()
      Is this the defining declaration of the identifier? According to C11, "A definition of an identifier is a declaration for that identifier that: - for an object, causes storage to be reserved for that object; - for a function, includes the function body; - for an enumeration constant, is the (only) declaration of the identifier; - for a typedef name, is the first (or only) declaration of the identifier."
      Returns:
      true iff this is the identifier's definition.
      See Also:
    • setIsDefinition

      void setIsDefinition(boolean value)
      Sets the "isDefinition" field to the given boolean value.
      Parameters:
      value - new value for "isDefinition"
      See Also:
    • getEntity

      Entity getEntity()
      Returns the entity whose existence is declared by this declaration. This is initially null, and can be changed by setEntity(Entity).
      Returns:
      the entity declared by this declaration
      See Also:
    • setEntity

      void setEntity(Entity entity)
      Sets the entity associated to this declaration.
      Parameters:
      entity - the entity to associate to this node
      See Also:
    • copy

      Description copied from interface: ASTNode
      Returns a deep copy of this AST node. The node and all of its descendants will be cloned. The cloning does not copy analysis or attribute information.
      Specified by:
      copy in interface ASTNode
      Returns:
      deep copy of this node