Examples of SootClass


Examples of soot.SootClass

            // its own superclass!
            PtolemyUtilities.objectClass.setSuperclass(null);

            for (Iterator classes = Scene.v().getApplicationClasses()
                    .snapshotIterator(); classes.hasNext();) {
                SootClass theClass = (SootClass) classes.next();
                theClass.setLibraryClass();
            }
        }
View Full Code Here

Examples of soot.SootClass

    protected void internalTransform(String phaseName, Map options) {
        System.out.println("UnusedFieldRemover.internalTransform(" + phaseName
                + ", " + options + ")");

        SootClass stringClass = Scene.v().loadClassAndSupport(
                "java.lang.String");
        /*Type stringType = */RefType.v(stringClass);
        SootClass objectClass = Scene.v().loadClassAndSupport(
                "java.lang.Object");
        /*SootMethod toStringMethod =*/objectClass
                .getMethod("java.lang.String toString()");
        SootClass namedObjClass = Scene.v().loadClassAndSupport(
                "ptolemy.kernel.util.NamedObj");
        /*SootMethod getAttributeMethod = */namedObjClass
                .getMethod("ptolemy.kernel.util.Attribute getAttribute(java.lang.String)");
        /*SootMethod attributeChangedMethod = */namedObjClass
                .getMethod("void attributeChanged(ptolemy.kernel.util.Attribute)");

        SootClass attributeClass = Scene.v().loadClassAndSupport(
                "ptolemy.kernel.util.Attribute");
        /*Type attributeType =*/RefType.v(attributeClass);
        SootClass settableClass = Scene.v().loadClassAndSupport(
                "ptolemy.kernel.util.Settable");
        /*Type settableType =*/RefType.v(settableClass);
        /*SootMethod getExpressionMethod = */settableClass
                .getMethod("java.lang.String getExpression()");
        /*SootMethod setExpressionMethod = */settableClass
                .getMethod("void setExpression(java.lang.String)");

        SootClass tokenClass = Scene.v().loadClassAndSupport(
                "ptolemy.data.Token");
        /*Type tokenType = */RefType.v(tokenClass);
        SootClass parameterClass = Scene.v().loadClassAndSupport(
                "ptolemy.data.expr.Variable");
        /*SootMethod getTokenMethod = */parameterClass
                .getMethod("ptolemy.data.Token getToken()");
        /*SootMethod setTokenMethod = */parameterClass
                .getMethod("void setToken(ptolemy.data.Token)");

        Set unusedFieldSet = new HashSet();

        // Loop over all the actor instance classes and create the set of
        // all fields.
        for (Iterator i = Scene.v().getApplicationClasses().iterator(); i
                .hasNext();) {
            SootClass entityClass = (SootClass) i.next();

            unusedFieldSet.addAll(entityClass.getFields());
        }

        // Loop through all the methods and kill all the used fields.
        for (Iterator i = Scene.v().getApplicationClasses().iterator(); i
                .hasNext();) {
            SootClass entityClass = (SootClass) i.next();

            for (Iterator methods = entityClass.getMethods().iterator(); methods
                    .hasNext();) {
                SootMethod method = (SootMethod) methods.next();
                JimpleBody body = (JimpleBody) method.retrieveActiveBody();

                for (Iterator stmts = body.getUnits().iterator(); stmts
                        .hasNext();) {
                    Stmt stmt = (Stmt) stmts.next();

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

                        if (value instanceof FieldRef) {
                            Object field = ((FieldRef) value).getField();
                            unusedFieldSet.remove(field);
                        }
                    }
                }
            }
        }

        // Loop through the methods again, and kill the statements
        // that write to an unused field.
        for (Iterator i = Scene.v().getApplicationClasses().iterator(); i
                .hasNext();) {
            SootClass entityClass = (SootClass) i.next();

            for (Iterator methods = entityClass.getMethods().iterator(); methods
                    .hasNext();) {
                SootMethod method = (SootMethod) methods.next();
                JimpleBody body = (JimpleBody) method.retrieveActiveBody();

                for (Iterator stmts = body.getUnits().snapshotIterator(); stmts
                        .hasNext();) {
                    Stmt stmt = (Stmt) stmts.next();

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

                        if (value instanceof FieldRef) {
                            Object field = ((FieldRef) value).getField();

                            if (unusedFieldSet.contains(field)) {
                                body.getUnits().remove(stmt);
                            }
                        }
                    }
                }
            }

            for (Iterator fields = entityClass.getFields().snapshotIterator(); fields
                    .hasNext();) {
                SootField field = (SootField) fields.next();

                if (unusedFieldSet.contains(field)) {
                    entityClass.removeField(field);
                }
            }
        }
    }
View Full Code Here

