Search in sources :

Example 6 with BooleanType

use of soot.BooleanType in project soot by Sable.

the class DexPrinter method makeConstantItem.

private EncodedValue makeConstantItem(SootField sf, Tag t) {
    if (!(t instanceof ConstantValueTag))
        throw new RuntimeException("error: t not ConstantValueTag.");
    if (t instanceof IntegerConstantValueTag) {
        Type sft = sf.getType();
        IntegerConstantValueTag i = (IntegerConstantValueTag) t;
        if (sft instanceof BooleanType) {
            int v = i.getIntValue();
            if (v == 0) {
                return ImmutableBooleanEncodedValue.FALSE_VALUE;
            } else if (v == 1) {
                return ImmutableBooleanEncodedValue.TRUE_VALUE;
            } else {
                throw new RuntimeException("error: boolean value from int with value != 0 or 1.");
            }
        } else if (sft instanceof CharType) {
            return new ImmutableCharEncodedValue((char) i.getIntValue());
        } else if (sft instanceof ByteType) {
            return new ImmutableByteEncodedValue((byte) i.getIntValue());
        } else if (sft instanceof IntType) {
            return new ImmutableIntEncodedValue(i.getIntValue());
        } else if (sft instanceof ShortType) {
            return new ImmutableShortEncodedValue((short) i.getIntValue());
        } else {
            throw new RuntimeException("error: unexpected constant tag type: " + t + " for field " + sf);
        }
    } else if (t instanceof LongConstantValueTag) {
        LongConstantValueTag l = (LongConstantValueTag) t;
        return new ImmutableLongEncodedValue(l.getLongValue());
    } else if (t instanceof DoubleConstantValueTag) {
        DoubleConstantValueTag d = (DoubleConstantValueTag) t;
        return new ImmutableDoubleEncodedValue(d.getDoubleValue());
    } else if (t instanceof FloatConstantValueTag) {
        FloatConstantValueTag f = (FloatConstantValueTag) t;
        return new ImmutableFloatEncodedValue(f.getFloatValue());
    } else if (t instanceof StringConstantValueTag) {
        StringConstantValueTag s = (StringConstantValueTag) t;
        if (sf.getType().equals(RefType.v("java.lang.String")))
            return new ImmutableStringEncodedValue(s.getStringValue());
        else
            // Results in "Bogus static initialization"
            return null;
    } else
        throw new RuntimeException("Unexpected constant type");
}
Also used : ImmutableShortEncodedValue(org.jf.dexlib2.immutable.value.ImmutableShortEncodedValue) ImmutableCharEncodedValue(org.jf.dexlib2.immutable.value.ImmutableCharEncodedValue) ImmutableByteEncodedValue(org.jf.dexlib2.immutable.value.ImmutableByteEncodedValue) ShortType(soot.ShortType) BooleanType(soot.BooleanType) IntegerConstantValueTag(soot.tagkit.IntegerConstantValueTag) ByteType(soot.ByteType) DoubleConstantValueTag(soot.tagkit.DoubleConstantValueTag) IntType(soot.IntType) ConstantValueTag(soot.tagkit.ConstantValueTag) FloatConstantValueTag(soot.tagkit.FloatConstantValueTag) IntegerConstantValueTag(soot.tagkit.IntegerConstantValueTag) DoubleConstantValueTag(soot.tagkit.DoubleConstantValueTag) LongConstantValueTag(soot.tagkit.LongConstantValueTag) StringConstantValueTag(soot.tagkit.StringConstantValueTag) BooleanType(soot.BooleanType) Type(soot.Type) DexType(soot.dexpler.DexType) RefType(soot.RefType) ShortType(soot.ShortType) ByteType(soot.ByteType) IntType(soot.IntType) CharType(soot.CharType) ImmutableDoubleEncodedValue(org.jf.dexlib2.immutable.value.ImmutableDoubleEncodedValue) ImmutableFloatEncodedValue(org.jf.dexlib2.immutable.value.ImmutableFloatEncodedValue) ImmutableStringEncodedValue(org.jf.dexlib2.immutable.value.ImmutableStringEncodedValue) LongConstantValueTag(soot.tagkit.LongConstantValueTag) ImmutableIntEncodedValue(org.jf.dexlib2.immutable.value.ImmutableIntEncodedValue) CharType(soot.CharType) StringConstantValueTag(soot.tagkit.StringConstantValueTag) ImmutableLongEncodedValue(org.jf.dexlib2.immutable.value.ImmutableLongEncodedValue) FloatConstantValueTag(soot.tagkit.FloatConstantValueTag)

