- All Superinterfaces:
ASTNode,ForLoopInitializerNode,InitializerNode,SizeableNode
- All Known Subinterfaces:
AlignOfNode,ArrayLambdaNode,ArrowNode,CastNode,CharacterConstantNode,CompoundLiteralNode,ConstantNode,DerivativeExpressionNode,DotNode,EnumerationConstantNode,ExtendedQuantifiedExpressionNode,FloatingConstantNode,FunctionCallNode,GenericSelectionNode,HereOrRootNode,IdentifierExpressionNode,IntegerConstantNode,LambdaNode,NothingNode,ObjectOrRegionOfNode,OperatorNode,ProcnullNode,QuantifiedExpressionNode,RegularRangeNode,RemoteOnExpressionNode,ResultNode,ScopeOfNode,SelfNode,SizeofNode,SpawnNode,StatementExpressionNode,StatenullNode,StringLiteralNode,WildcardNode
A node representing any kind of C expression. This is the root of a type hierarchy of expression nodes.
This interface extends InitializerNode because an expression can be
used as an initializer for a scalar variable.
This interface extends SizeableNode because an expression can be used
as an argument to the sizeof operator.
This interface extends ForLoopInitializerNode to indicate that an
expression can be used as the first clause of a "for" loop (as
can a variable declaration).
There are many different subtypes of this interface, for the different kinds
of expressions. An enumerated type ExpressionNode.ExpressionKind is provided to make
it easy to identify the subtype and, for example, switch on it.
Every expression has an initial type, and then some number (possibly 0) of implicit conversions. Each conversion specifies an old type and a new type. The conversions form a chain: the first conversion (conversion number 0) has as its old type the initial type of the expression. The old type of conversion n (for any n≥1) equals the new type of conversion n-1. The new type of the last conversion is the final "converted type" of the expression.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumAn enumerated type used to categorize the different kinds of expression nodes.Nested classes/interfaces inherited from interface dev.civl.abc.ast.node.IF.ASTNode
ASTNode.NodeKind -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConversion(Conversion conversion) Adds a conversion to the sequence of conversions for this expression.copy()Returns a deep copy of this AST node.Returns the kind of this expression.getConversion(int index) Returns the index-th conversion in the chain of types for this expression.Returns the final converted type of the expression.Returns the initial type of the expression.intReturns the number of conversions in the chain leading from the initial type of the expression to the final converted type.booleanIs this expression a "constant expression" in the sense of the C11 Standard?booleanisLvalue()checks if this expression is an lvalue expression.voidRemoves all conversions from this nodevoidsetInitialType(Type type) Sets the initial type of the expression.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, removeChild, removeTransformAnnotation, setAttribute, setChild, setId, setOwner, setScope, toString, transformAnnotationsMethods inherited from interface dev.civl.abc.ast.node.IF.declaration.InitializerNode
isSideEffectFreeMethods inherited from interface dev.civl.abc.ast.node.IF.expression.SizeableNode
getType
-
Method Details
-
addConversion
Adds a conversion to the sequence of conversions for this expression. The added conversion must satisfy the following, else an IllegalArgumentException will be thrown: (1) if this is the first conversion (index 0) to be added, the old type of the conversion must equal the initial type; (2) if this is not the first conversion (index > 0) to be added, the old type of the conversion must equal the newType of the previous conversion.- Parameters:
conversion- the conversion to add to the conversion chain for this expression
-
copy
ExpressionNode 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 interfaceForLoopInitializerNode- Specified by:
copyin interfaceInitializerNode- Specified by:
copyin interfaceSizeableNode- Returns:
- deep copy of this node
-
expressionKind
ExpressionNode.ExpressionKind expressionKind()Returns the kind of this expression. Every expression belongs to exactly one kind.- Returns:
- the kind of this expression
-
getConversion
Returns the index-th conversion in the chain of types for this expression.- Parameters:
index- an integer in the range [0,numTypes-1]- Returns:
- the index-th conversion associated to this expression
-
getConvertedType
Type getConvertedType()Returns the final converted type of the expression. This is the type the expression has after going through all conversions in its conversion sequence (if any). If there are no conversions, it is the same as the initial type. Otherwise, it is the newType of the last conversion.- Returns:
- the final converted type of the expression
-
getInitialType
Type getInitialType()Returns the initial type of the expression. This is the type the expression has independent of any context in which the expression occurs.- Returns:
- initial type of expression
-
getNumConversions
int getNumConversions()Returns the number of conversions in the chain leading from the initial type of the expression to the final converted type. The type of an expression may go through a number of type conversions before arriving at its final "converted type". These conversions depend upon the context in which the expression occurs. The sequence of conversions leading from the initial type to the final converted type form a chain in which the "newType" of conversion i equals the "oldType" of conversion i+1 for each i. The oldType of conversion 0 is the original type of the expression; the newType of the last conversion is the converted type of the expression. This method returns the total number of conversions in that chain. The method will return a nonnegative integer. If there are no conversions, this method returns 0 and the initial and final types are equal.- Returns:
- the number of type conversions between the original type and the converted type
-
isConstantExpression
boolean isConstantExpression()Is this expression a "constant expression" in the sense of the C11 Standard?- Returns:
- true iff this expression is a constant expression
-
removeConversions
void removeConversions()Removes all conversions from this node -
setInitialType
Sets the initial type of the expression. This must be set before any conversions are added.- Parameters:
type- the type that will be the initial type of this expression
-
isLvalue
boolean isLvalue()checks if this expression is an lvalue expression.
-