public boolean twoValueEquals(Value v1, Value v2) { if (v1.toString().equals(v2.toString()) && v1.getType().toString().equals(v2.getType().toString())) { return true; } return false; }
public static List<Value> getAllImmediateValue(Stmt stmt) { List<Value> rtVal = new ArrayList<Value>(); List<ValueBox> vbs = stmt.getUseAndDefBoxes(); Set<String> frs = new HashSet<String>(); for (ValueBox vb : vbs) { Value v = vb.getValue(); if (v instanceof FieldRef) { int endPos = v.toString().indexOf('.'); String name = v.toString().substring(0, endPos); frs.add(name); Value existV = null; for (ValueBox vBox : vbs) { if (name.equals(vBox.getValue().toString())) { existV = vBox.getValue(); break; } } if (null != existV) { rtVal.remove(existV); } rtVal.add(v); } if (v instanceof Immediate) { if (!frs.contains(v.toString())) { rtVal.add(v); } } } return rtVal; }