Search in sources :

Example 1 with RectangleNode

use of soot.jimple.spark.geom.dataRep.RectangleNode in project soot by Sable.

the class GeometricManager method addNewFigure.

/**
 * Insert a new figure into this manager if it is not covered by any exisiting figure.
 */
public SegmentNode addNewFigure(int code, RectangleNode pnew) {
    SegmentNode p;
    // We first check if there is an existing object contains this new object
    if (checkRedundancy(code, pnew))
        return null;
    // Oppositely, we check if any existing objects are obsoleted
    filterOutDuplicates(code, pnew);
    // Ok, now we generate a copy
    if (code == GeometricManager.ONE_TO_ONE) {
        p = getSegmentNode();
        p.copySegment(pnew);
    } else {
        p = getRectangleNode();
        ((RectangleNode) p).copyRectangle(pnew);
    }
    hasNewFigure = true;
    p.next = header[code];
    header[code] = p;
    size[code]++;
    return p;
}
Also used : RectangleNode(soot.jimple.spark.geom.dataRep.RectangleNode) SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Example 2 with RectangleNode

use of soot.jimple.spark.geom.dataRep.RectangleNode in project soot by Sable.

the class GeometricManager method filterOutDuplicates.

/**
 * Drop the redundant existing objects.
 * @param code
 * @param p
 */
private void filterOutDuplicates(int code, SegmentNode p) {
    boolean flag;
    SegmentNode q_head, q_tail;
    SegmentNode pold;
    int countAll;
    for (int i = code; i > -1; --i) {
        pold = header[i];
        q_head = null;
        q_tail = null;
        countAll = 0;
        while (pold != null) {
            flag = false;
            switch(i) {
                case GeometricManager.ONE_TO_ONE:
                    if (code == GeometricManager.MANY_TO_MANY) {
                        if (pold.I1 >= p.I1 && pold.I2 >= p.I2) {
                            if ((pold.I1 + pold.L) <= (p.I1 + p.L) && (pold.I2 + pold.L) <= (p.I2 + ((RectangleNode) p).L_prime))
                                flag = true;
                        }
                    } else {
                        if ((p.I2 - p.I1) == (pold.I2 - pold.I1)) {
                            if (pold.I1 >= p.I1 && (pold.I1 + pold.L) <= (p.I1 + p.L))
                                flag = true;
                        }
                    }
                    break;
                case GeometricManager.MANY_TO_MANY:
                    if (pold.I1 >= p.I1 && pold.I2 >= p.I2) {
                        if ((pold.I1 + pold.L) <= (p.I1 + p.L) && (pold.I2 + ((RectangleNode) pold).L_prime) <= (p.I2 + ((RectangleNode) p).L_prime))
                            flag = true;
                    }
                    break;
            }
            if (flag == false) {
                // We keep this figure
                if (q_head == null)
                    q_head = pold;
                else
                    q_tail.next = pold;
                q_tail = pold;
                ++countAll;
                pold = pold.next;
            } else {
                // We reclaim this figure
                if (i == GeometricManager.ONE_TO_ONE)
                    pold = reclaimSegmentNode(pold);
                else
                    pold = reclaimRectangleNode(pold);
            }
        }
        if (q_tail != null)
            q_tail.next = null;
        header[i] = q_head;
        size[i] = countAll;
    }
}
Also used : RectangleNode(soot.jimple.spark.geom.dataRep.RectangleNode) SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Example 3 with RectangleNode

use of soot.jimple.spark.geom.dataRep.RectangleNode in project soot by Sable.

the class GeometricManager method mergeOneToOne.

/**
 * Find the bounding rectangle for all segment figures.
 * @return
 */
private RectangleNode mergeOneToOne() {
    long x_min = Long.MAX_VALUE, y_min = Long.MAX_VALUE;
    long x_max = Long.MIN_VALUE, y_max = Long.MIN_VALUE;
    SegmentNode p = header[GeometricManager.ONE_TO_ONE];
    header[GeometricManager.ONE_TO_ONE] = null;
    size[GeometricManager.ONE_TO_ONE] = 0;
    while (p != null) {
        if (p.I1 < x_min)
            x_min = p.I1;
        if (p.I2 < y_min)
            y_min = p.I2;
        if (p.I1 + p.L > x_max)
            x_max = p.I1 + p.L;
        if (p.I2 + p.L > y_max)
            y_max = p.I2 + p.L;
        p = reclaimSegmentNode(p);
    }
    RectangleNode q = getRectangleNode();
    q.I1 = x_min;
    q.I2 = y_min;
    q.L = x_max - x_min;
    q.L_prime = y_max - y_min;
    return q;
}
Also used : RectangleNode(soot.jimple.spark.geom.dataRep.RectangleNode) SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Example 4 with RectangleNode

