Class Expression
java.lang.Object
de.fraunhofer.aisec.cpg.graph.Node
de.fraunhofer.aisec.cpg.graph.statements.Statement
de.fraunhofer.aisec.cpg.graph.statements.expressions.Expression
- All Implemented Interfaces:
DeclarationHolder,HasType,Persistable,IVisitable<de.fraunhofer.aisec.cpg.graph.Node>
- Direct Known Subclasses:
ArrayCreationExpression,ArrayRangeExpression,ArraySubscriptionExpression,BinaryOperator,CallExpression,CastExpression,CompoundStatementExpression,ConditionalExpression,DeclaredReferenceExpression,DeleteExpression,DesignatedInitializerExpression,ExpressionList,InitializerListExpression,Literal,NewExpression,TypeExpression,TypeIdExpression,UnaryOperator,UninitializedValue
public abstract class Expression extends Statement implements HasType
Represents one expression. It is used as a base class for multiple different types of
expressions. The only constraint is, that each expression has a type.
Note: In our graph, Expression is inherited from Statement. This is a
constraint of the C++ language. In C++, it is valid to have an expression (for example a Literal) as part of a function body, even though the expression value is not used. Consider the
following code:
int main() {
1;
}
This is not possible in Java, the aforementioned code example would prompt a compile error.
-
Nested Class Summary
Nested classes/interfaces inherited from class de.fraunhofer.aisec.cpg.graph.Node
de.fraunhofer.aisec.cpg.graph.Node.CompanionNested classes/interfaces inherited from interface de.fraunhofer.aisec.cpg.graph.HasType
HasType.SecondaryTypeEdge, HasType.TypeListener -
Field Summary
Fields Modifier and Type Field Description protected TypetypeThe type of the value after evaluation.Fields inherited from class de.fraunhofer.aisec.cpg.graph.Node
Companion, EMPTY_NAME, TO_STRING_STYLE -
Constructor Summary
Constructors Constructor Description Expression() -
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object o)java.util.Set<Type>getPossibleSubTypes()TypegetPropagationType()TypegetType()java.util.Set<HasType.TypeListener>getTypeListeners()inthashCode()voidrefreshType()voidregisterTypeListener(HasType.TypeListener listener)voidresetTypes(Type type)Used to set the type and clear the possible subtypes list for when a type is more precise than the current.voidsetPossibleSubTypes(java.util.Set<Type> possibleSubTypes, java.util.Collection<HasType> root)Set the node's possible subtypes.voidsetType(Type type, java.util.Collection<HasType> root)Set the node's type.java.lang.StringtoString()voidunregisterTypeListener(HasType.TypeListener listener)voidupdatePossibleSubtypes(java.util.Set<Type> types)voidupdateType(Type type)Sideeffect free type modification WARNING: This should only be used by the TypeSystem PassMethods inherited from class de.fraunhofer.aisec.cpg.graph.statements.Statement
addDeclaration, getDeclarations, getLocals, getLocalsPropertyEdge, removeLocal, setLocalsMethods inherited from class de.fraunhofer.aisec.cpg.graph.Node
addAnnotations, addNextDFG, addNextEOG, addPrevDFG, addPrevEOG, addTypedef, clearNextEOG, disconnectFromGraph, getAnnotations, getArgumentIndex, getAstChildren, getCode, getComment, getFile, getId, getLocation, getName, getNextDFG, getNextEOG, getNextEOGEdges, getPrevDFG, getPrevEOG, getPrevEOGEdges, getTypedefs, isImplicit, isInferred, removeNextDFG, removePrevDFG, removePrevEOGEntry, setAnnotations, setArgumentIndex, setCode, setComment, setFile, setId, setImplicit, setInferred, setLocation, setName, setNextDFG, setNextEOG, setNextEOGEdges, setPrevDFG, setPrevEOG, setPrevEOGEdges, setTypedefsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface de.fraunhofer.aisec.cpg.graph.DeclarationHolder
addIfNotContains, addIfNotContains, addIfNotContainsMethods inherited from interface de.fraunhofer.aisec.cpg.graph.HasType
setPossibleSubTypes, setTypeMethods inherited from interface de.fraunhofer.aisec.cpg.processing.IVisitable
accept
-
Field Details
-
type
The type of the value after evaluation.
-
-
Constructor Details
-
Expression
public Expression()
-
-
Method Details
-
getType
-
getPropagationType
- Specified by:
getPropagationTypein interfaceHasType- Returns:
- The returned Type is always the same as getType() with the exception of ReferenceType since there is no case in which we want to propagate a reference when using typeChanged()
-
updateType
Description copied from interface:HasTypeSideeffect free type modification WARNING: This should only be used by the TypeSystem Pass- Specified by:
updateTypein interfaceHasType- Parameters:
type- new type
-
updatePossibleSubtypes
- Specified by:
updatePossibleSubtypesin interfaceHasType
-
setType
Description copied from interface:HasTypeSet the node's type. This may start a chain of type listener notifications- Specified by:
setTypein interfaceHasType- Parameters:
type- new typeroot- The nodes which we have seen in the type change chain. When a node receives a type setting command where root.contains(this), we know that we have a type listener circle and can abort. If root is an empty list, the type change is seen as an externally triggered event and subsequent type listeners receive the current node as their root.
-
getPossibleSubTypes
- Specified by:
getPossibleSubTypesin interfaceHasType
-
setPossibleSubTypes
public void setPossibleSubTypes(java.util.Set<Type> possibleSubTypes, @NotNull java.util.Collection<HasType> root)Description copied from interface:HasTypeSet the node's possible subtypes. Listener circle detection works the same way as withHasType.setType(Type, Collection<HasType>)- Specified by:
setPossibleSubTypesin interfaceHasTyperoot- A list of already seen nodes which is used for detecting loops.
-
resetTypes
Description copied from interface:HasTypeUsed to set the type and clear the possible subtypes list for when a type is more precise than the current.- Specified by:
resetTypesin interfaceHasType- Parameters:
type- the more precise type
-
registerTypeListener
- Specified by:
registerTypeListenerin interfaceHasType
-
unregisterTypeListener
- Specified by:
unregisterTypeListenerin interfaceHasType
-
getTypeListeners
- Specified by:
getTypeListenersin interfaceHasType
-
refreshType
public void refreshType()- Specified by:
refreshTypein interfaceHasType
-
toString
public java.lang.String toString()- Overrides:
toStringin classde.fraunhofer.aisec.cpg.graph.Node
-
equals
public boolean equals(java.lang.Object o) -
hashCode
public int hashCode()
-