Class Expression
- java.lang.Object
-
- it.unive.lisa.program.cfg.statement.Statement
-
- it.unive.lisa.program.cfg.statement.Expression
-
- All Implemented Interfaces:
ProgramPoint
,CodeElement
,CodeNode<CFG,Statement,Edge>
,Node<CFG,Statement,Edge>
,java.lang.Comparable<Statement>
- Direct Known Subclasses:
DefaultParamInitialization
,Literal
,NaryExpression
,VariableRef
public abstract class Expression extends Statement
An expression that is part of a statement of the program.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Expression(CFG cfg, CodeLocation location)
Builds an untyped expression happening at the given source location, that is its type isUntyped.INSTANCE
.protected
Expression(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 boolean
equals(java.lang.Object obj)
java.util.Collection<Identifier>
getMetaVariables()
Yields the meta variables that are generated by the evaluation of this expression.Statement
getParentStatement()
Yields theStatement
that contains this expression, if any.Statement
getRootStatement()
Yields the outer-mostStatement
containing this expression, that is used as a node in the cfg.Statement
getStatementEvaluatedAfter(Statement other)
Yields theStatement
that follows the given one, assuming thatother
is contained into this statement.Statement
getStatementEvaluatedBefore(Statement other)
Yields theStatement
that precedes the given one, assuming thatother
is contained into this statement.Type
getStaticType()
Yields the static type of this expression.int
hashCode()
void
setParentStatement(Statement st)
Sets theStatement
that contains this expression.-
Methods inherited from class it.unive.lisa.program.cfg.statement.Statement
backwardSemantics, compareTo, forwardSemantics, getCFG, getEvaluationPredecessor, getEvaluationSuccessor, getLocation, getOffset, stopsExecution, throwsError, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.program.cfg.ProgramPoint
getProgram
-
-
-
-
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 program
-
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 programstaticType
- 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
-
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 expression semantics, thus invoking this method before computing the semantics will yield an empty collection. Variables added here should represent stack values that cannot be re-computed at a later time (e.g., call return values).- Returns:
- the meta variables
-
setParentStatement
public final void setParentStatement(Statement st)
Sets theStatement
that contains this expression.- Parameters:
st
- the containing statement
-
getParentStatement
public final Statement getParentStatement()
Yields theStatement
that 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
-
getRootStatement
public final Statement getRootStatement()
Yields the outer-mostStatement
containing this expression, that is used as a node in the cfg. If this expression is used a command, then this method returnthis
. If this expression is aCall
built as a resolved version of anUnresolvedCall
uc
, thenuc.getRootStatement()
is returned.- Returns:
- the outer-most statement containing this expression, or
this
-
getStatementEvaluatedBefore
public Statement getStatementEvaluatedBefore(Statement other)
Description copied from class:Statement
Yields theStatement
that precedes the given one, assuming thatother
is contained into this statement. If this method returnsnull
, thenother
is the first expression evaluated when this statement is evaluated.- Overrides:
getStatementEvaluatedBefore
in classStatement
- Parameters:
other
- the other statement- Returns:
- the previous statement, or
null
-
getStatementEvaluatedAfter
public Statement getStatementEvaluatedAfter(Statement other)
Description copied from class:Statement
Yields theStatement
that follows the given one, assuming thatother
is contained into this statement. If this method returnsnull
, thenother
is the last expression evaluated when this statement is evaluated.- Overrides:
getStatementEvaluatedAfter
in classStatement
- Parameters:
other
- the other statement- Returns:
- the next statement, or
null
-
-