Package soot

Examples of soot.SootMethod


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

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

                // Find out whether this method is supported. Its supported
                // if the source either declares or inherits this method.
                if (source.declaresMethod(method.getSubSignature())) {
                    interfaceMethodMap.put(method, source.getMethod(method
                            .getSubSignature()));
                } else {
                    Iterator inheritedMethods = MethodListGenerator
                            .getInheritedMethods(source).iterator();

                    while (inheritedMethods.hasNext()) {
                        SootMethod inheritedMethod = (SootMethod) inheritedMethods
                                .next();

                        if (inheritedMethod.getSubSignature().equals(
                                method.getSubSignature())) {
                            interfaceMethodMap.put(method, inheritedMethod);
                        }
                    }
                }
View Full Code Here


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

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

                if (!m.isConcrete()) {
                    continue;
                }

                JimpleBody body = (JimpleBody) m.retrieveActiveBody();

                internalTransform(body, phaseName, options);
            }
        }
    }
View Full Code Here

            }
        }

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

            System.out.println("processing method = " + method);
            // Grab the classes of all arguments.
            for (Iterator types = method.getParameterTypes().iterator(); types
                    .hasNext();) {
                Type type = (Type) types.next();

                if (type instanceof RefType) {
                    _addClass(((RefType) type).getSootClass());
                }
            }
            // Grab the method return types.
            {
                Type type = method.getReturnType();

                if (type instanceof RefType) {
                    _addClass(((RefType) type).getSootClass());
                }
            }

            // Don't drag in the bodies of abstract methods.
            if (!method.isConcrete()) {
                continue;
            }

            JimpleBody body = (JimpleBody) method.retrieveActiveBody();
            Scene.v().releaseActiveHierarchy();

            // Grab the types of all traps.
            for (Iterator it = body.getTraps().iterator(); it.hasNext();) {
                Trap t = (Trap) it.next();
                _addClass(t.getException());
            }

            // Grab the classes of all referenced fields, invoked
            // methods, and created classes.
            for (Iterator units = body.getUnits().iterator(); units.hasNext();) {
                Unit unit = (Unit) units.next();

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

                    if (value instanceof FieldRef) {
                        SootField field = ((FieldRef) value).getField();
                        SootClass refClass = field.getDeclaringClass();

                        if (!refClass.equals(theClass)) {
                            _addClass(refClass);
                        }
                    } else if (value instanceof InvokeExpr) {
                        SootMethod refMethod = ((InvokeExpr) value).getMethod();
                        SootClass refClass = refMethod.getDeclaringClass();

                        if (!refClass.equals(theClass)) {
                            _addClass(refClass);
                        }
                    } else if (value instanceof NewExpr) {
View Full Code Here

        // Export function prototypes for all non-private
        // methods.
        Iterator methods = source.getMethods().iterator();

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

            if ((!method.isPrivate())
                    && RequiredFileGenerator.isRequired(method)) {
                bodyCode.append("\n" + _comment(method.getSubSignature()));
                bodyCode.append("extern " + _generateMethodHeader(method)
                        + ";\n");
            }
        }
View Full Code Here

        final String indent = _indent(2);
        Iterator methods = methodList.iterator();
        int insertedMethods = 0;

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

            if (!method.isStatic() && _isDeclarable(method)) {
                if (insertedMethods == 0) {
                    methodCode.append("\n" + indent + _comment(comment));

                    // If importing of referenced include files in
                    // disabled, then place the method table in
                    // comments.
                    if (_context.getDisableImports()) {
                        methodCode.append(_indent(2) + _openComment);
                    }
                }

                methodCode.append(indent);

                methodCode.append(CNames.typeNameOf(method.getReturnType()));

                methodCode.append(" (*");
                methodCode.append(CNames.methodNameOf(method));
                methodCode.append(")(");
                methodCode.append(_generateParameterTypeList(method));
                methodCode.append(");\n");

                // The return type is required.
                _updateRequiredTypes(method.getReturnType());

                // The type of the class that declares this method.
                Type declaringClassType = method.getDeclaringClass().getType();

                if (RequiredFileGenerator.isRequired(declaringClassType)) {
                    _updateRequiredTypes(declaringClassType);
                }

                insertedMethods++;

                // Add the method's return type to the context as a
                // required type if it is an array.
                if (method.getReturnType() instanceof ArrayType) {
                    _context.addArrayInstance(CNames.typeNameOf(method
                            .getReturnType()));
                }
            }
        }

