Package it.unive.lisa.analysis.types
Class InferredTypes
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<T>
-
- it.unive.lisa.analysis.nonrelational.inference.BaseInferredValue<InferredTypes>
-
- it.unive.lisa.analysis.types.InferredTypes
-
- All Implemented Interfaces:
Lattice<InferredTypes>,InferredValue<InferredTypes>,NonRelationalElement<InferredTypes,ValueExpression,InferenceSystem<InferredTypes>>,SemanticEvaluator
public class InferredTypes extends BaseInferredValue<InferredTypes>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface it.unive.lisa.analysis.nonrelational.inference.InferredValue
InferredValue.InferredPair<T extends InferredValue<T>>, InferredValue.InferredPairRepresentation
-
-
Field Summary
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_REPR, BOTTOM_STRING, TOP_REPR, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description InferredTypes()Builds the inferred types.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InferredTypesbottom()Yields the bottom element of this lattice.booleancanProcess(SymbolicExpression expression)Yieldstrueif the domain can processexpression,falseotherwise.booleanequals(java.lang.Object obj)protected InferredValue.InferredPair<InferredTypes>evalBinaryExpression(BinaryOperator operator, InferredTypes left, InferredTypes right, InferredTypes state, ProgramPoint pp)Yields the evaluation of aBinaryExpressionapplyingoperatorto two expressions whose abstract value areleftandright, respectively.protected InferredValue.InferredPair<InferredTypes>evalIdentifier(Identifier id, InferenceSystem<InferredTypes> environment, ProgramPoint pp)Yields the evaluation of an identifier in a given environment.protected InferredValue.InferredPair<InferredTypes>evalNonNullConstant(Constant constant, InferredTypes state, ProgramPoint pp)Yields the evaluation of the given non-null constant.protected InferredValue.InferredPair<InferredTypes>evalNullConstant(InferredTypes state, ProgramPoint pp)Yields the evaluation of the null constantNullConstant.protected InferredValue.InferredPair<InferredTypes>evalPushAny(PushAny pushAny, InferredTypes state, ProgramPoint pp)Yields the evaluation of a push-any expression.protected InferredValue.InferredPair<InferredTypes>evalTernaryExpression(TernaryOperator operator, InferredTypes left, InferredTypes middle, InferredTypes right, InferredTypes state, ProgramPoint pp)Yields the evaluation of aTernaryExpressionapplyingoperatorto two expressions whose abstract value areleft,middleandright, respectively.protected InferredValue.InferredPair<InferredTypes>evalTypeCast(BinaryExpression cast, InferredTypes left, InferredTypes right, InferredTypes state, ProgramPoint pp)Yields the evaluation of a type cast expression.protected InferredValue.InferredPair<InferredTypes>evalTypeConv(BinaryExpression conv, InferredTypes left, InferredTypes right, InferredTypes state, ProgramPoint pp)Yields the evaluation of a type conversion expression.protected InferredValue.InferredPair<InferredTypes>evalUnaryExpression(UnaryOperator operator, InferredTypes arg, InferredTypes state, ProgramPoint pp)Yields the evaluation of aUnaryExpressionapplyingoperatorto an expression whose abstract value isarg.ExternalSet<Type>getRuntimeTypes()Yields theExternalSetcontaining the types held by this instance.inthashCode()protected booleanlessOrEqualAux(InferredTypes other)Yieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled.protected InferredTypeslubAux(InferredTypes other)Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.DomainRepresentationrepresentation()Yields aDomainRepresentationof the information contained in this domain's instance.protected SemanticDomain.SatisfiabilitysatisfiesBinaryExpression(BinaryOperator operator, InferredTypes left, InferredTypes right, InferredTypes state, ProgramPoint pp)Yields the satisfiability of aBinaryExpressionapplyingoperatorto two expressions whose abstract values areleft, andright.InferredTypestop()Yields the top element of this lattice.booleantracksIdentifiers(Identifier id)Yieldstrueif the domain tracks information on the identifierid,falseotherwise.protected InferredTypeswideningAux(InferredTypes other)Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled.-
Methods inherited from class it.unive.lisa.analysis.nonrelational.inference.BaseInferredValue
assume, eval, glb, glbAux, satisfies, satisfiesAbstractValue, satisfiesNonNullConstant, satisfiesNullConstant, satisfiesPushAny, satisfiesTernaryExpression, satisfiesUnaryExpression, toString
-
Methods inherited from class it.unive.lisa.analysis.BaseLattice
lessOrEqual, lub, widening
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.Lattice
isBottom, isTop, lessOrEqual, lub, widening
-
Methods inherited from interface it.unive.lisa.analysis.nonrelational.NonRelationalElement
variable
-
-
-
-
Method Detail
-
getRuntimeTypes
public ExternalSet<Type> getRuntimeTypes()
Yields theExternalSetcontaining the types held by this instance.- Returns:
- the set of types inside this instance
-
top
public InferredTypes top()
Description copied from interface:LatticeYields the top element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isTop()uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isTop()accordingly to provide a coherent test.- Returns:
- the top element
-
bottom
public InferredTypes bottom()
Description copied from interface:LatticeYields the bottom element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isBottom()uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isBottom()accordingly to provide a coherent test.- Returns:
- the bottom element
-
representation
public DomainRepresentation representation()
Description copied from interface:NonRelationalElementYields aDomainRepresentationof the information contained in this domain's instance.- Returns:
- the representation
-
evalIdentifier
protected InferredValue.InferredPair<InferredTypes> evalIdentifier(Identifier id, InferenceSystem<InferredTypes> environment, ProgramPoint pp) throws SemanticException
Description copied from class:BaseInferredValueYields the evaluation of an identifier in a given environment.- Overrides:
evalIdentifierin classBaseInferredValue<InferredTypes>- Parameters:
id- the identifier to be evaluatedenvironment- the environment where the identifier must be evaluatedpp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the identifier
- Throws:
SemanticException- if an error occurs during the computation
-
evalPushAny
protected InferredValue.InferredPair<InferredTypes> evalPushAny(PushAny pushAny, InferredTypes state, ProgramPoint pp)
Description copied from class:BaseInferredValueYields the evaluation of a push-any expression.- Overrides:
evalPushAnyin classBaseInferredValue<InferredTypes>- Parameters:
pushAny- the push-any expression to be evaluatedstate- the current execution statepp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the push-any expression
-
evalNullConstant
protected InferredValue.InferredPair<InferredTypes> evalNullConstant(InferredTypes state, ProgramPoint pp)
Description copied from class:BaseInferredValueYields the evaluation of the null constantNullConstant.- Overrides:
evalNullConstantin classBaseInferredValue<InferredTypes>- Parameters:
state- the current execution statepp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the constant
-
evalNonNullConstant
protected InferredValue.InferredPair<InferredTypes> evalNonNullConstant(Constant constant, InferredTypes state, ProgramPoint pp)
Description copied from class:BaseInferredValueYields the evaluation of the given non-null constant.- Overrides:
evalNonNullConstantin classBaseInferredValue<InferredTypes>- Parameters:
constant- the constant to evaluatestate- the current execution statepp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the constant
-
evalUnaryExpression
protected InferredValue.InferredPair<InferredTypes> evalUnaryExpression(UnaryOperator operator, InferredTypes arg, InferredTypes state, ProgramPoint pp)
Description copied from class:BaseInferredValueYields the evaluation of aUnaryExpressionapplyingoperatorto an expression whose abstract value isarg. It is guaranteed thatargis notLattice.bottom().- Overrides:
evalUnaryExpressionin classBaseInferredValue<InferredTypes>- Parameters:
operator- the operator applied by the expressionarg- the instance of this domain representing the abstract value of the expresion's argumentstate- the current execution statepp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the expression
-
evalBinaryExpression
protected InferredValue.InferredPair<InferredTypes> evalBinaryExpression(BinaryOperator operator, InferredTypes left, InferredTypes right, InferredTypes state, ProgramPoint pp)
Description copied from class:BaseInferredValueYields the evaluation of aBinaryExpressionapplyingoperatorto two expressions whose abstract value areleftandright, respectively. It is guaranteed that bothleftandrightare notLattice.bottom()and thatoperatoris neitherBinaryOperator.TYPE_CASTnorBinaryOperator.TYPE_CONV.- Overrides:
evalBinaryExpressionin classBaseInferredValue<InferredTypes>- Parameters:
operator- the operator applied by the expressionleft- the instance of this domain representing the abstract value of the left-hand side argumentright- the instance of this domain representing the abstract value of the right-hand side argumentstate- the current execution statepp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the expression
-
evalTernaryExpression
protected InferredValue.InferredPair<InferredTypes> evalTernaryExpression(TernaryOperator operator, InferredTypes left, InferredTypes middle, InferredTypes right, InferredTypes state, ProgramPoint pp)
Description copied from class:BaseInferredValueYields the evaluation of aTernaryExpressionapplyingoperatorto two expressions whose abstract value areleft,middleandright, respectively. It is guaranteed that bothleftandrightare notLattice.bottom().- Overrides:
evalTernaryExpressionin classBaseInferredValue<InferredTypes>- Parameters:
operator- the operator applied by the expressionleft- the instance of this domain representing the abstract value of the left-hand side argumentmiddle- the instance of this domain representing the abstract value of the middle argumentright- the instance of this domain representing the abstract value of the right-hand side argumentstate- the current execution statepp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the expression
-
satisfiesBinaryExpression
protected SemanticDomain.Satisfiability satisfiesBinaryExpression(BinaryOperator operator, InferredTypes left, InferredTypes right, InferredTypes state, ProgramPoint pp)
Description copied from class:BaseInferredValueYields the satisfiability of aBinaryExpressionapplyingoperatorto two expressions whose abstract values areleft, andright. This method returns an instance ofSemanticDomain.Satisfiability. It is guaranteed thatoperatoris neitherBinaryOperator.LOGICAL_ANDnorBinaryOperator.LOGICAL_OR, and that bothleftandrightare notLattice.bottom().- Overrides:
satisfiesBinaryExpressionin classBaseInferredValue<InferredTypes>- Parameters:
operator- the binary operator applied by the expressionleft- an instance of this abstract domain representing the argument of the left-hand side of the binary expressionright- an instance of this abstract domain representing the argument of the right-hand side of the binary expressionstate- the current execution statepp- the program point that where this operation is being evaluated- Returns:
SemanticDomain.Satisfiability.SATISFIEDif the expression is satisfied by this domain,SemanticDomain.Satisfiability.NOT_SATISFIEDif it is not satisfied, orSemanticDomain.Satisfiability.UNKNOWNif it is either impossible to determine if it satisfied, or if it is satisfied by some values and not by some others (this is equivalent to a TOP boolean value)
-
lubAux
protected InferredTypes lubAux(InferredTypes other) throws SemanticException
Description copied from class:BaseLatticePerforms the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
lubAuxin classBaseLattice<InferredTypes>- Parameters:
other- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
wideningAux
protected InferredTypes wideningAux(InferredTypes other) throws SemanticException
Description copied from class:BaseLatticePerforms the widening operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
wideningAuxin classBaseLattice<InferredTypes>- Parameters:
other- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
lessOrEqualAux
protected boolean lessOrEqualAux(InferredTypes other) throws SemanticException
Description copied from class:BaseLatticeYieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
lessOrEqualAuxin classBaseLattice<InferredTypes>- Parameters:
other- the other lattice element- Returns:
trueif and only if that condition holds- Throws:
SemanticException- if an error occurs during the computation
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBaseLattice<InferredTypes>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classBaseLattice<InferredTypes>
-
evalTypeCast
protected InferredValue.InferredPair<InferredTypes> evalTypeCast(BinaryExpression cast, InferredTypes left, InferredTypes right, InferredTypes state, ProgramPoint pp)
Description copied from class:BaseInferredValueYields the evaluation of a type cast expression.- Overrides:
evalTypeCastin classBaseInferredValue<InferredTypes>- Parameters:
cast- the type casted expressionleft- the left expression, namely the expression to be castedright- the right expression, namely the types to which left should be castedstate- the current execution statepp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the type cast expression
-
evalTypeConv
protected InferredValue.InferredPair<InferredTypes> evalTypeConv(BinaryExpression conv, InferredTypes left, InferredTypes right, InferredTypes state, ProgramPoint pp)
Description copied from class:BaseInferredValueYields the evaluation of a type conversion expression.- Overrides:
evalTypeConvin classBaseInferredValue<InferredTypes>- Parameters:
conv- the type conversion expressionleft- the left expression, namely the expression to be convertedright- the right expression, namely the types to which left should be convertedstate- the current execution statepp- the program point that where this operation is being evaluated- Returns:
- the evaluation of the type conversion expression
-
tracksIdentifiers
public boolean tracksIdentifiers(Identifier id)
Description copied from interface:SemanticEvaluatorYieldstrueif the domain tracks information on the identifierid,falseotherwise.- Parameters:
id- the identifier- Returns:
trueif the domain tracks information on the identifierid,falseotherwise
-
canProcess
public boolean canProcess(SymbolicExpression expression)
Description copied from interface:SemanticEvaluatorYieldstrueif the domain can processexpression,falseotherwise.- Parameters:
expression- the expression- Returns:
trueif the domain can processexpression,falseotherwise.
-
-