Class CastCounter
java.lang.Object
sootup.core.jimple.visitor.AbstractStmtVisitor
sootup.interceptors.typeresolving.TypeChecker
sootup.interceptors.typeresolving.CastCounter
- All Implemented Interfaces:
StmtVisitor
,Visitor
For a given body, type hierarchy and typing, this class calculates all statements that are
necessary for the body to become use-valid.
That means it inserts casts when a variable is used in a place where a sub-type of the type of the variable is required.
It may also introduce additional local variables when a cast is necessary, but the use of the original variable doesn't allow inserting a cast into the statement directly.
Calling the constructor
That means it inserts casts when a variable is used in a place where a sub-type of the type of the variable is required.
It may also introduce additional local variables when a cast is necessary, but the use of the original variable doesn't allow inserting a cast into the statement directly.
Calling the constructor
CastCounter(sootup.core.model.Body.BodyBuilder, sootup.interceptors.typeresolving.AugEvalFunction, sootup.interceptors.typeresolving.BytecodeHierarchy, sootup.interceptors.typeresolving.Typing)
will calculate all necessary modifications to the
body, but not apply them yet. Then you can use getCastCount()
to get the amount of casts
that are necessary for this typing. If you have multiple possible Typing
s, this can be
used to select the one requiring the least number of casts. insertCastStmts()
will actually apply the modifications to the body and insert the new
locals into the typing as well.-
Field Summary
Fields inherited from class sootup.interceptors.typeresolving.TypeChecker
builder, graph, result
-
Constructor Summary
ConstructorDescriptionCastCounter
(Body.BodyBuilder builder, AugEvalFunction evalFunction, BytecodeHierarchy hierarchy, Typing typing) -
Method Summary
Modifier and TypeMethodDescriptionint
void
void
This method is used to check whether a value in a stmt needs a cast.Methods inherited from class sootup.interceptors.typeresolving.TypeChecker
caseAssignStmt, caseEnterMonitorStmt, caseExitMonitorStmt, caseIfStmt, caseInvokeStmt, caseReturnStmt, caseSwitchStmt, caseThrowStmt, getFuntion, getHierarchy, getResult, getTyping, selectArrayType, setResult, setTyping
Methods inherited from class sootup.core.jimple.visitor.AbstractStmtVisitor
caseBreakpointStmt, caseGotoStmt, caseIdentityStmt, caseNopStmt, caseRetStmt, caseReturnVoidStmt, defaultCaseStmt
-
Constructor Details
-
CastCounter
public CastCounter(@Nonnull Body.BodyBuilder builder, @Nonnull AugEvalFunction evalFunction, @Nonnull BytecodeHierarchy hierarchy, @Nonnull Typing typing)
-
-
Method Details
-
getCastCount
public int getCastCount() -
insertCastStmts
public void insertCastStmts() -
visit
This method is used to check whether a value in a stmt needs a cast.- Specified by:
visit
in classTypeChecker
-