Search in sources :

Example 16 with SegmentNode

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

the class FullSensitiveNode method pointer_interval_points_to.

@Override
public boolean pointer_interval_points_to(long l, long r, AllocNode obj) {
    SegmentNode[] int_entry = find_points_to(obj);
    for (int i = 0; i < GeometricManager.Divisions; ++i) {
        SegmentNode p = int_entry[i];
        while (p != null) {
            long R = p.I1 + p.L;
            if ((l <= p.I1 && p.I1 < r) || (p.I1 <= l && l < R))
                return true;
            p = p.next;
        }
    }
    return false;
}
Also used : PlainConstraint(soot.jimple.spark.geom.dataRep.PlainConstraint) SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Example 17 with SegmentNode

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

the class GeometricManager method removeUselessSegments.

/**
 * The lines that are included in some rectangles can be deleted.
 */
public void removeUselessSegments() {
    SegmentNode p = header[GeometricManager.ONE_TO_ONE];
    SegmentNode q = null;
    int countAll = 0;
    while (p != null) {
        SegmentNode temp = p.next;
        if (!isContainedInRectangles(p)) {
            p.next = q;
            q = p;
            ++countAll;
        } else {
            reclaimSegmentNode(p);
        }
        p = temp;
    }
    size[GeometricManager.ONE_TO_ONE] = countAll;
    header[GeometricManager.ONE_TO_ONE] = q;
}
Also used : SegmentNode(soot.jimple.spark.geom.dataRep.SegmentNode)

Example 18 with SegmentNode

use of soot.jimple.spark.geom.dataRep.SegmentNode 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 19 with SegmentNode

use of soot.jimple.spark.geom.dataRep.SegmentNode 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 20 with SegmentNode

use of soot.jimple.spark.geom.dataRep.SegmentNode 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)

Aggregations

SegmentNode (soot.jimple.spark.geom.dataRep.SegmentNode)51 PlainConstraint (soot.jimple.spark.geom.dataRep.PlainConstraint)24 AllocNode (soot.jimple.spark.pag.AllocNode)12 HashMap (java.util.HashMap)6 Map (java.util.Map)6 RectangleNode (soot.jimple.spark.geom.dataRep.RectangleNode)5 SootMethod (soot.SootMethod)3 GeomPointsTo (soot.jimple.spark.geom.geomPA.GeomPointsTo)3 StringConstantNode (soot.jimple.spark.pag.StringConstantNode)3 ClassConstantNode (soot.jimple.spark.pag.ClassConstantNode)2