Class Expression
- java.lang.Object
-
- it.unive.lisa.program.cfg.statement.Statement
-
- it.unive.lisa.program.cfg.statement.Expression
-
- All Implemented Interfaces:
ProgramPoint,CodeElement,Node<Statement,Edge,CFG>,java.lang.Comparable<Statement>
- Direct Known Subclasses:
AccessGlobal,AccessInstanceGlobal,BinaryExpression,Call,Literal,VariableRef
public abstract class Expression extends Statement
An expression that is part of a statement of the program.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedExpression(CFG cfg, CodeLocation location)Builds an untyped expression happening at the given source location, that is its type isUntyped.INSTANCE.protectedExpression(CFG cfg, CodeLocation location, Type staticType)Builds a typed expression happening at the given source location.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)TypegetDynamicType()Yields the dynamic type of this expression, that is, the most specific common supertype of all its runtime types (available throughgetRuntimeTypes().java.util.Collection<Identifier>getMetaVariables()Yields the meta variables that are generated by the evaluation of this expression.StatementgetParentStatement()Yields theStatementthat contains this expression, if any.StatementgetRootStatement()Yields the outer-mostStatementcontaining this expression, that is used as a node in the cfg.ExternalSet<Type>getRuntimeTypes()The concrete types that this expression can have at runtime.TypegetStaticType()Yields the static type of this expression.inthashCode()voidsetParentStatement(Statement st)Sets theStatementthat contains this expression.voidsetRuntimeTypes(ExternalSet<Type> runtimeTypes)Sets the runtime types of this expression.-
Methods inherited from class it.unive.lisa.program.cfg.statement.Statement
compareTo, getCFG, getLocation, getOffset, semantics, stopsExecution, throwsError, toString
-
-
-
-
Constructor Detail
-
Expression
protected Expression(CFG cfg, CodeLocation location)
Builds an untyped expression happening at the given source location, that is its type isUntyped.INSTANCE.- Parameters:
cfg- the cfg that this expression belongs tolocation- the location where the expression is defined within the source file. If unknown, usenull
-
Expression
protected Expression(CFG cfg, CodeLocation location, Type staticType)
Builds a typed expression happening at the given source location.- Parameters:
cfg- the cfg that this expression belongs tolocation- the location where this expression is defined within the source file. If unknown, usenullstaticType- the static type of this expression
-
-
Method Detail
-
getStaticType
public final Type getStaticType()
Yields the static type of this expression.- Returns:
- the static type of this expression
-
setRuntimeTypes
public final void setRuntimeTypes(ExternalSet<Type> runtimeTypes)
Sets the runtime types of this expression.- Parameters:
runtimeTypes- the set of concrete types that this expression can have at runtime
-
getRuntimeTypes
public final ExternalSet<Type> getRuntimeTypes()
The concrete types that this expression can have at runtime. If type inference has not been executed, this method returns a singleton set containing the static type of this expression.- Returns:
- the set of runtime types
-
getDynamicType
public final Type getDynamicType()
Yields the dynamic type of this expression, that is, the most specific common supertype of all its runtime types (available throughgetRuntimeTypes().- Returns:
- the dynamic type of this expression
-
getMetaVariables
public java.util.Collection<Identifier> getMetaVariables()
Yields the meta variables that are generated by the evaluation of this expression. These should be removed as soon as the values computed by those gets out of scope (e.g., popped from the stack). The returned collection will be filled while evaluating this expressionStatement.semantics(AnalysisState, it.unive.lisa.interprocedural.InterproceduralAnalysis, StatementStore), thus invoking this method before computing the semantics will yield an empty collection.- Returns:
- the meta variables
-
setParentStatement
public final void setParentStatement(Statement st)
Sets theStatementthat contains this expression.- Parameters:
st- the containing statement
-
getParentStatement
public final Statement getParentStatement()
Yields theStatementthat contains this expression, if any. If this method returnsnull, than this expression is used as a command: it is the root statement of a node in the cfg, and its returned value is discarded.- Returns:
- the statement that contains this expression, if any
-
-