Example 7 with BooleanType

use of soot.BooleanType in project soot by Sable.

the class TypeResolver method typePromotion.

private Typing typePromotion(Typing tg) {
    final BooleanType booleanType = BooleanType.v();
    final ByteType byteType = ByteType.v();
    final ShortType shortType = ShortType.v();
    boolean conversionDone;
    do {
        AugEvalFunction ef = new AugEvalFunction(this.jb);
        AugHierarchy h = new AugHierarchy();
        UseChecker uc = new UseChecker(this.jb);
        TypePromotionUseVisitor uv = new TypePromotionUseVisitor(jb, tg);
        do {
            Collection<Typing> sigma = this.applyAssignmentConstraints(tg, ef, h);
            if (sigma.isEmpty())
                return null;
            tg = sigma.iterator().next();
            uv.typingChanged = false;
            uc.check(tg, uv);
            if (uv.fail)
                return null;
        } while (uv.typingChanged);
        conversionDone = false;
        for (Local v : this.jb.getLocals()) {
            Type t = tg.get(v);
            if (t instanceof Integer1Type) {
                tg.set(v, booleanType);
                conversionDone = true;
            } else if (t instanceof Integer127Type) {
                tg.set(v, byteType);
                conversionDone = true;
            } else if (t instanceof Integer32767Type) {
                tg.set(v, shortType);
                conversionDone = true;
            }
        }
    } while (conversionDone);
    return tg;
}
Also used : ShortType(soot.ShortType) BooleanType(soot.BooleanType) Local(soot.Local) ByteType(soot.ByteType) RefType(soot.RefType) IntType(soot.IntType) ShortType(soot.ShortType) CharType(soot.CharType) BooleanType(soot.BooleanType) ByteType(soot.ByteType) ArrayType(soot.ArrayType) IntegerType(soot.IntegerType) Type(soot.Type)

Example 8 with BooleanType

use of soot.BooleanType in project soot by Sable.

the class UseChecker method handleBinopExpr.

private void handleBinopExpr(BinopExpr be, Stmt stmt, Type tlhs) {
    Value opl = be.getOp1(), opr = be.getOp2();
    Type tl = AugEvalFunction.eval_(this.tg, opl, stmt, this.jb), tr = AugEvalFunction.eval_(this.tg, opr, stmt, this.jb);
    if (be instanceof AddExpr || be instanceof SubExpr || be instanceof MulExpr || be instanceof DivExpr || be instanceof RemExpr || be instanceof GeExpr || be instanceof GtExpr || be instanceof LeExpr || be instanceof LtExpr || be instanceof ShlExpr || be instanceof ShrExpr || be instanceof UshrExpr) {
        if (tlhs instanceof IntegerType) {
            be.setOp1(this.uv.visit(opl, IntType.v(), stmt));
            be.setOp2(this.uv.visit(opr, IntType.v(), stmt));
        }
    } else if (be instanceof CmpExpr || be instanceof CmpgExpr || be instanceof CmplExpr) {
    // No checks in the original assigner
    } else if (be instanceof AndExpr || be instanceof OrExpr || be instanceof XorExpr) {
        be.setOp1(this.uv.visit(opl, tlhs, stmt));
        be.setOp2(this.uv.visit(opr, tlhs, stmt));
    } else if (be instanceof EqExpr || be instanceof NeExpr) {
        if (tl instanceof BooleanType && tr instanceof BooleanType) {
        } else if (tl instanceof Integer1Type || tr instanceof Integer1Type) {
        } else if (tl instanceof IntegerType) {
            be.setOp1(this.uv.visit(opl, IntType.v(), stmt));
            be.setOp2(this.uv.visit(opr, IntType.v(), stmt));
        }
    }
}
Also used : MulExpr(soot.jimple.MulExpr) AndExpr(soot.jimple.AndExpr) GtExpr(soot.jimple.GtExpr) LtExpr(soot.jimple.LtExpr) GeExpr(soot.jimple.GeExpr) UshrExpr(soot.jimple.UshrExpr) LeExpr(soot.jimple.LeExpr) ShlExpr(soot.jimple.ShlExpr) XorExpr(soot.jimple.XorExpr) NeExpr(soot.jimple.NeExpr) SubExpr(soot.jimple.SubExpr) BooleanType(soot.BooleanType) AddExpr(soot.jimple.AddExpr) OrExpr(soot.jimple.OrExpr) IntegerType(soot.IntegerType) RefType(soot.RefType) BooleanType(soot.BooleanType) Type(soot.Type) IntType(soot.IntType) NullType(soot.NullType) ArrayType(soot.ArrayType) IntegerType(soot.IntegerType) PrimType(soot.PrimType) DivExpr(soot.jimple.DivExpr) RemExpr(soot.jimple.RemExpr) ShrExpr(soot.jimple.ShrExpr) CmpExpr(soot.jimple.CmpExpr) EqExpr(soot.jimple.EqExpr) CmpgExpr(soot.jimple.CmpgExpr) Value(soot.Value) CmplExpr(soot.jimple.CmplExpr)

