Search in sources :

Example 51 with SootClass

use of soot.SootClass in project soot by Sable.

the class SparkTransformer method addTags.

protected void addTags(PAG pag) {
    final Tag unknown = new StringTag("Untagged Spark node");
    final Map<Node, Tag> nodeToTag = pag.getNodeTags();
    for (final SootClass c : Scene.v().getClasses()) {
        for (final SootMethod m : c.getMethods()) {
            if (!m.isConcrete())
                continue;
            if (!m.hasActiveBody())
                continue;
            for (final Unit u : m.getActiveBody().getUnits()) {
                final Stmt s = (Stmt) u;
                if (s instanceof DefinitionStmt) {
                    Value lhs = ((DefinitionStmt) s).getLeftOp();
                    VarNode v = null;
                    if (lhs instanceof Local) {
                        v = pag.findLocalVarNode(lhs);
                    } else if (lhs instanceof FieldRef) {
                        v = pag.findGlobalVarNode(((FieldRef) lhs).getField());
                    }
                    if (v != null) {
                        PointsToSetInternal p2set = v.getP2Set();
                        p2set.forall(new P2SetVisitor() {

                            public final void visit(Node n) {
                                addTag(s, n, nodeToTag, unknown);
                            }
                        });
                        Node[] simpleSources = pag.simpleInvLookup(v);
                        for (Node element : simpleSources) {
                            addTag(s, element, nodeToTag, unknown);
                        }
                        simpleSources = pag.allocInvLookup(v);
                        for (Node element : simpleSources) {
                            addTag(s, element, nodeToTag, unknown);
                        }
                        simpleSources = pag.loadInvLookup(v);
                        for (Node element : simpleSources) {
                            addTag(s, element, nodeToTag, unknown);
                        }
                    }
                }
            }
        }
    }
}
Also used : StringTag(soot.tagkit.StringTag) VarNode(soot.jimple.spark.pag.VarNode) FieldRef(soot.jimple.FieldRef) PointsToSetInternal(soot.jimple.spark.sets.PointsToSetInternal) Node(soot.jimple.spark.pag.Node) VarNode(soot.jimple.spark.pag.VarNode) AllocNode(soot.jimple.spark.pag.AllocNode) Local(soot.Local) SootClass(soot.SootClass) Unit(soot.Unit) Stmt(soot.jimple.Stmt) DefinitionStmt(soot.jimple.DefinitionStmt) Value(soot.Value) SootMethod(soot.SootMethod) Tag(soot.tagkit.Tag) StringTag(soot.tagkit.StringTag) DefinitionStmt(soot.jimple.DefinitionStmt) P2SetVisitor(soot.jimple.spark.sets.P2SetVisitor)

Example 52 with SootClass

use of soot.SootClass in project soot by Sable.

the class PropAlias method handleVarNode.

/**
 * Propagates new points-to information of node src to all its successors.
 */
