private InstanceFieldKeyAndState getInstFieldKey(InstanceKeyAndState ikAndState, IField field) { return new InstanceFieldKeyAndState(new InstanceFieldKey(ikAndState.getInstanceKey(), field), ikAndState.getState()); }
private int compareFieldKey(InstanceFieldKey key1, Object key2) { if (key2 instanceof InstanceFieldKey) { int r1 = compareInstanceKeys(key1.getInstanceKey(), ((InstanceFieldKey)key2).getInstanceKey()); if (r1 != 0) return r1; else { return compareFields(key1.getField(), ((InstanceFieldKey)key2).getField()); } } else return -1; }
private IClass inferType(PointerKey key) { if (key instanceof LocalPointerKeyWithFilter) { LocalPointerKeyWithFilter lpk = (LocalPointerKeyWithFilter) key; FilteredPointerKey.TypeFilter filter = lpk.getTypeFilter(); assert filter instanceof FilteredPointerKey.SingleClassFilter; return ((FilteredPointerKey.SingleClassFilter) filter).getConcreteType(); } else if (key instanceof StaticFieldKey) { StaticFieldKey s = (StaticFieldKey) key; return getCallGraph().getClassHierarchy().lookupClass(s.getField().getFieldTypeReference()); } else if (key instanceof InstanceFieldKey) { InstanceFieldKey i = (InstanceFieldKey) key; return getCallGraph().getClassHierarchy().lookupClass(i.getField().getFieldTypeReference()); } else if (key instanceof ArrayContentsKey) { ArrayContentsKey i = (ArrayContentsKey) key; FilteredPointerKey.TypeFilter filter = i.getTypeFilter(); assert filter instanceof FilteredPointerKey.SingleClassFilter; return ((FilteredPointerKey.SingleClassFilter) filter).getConcreteType(); } else if (key instanceof ExceptionReturnValueKey) { return getCallGraph().getClassHierarchy().lookupClass(TypeReference.JavaLangException); } else if (key instanceof ReturnValueKey) { ReturnValueKey r = (ReturnValueKey) key; return getCallGraph().getClassHierarchy().lookupClass(r.getNode().getMethod().getReturnType()); } else { Assertions.UNREACHABLE("inferType " + key.getClass()); return null; } }
@Override @SuppressWarnings("unchecked") public OrdinalSet<InstanceKey> getPointsToSet(PointerKey key) { if (pointsToMap.isImplicit(key)) { return computeImplicitPointsToSet(key); } // special logic to handle contents of char[] from string constants. if (key instanceof InstanceFieldKey) { InstanceFieldKey ifk = (InstanceFieldKey) key; if (ifk.getInstanceKey() instanceof ConstantKey) { ConstantKey<?> i = (ConstantKey<?>) ifk.getInstanceKey(); if (i.getValue() instanceof String && i.getConcreteType().getClassLoader().getLanguage().equals(Language.JAVA)) { StringConstantCharArray contents = StringConstantCharArray.make((ConstantKey<String>) i); instanceKeys.add(contents); Collection<InstanceKey> singleton = HashSetFactory.make(); singleton.add(contents); return OrdinalSet.toOrdinalSet(singleton, instanceKeys); } } } PointsToSetVariable v = pointsToMap.getPointsToSet(key); if (v == null) { return OrdinalSet.empty(); } else { IntSet S = v.getValue(); return new OrdinalSet<>(S, instanceKeys); } }
private IClass inferType(PointerKey key) { if (key instanceof LocalPointerKeyWithFilter) { LocalPointerKeyWithFilter lpk = (LocalPointerKeyWithFilter) key; FilteredPointerKey.TypeFilter filter = lpk.getTypeFilter(); assert filter instanceof FilteredPointerKey.SingleClassFilter; return ((FilteredPointerKey.SingleClassFilter) filter).getConcreteType(); } else if (key instanceof StaticFieldKey) { StaticFieldKey s = (StaticFieldKey) key; return getCallGraph().getClassHierarchy().lookupClass(s.getField().getFieldTypeReference()); } else if (key instanceof InstanceFieldKey) { InstanceFieldKey i = (InstanceFieldKey) key; return getCallGraph().getClassHierarchy().lookupClass(i.getField().getFieldTypeReference()); } else if (key instanceof ArrayContentsKey) { ArrayContentsKey i = (ArrayContentsKey) key; FilteredPointerKey.TypeFilter filter = i.getTypeFilter(); assert filter instanceof FilteredPointerKey.SingleClassFilter; return ((FilteredPointerKey.SingleClassFilter) filter).getConcreteType(); } else if (key instanceof ExceptionReturnValueKey) { return getCallGraph().getClassHierarchy().lookupClass(TypeReference.JavaLangException); } else if (key instanceof ReturnValueKey) { ReturnValueKey r = (ReturnValueKey) key; return getCallGraph().getClassHierarchy().lookupClass(r.getNode().getMethod().getReturnType()); } else { Assertions.UNREACHABLE("inferType " + key.getClass()); return null; } }
@Override @SuppressWarnings("unchecked") public OrdinalSet<InstanceKey> getPointsToSet(PointerKey key) { if (pointsToMap.isImplicit(key)) { return computeImplicitPointsToSet(key); } // special logic to handle contents of char[] from string constants. if (key instanceof InstanceFieldKey) { InstanceFieldKey ifk = (InstanceFieldKey) key; if (ifk.getInstanceKey() instanceof ConstantKey) { ConstantKey<?> i = (ConstantKey<?>) ifk.getInstanceKey(); if (i.getValue() instanceof String && i.getConcreteType().getClassLoader().getLanguage().equals(Language.JAVA)) { StringConstantCharArray contents = StringConstantCharArray.make((ConstantKey<String>) i); instanceKeys.add(contents); Collection<InstanceKey> singleton = HashSetFactory.make(); singleton.add(contents); return OrdinalSet.toOrdinalSet(singleton, instanceKeys); } } } PointsToSetVariable v = pointsToMap.getPointsToSet(key); if (v == null) { return OrdinalSet.empty(); } else { IntSet S = v.getValue(); return new OrdinalSet<>(S, instanceKeys); } }
private int compareFieldKey(InstanceFieldKey key1, Object key2) { if (key2 instanceof InstanceFieldKey) { int r1 = compareInstanceKeys(key1.getInstanceKey(), ((InstanceFieldKey)key2).getInstanceKey()); if (r1 != 0) return r1; else { return compareFields(key1.getField(), ((InstanceFieldKey)key2).getField()); } } else return -1; }
private InstanceFieldKeyAndState getInstFieldKey(InstanceKeyAndState ikAndState, IField field) { return new InstanceFieldKeyAndState(new InstanceFieldKey(ikAndState.getInstanceKey(), field), ikAndState.getState()); }
@Override public PointerKey getPointerKeyForInstanceField(InstanceKey I, IField field) { if (field == null) { throw new IllegalArgumentException("field is null"); } IField resolveAgain = I.getConcreteType().getField(field.getName(), field.getFieldTypeReference().getName()); if (resolveAgain != null) { field = resolveAgain; } return new InstanceFieldKey(I, field); }
@Override public PointerKey getPointerKeyForInstanceField(InstanceKey I, IField field) { if (field == null) { throw new IllegalArgumentException("field is null"); } IField resolveAgain = I.getConcreteType().getField(field.getName(), field.getFieldTypeReference().getName()); if (resolveAgain != null) { field = resolveAgain; } return new InstanceFieldKey(I, field); }