Skip to content

Commit

Permalink
refactor(spgroup#31): don't compare as a string
Browse files Browse the repository at this point in the history
  • Loading branch information
barbosamaatheus committed Dec 22, 2020
1 parent 1804a3e commit 7d2727a
Showing 1 changed file with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,32 +214,18 @@ private void checkConflicts(Unit unit, List<DataFlowAbstraction> potentialConfli
}

// TODO improve method name
// TODO don't compare as a string
private boolean compareItens(ValueBox valueBox, DataFlowAbstraction dataFlowAbstraction) {
// TODO check why equivTo(Object o) doesn't work
if (valueBox.getValue() instanceof InstanceFieldRef && dataFlowAbstraction.getFieldRef() != null) {
return getVariableNameInFromValueBoxInstanceFieldRef(valueBox).equals(dataFlowAbstraction.getFieldRef().getBase().toString());
return valueBox.getValue().equivHashCode() == dataFlowAbstraction.getFieldRef().equivHashCode();
} else if (valueBox.getValue() instanceof StaticFieldRef && dataFlowAbstraction.getLocalStaticRef() != null) {
return getVariableNameInFromValueBoxStaticFieldRef(valueBox).equals(dataFlowAbstraction.getLocalStaticRef().getField().getName());
return valueBox.getValue().equivHashCode() == dataFlowAbstraction.getLocalStaticRef().equivHashCode();
} else if (valueBox.getValue() instanceof Local && dataFlowAbstraction.getLocal() != null) {
return getVariableNameInFromValueBoxLocal(valueBox).equals(dataFlowAbstraction.getLocal().getName());
return valueBox.getValue().equivHashCode() == dataFlowAbstraction.getLocal().equivHashCode();
}
return false;
}

private String getVariableNameInFromValueBoxInstanceFieldRef(ValueBox valueBox) {
InstanceFieldRef instanceFieldRef = (InstanceFieldRef) valueBox.getValue();
return instanceFieldRef.getBase().toString();
}

private String getVariableNameInFromValueBoxStaticFieldRef(ValueBox valueBox) {
StaticFieldRef staticFieldRef = (StaticFieldRef) valueBox.getValue();
return staticFieldRef.getField().getName();
}

private String getVariableNameInFromValueBoxLocal(ValueBox valueBox) {
Local local = (Local) valueBox.getValue();
return local.getName();
}

/*
* Returns the Statement changeTag
Expand Down

0 comments on commit 7d2727a

Please sign in to comment.