Example 9 with BooleanType

use of soot.BooleanType in project soot by Sable.

the class DavaPrinter method printTo.

public void printTo(SootClass cl, PrintWriter out) {
    // IterableSet packagesUsed = new IterableSet();
    IterableSet importList = new IterableSet();
    {
        String curPackage = cl.getJavaPackageName();
        if (!curPackage.equals("")) {
            out.println("package " + curPackage + ";");
            out.println();
        }
        if (cl.hasSuperclass()) {
            SootClass superClass = cl.getSuperclass();
            importList.add(superClass.toString());
        // packagesUsed.add(superClass.getJavaPackageName());
        }
        Iterator<SootClass> interfaceIt = cl.getInterfaces().iterator();
        while (interfaceIt.hasNext()) {
            String interfacePackage = ((SootClass) interfaceIt.next()).toString();
            if (!importList.contains(interfacePackage))
                importList.add(interfacePackage);
        // if (!packagesUsed.contains(interfacePackage))
        // packagesUsed.add(interfacePackage);
        }
        Iterator<SootMethod> methodIt = cl.methodIterator();
        while (methodIt.hasNext()) {
            SootMethod dm = (SootMethod) methodIt.next();
            if (dm.hasActiveBody()) {
                // packagesUsed = packagesUsed.union(((DavaBody) dm.getActiveBody()).get_PackagesUsed());
                importList = importList.union(((DavaBody) dm.getActiveBody()).getImportList());
            }
            Iterator<SootClass> eit = dm.getExceptions().iterator();
            while (eit.hasNext()) {
                String thrownPackage = eit.next().toString();
                if (!importList.contains(thrownPackage))
                    importList.add(thrownPackage);
            // if (!packagesUsed.contains(thrownPackage))
            // packagesUsed.add(thrownPackage);
            }
            Iterator<Type> pit = dm.getParameterTypes().iterator();
            while (pit.hasNext()) {
                Type t = (Type) pit.next();
                if (t instanceof RefType) {
                    String paramPackage = ((RefType) t).getSootClass().toString();
                    if (!importList.contains(paramPackage))
                        importList.add(paramPackage);
                // if (packagesUsed.contains(paramPackage) == false)
                // packagesUsed.add(paramPackage);
                }
            }
            Type t = dm.getReturnType();
            if (t instanceof RefType) {
                String returnPackage = ((RefType) t).getSootClass().toString();
                if (!importList.contains(returnPackage))
                    importList.add(returnPackage);
            // if (packagesUsed.contains(returnPackage) == false)
            // packagesUsed.add(returnPackage);
            }
        }
        Iterator<SootField> fieldIt = cl.getFields().iterator();
        while (fieldIt.hasNext()) {
            SootField f = (SootField) fieldIt.next();
            if (f.isPhantom())
                continue;
            Type t = f.getType();
            if (t instanceof RefType) {
                String fieldPackage = ((RefType) t).getSootClass().toString();
                if (!importList.contains(fieldPackage))
                    importList.add(fieldPackage);
            }
        }
        Iterator<String> pit = importList.iterator();
        List<String> toImport = new ArrayList<String>();
        while (pit.hasNext()) {
            /*
            	 * dont import any file which has currentPackage.className
            	 * dont import any file which starts with java.lang
            	 */
            String temp = (String) pit.next();
            // System.out.println("temp is "+temp);
            if (temp.indexOf("java.lang") > -1) {
                // problem is that we need to import sub packages java.lang.ref
                // for instance if the type is java.lang.ref.WeakReference
                String tempClassName = RemoveFullyQualifiedName.getClassName(temp);
                if (temp.equals("java.lang." + tempClassName)) {
                    // System.out.println("temp was not printed as it belongs to java.lang");
                    continue;
                }
            }
            if (curPackage.length() > 0 && temp.indexOf(curPackage) > -1) {
                // System.out.println("here  "+temp);
                continue;
            }
            if (cl.toString().equals(temp))
                continue;
            // System.out.println("printing"+);
            toImport.add(temp);
        }
        /*
             * Check that we are not importing two classes with the same last name
             * If yes then remove explicit import and import the whole package
             * else output explicit import statement
             */
        Iterator it = toImport.iterator();
        while (it.hasNext()) {
            String temp = (String) it.next();
            if (RemoveFullyQualifiedName.containsMultiple(toImport.iterator(), temp, null)) {
                // import package add *
                if (temp.lastIndexOf('.') > -1) {
                    temp = temp.substring(0, temp.lastIndexOf('.'));
                    out.println("import " + temp + ".*;");
                } else
                    throw new DecompilationException("Cant find the DOT . for fullyqualified name");
            } else {
                if (temp.lastIndexOf('.') == -1) {
                // dot not found this is a class belonging to this package so dont add
                } else
                    out.println("import " + temp + ";");
            }
        }
        boolean addNewLine = false;
        addNewLine = true;
        if (addNewLine)
            out.println();
        /*if (!packagesUsed.isEmpty())
                out.println();

            packagesUsed.add("java.lang");
            packagesUsed.add(curPackage);
            */
        Dava.v().set_CurrentPackageContext(importList);
        // Dava.v().set_CurrentPackageContext(packagesUsed);
        Dava.v().set_CurrentPackage(curPackage);
    }
    // Print class name + modifiers
    {
        String classPrefix = "";
        classPrefix = classPrefix + " " + Modifier.toString(cl.getModifiers());
        classPrefix = classPrefix.trim();
        if (!cl.isInterface()) {
            classPrefix = classPrefix + " class";
            classPrefix = classPrefix.trim();
        }
        out.print(classPrefix + " " + cl.getShortJavaStyleName());
    }
    // Print extension
    if (cl.hasSuperclass() && !(cl.getSuperclass().getName().equals("java.lang.Object"))) {
        String superClassName = cl.getSuperclass().getName();
        // Nomair Naeem 8th Feb 2006
        // also check if the super class name is not a fully qualified
        // name. in which case if the package is imported no need for
        // the long name
        superClassName = RemoveFullyQualifiedName.getReducedName(importList, superClassName, cl.getType());
        out.print(" extends " + superClassName + "");
    }
    // Print interfaces
    {
        Iterator<SootClass> interfaceIt = cl.getInterfaces().iterator();
        if (interfaceIt.hasNext()) {
            if (cl.isInterface())
                out.print(" extends ");
            else
                out.print(" implements ");
            out.print("" + (interfaceIt.next()).getName() + "");
            while (interfaceIt.hasNext()) out.print(", " + (interfaceIt.next()).getName() + "");
        }
    }
    out.println();
    out.println("{");
    // Print fields
    {
        Iterator<SootField> fieldIt = cl.getFields().iterator();
        if (fieldIt.hasNext()) {
            while (fieldIt.hasNext()) {
                SootField f = fieldIt.next();
                if (f.isPhantom())
                    continue;
                String declaration = null;
                Type fieldType = f.getType();
                String qualifiers = Modifier.toString(f.getModifiers()) + " ";
                qualifiers += RemoveFullyQualifiedName.getReducedName(importList, fieldType.toString(), fieldType);
                qualifiers = qualifiers.trim();
                if (qualifiers.equals(""))
                    declaration = Scene.v().quotedNameOf(f.getName());
                else
                    declaration = qualifiers + " " + Scene.v().quotedNameOf(f.getName()) + "";
                if (f.isFinal() && f.isStatic()) {
                    if (fieldType instanceof DoubleType && f.hasTag("DoubleConstantValueTag")) {
                        double val = ((DoubleConstantValueTag) f.getTag("DoubleConstantValueTag")).getDoubleValue();
                        out.println("    " + declaration + " = " + val + ";");
                    } else if (fieldType instanceof FloatType && f.hasTag("FloatConstantValueTag")) {
                        float val = ((FloatConstantValueTag) f.getTag("FloatConstantValueTag")).getFloatValue();
                        out.println("    " + declaration + " = " + val + "f;");
                    } else if (fieldType instanceof LongType && f.hasTag("LongConstantValueTag")) {
                        long val = ((LongConstantValueTag) f.getTag("LongConstantValueTag")).getLongValue();
                        out.println("    " + declaration + " = " + val + "l;");
                    } else if (fieldType instanceof CharType && f.hasTag("IntegerConstantValueTag")) {
                        int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue();
                        out.println("    " + declaration + " = '" + ((char) val) + "';");
                    } else if (fieldType instanceof BooleanType && f.hasTag("IntegerConstantValueTag")) {
                        int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue();
                        if (val == 0)
                            out.println("    " + declaration + " = false;");
                        else
                            out.println("    " + declaration + " = true;");
                    } else if ((fieldType instanceof IntType || fieldType instanceof ByteType || fieldType instanceof ShortType) && f.hasTag("IntegerConstantValueTag")) {
                        int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue();
                        out.println("    " + declaration + " = " + val + ";");
                    } else if (f.hasTag("StringConstantValueTag")) {
                        String val = ((StringConstantValueTag) f.getTag("StringConstantValueTag")).getStringValue();
                        out.println("    " + declaration + " = \"" + val + "\";");
                    } else {
                        // System.out.println("Couldnt find type of
                        // field"+f.getDeclaration());
                        out.println("    " + declaration + ";");
                    }
                } else // field is static final
                {
                    out.println("    " + declaration + ";");
                }
            }
        }
    }
    // Print methods
    {
        Iterator<SootMethod> methodIt = cl.methodIterator();
        if (methodIt.hasNext()) {
            if (cl.getMethodCount() != 0)
                out.println();
            while (methodIt.hasNext()) {
                SootMethod method = (SootMethod) methodIt.next();
                if (method.isPhantom())
                    continue;
                if (!Modifier.isAbstract(method.getModifiers()) && !Modifier.isNative(method.getModifiers())) {
                    if (!method.hasActiveBody())
                        throw new RuntimeException("method " + method.getName() + " has no active body!");
                    else
                        printTo(method.getActiveBody(), out);
                    if (methodIt.hasNext())
                        out.println();
                } else {
                    // if method is abstract then print the declaration
                    out.print("    ");
                    out.print(method.getDavaDeclaration());
                    out.println(";");
                    if (methodIt.hasNext())
                        out.println();
                }
            }
        }
    }
    if (G.v().SootClassNeedsDavaSuperHandlerClass.contains(cl)) {
        out.println("\n    private static class DavaSuperHandler{");
        out.println("         java.util.Vector myVector = new java.util.Vector();");
        out.println("\n         public Object get(int pos){");
        out.println("            return myVector.elementAt(pos);");
        out.println("         }");
        out.println("\n         public void store(Object obj){");
        out.println("            myVector.add(obj);");
        out.println("         }");
        out.println("    }");
    }
    out.println("}");
}
Also used : LongType(soot.LongType) ShortType(soot.ShortType) BooleanType(soot.BooleanType) IntegerConstantValueTag(soot.tagkit.IntegerConstantValueTag) ByteType(soot.ByteType) IterableSet(soot.util.IterableSet) SootClass(soot.SootClass) FloatType(soot.FloatType) IntType(soot.IntType) RefType(soot.RefType) RefType(soot.RefType) DoubleType(soot.DoubleType) FloatType(soot.FloatType) IntType(soot.IntType) ShortType(soot.ShortType) CharType(soot.CharType) LongType(soot.LongType) BooleanType(soot.BooleanType) ByteType(soot.ByteType) Type(soot.Type) DoubleType(soot.DoubleType) Iterator(java.util.Iterator) SootMethod(soot.SootMethod) SootField(soot.SootField) ArrayList(java.util.ArrayList) List(java.util.List) CharType(soot.CharType) FloatConstantValueTag(soot.tagkit.FloatConstantValueTag)