Examples of soot.SootClass

        // User-defined compulsory methods.
        compulsoryNodes.addAll(_getForcedCompulsoryMethods());

        // Add java.lang.String.String(char[]). Initializer
        SootClass source = Scene.v().getSootClass("java.lang.String");
        SootMethod method = source.getMethod("void <init>(char[])");
        compulsoryNodes.add(method);

        // Add java.lang.String.<clinit>.
        method = source.getMethodByName("<clinit>");
        compulsoryNodes.add(method);

        // java.lang.String.toString() is needed.
        method = source.getMethodByName("toString");
        compulsoryNodes.add(method);

        // All fields of String are required.
        compulsoryNodes.addAll(source.getFields());

        // Add java.lang.System.initializeSystemClass()
        // Soot-2.2.2 required tryLoadClass()
        Scene.v().tryLoadClass("java.lang.System", SootClass.SIGNATURES);
        source = Scene.v().getSootClass("java.lang.System");
        method = source.getMethodByName("initializeSystemClass");
        compulsoryNodes.add(method);

        // System.out is required by initializeSystemClass
        SootField field = source.getFieldByName("out");
        compulsoryNodes.add(field);

        // System.err is required by initializeSystemClass
        field = source.getFieldByName("err");
        compulsoryNodes.add(field);

        // Printstream is required by the force-overridden version of
        // System.initializeSystemClass(), but it doesn't have a clinit.
        source = Scene.v().getSootClass("java.io.PrintStream");
        method = source.getMethod("void println(int)");
        compulsoryNodes.add(method);

        // Class is required by Object.
        source = Scene.v().getSootClass("java.lang.Class");
        compulsoryNodes.add(source);
View Full Code Here

Examples of soot.SootClass

                + ", " + options + ")");

        // Loop through all the methods and kill all the used fields.
        for (Iterator i = Scene.v().getApplicationClasses().iterator(); i
                .hasNext();) {
            SootClass entityClass = (SootClass) i.next();

            for (Iterator methods = entityClass.getMethods().iterator(); methods
                    .hasNext();) {
                SootMethod method = (SootMethod) methods.next();

                if (method.isConcrete()) {
                    method.setActiveBody(Grimp.v().newBody(
View Full Code Here

Examples of soot.SootClass

        Iterator stringConstants = _context.getStringConstants();

        if (stringConstants.hasNext()) {
            code.append(_indent(1) + "/* String Constant Initialization */\n");

            SootClass stringClass = Scene.v().getSootClass("java.lang.String");
            String stringType = CNames.instanceNameOf(stringClass);
            String stringStructure = CNames.classStructureNameOf(stringClass);
            String stringInitializer = CNames.methodNameOf(stringClass
                    .getMethod("void <init>(char[])"));
            code.append("\n" + _indent(1)
                    + _comment("Initialization of string constants"));

            while (stringConstants.hasNext()) {
View Full Code Here

Examples of soot.SootClass

        String outDir = PhaseOptions.getString(options, "outDir");

        for (Iterator classes = Scene.v().getApplicationClasses().iterator(); classes
                .hasNext();) {
            SootClass theClass = (SootClass) classes.next();

            String fileName;

            if (!outDir.equals("")) {
                File outDirFile = new File(outDir);

                if (!outDirFile.isDirectory()) {
                    outDirFile.mkdirs();
                }

                fileName = outDir + System.getProperty("file.separator");
            } else {
                fileName = "";
            }

            fileName += (theClass.getName() + ".jimple");

            FileOutputStream streamOut = null;
            PrintWriter writerOut = null;

            try {
View Full Code Here

Examples of soot.SootClass

        HashMap interfaceMethodMap = new HashMap();
        Iterator interfaces = AnalysisUtilities.getAllInterfacesOf(source)
                .iterator();

        while (interfaces.hasNext()) {
            SootClass thisInterface = (SootClass) interfaces.next();
            Iterator methods = thisInterface.getMethods().iterator();

            while (methods.hasNext()) {
                // The method in the interface.
                SootMethod method = (SootMethod) methods.next();
View Full Code Here

Examples of soot.SootClass

                + phaseName + ", " + options + ")");

        Iterator classes = Scene.v().getApplicationClasses().iterator();

        while (classes.hasNext()) {
            SootClass theClass = (SootClass) classes.next();
            Iterator methods = theClass.getMethods().iterator();

            while (methods.hasNext()) {
                SootMethod m = (SootMethod) methods.next();

                if (!m.isConcrete()) {
View Full Code Here

Examples of soot.SootClass

                + ", " + options + ")");

        Iterator classes = Scene.v().getApplicationClasses().iterator();

        while (classes.hasNext()) {
            SootClass theClass = (SootClass) classes.next();
            Iterator methods = theClass.getMethods().iterator();

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

                if (!method.isConcrete()) {
View Full Code Here

Examples of soot.SootClass

        Iterator classes = _unprocessedClasses.reader();

        _addClasses(initialClasses);

        while (classes.hasNext()) {
            SootClass nextClass = (SootClass) classes.next();
            _processClass(nextClass);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.