protected final boolean handleVarNode(final VarNode src) {
    boolean ret = false;
    if (src.getReplacement() != src)
        throw new RuntimeException("Got bad node " + src + " with rep " + src.getReplacement());
    final PointsToSetInternal newP2Set = src.getP2Set().getNewSet();
    if (newP2Set.isEmpty())
        return false;
    if (ofcg != null) {
        QueueReader<Node> addedEdges = pag.edgeReader();
        ofcg.updatedNode(src);
        ofcg.build();
        while (addedEdges.hasNext()) {
            Node addedSrc = (Node) addedEdges.next();
            Node addedTgt = (Node) addedEdges.next();
            ret = true;
            if (addedSrc instanceof VarNode) {
                VarNode edgeSrc = (VarNode) addedSrc;
                if (addedTgt instanceof VarNode) {
                    VarNode edgeTgt = (VarNode) addedTgt;
                    if (edgeTgt.makeP2Set().addAll(edgeSrc.getP2Set(), null))
                        addToWorklist(edgeTgt);
                } else if (addedTgt instanceof NewInstanceNode) {
                    NewInstanceNode edgeTgt = (NewInstanceNode) addedTgt.getReplacement();
                    if (edgeTgt.makeP2Set().addAll(edgeSrc.getP2Set(), null)) {
                        for (Node element : pag.assignInstanceLookup(edgeTgt)) {
                            addToWorklist((VarNode) element);
                        }
                    }
                }
            } else if (addedSrc instanceof AllocNode) {
                AllocNode edgeSrc = (AllocNode) addedSrc;
                VarNode edgeTgt = (VarNode) addedTgt;
                if (edgeTgt.makeP2Set().add(edgeSrc))
                    addToWorklist(edgeTgt);
            } else if (addedSrc instanceof NewInstanceNode && addedTgt instanceof VarNode) {
                final NewInstanceNode edgeSrc = (NewInstanceNode) addedSrc.getReplacement();
                final VarNode edgeTgt = (VarNode) addedTgt.getReplacement();
                addedSrc.getP2Set().forall(new P2SetVisitor() {

                    @Override
                    public void visit(Node n) {
                        if (n instanceof ClassConstantNode) {
                            ClassConstantNode ccn = (ClassConstantNode) n;
                            Type ccnType = ccn.getClassConstant().toSootType();
                            // If the referenced class has not been loaded,
                            // we do this now
                            SootClass targetClass = ((RefType) ccnType).getSootClass();
                            if (targetClass.resolvingLevel() == SootClass.DANGLING)
                                Scene.v().forceResolve(targetClass.getName(), SootClass.SIGNATURES);
                            edgeTgt.makeP2Set().add(pag.makeAllocNode(edgeSrc.getValue(), ccnType, ccn.getMethod()));
                            addToWorklist(edgeTgt);
                        }
                    }
                });
            }
            FieldRefNode frn = null;
            if (addedSrc instanceof FieldRefNode)
                frn = (FieldRefNode) addedSrc;
            if (addedTgt instanceof FieldRefNode)
                frn = (FieldRefNode) addedTgt;
            if (frn != null) {
                VarNode base = frn.getBase();
                if (fieldToBase.put(frn.getField(), base)) {
                    aliasWorkList.add(base);
                }
            }
        }
    }
    Node[] simpleTargets = pag.simpleLookup(src);
    for (Node element : simpleTargets) {
        if (element.makeP2Set().addAll(newP2Set, null)) {
            addToWorklist((VarNode) element);
            ret = true;
        }
    }
    Node[] storeTargets = pag.storeLookup(src);
    for (Node element : storeTargets) {
        final FieldRefNode fr = (FieldRefNode) element;
        if (fr.makeP2Set().addAll(newP2Set, null)) {
            fieldRefWorkList.add(fr);
            ret = true;
        }
    }
    src.getP2Set().flushNew();
    return ret;
}
Also used : VarNode(soot.jimple.spark.pag.VarNode) NewInstanceNode(soot.jimple.spark.pag.NewInstanceNode) PointsToSetInternal(soot.jimple.spark.sets.PointsToSetInternal) FieldRefNode(soot.jimple.spark.pag.FieldRefNode) ClassConstantNode(soot.jimple.spark.pag.ClassConstantNode) NewInstanceNode(soot.jimple.spark.pag.NewInstanceNode) Node(soot.jimple.spark.pag.Node) VarNode(soot.jimple.spark.pag.VarNode) AllocNode(soot.jimple.spark.pag.AllocNode) ClassConstantNode(soot.jimple.spark.pag.ClassConstantNode) SootClass(soot.SootClass) RefType(soot.RefType) Type(soot.Type) FieldRefNode(soot.jimple.spark.pag.FieldRefNode) AllocNode(soot.jimple.spark.pag.AllocNode) P2SetVisitor(soot.jimple.spark.sets.P2SetVisitor)

Example 53 with SootClass

use of soot.SootClass in project soot by Sable.

the class PropWorklist method handleVarNode.

/**
 * Propagates new points-to information of node src to all its successors.
 */
