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<Node>
- Direct Known Subclasses:
ArrayCreationExpression,ArrayRangeExpression,ArraySubscriptionExpression,BinaryOperator,CallExpression,CastExpression,CompoundStatementExpression,ConditionalExpression,ConstructExpression,DeclaredReferenceExpression,DeleteExpression,DesignatedInitializerExpression,ExpressionList,InitializerListExpression,Literal,NewExpression,TypeIdExpression,UnaryOperator,UninitializedValue
public 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,
Expressionis inherited fromStatement. This is a constraint of the C++ language. In C++, it is valid to have an expression (for example aLiteral) 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 interface de.fraunhofer.aisec.cpg.graph.HasType
HasType.TypeListener
-
-
Constructor Summary
Constructors Constructor Description Expression()
-
Method Summary
All Methods Instance Methods Concrete Methods 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, HasType root)Set the node's possible subtypes.voidsetType(Type type, 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 Pass-
Methods inherited from class de.fraunhofer.aisec.cpg.graph.statements.Statement
addDeclaration, getLocals, getLocalsPropertyEdge, removeLocal, setLocals
-
Methods inherited from class de.fraunhofer.aisec.cpg.graph.Node
addAnnotations, addNextCFG, addNextCFG, addNextDFG, addNextEOG, addPrevDFG, addPrevEOG, addTypedef, clearNextEOG, disconnectFromGraph, getAnnotations, getArgumentIndex, getCode, getFile, getId, getLocation, getName, getNextCFG, getNextDFG, getNextEOG, getNextEOGProperties, getNextEOGPropertyEdge, getPrevDFG, getPrevEOG, getPrevEOGProperties, getTypedefs, isDummy, isImplicit, removeNextDFG, removePrevDFG, removePrevEOGEntries, removePrevEOGEntry, setArgumentIndex, setCode, setComment, setDummy, setFile, setImplicit, setLocation, setName, setNextDFG, setNextEOG, setPrevDFG, setPrevEOG, setPrevEOGProperties, setTypedefs
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.fraunhofer.aisec.cpg.graph.DeclarationHolder
addIfNotContains, addIfNotContains, addIfNotContains
-
Methods inherited from interface de.fraunhofer.aisec.cpg.graph.HasType
setPossibleSubTypes, setType
-
Methods inherited from interface de.fraunhofer.aisec.cpg.processing.IVisitable
accept
-
-
-
-
Field Detail
-
type
protected Type type
The type of the value after evaluation.
-
-
Method Detail
-
getPropagationType
public Type 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
public void updateType(Type type)
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
public void updatePossibleSubtypes(java.util.Set<Type> types)
- Specified by:
updatePossibleSubtypesin interfaceHasType
-
setType
public void setType(Type type, HasType root)
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 node that initiated the type change chain. When a node receives a type setting command where root == this, we know that we have a type listener circle and can abort. If root == null, the type change is seen as an externally triggered event and subsequent type listeners receive the current node as their root.
-
getPossibleSubTypes
public java.util.Set<Type> getPossibleSubTypes()
- Specified by:
getPossibleSubTypesin interfaceHasType
-
setPossibleSubTypes
public void setPossibleSubTypes(java.util.Set<Type> possibleSubTypes, HasType root)
Description copied from interface:HasTypeSet the node's possible subtypes. Listener circle detection works the same way as withHasType.setType(Type, HasType)- Specified by:
setPossibleSubTypesin interfaceHasType
-
resetTypes
public void resetTypes(Type type)
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
public void registerTypeListener(HasType.TypeListener listener)
- Specified by:
registerTypeListenerin interfaceHasType
-
unregisterTypeListener
public void unregisterTypeListener(HasType.TypeListener listener)
- Specified by:
unregisterTypeListenerin interfaceHasType
-
getTypeListeners
public java.util.Set<HasType.TypeListener> getTypeListeners()
- Specified by:
getTypeListenersin interfaceHasType
-
refreshType
public void refreshType()
- Specified by:
refreshTypein interfaceHasType
-
-