Package sootup.core.jimple.basic
Class JimpleComparator
java.lang.Object
sootup.core.jimple.basic.JimpleComparator
- Direct Known Subclasses:
IgnoreLocalNameComparator
This class contains the equivalence implementations for the individual
EquivTo.equivTo(Object)
methods of the Jimple IR. You can use it as your base class if your use
case needs an adjustment for checking structural equivalence. This follows a contract weaker than
Object.equals(Object)
:
X x = ...; Y y = ...; x.equivTo(y);
will check whether y
is an instance of
X
and whether the properties known to X
are equal in both objects.
- It is reflexive: for any non-null reference value
x
,x.equivTo(x)
should returntrue
. - In contrast to
Object.equals(Object)
it is not necessarily symmetric: Consider reference valuesFoo x
andBar y
whereclass Bar extends Foo
. Ifx.equivTo(y)
returnstrue
, it is still valid fory.equivTo(x)
to returnfalse
. This is becausex.equivTo(y)
will only compare the properties defined inFoo
. IfBar
has added any other properties, it will also take these into consideration for the comparison. SinceFoo
does not contain them,y.equivTo(x)
will returnfalse
in this case. - In contrast to
Object.equals(Object)
it is not necessarily transitive. This is because it is reflexive, but not necessarily symmetric. This means that whenx.equivTo(y) == true
andy.equivTo(z) == true
, this does not implyx.equivTo(z) == true
. A trivial example showing this is whenx
refers to the same object asz
, sinceequivTo
is not always symmetric. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equivTo(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequivTo
comparisons on the objects is modified. - For any non-null reference value
x
,x.equivTo(null)
should returnfalse
.
- Author:
- Markus Schmidt
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
protected boolean
boolean
caseArrayRef
(JArrayRef obj, Object o) boolean
caseAssignStmt
(JAssignStmt stmt, Object o) boolean
caseBlock
(BasicBlock<?> block, Object o) boolean
caseBreakpointStmt
(JBreakpointStmt stmt, Object o) boolean
caseCastExpr
(JCastExpr v, Object o) boolean
boolean
caseConstant
(Constant constant, Object o) boolean
boolean
caseEnterMonitorStmt
(JEnterMonitorStmt stmt, Object o) boolean
caseExitMonitorStmt
(JExitMonitorStmt stmt, Object o) boolean
caseGotoStmt
(JGotoStmt stmt, Object o) boolean
caseIdentityStmt
(JIdentityStmt stmt, Object o) boolean
caseIfStmt
(JIfStmt stmt, Object o) boolean
boolean
boolean
boolean
caseInvokeStmt
(JInvokeStmt stmt, Object o) boolean
caseJPhiExpr
(JPhiExpr v, Object o) boolean
caseLengthExpr
(JLengthExpr v, Object o) boolean
boolean
caseNegExpr
(JNegExpr v, Object o) boolean
boolean
caseNewExpr
(JNewExpr v, Object o) boolean
boolean
caseNopStmt
(JNopStmt stmt, Object o) boolean
caseParameterRef
(JParameterRef obj, Object o) boolean
caseRetStmt
(JRetStmt stmt, Object o) boolean
caseReturnStmt
(JReturnStmt stmt, Object o) boolean
caseReturnVoidStmt
(JReturnVoidStmt stmt, Object o) boolean
boolean
caseStaticFieldRef
(JStaticFieldRef obj, Object o) boolean
boolean
boolean
caseSwitchStmt
(JSwitchStmt stmt, Object o) assumes that different sequence of (otherwise equivalent) cases means values are not considered equivalentboolean
caseThisRef
(JThisRef obj, Object o) boolean
caseThrowStmt
(JThrowStmt stmt, Object o) boolean
static JimpleComparator
Returns the defaultJimpleComparator
.
-
Constructor Details
-
JimpleComparator
public JimpleComparator()
-
-
Method Details
-
getInstance
Returns the defaultJimpleComparator
. You may customize the behavior by extendingJimpleComparator
and overriding methods. -
caseLocal
-
caseBlock
-
caseStmt
-
caseBreakpointStmt
-
caseInvokeStmt
-
caseAssignStmt
-
caseIdentityStmt
-
caseEnterMonitorStmt
-
caseExitMonitorStmt
-
caseGotoStmt
-
caseIfStmt
-
caseSwitchStmt
assumes that different sequence of (otherwise equivalent) cases means values are not considered equivalent -
caseNopStmt
-
caseRetStmt
-
caseReturnStmt
-
caseReturnVoidStmt
-
caseThrowStmt
-
caseAbstractBinopExpr
-
caseStaticInvokeExpr
-
caseDynamicInvokeExpr
-
caseCastExpr
-
caseInstanceOfExpr
-
caseNewArrayExpr
-
caseNewMultiArrayExpr
-
caseJPhiExpr
-
caseNewExpr
-
caseLengthExpr
-
caseNegExpr
-
caseAbstractInstanceInvokeExpr
-
caseInterfaceInvokeExpr
-
caseSpecialInvokeExpr
-
caseVirtualInvokeExpr
-
caseArrayRef
-
caseCaughtException
-
caseInstanceFieldRef
-
caseParameterRef
-
caseStaticFieldRef
-
caseThisRef
-
caseConstant
-