Interface CompoundInitializerNode

All Superinterfaces:
ASTNode, InitializerNode, Iterable<PairNode<DesignationNode,InitializerNode>>, SequenceNode<PairNode<DesignationNode,InitializerNode>>

public interface CompoundInitializerNode extends InitializerNode, SequenceNode<PairNode<DesignationNode,InitializerNode>>

A compound initializer (written with curly braces in C) is used to initialize an array, struct, or union. It is specified as a sequence of designation-initializer pairs. In any such pair, the designation is optional; if it is absent, it is represented here by null. The initializer node can never be null.

This class is also used in the representation of a compound literal. A CompoundLiteralNode has a reference to a CompoundInitializerNode. This is because the two structures are essentially identical. The only difference is that a compound literal expression begins with a type name in parentheses, which specifies the type of the compound literal, while a compound initializer does not have that component because the type is taken from the type of the variable being initialized.

This class is also used to represent a CIVL-C Cartesian domain literal. A Cartesian domain is the Cartesian product of a sequence of ranges. Each range represents an (ordered) set of integers. The domain is an (ordered) set of tuples of integers. All tuples in a domain have the same arity, say n, called the dimension of the domain. For a Cartesian domain, n is the number of ranges used to form the domain. The order on the domain is the dictionary order. In a Cartesian domain literal, all the designation nodes are null, and each initializer node is an expression of range type. Moreover, the method getLiteralObject() will return null, as there is not object associated to a Caretesian domain literal, only a type. The method getType() returns (after analysis) all the information you need about the domain.

See Also:
  • Method Details

    • 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
      Specified by:
      copy in interface InitializerNode
      Specified by:
      copy in interface SequenceNode<PairNode<DesignationNode,InitializerNode>>
      deep copy of this node
    • getType

      ObjectType getType()
      Returns the type of this initializer. The type is determined from the type of the expression of which this initializer is part, or the declared type of the variable which it is being used to initialize.
      the type of this initializer
      See Also:
    • setType

      void setType(ObjectType type)
      Sets the type of this initializer. This method should only be called by an Analyzer.
      type - the type of the thing being initialized
      See Also:
    • getLiteralObject

      CompoundLiteralObject getLiteralObject()

      Returns the compound literal object obtained by analyzing the tree rooted at this compound initializer node. The compound literal object provides an abstract view of the literal which is very simple and easy to use. This method will return null before the analysis has been carried out. The analyzer will set the literal object value using method setLiteralObject(CompoundLiteralObject).

      Note that for a CIVL-C Cartestian domain literal, this will always return null, as there is no compound object associated to the construct, only a type.

      the compound literal object or null
    • setLiteralObject

      void setLiteralObject(CompoundLiteralObject object)
      Sets the value of this compound initializer to the given object.
      object - the value of this compound initializer
      See Also: