Пример #1
0
  public Set<? extends IAllocNode> getPTSetOfArrayElement(IAllocNode allocNode) {
    final Set<AllocNode> ptSet = new LinkedHashSet<AllocNode>();
    if (!(allocNode.getType() instanceof ArrayType)) {
      logger.error(
          "Calling getPTSetOfArrayElement on non array type: {} with {}",
          allocNode,
          allocNode.getType());
    }

    final Type filteringType = ((ArrayType) allocNode.getType()).getElementType();

    HashPointsToSet pointsToSet = new HashPointsToSet(allocNode.getType(), ptsProvider);
    pointsToSet.add((AllocNode) allocNode);

    ((PointsToSetInternal) ptsProvider.reachingObjectsOfArrayElement(pointsToSet))
        .forall(
            new P2SetVisitor() {
              @Override
              public void visit(Node node) {
                if (typeManager.castNeverFails(node.getType(), filteringType))
                  ptSet.add((AllocNode) node);
              }
            });

    return (Set<? extends IAllocNode>) ptSet;
  }
Пример #2
0
  @Override
  public Set<? extends IAllocNode> getPTSet(IAllocNode node, final SootField f) {
    if (f.isStatic()) {
      logger.error("Cannot call getPTSet(node, field) with static field: {}", f);
      droidsafe.main.Main.exit(1);
    }
    final Type filteringType = f.getType();

    final Set<AllocNode> allocNodes = new LinkedHashSet<AllocNode>();

    HashPointsToSet pointsToSet = new HashPointsToSet(node.getType(), ptsProvider);
    pointsToSet.add((AllocNode) node);

    ((PointsToSetInternal) ptsProvider.reachingObjects(pointsToSet, f))
        .forall(
            new P2SetVisitor() {
              @Override
              public void visit(Node node) {
                if (typeManager.castNeverFails(node.getType(), filteringType))
                  allocNodes.add((AllocNode) node);
              }
            });

    /*
    PointsToSetInternal bases = (PointsToSetInternal)ptsProvider.getSetFactory().newSet(node.getType(), ptsProvider);
    bases.add(node);

    final PointsToSetInternal pts = ptsProvider.getSetFactory().newSet(
        (f instanceof SootField) ? ((SootField)f).getType() : null, ptsProvider );
    bases.forall( new P2SetVisitor() {
        public final void visit( Node n ) {
            Node nDotF = ((AllocNode) n).dot( f );
            if(nDotF != null) pts.addAll( nDotF.getP2Set(), null );
        }} );

    //visit internal points to set and grab all allocnodes
    pts.forall(new P2SetVisitor() {
        public void visit(Node n) {
            allocNodes.add((AllocNode)n);
        }
    });
     */
    return (Set<? extends IAllocNode>) allocNodes;
  }