- All Superinterfaces:
ASTNode,InitializerNode,Iterable<PairNode<DesignationNode,,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 Cartesian domain literal, only a type. The method
getType() returns (after analysis) all the information you need
about the domain.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.civl.abc.ast.node.IF.ASTNode
ASTNode.NodeKind -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns a deep copy of this AST node.Returns the compound literal object obtained by analyzing the tree rooted at this compound initializer node.getType()Returns the type of this initializer.voidSets the value of this compound initializer to the given object.voidsetType(ObjectType type) Sets the type of this initializer.Methods inherited from interface dev.civl.abc.ast.node.IF.ASTNode
addAllTransformAnnotations, addTransformAnnotation, child, childIndex, children, diff, equiv, getAttribute, getOwner, getScope, getSource, id, keepOnly, nextDFS, nodeKind, numChildren, parent, prettyPrint, prettyRepresentation, prettyRepresentation, print, remove, removeTransformAnnotation, setAttribute, setChild, setId, setOwner, setScope, toString, transformAnnotationsMethods inherited from interface dev.civl.abc.ast.node.IF.declaration.InitializerNode
isSideEffectFreeMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface dev.civl.abc.ast.node.IF.SequenceNode
addSequenceChild, getSequenceChild, insertChildren, removeChild, setSequenceChild, shiftRemoveChild
-
Method Details
-
copy
CompoundInitializerNode copy()Description copied from interface:ASTNodeReturns 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:
copyin interfaceASTNode- Specified by:
copyin interfaceInitializerNode- Specified by:
copyin interfaceSequenceNode<PairNode<DesignationNode,InitializerNode>> - Returns:
- 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.- Returns:
- the type of this initializer
- See Also:
-
setType
Sets the type of this initializer. This method should only be called by an Analyzer.- Parameters:
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
nullbefore the analysis has been carried out. The analyzer will set the literal object value using methodsetLiteralObject(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.- Returns:
- the compound literal object or null
-
setLiteralObject
Sets the value of this compound initializer to the given object.- Parameters:
object- the value of this compound initializer- See Also:
-