Example 10 with BooleanType

use of soot.BooleanType in project soot by Sable.

the class LocalNameStandardizer method internalTransform.

@Override
protected void internalTransform(Body body, String phaseName, Map<String, String> options) {
    boolean onlyStackName = PhaseOptions.getBoolean(options, "only-stack-locals");
    boolean sortLocals = PhaseOptions.getBoolean(options, "sort-locals");
    final BooleanType booleanType = BooleanType.v();
    final ByteType byteType = ByteType.v();
    final ShortType shortType = ShortType.v();
    final CharType charType = CharType.v();
    final IntType intType = IntType.v();
    final LongType longType = LongType.v();
    final DoubleType doubleType = DoubleType.v();
    final FloatType floatType = FloatType.v();
    final ErroneousType erroneousType = ErroneousType.v();
    final UnknownType unknownType = UnknownType.v();
    final StmtAddressType stmtAddressType = StmtAddressType.v();
    final NullType nullType = NullType.v();
    // Change the names to the standard forms now.
    {
        int objectCount = 0;
        int intCount = 0;
        int longCount = 0;
        int floatCount = 0;
        int doubleCount = 0;
        int addressCount = 0;
        int errorCount = 0;
        int nullCount = 0;
        /* The goal of this option is to ensure that local ordering remains
             * consistent between different iterations of soot. This helps to ensure
             * things like stable string representations of instructions and stable
             * jimple representations of a methods body when soot is used to load
             * the same code in different iterations.
             * 
             * First sorts the locals alphabetically by the string representation of
             * their type. Then if there are two locals with the same type, it uses
             * the only other source of structurally stable information (i.e. the 
             * instructions themselves) to produce an ordering for the locals
             * that remains consistent between different soot instances. It achieves
             * this by determining the position of a local's first occurrence in the 
             * instruction's list of definition statements. This position is then used
             * to sort the locals with the same type in an ascending order. 
             * 
             * The only times that this may not produce a consistent ordering for the 
             * locals between different soot instances is if a local is never defined in
             * the instructions or if the instructions themselves are changed in some way
             * that effects the ordering of the locals. In the first case, if a local is 
             * never defined, the other jimple body phases will remove this local as it is 
             * unused. As such, all we have to do is rerun this LocalNameStandardizer after
             * all other jimple body phases to eliminate any ambiguity introduced by these
             * phases and by the removed unused locals. In the second case, if the instructions
             * themselves changed then the user would have had to intentionally told soot to
             * modify the instructions of the code. Otherwise, the instructions would not have
             * changed because we assume the instructions to always be structurally stable
             * between different instances of soot. As such, in this instance, the user should
             * not be expecting soot to produce the same output as the input and thus the
             * ordering of the locals does not matter.
             */
        if (sortLocals) {
            Chain<Local> locals = body.getLocals();
            final List<ValueBox> defs = body.getDefBoxes();
            ArrayList<Local> sortedLocals = new ArrayList<Local>(locals);
            Collections.sort(sortedLocals, new Comparator<Local>() {

                private Map<Local, Integer> firstOccuranceCache = new HashMap<Local, Integer>();

                @Override
                public int compare(Local arg0, Local arg1) {
                    int ret = arg0.getType().toString().compareTo(arg1.getType().toString());
                    if (ret == 0) {
                        ret = Integer.compare(getFirstOccurance(arg0), getFirstOccurance(arg1));
                    }
                    return ret;
                }

                private int getFirstOccurance(Local l) {
                    Integer cur = firstOccuranceCache.get(l);
                    if (cur != null) {
                        return cur;
                    } else {
                        int count = 0;
                        int first = -1;
                        for (ValueBox vb : defs) {
                            Value v = vb.getValue();
                            if (v instanceof Local && v.equals(l)) {
                                first = count;
                                break;
                            }
                            count++;
                        }
                        firstOccuranceCache.put(l, first);
                        return first;
                    }
                }
            });
            locals.clear();
            locals.addAll(sortedLocals);
        }
        for (Local l : body.getLocals()) {
            String prefix = "";
            if (l.getName().startsWith("$"))
                prefix = "$";
            else {
                if (onlyStackName)
                    continue;
            }
            final Type type = l.getType();
            if (type.equals(booleanType))
                l.setName(prefix + "z" + intCount++);
            else if (type.equals(byteType))
                l.setName(prefix + "b" + longCount++);
            else if (type.equals(shortType))
                l.setName(prefix + "s" + longCount++);
            else if (type.equals(charType))
                l.setName(prefix + "c" + longCount++);
            else if (type.equals(intType))
                l.setName(prefix + "i" + longCount++);
            else if (type.equals(longType))
                l.setName(prefix + "l" + longCount++);
            else if (type.equals(doubleType))
                l.setName(prefix + "d" + doubleCount++);
            else if (type.equals(floatType))
                l.setName(prefix + "f" + floatCount++);
            else if (type.equals(stmtAddressType))
                l.setName(prefix + "a" + addressCount++);
            else if (type.equals(erroneousType) || type.equals(unknownType)) {
                l.setName(prefix + "e" + errorCount++);
            } else if (type.equals(nullType))
                l.setName(prefix + "n" + nullCount++);
            else
                l.setName(prefix + "r" + objectCount++);
        }
    }
}
Also used : Chain(soot.util.Chain) LongType(soot.LongType) ArrayList(java.util.ArrayList) ByteType(soot.ByteType) IntType(soot.IntType) FloatType(soot.FloatType) Comparator(java.util.Comparator) ErroneousType(soot.ErroneousType) ArrayList(java.util.ArrayList) List(java.util.List) ShortType(soot.ShortType) BooleanType(soot.BooleanType) Local(soot.Local) UnknownType(soot.UnknownType) UnknownType(soot.UnknownType) DoubleType(soot.DoubleType) FloatType(soot.FloatType) IntType(soot.IntType) ShortType(soot.ShortType) CharType(soot.CharType) LongType(soot.LongType) NullType(soot.NullType) StmtAddressType(soot.StmtAddressType) BooleanType(soot.BooleanType) ErroneousType(soot.ErroneousType) ByteType(soot.ByteType) Type(soot.Type) DoubleType(soot.DoubleType) ValueBox(soot.ValueBox) Value(soot.Value) CharType(soot.CharType) StmtAddressType(soot.StmtAddressType) NullType(soot.NullType) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

BooleanType (soot.BooleanType)16 IntType (soot.IntType)15 Type (soot.Type)14 ByteType (soot.ByteType)13 CharType (soot.CharType)13 ShortType (soot.ShortType)13 DoubleType (soot.DoubleType)11 FloatType (soot.FloatType)11 LongType (soot.LongType)11 Local (soot.Local)9 RefType (soot.RefType)9 Value (soot.Value)9 ArrayType (soot.ArrayType)8 ArrayList (java.util.ArrayList)7 List (java.util.List)6 PrimType (soot.PrimType)5 Iterator (java.util.Iterator)4 NullType (soot.NullType)4 SootClass (soot.SootClass)3 StmtAddressType (soot.StmtAddressType)3