use of soot.jimple.spark.geom.dataRep.RectangleNode in project soot by Sable.

the class FullSensitiveNode method get_all_context_sensitive_objects.

@Override
public void get_all_context_sensitive_objects(long l, long r, PtSensVisitor visitor) {
    if (parent != this) {
        getRepresentative().get_all_context_sensitive_objects(l, r, visitor);
        return;
    }
    GeomPointsTo geomPTA = (GeomPointsTo) Scene.v().getPointsToAnalysis();
    for (Map.Entry<AllocNode, GeometricManager> entry : pt_objs.entrySet()) {
        AllocNode obj = entry.getKey();
        SootMethod sm = obj.getMethod();
        int sm_int = geomPTA.getIDFromSootMethod(sm);
        if (sm_int == -1)
            continue;
        GeometricManager gm = entry.getValue();
        SegmentNode[] int_entry = gm.getFigures();
        for (int i = 0; i < GeometricManager.Divisions; ++i) {
            // We iterate all the figures
            SegmentNode p = int_entry[i];
            while (p != null) {
                long L = p.I1;
                long R = L + p.L;
                long objL = -1, objR = -1;
                // Now we compute which context sensitive objects are pointed to by this pointer
                if (l <= L && L < r) {
                    // L------------R
                    if (i == GeometricManager.ONE_TO_ONE) {
                        long d = r - L;
                        if (R < r)
                            d = p.L;
                        objL = p.I2;
                        objR = objL + d;
                    } else {
                        objL = p.I2;
                        objR = p.I2 + ((RectangleNode) p).L_prime;
                    }
                } else if (L <= l && l < R) {
                    // L--------------------R
                    if (i == GeometricManager.ONE_TO_ONE) {
                        long d = R - l;
                        if (R > r)
                            d = r - l;
                        objL = p.I2 + l - L;
                        objR = objL + d;
                    } else {
                        objL = p.I2;
                        objR = p.I2 + ((RectangleNode) p).L_prime;
                    }
                }
                // Now we test which context versions this interval [objL, objR) maps to
                if (objL != -1 && objR != -1)
                    visitor.visit(obj, objL, objR, sm_int);
                p = p.next;
            }
        }
    }
}
Also used : AllocNode(soot.jimple.spark.pag.AllocNode) RectangleNode(soot.jimple.spark.geom.dataRep.RectangleNode) GeomPointsTo(soot.jimple.spark.geom.geomPA.GeomPointsTo) SootMethod(soot.SootMethod) HashMap(java.util.HashMap) Map(java.util.Map) PlainConstraint(soot.jimple.spark.geom.dataRep.PlainConstraint) SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Example 5 with RectangleNode

use of soot.jimple.spark.geom.dataRep.RectangleNode in project soot by Sable.

the class FullSensitiveNode method print_context_sensitive_points_to.

@Override
public void print_context_sensitive_points_to(PrintStream outPrintStream) {
    for (Iterator<AllocNode> it = pt_objs.keySet().iterator(); it.hasNext(); ) {
        AllocNode obj = it.next();
        SegmentNode[] int_entry = find_points_to(obj);
        for (int j = 0; j < GeometricManager.Divisions; ++j) {
            SegmentNode p = int_entry[j];
            while (p != null) {
                outPrintStream.print("(" + obj.toString() + ", " + p.I1 + ", " + p.I2 + ", " + p.L + ", ");
                if (p instanceof RectangleNode)
                    outPrintStream.print(((RectangleNode) p).L_prime + ", ");
                outPrintStream.println(symbols[j] + ")");
                p = p.next;
            }
        }
    }
}
Also used : AllocNode(soot.jimple.spark.pag.AllocNode) RectangleNode(soot.jimple.spark.geom.dataRep.RectangleNode) PlainConstraint(soot.jimple.spark.geom.dataRep.PlainConstraint) SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Aggregations

RectangleNode (soot.jimple.spark.geom.dataRep.RectangleNode)8 SegmentNode (soot.jimple.spark.geom.dataRep.SegmentNode)5 PlainConstraint (soot.jimple.spark.geom.dataRep.PlainConstraint)2 AllocNode (soot.jimple.spark.pag.AllocNode)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SootMethod (soot.SootMethod)1 GeomPointsTo (soot.jimple.spark.geom.geomPA.GeomPointsTo)1