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;
 }
Ejemplo n.º 2
0
 public IR getIR(CGNode n) {
   // AnalysisOptions options = new AnalysisOptions();
   IR ir =
       analysisCache
           .getSSACache()
           .findOrCreateIR(n.getMethod(), n.getContext(), options.getSSAOptions());
   return ir;
 }
Ejemplo n.º 3
0
 /**
  * @see
  *     com.ibm.wala.ipa.callgraph.propagation.rta.RTAContextInterpreter#understands(com.ibm.wala.ipa.callgraph.CGNode)
  */
 @Override
 public boolean understands(CGNode node) {
   if (node == null) {
     throw new IllegalArgumentException("node is null");
   }
   if (!(node.getContext() instanceof GetMethodContext)) {
     return false;
   }
   MethodReference mRef = node.getMethod().getReference();
   return mRef.equals(GET_METHOD) || mRef.equals(GET_DECLARED_METHOD);
 }
Ejemplo n.º 4
0
  private FilteredPointerKey.TypeFilter getFilter(CGNode target) {
    FilteredPointerKey.TypeFilter filter =
        (FilteredPointerKey.TypeFilter) target.getContext().get(ContextKey.PARAMETERS[0]);

    if (filter != null) {
      return filter;
    } else {
      // the context does not select a particular concrete type for the
      // receiver.
      IClass C = getReceiverClass(target.getMethod());
      return new FilteredPointerKey.SingleClassFilter(C);
    }
  }
Ejemplo n.º 5
0
 @Override
 public Iterator<NewSiteReference> iterateNewSites(CGNode node) {
   if (node == null) {
     throw new IllegalArgumentException("node is null");
   }
   assert understands(node);
   GetMethodContext context = (GetMethodContext) node.getContext();
   TypeReference tr = context.getType().getTypeReference();
   if (tr != null) {
     return new NonNullSingletonIterator<NewSiteReference>(NewSiteReference.make(0, tr));
   }
   return EmptyIterator.instance();
 }
Ejemplo n.º 6
0
 /**
  * @see
  *     com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter#getIR(com.ibm.wala.ipa.callgraph.CGNode)
  */
 @Override
 public IR getIR(CGNode node) {
   if (node == null) {
     throw new IllegalArgumentException("node is null");
   }
   assert understands(node);
   if (DEBUG) {
     System.err.println("generating IR for " + node);
   }
   IMethod method = node.getMethod();
   GetMethodContext context = (GetMethodContext) node.getContext();
   Map<Integer, ConstantValue> constants = HashMapFactory.make();
   if (method.getReference().equals(GET_METHOD)) {
     Atom name = Atom.findOrCreateAsciiAtom(context.getName());
     SSAInstruction instrs[] = makeGetMethodStatements(context, constants, name);
     return new SyntheticIR(
         method,
         context,
         new InducedCFG(instrs, method, context),
         instrs,
         SSAOptions.defaultOptions(),
         constants);
   }
   if (method.getReference().equals(GET_DECLARED_METHOD)) {
     Atom name = Atom.findOrCreateAsciiAtom(context.getName());
     SSAInstruction instrs[] = makeGetDeclaredMethodStatements(context, constants, name);
     return new SyntheticIR(
         method,
         context,
         new InducedCFG(instrs, method, context),
         instrs,
         SSAOptions.defaultOptions(),
         constants);
   }
   Assertions.UNREACHABLE("Unexpected method " + node);
   return null;
 }