Class CastCounter

All Implemented Interfaces:
StmtVisitor, Visitor

public class CastCounter extends TypeChecker
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 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 Typings, 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.