protected final boolean handleVarNode(final VarNode src) {
    boolean ret = false;
    boolean flush = true;
    if (src.getReplacement() != src)
        throw new RuntimeException("Got bad node " + src + " with rep " + src.getReplacement());
    final PointsToSetInternal newP2Set = src.getP2Set().getNewSet();
    if (newP2Set.isEmpty())
        return false;
    if (ofcg != null) {
        QueueReader<Node> addedEdges = pag.edgeReader();
        ofcg.updatedNode(src);
        ofcg.build();
        while (addedEdges.hasNext()) {
            Node addedSrc = (Node) addedEdges.next();
            Node addedTgt = (Node) addedEdges.next();
            ret = true;
            if (addedSrc instanceof VarNode) {
                VarNode edgeSrc = (VarNode) addedSrc.getReplacement();
                if (addedTgt instanceof VarNode) {
                    VarNode edgeTgt = (VarNode) addedTgt.getReplacement();
                    if (edgeTgt.makeP2Set().addAll(edgeSrc.getP2Set(), null)) {
                        varNodeWorkList.add(edgeTgt);
                        if (edgeTgt == src)
                            flush = false;
                    }
                } else if (addedTgt instanceof NewInstanceNode) {
                    NewInstanceNode edgeTgt = (NewInstanceNode) addedTgt.getReplacement();
                    if (edgeTgt.makeP2Set().addAll(edgeSrc.getP2Set(), null)) {
                        for (Node element : pag.assignInstanceLookup(edgeTgt)) {
                            varNodeWorkList.add((VarNode) element);
                            if (element == src)
                                flush = false;
                        }
                    }
                }
            } else if (addedSrc instanceof AllocNode) {
                VarNode edgeTgt = (VarNode) addedTgt.getReplacement();
                if (edgeTgt.makeP2Set().add(addedSrc)) {
                    varNodeWorkList.add(edgeTgt);
                    if (edgeTgt == src)
                        flush = false;
                }
            } else if (addedSrc instanceof NewInstanceNode && addedTgt instanceof VarNode) {
                final NewInstanceNode edgeSrc = (NewInstanceNode) addedSrc.getReplacement();
                final VarNode edgeTgt = (VarNode) addedTgt.getReplacement();
                addedSrc.getP2Set().forall(new P2SetVisitor() {

                    @Override
                    public void visit(Node n) {
                        if (n instanceof ClassConstantNode) {
                            ClassConstantNode ccn = (ClassConstantNode) n;
                            Type ccnType = ccn.getClassConstant().toSootType();
                            // If the referenced class has not been loaded,
                            // we do this now
                            SootClass targetClass = ((RefType) ccnType).getSootClass();
                            if (targetClass.resolvingLevel() == SootClass.DANGLING)
                                Scene.v().forceResolve(targetClass.getName(), SootClass.SIGNATURES);
                            // We can only create alloc nodes for types that
                            // we know
                            edgeTgt.makeP2Set().add(pag.makeAllocNode(edgeSrc.getValue(), ccnType, ccn.getMethod()));
                            varNodeWorkList.add(edgeTgt);
                        }
                    }
                });
                if (edgeTgt.makeP2Set().add(addedSrc)) {
                    if (edgeTgt == src)
                        flush = false;
                }
            }
        }
    }
    Node[] simpleTargets = pag.simpleLookup(src);
    for (Node element : simpleTargets) {
        if (element.makeP2Set().addAll(newP2Set, null)) {
            varNodeWorkList.add((VarNode) element);
            if (element == src)
                flush = false;
            ret = true;
        }
    }
    Node[] storeTargets = pag.storeLookup(src);
    for (Node element : storeTargets) {
        final FieldRefNode fr = (FieldRefNode) element;
        final SparkField f = fr.getField();
        ret = fr.getBase().getP2Set().forall(new P2SetVisitor() {

            public final void visit(Node n) {
                AllocDotField nDotF = pag.makeAllocDotField((AllocNode) n, f);
                if (nDotF.makeP2Set().addAll(newP2Set, null)) {
                    returnValue = true;
                }
            }
        }) | ret;
    }
    final HashSet<Node[]> storesToPropagate = new HashSet<Node[]>();
    final HashSet<Node[]> loadsToPropagate = new HashSet<Node[]>();
    for (final FieldRefNode fr : src.getAllFieldRefs()) {
        final SparkField field = fr.getField();
        final Node[] storeSources = pag.storeInvLookup(fr);
        if (storeSources.length > 0) {
            newP2Set.forall(new P2SetVisitor() {

                public final void visit(Node n) {
                    AllocDotField nDotF = pag.makeAllocDotField((AllocNode) n, field);
                    for (Node element : storeSources) {
                        Node[] pair = { element, nDotF.getReplacement() };
                        storesToPropagate.add(pair);
                    }
                }
            });
        }
        final Node[] loadTargets = pag.loadLookup(fr);
        if (loadTargets.length > 0) {
            newP2Set.forall(new P2SetVisitor() {

                public final void visit(Node n) {
                    AllocDotField nDotF = pag.makeAllocDotField((AllocNode) n, field);
                    if (nDotF != null) {
                        for (Node element : loadTargets) {
                            Node[] pair = { nDotF.getReplacement(), element };
                            loadsToPropagate.add(pair);
                        }
                    }
                }
            });
        }
    }
    if (flush)
        src.getP2Set().flushNew();
    for (Node[] p : storesToPropagate) {
        VarNode storeSource = (VarNode) p[0];
        AllocDotField nDotF = (AllocDotField) p[1];
        if (nDotF.makeP2Set().addAll(storeSource.getP2Set(), null)) {
            ret = true;
        }
    }
    for (Node[] p : loadsToPropagate) {
        AllocDotField nDotF = (AllocDotField) p[0];
        VarNode loadTarget = (VarNode) p[1];
        if (loadTarget.makeP2Set().addAll(nDotF.getP2Set(), null)) {
            varNodeWorkList.add(loadTarget);
            ret = true;
        }
    }
    return ret;
}
Also used : VarNode(soot.jimple.spark.pag.VarNode) NewInstanceNode(soot.jimple.spark.pag.NewInstanceNode) AllocDotField(soot.jimple.spark.pag.AllocDotField) PointsToSetInternal(soot.jimple.spark.sets.PointsToSetInternal) ClassConstantNode(soot.jimple.spark.pag.ClassConstantNode) FieldRefNode(soot.jimple.spark.pag.FieldRefNode) NewInstanceNode(soot.jimple.spark.pag.NewInstanceNode) Node(soot.jimple.spark.pag.Node) VarNode(soot.jimple.spark.pag.VarNode) AllocNode(soot.jimple.spark.pag.AllocNode) SparkField(soot.jimple.spark.pag.SparkField) ClassConstantNode(soot.jimple.spark.pag.ClassConstantNode) SootClass(soot.SootClass) RefType(soot.RefType) Type(soot.Type) FieldRefNode(soot.jimple.spark.pag.FieldRefNode) AllocNode(soot.jimple.spark.pag.AllocNode) P2SetVisitor(soot.jimple.spark.sets.P2SetVisitor) HashSet(java.util.HashSet)

