/** * The method this accessor reads the parameters from. */ public MethodReference forMethod() { if (this.mRef != null) { return this.mRef; } else { return this.method.getReference(); } }
public SyntheticMethod(IMethod method, IClass declaringClass, boolean isStatic, boolean isFactory) { super(); if (method == null) { throw new IllegalArgumentException("null method"); } this.resolvedMethod = method; this.method = resolvedMethod.getReference(); this.declaringClass = declaringClass; this.isStatic = isStatic; this.isFactory = isFactory; }
private Set<CGNode> findOrCreateMr2Nodes(IMethod method) { Set<CGNode> result = mr2Nodes.get(method.getReference()); if (result == null) { result = HashSetFactory.make(3); mr2Nodes.put(method.getReference(), result); } return result; }
/** * This object understands a dispatch to {@link java.lang.Class#getMethod(String, Class...)} * or {@link java.lang.Class#getDeclaredMethod} when the receiver is a type constant. */ private static boolean mayUnderstand(IMethod targetMethod,InstanceKey instance) { return UNDERSTOOD_METHOD_REFS.contains(targetMethod.getReference()) && getTypeConstant(instance) != null; }
/** * Method getBypass. check to see if a call to the receiver 'target' should be redirected to a different receiver. * * @throws IllegalArgumentException if target is null */ public SyntheticMethod getBypass(IMethod target) { if (target == null) { throw new IllegalArgumentException("target is null"); } return getBypass(target.getReference()); }
/** * This object may understand a dispatch to Class.getContructor when the receiver is a type constant. */ private static boolean mayUnderstand(IMethod targetMethod, InstanceKey instance) { return UNDERSTOOD_METHOD_REFS.contains(targetMethod.getReference()) && getTypeConstant(instance) != null; }
@Override public Set<CGNode> getNodes(MethodReference m) { IMethod im = getClassHierarchy().resolveMethod(m); if (im != null) { m = im.getReference(); } Set<CGNode> result = mr2Nodes.get(m); return (result == null) ? Collections.emptySet() : result; }
/** * @return true iff block is a basic block in the fake root method * @throws IllegalArgumentException if block is null */ public static boolean isFromFakeRoot(IBasicBlock block) { if (block == null) { throw new IllegalArgumentException("block is null"); } IMethod m = block.getMethod(); return m instanceof FakeRootMethod && ((FakeRootMethod)m).isFakeRootMethod(m.getReference()); } }
protected MethodReference resolveTarget(MethodReference target) { IMethod m = getClassHierarchy().resolveMethod(target); if (m != null) { if (DEBUG) { System.err.println(("resolveTarget: resolved to " + m)); } target = m.getReference(); } return target; }
@Override public Context getCalleeTarget(CGNode caller, CallSiteReference site, IMethod callee, InstanceKey[] receiver) { if (methodsToSpecialize.contains(site.getDeclaredTarget()) || methodsToSpecialize.contains(callee.getReference())) { return specialPolicy.getCalleeTarget(caller, site, callee, receiver); } else { return basePolicy.getCalleeTarget(caller, site, callee, receiver); } }
@Override public boolean understands(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } return (node.getMethod().getReference().equals(CLONE) && ContextUtil.getConcreteClassFromContext(node.getContext()) != null); }
@Override public boolean understands(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } if (!(node.getContext().isA(JavaTypeContext.class))) { return false; } return ClassFactoryContextSelector.isClassFactory(node.getMethod().getReference()); }
@Override public boolean understands(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } if (!(node.getContext().isA(JavaTypeContext.class))) { return false; } return node.getMethod().getReference().equals(CLASS_NEW_INSTANCE_REF); }
@Override public boolean understands(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } return (node.getMethod().getReference().equals(CLONE) && ContextUtil.getConcreteClassFromContext(node.getContext()) != null); }
@Override public Iterator<Pair<CGNode, NewSiteReference>> getCreationSites(CallGraph CG) { return new MapIterator<>( new FilterIterator<>( CG.getNodes(method.getReference()).iterator(), o -> o.getMethod().equals(method) ), object -> Pair.make(object, site)); } }
@Override public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) { IMethod declaredTarget = cha.resolveMethod(site.getDeclaredTarget()); if (declaredTarget != null && declaredTarget.getReference().equals(CloneInterpreter.CLONE)) { return selector.getRelevantParameters(caller, site); } else { return EmptyIntSet.instance; } }
@Override protected boolean sameMethod(CGNode opNode, String definingMethod) { MethodReference reference = opNode.getMethod().getReference(); String selector = reference.getSelector().toString(); String containingClass = reference.getDeclaringClass().getName().toString(); return definingMethod.equals(containingClass + '/' + selector); }
@Override protected boolean sameMethod(CGNode opNode, String definingMethod) { MethodReference reference = opNode.getMethod().getReference(); String selector = reference.getSelector().toString(); String containingClass = reference.getDeclaringClass().getName().toString(); return definingMethod.equals(containingClass + '/' + selector); }
@Override public Context getCalleeTarget(CGNode caller, CallSiteReference site, IMethod callee, InstanceKey[] receiver) { if (callee.getReference().equals(GET_CLASS)) { return new JavaTypeContext(new PointType(receiver[0].getConcreteType())); } return null; }
@Override public Iterator<MethodReference> getPredNodes(MethodReference N) { Set<MethodReference> pred = HashSetFactory.make(10); MethodReference methodReference = N; for (CGNode cgNode : cg.getNodes(methodReference)) for (CGNode p : Iterator2Iterable.make(cg.getPredNodes(cgNode))) pred.add(p.getMethod().getReference()); return pred.iterator(); }