Package soot

Examples of soot.SootClass


                .hasNext();) {
            SootMethod method = (SootMethod) reachables.next();
            String methodName = method.getSignature();
            list.add(methodName);

            SootClass declaringClass = method.getDeclaringClass();

            if (!declaringClass.getName().startsWith("java")) {
                necessaryClasses.add(declaringClass);
            }

            if (method.isConcrete()) {
                for (Iterator units = method.retrieveActiveBody().getUnits()
                        .iterator(); units.hasNext();) {
                    Unit unit = (Unit) units.next();

                    for (Iterator boxes = unit.getUseBoxes().iterator(); boxes
                            .hasNext();) {
                        ValueBox box = (ValueBox) boxes.next();
                        Value value = box.getValue();

                        if (value instanceof CastExpr) {
                            CastExpr expr = (CastExpr) value;
                            Type castType = expr.getCastType();

                            if (castType instanceof RefType) {
                                SootClass castClass = ((RefType) castType)
                                        .getSootClass();

                                if (castClass.isInterface()) {
                                    necessaryClasses.add(castClass);
                                } else {
                                    necessaryClasses
                                            .addAll(hierarchy
                                                    .getSuperclassesOfIncluding(castClass));
                                }

                                _addAllInterfaces(necessaryClasses, castClass);
                            }
                        } else if (value instanceof InstanceOfExpr) {
                            InstanceOfExpr expr = (InstanceOfExpr) value;
                            Type checkType = expr.getCheckType();

                            if (checkType instanceof RefType) {
                                SootClass checkClass = ((RefType) checkType)
                                        .getSootClass();

                                if (!checkClass.isInterface()) {
                                    necessaryClasses
                                            .addAll(hierarchy
                                                    .getSuperclassesOfIncluding(checkClass));
                                }

                                _addAllInterfaces(necessaryClasses, checkClass);
                            }
                        }
                    }
                }
            }
        }

        // Print out all the used methods
        Collections.sort(list);

        for (Iterator names = list.iterator(); names.hasNext();) {
            System.out.println(names.next());
        }

        try {
            // Add to the set of necessary classes all that they depend on.
            DependedClasses dependedClasses = new DependedClasses(
                    necessaryClasses);
            FileWriter writer = null;
            try {
                writer = new FileWriter(outFile);

                for (Iterator classes = dependedClasses.list().iterator(); classes
                        .hasNext();) {
                    SootClass theClass = (SootClass) classes.next();

                    if (analyzeAllReachables) {
                        // Set the class to be an application class, so we can
                        // analyze it.
                        theClass.setApplicationClass();
                    }

                    writer.write(theClass.getName());
                    writer.write("\n");
                }
            } finally {
                if (writer != null) {
                    try {
View Full Code Here


        }
    }

    private void _addAllInterfaces(Set classSet, SootClass theClass) {
        for (Iterator i = theClass.getInterfaces().iterator(); i.hasNext();) {
            SootClass theInterface = (SootClass) i.next();
            classSet.add(theInterface);
            _addAllInterfaces(classSet, theInterface);
        }
    }
View Full Code Here

        HashSet requiredMethodSet = new HashSet();

        Iterator classes = classSet.iterator();

        while (classes.hasNext()) {
            SootClass source = (SootClass) classes.next();
            Iterator methods = methodSet.iterator();
            Hierarchy hierarchy = new Hierarchy();

            // Candidates for I. All superclasses and all implemented
            // interfaces.
            Collection allParents = AnalysisUtilities
                    .getAllInterfacesOf(source);

            if (!source.isInterface()) {
                allParents.addAll(hierarchy.getSuperclassesOf(source));
            }

            while (methods.hasNext()) {
                SootMethod method = (SootMethod) methods.next();
                String subSignature = method.getSubSignature();

                if (source.declaresMethod(subSignature)
                        && allParents.contains(method.getDeclaringClass())) {
                    requiredMethodSet.add(source.getMethod(subSignature));
                }
            }
        }

        return requiredMethodSet;
View Full Code Here

            if (node.declaresMethodByName("<clinit>")) {
                _add(node.getMethodByName("<clinit>"));
            }

            // Add all superClasses.
            SootClass superclass = node;

            while (superclass.hasSuperclass()
                    && !_reachableClasses.contains(superclass)) {
                superclass = superclass.getSuperclass();
                _add(superclass);
            }
        }

        _done(node);
View Full Code Here

            subSignature = names[i].substring(0, spaceIndex) + " "
                    + names[i].substring(classNameEndIndex + 1);

            className = names[i].substring(spaceIndex + 1, classNameEndIndex);

            SootClass source = Scene.v().getSootClass(className);
            SootMethod method = source.getMethod(subSignature);
            methods.add(method);
        }

        return methods;
    }
View Full Code Here

     *  at the given unit in the
     *  given body with a circular array reference.
     */
    public void inlineBroadcast(JimpleBody body, Stmt stmt, InvokeExpr expr,
            TypedIOPort port) {
        SootClass theClass = body.getMethod().getDeclaringClass();

        Local bufferLocal = Jimple.v().newLocal("buffer",
                ArrayType.v(PtolemyUtilities.tokenType, 1));
        body.getLocals().add(bufferLocal);

View Full Code Here

        for (Iterator entities = _model.deepEntityList().iterator(); entities
                .hasNext();) {
            ComponentEntity entity = (ComponentEntity) entities.next();
            String className = ModelTransformer.getInstanceClassName(entity,
                    _options);
            SootClass entityClass = Scene.v().loadClassAndSupport(className);

            _createBufferReferences(entity, entityClass);
        }
    }
View Full Code Here

     *  returned.
     */
    private Value _getBufferAndSize(JimpleBody body, Stmt stmt,
            TypedIOPort port, ptolemy.data.type.Type type, Value channelValue,
            Local bufferLocal, Map portToTypeNameToBufferField, boolean inside) {
        SootClass theClass = body.getMethod().getDeclaringClass();

        Value bufferSizeValue = null;

        // Now get the appropriate buffer
        if (Evaluator.isValueConstantValued(channelValue)) {
View Full Code Here

                debug);

        // Replace the token calls... on ALL the classes.
        for (Iterator classes = Scene.v().getApplicationClasses().iterator(); classes
                .hasNext();) {
            SootClass theClass = (SootClass) classes.next();

            if (SootUtilities.derivesFrom(theClass,
                    PtolemyUtilities.inequalityTermClass)) {
                continue;
            }

            // Inline calls to parameter.getToken and getExpression
            for (Iterator methods = theClass.getMethods().iterator(); methods
                    .hasNext();) {
                SootMethod method = (SootMethod) methods.next();

                // What about static methods?  They don't have a this
                // local
View Full Code Here

                                    .getMethod()
                                    .getSubSignature()
                                    .equals(
                                            PtolemyUtilities.variableConstructorWithToken
                                                    .getSubSignature())) {
                                SootClass variableClass = r.getMethod()
                                        .getDeclaringClass();
                                SootMethod constructorWithoutToken = variableClass
                                        .getMethod(PtolemyUtilities.variableConstructorWithoutToken
                                                .getSubSignature());

                                // Replace the three-argument
                                // constructor with a two-argument
View Full Code Here

TOP

Related Classes of soot.SootClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.