Example 54 with SootClass

use of soot.SootClass in project soot by Sable.

the class SuperFirstStmtHandler method getProperCasting.

public Value getProperCasting(Type tempType, DVirtualInvokeExpr tempInvokeExpr) {
    if (tempType instanceof RefType) {
        // System.out.println("This is a reftype:"+tempType);
        return new GCastExpr(tempInvokeExpr, tempType);
    } else if (tempType instanceof PrimType) {
        PrimType t = (PrimType) tempType;
        if (t == BooleanType.v()) {
            Value tempExpr = new GCastExpr(tempInvokeExpr, RefType.v("java.lang.Boolean"));
            // booleanValue
            SootMethod tempMethod = Scene.v().makeSootMethod("booleanValue", new ArrayList(), BooleanType.v());
            tempMethod.setDeclaringClass(new SootClass("java.lang.Boolean"));
            SootMethodRef tempMethodRef = tempMethod.makeRef();
            return new DVirtualInvokeExpr(tempExpr, tempMethodRef, new ArrayList(), new HashSet<Object>());
        } else if (t == ByteType.v()) {
            Value tempExpr = new GCastExpr(tempInvokeExpr, RefType.v("java.lang.Byte"));
            // byteValue
            SootMethod tempMethod = Scene.v().makeSootMethod("byteValue", new ArrayList(), ByteType.v());
            tempMethod.setDeclaringClass(new SootClass("java.lang.Byte"));
            SootMethodRef tempMethodRef = tempMethod.makeRef();
            return new DVirtualInvokeExpr(tempExpr, tempMethodRef, new ArrayList(), new HashSet<Object>());
        } else if (t == CharType.v()) {
            Value tempExpr = new GCastExpr(tempInvokeExpr, RefType.v("java.lang.Character"));
            // charValue
            SootMethod tempMethod = Scene.v().makeSootMethod("charValue", new ArrayList(), CharType.v());
            tempMethod.setDeclaringClass(new SootClass("java.lang.Character"));
            SootMethodRef tempMethodRef = tempMethod.makeRef();
            return new DVirtualInvokeExpr(tempExpr, tempMethodRef, new ArrayList(), new HashSet<Object>());
        } else if (t == DoubleType.v()) {
            Value tempExpr = new GCastExpr(tempInvokeExpr, RefType.v("java.lang.Double"));
            // doubleValue
            SootMethod tempMethod = Scene.v().makeSootMethod("doubleValue", new ArrayList(), DoubleType.v());
            tempMethod.setDeclaringClass(new SootClass("java.lang.Double"));
            SootMethodRef tempMethodRef = tempMethod.makeRef();
            return new DVirtualInvokeExpr(tempExpr, tempMethodRef, new ArrayList(), new HashSet<Object>());
        } else if (t == FloatType.v()) {
            Value tempExpr = new GCastExpr(tempInvokeExpr, RefType.v("java.lang.Float"));
            // floatValue
            SootMethod tempMethod = Scene.v().makeSootMethod("floatValue", new ArrayList(), FloatType.v());
            tempMethod.setDeclaringClass(new SootClass("java.lang.Float"));
            SootMethodRef tempMethodRef = tempMethod.makeRef();
            return new DVirtualInvokeExpr(tempExpr, tempMethodRef, new ArrayList(), new HashSet<Object>());
        } else if (t == IntType.v()) {
            Value tempExpr = new GCastExpr(tempInvokeExpr, RefType.v("java.lang.Integer"));
            // intValue
            SootMethod tempMethod = Scene.v().makeSootMethod("intValue", new ArrayList(), IntType.v());
            tempMethod.setDeclaringClass(new SootClass("java.lang.Integer"));
            SootMethodRef tempMethodRef = tempMethod.makeRef();
            return new DVirtualInvokeExpr(tempExpr, tempMethodRef, new ArrayList(), new HashSet<Object>());
        } else if (t == LongType.v()) {
            Value tempExpr = new GCastExpr(tempInvokeExpr, RefType.v("java.lang.Long"));
            // longValue
            SootMethod tempMethod = Scene.v().makeSootMethod("longValue", new ArrayList(), LongType.v());
            tempMethod.setDeclaringClass(new SootClass("java.lang.Long"));
            SootMethodRef tempMethodRef = tempMethod.makeRef();
            return new DVirtualInvokeExpr(tempExpr, tempMethodRef, new ArrayList(), new HashSet<Object>());
        } else if (t == ShortType.v()) {
            Value tempExpr = new GCastExpr(tempInvokeExpr, RefType.v("java.lang.Short"));
            // shortValue
            SootMethod tempMethod = Scene.v().makeSootMethod("shortValue", new ArrayList(), ShortType.v());
            tempMethod.setDeclaringClass(new SootClass("java.lang.Short"));
            SootMethodRef tempMethodRef = tempMethod.makeRef();
            return new DVirtualInvokeExpr(tempExpr, tempMethodRef, new ArrayList(), new HashSet<Object>());
        } else {
            throw new DecompilationException("Unhandle primType:" + tempType);
        }
    } else {
        throw new DecompilationException("The type:" + tempType + " was not a reftye or primtype. PLEASE REPORT.");
    }
}
Also used : SootMethodRef(soot.SootMethodRef) ArrayList(java.util.ArrayList) DecompilationException(soot.dava.DecompilationException) SootClass(soot.SootClass) RefType(soot.RefType) DVirtualInvokeExpr(soot.dava.internal.javaRep.DVirtualInvokeExpr) Value(soot.Value) PrimType(soot.PrimType) SootMethod(soot.SootMethod) GCastExpr(soot.grimp.internal.GCastExpr) HashSet(java.util.HashSet)