View Full Code Here

        while (source.hasSuperclass()) {
            source = source.getSuperclass();

            if (source.declaresMethod(method.getSubSignature())) {
                SootMethod m = source.getMethod(method.getSubSignature());

                if (RequiredFileGenerator.isRequired(m)) {
                    return true;
                }
            }
View Full Code Here

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

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

                if (!method.isConcrete()) {
                    continue;
                }

                try {
                    JimpleBody body = (JimpleBody) method.retrieveActiveBody();

                    for (Iterator transformers = _transformers.iterator(); transformers
                            .hasNext();) {
                        BodyTransformer transformer = (BodyTransformer) transformers
                                .next();
View Full Code Here

            LinkedList methodsList = new LinkedList();
            methodsList.addAll(c.getMethods());

            while (!methodsList.isEmpty()) {
                SootMethod container = (SootMethod) methodsList.removeFirst();

                if (!container.isConcrete()) {
                    // System.out.println("skipping " + container + ": not concrete");
                    continue;
                }

                if (!instanceInvokesFilter.wrap(cg.edgesOutOf(container))
                        .hasNext()) {
                    continue;
                }

                JimpleBody b = (JimpleBody) container.getActiveBody();

                List unitList = new ArrayList();
                unitList.addAll(b.getUnits());

                Iterator unitIt = unitList.iterator();

                while (unitIt.hasNext()) {
                    Stmt s = (Stmt) unitIt.next();

                    if (!s.containsInvokeExpr()) {
                        continue;
                    }

                    InvokeExpr ie = s.getInvokeExpr();

                    if (ie instanceof StaticInvokeExpr
                            || ie instanceof SpecialInvokeExpr) {
                        // System.out.println("skipping " + container + ":" +
                        //        s + ": not virtual");
                        continue;
                    }

                    Iterator targets = new Targets(cg.edgesOutOf(s));

                    if (!targets.hasNext()) {
                        continue;
                    }

                    SootMethod target = (SootMethod) targets.next();

                    if (targets.hasNext()) {
                        continue;
                    }

                    // Ok, we have an Interface or VirtualInvoke going to 1.
                    if (!AccessManager.ensureAccess(container, target,
                            modifierOptions)) {
                        // System.out.println("skipping: no access");
                        continue;
                    }

                    if (!target.isConcrete()) {
                        //  System.out.println("skipping: not concrete");
                        continue;
                    }

                    // HACK! because the callgraph seems to be
                    // incorrect in soot 2.0.1
                    if (!Scene.v().getApplicationClasses().contains(
                            target.getDeclaringClass())) {
                        continue;
                    }

                    // Change the InterfaceInvoke or VirtualInvoke to
                    // a new VirtualInvoke.
                    ValueBox box = s.getInvokeExprBox();
                    box.setValue(Jimple.v().newVirtualInvokeExpr(
                            (Local) ((InstanceInvokeExpr) ie).getBase(),
                            target.makeRef(), ie.getArgs()));
                }
            }
        }
    }
View Full Code Here

        final Set createableClasses = new HashSet();

        for (Iterator reachables = reachableMethods.listener(); reachables
                .hasNext();) {
            SootMethod method = (SootMethod) reachables.next();
            //String methodName = method.getSignature();

            if (method.getName().equals("<init>")
                    && !method.getDeclaringClass().getName().startsWith("java")) {
                createableClasses
                        .addAll(hierarchy.getSuperclassesOfIncluding(method
                                .getDeclaringClass()));
                _addAllInterfaces(createableClasses, method.getDeclaringClass());
            }
        }

        System.out.println("createableClasses = " + createableClasses);

        // Now create a new set of reachable methods that only
        // includes methods that are static or are declared in classes
        // that can are created.
        Filter filter = new Filter(new EdgePredicate() {
            public boolean want(Edge e) {
                SootMethod target = e.tgt();
                return e.isExplicit()
                        && (target.isStatic() || createableClasses
                                .contains(target.getDeclaringClass()));
            }
        });
        Set necessaryClasses = new HashSet();
        ReachableMethods RTAReachableMethods = new ReachableMethods(callGraph,
                EntryPoints.v().application().iterator(), filter);
        RTAReachableMethods.update();

        List list = new LinkedList();

        for (Iterator reachables = RTAReachableMethods.listener(); reachables
                .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();) {
View Full Code Here

        while (nodes.hasNext()) {
            Object node = nodes.next();

            if (node instanceof SootMethod) {
                SootMethod method = (SootMethod) node;

                if (method.isConcrete()
                        && !OverriddenMethodGenerator.isOverridden(method)) {
                    entryPoints.add(method);
                }
            }
        }
View Full Code Here

TOP

Related Classes of soot.SootMethod

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.