private boolean exceedsRecursionBound(Context baseContext, int curLevel) { if (curLevel > recursionBound) { return true; } // we just do a case analysis here. we might have to add cases later to // account for new types of context / recursion. CGNode callerNode = (CGNode) baseContext.get(ContextKey.CALLER); if (callerNode != null && exceedsRecursionBound(callerNode.getContext(), curLevel + 1)) { return true; } for (int i = 0; i < MAX_INTERESTING_PARAM; i++) { FilteredPointerKey.SingleInstanceFilter filter = (SingleInstanceFilter) baseContext.get(ContextKey.PARAMETERS[i]); if (filter != null) { InstanceKey ik = filter.getInstance(); if (ik instanceof ScopeMappingInstanceKey) { ik = ((ScopeMappingInstanceKey) ik).getBase(); } if (ik instanceof InstanceKeyWithNode) { if (exceedsRecursionBound( ((InstanceKeyWithNode) ik).getNode().getContext(), curLevel + 1)) { return true; } } } } return false; }
@Override public Context getCalleeTarget( CGNode caller, CallSiteReference site, IMethod callee, InstanceKey[] receiver) { Context baseContext = baseSelector.getCalleeTarget(caller, site, callee, receiver); if (baseContext.equals(Everywhere.EVERYWHERE)) { return new CallerSiteContext(caller, site); } else { return new CallerSiteContextPair(caller, site, baseContext); } }