Example 55 with SootClass

use of soot.SootClass in project soot by Sable.

the class PolyglotMethodSource method addAssertInits.

public void addAssertInits(soot.Body body) {
    // if class is inner get desired assertion status from outer most class
    soot.SootClass assertStatusClass = body.getMethod().getDeclaringClass();
    HashMap<SootClass, InnerClassInfo> innerMap = soot.javaToJimple.InitialResolver.v().getInnerClassInfoMap();
    while ((innerMap != null) && (innerMap.containsKey(assertStatusClass))) {
        assertStatusClass = innerMap.get(assertStatusClass).getOuterClass();
    }
    String paramName = assertStatusClass.getName();
    String fieldName = "class$" + assertStatusClass.getName().replaceAll(".", "$");
    if (assertStatusClass.isInterface()) {
        assertStatusClass = InitialResolver.v().specialAnonMap().get(assertStatusClass);
    }
    // field ref
    soot.SootFieldRef field = soot.Scene.v().makeFieldRef(assertStatusClass, fieldName, soot.RefType.v("java.lang.Class"), true);
    soot.Local fieldLocal = soot.jimple.Jimple.v().newLocal("$r0", soot.RefType.v("java.lang.Class"));
    body.getLocals().add(fieldLocal);
    soot.jimple.FieldRef fieldRef = soot.jimple.Jimple.v().newStaticFieldRef(field);
    soot.jimple.AssignStmt fieldAssignStmt = soot.jimple.Jimple.v().newAssignStmt(fieldLocal, fieldRef);
    body.getUnits().add(fieldAssignStmt);
    // if field not null
    soot.jimple.ConditionExpr cond = soot.jimple.Jimple.v().newNeExpr(fieldLocal, soot.jimple.NullConstant.v());
    soot.jimple.NopStmt nop1 = soot.jimple.Jimple.v().newNopStmt();
    soot.jimple.IfStmt ifStmt = soot.jimple.Jimple.v().newIfStmt(cond, nop1);
    body.getUnits().add(ifStmt);
    // if alternative
    soot.Local invokeLocal = soot.jimple.Jimple.v().newLocal("$r1", soot.RefType.v("java.lang.Class"));
    body.getLocals().add(invokeLocal);
    ArrayList paramTypes = new ArrayList();
    paramTypes.add(soot.RefType.v("java.lang.String"));
    soot.SootMethodRef methodToInvoke = soot.Scene.v().makeMethodRef(assertStatusClass, "class$", paramTypes, soot.RefType.v("java.lang.Class"), true);
    ArrayList params = new ArrayList();
    params.add(soot.jimple.StringConstant.v(paramName));
    soot.jimple.StaticInvokeExpr invoke = soot.jimple.Jimple.v().newStaticInvokeExpr(methodToInvoke, params);
    soot.jimple.AssignStmt invokeAssign = soot.jimple.Jimple.v().newAssignStmt(invokeLocal, invoke);
    body.getUnits().add(invokeAssign);
    // field ref assign
    soot.jimple.AssignStmt fieldRefAssign = soot.jimple.Jimple.v().newAssignStmt(fieldRef, invokeLocal);
    body.getUnits().add(fieldRefAssign);
    soot.jimple.NopStmt nop2 = soot.jimple.Jimple.v().newNopStmt();
    soot.jimple.GotoStmt goto1 = soot.jimple.Jimple.v().newGotoStmt(nop2);
    body.getUnits().add(goto1);
    // add nop1 - and if consequence
    body.getUnits().add(nop1);
    soot.jimple.AssignStmt fieldRefAssign2 = soot.jimple.Jimple.v().newAssignStmt(invokeLocal, fieldRef);
    body.getUnits().add(fieldRefAssign2);
    body.getUnits().add(nop2);
    // boolean tests
    soot.Local boolLocal1 = soot.jimple.Jimple.v().newLocal("$z0", soot.BooleanType.v());
    body.getLocals().add(boolLocal1);
    soot.Local boolLocal2 = soot.jimple.Jimple.v().newLocal("$z1", soot.BooleanType.v());
    body.getLocals().add(boolLocal2);
    // virtual invoke
    soot.SootMethodRef vMethodToInvoke = Scene.v().makeMethodRef(soot.Scene.v().getSootClass("java.lang.Class"), "desiredAssertionStatus", new ArrayList(), soot.BooleanType.v(), false);
    soot.jimple.VirtualInvokeExpr vInvoke = soot.jimple.Jimple.v().newVirtualInvokeExpr(invokeLocal, vMethodToInvoke, new ArrayList());
    soot.jimple.AssignStmt testAssign = soot.jimple.Jimple.v().newAssignStmt(boolLocal1, vInvoke);
    body.getUnits().add(testAssign);
    // if
    soot.jimple.ConditionExpr cond2 = soot.jimple.Jimple.v().newNeExpr(boolLocal1, soot.jimple.IntConstant.v(0));
    soot.jimple.NopStmt nop3 = soot.jimple.Jimple.v().newNopStmt();
    soot.jimple.IfStmt ifStmt2 = soot.jimple.Jimple.v().newIfStmt(cond2, nop3);
    body.getUnits().add(ifStmt2);
    // alternative
    soot.jimple.AssignStmt altAssign = soot.jimple.Jimple.v().newAssignStmt(boolLocal2, soot.jimple.IntConstant.v(1));
    body.getUnits().add(altAssign);
    soot.jimple.NopStmt nop4 = soot.jimple.Jimple.v().newNopStmt();
    soot.jimple.GotoStmt goto2 = soot.jimple.Jimple.v().newGotoStmt(nop4);
    body.getUnits().add(goto2);
    body.getUnits().add(nop3);
    soot.jimple.AssignStmt conAssign = soot.jimple.Jimple.v().newAssignStmt(boolLocal2, soot.jimple.IntConstant.v(0));
    body.getUnits().add(conAssign);
    body.getUnits().add(nop4);
    // field assign
    soot.SootFieldRef fieldD = Scene.v().makeFieldRef(body.getMethod().getDeclaringClass(), "$assertionsDisabled", soot.BooleanType.v(), true);
    soot.jimple.FieldRef fieldRefD = soot.jimple.Jimple.v().newStaticFieldRef(fieldD);
    soot.jimple.AssignStmt fAssign = soot.jimple.Jimple.v().newAssignStmt(fieldRefD, boolLocal2);
    body.getUnits().add(fAssign);
}
Also used : ArrayList(java.util.ArrayList) SootClass(soot.SootClass) SootClass(soot.SootClass)

Aggregations

SootClass (soot.SootClass)194 SootMethod (soot.SootMethod)99 RefType (soot.RefType)69 ArrayList (java.util.ArrayList)60 Type (soot.Type)57 VoidType (soot.VoidType)33 ArrayType (soot.ArrayType)32 Iterator (java.util.Iterator)29 BooleanType (soot.BooleanType)29 DoubleType (soot.DoubleType)29 LongType (soot.LongType)29 Value (soot.Value)29 FloatType (soot.FloatType)28 Local (soot.Local)27 SootField (soot.SootField)27 List (java.util.List)26 CharType (soot.CharType)26 IntType (soot.IntType)26 ByteType (soot.ByteType)25 PrimType (soot.PrimType)23