Package soot

Examples of soot.SootMethodRef


        Local exceptionLocal = lg.generateLocal(runtimeExceptionType);
        AssignStmt assignStmt = Jimple.v().newAssignStmt(exceptionLocal, newExpr);
        body.getUnits().insertBefore(assignStmt, insertionPoint);
       
        //exc.<init>(message)
        SootMethodRef cref = runtimeExceptionType.getSootClass().getMethod("<init>", Collections.singletonList(RefType.v("java.lang.String"))).makeRef();
        SpecialInvokeExpr constructorInvokeExpr = Jimple.v().newSpecialInvokeExpr(exceptionLocal, cref, StringConstant.v(guard.message));
        InvokeStmt initStmt = Jimple.v().newInvokeStmt(constructorInvokeExpr);
        body.getUnits().insertAfter(initStmt, assignStmt);
       
        if(options.guards().equals("print")) {
View Full Code Here


                                    RefType.v(newClass), r.getIndex()));
                        }
                    } else if (value instanceof InvokeExpr) {
                        // Fix up the method invokes.
                        InvokeExpr r = (InvokeExpr) value;
                        SootMethodRef methodRef = r.getMethodRef();
                        System.out.println("invoke = " + r);

                        List newParameterTypes = new LinkedList();
                        for (Iterator i = methodRef.parameterTypes().iterator(); i
                                .hasNext();) {
                            Type type = (Type) i.next();
                            if (type instanceof RefType
                                    && (((RefType) type).getSootClass() == oldClass)) {
                                System.out.println("matchedParameter = "
                                        + newClass);
                                newParameterTypes.add(RefType.v(newClass));
                            } else if (type instanceof RefType
                                    && (((RefType) type).getSootClass()
                                            .getName().startsWith(oldClass
                                            .getName()))) {
                                System.out.println("matchedParameter = "
                                        + newClass);
                                SootClass changeClass = _getInnerClassCopy(
                                        oldClass, ((RefType) type)
                                                .getSootClass(), newClass);
                                newParameterTypes.add(RefType.v(changeClass));
                            } else {
                                newParameterTypes.add(type);
                            }

                        }

                        Type newReturnType = methodRef.returnType();
                        if (newReturnType instanceof RefType
                                && (((RefType) newReturnType).getSootClass() == oldClass)) {
                            newReturnType = RefType.v(newClass);
                        }

                        // Update the parameter types and the return type.
                        methodRef = Scene.v().makeMethodRef(
                                methodRef.declaringClass(), methodRef.name(),
                                newParameterTypes, newReturnType,
                                methodRef.isStatic());
                        r.setMethodRef(methodRef);

                        if (methodRef.declaringClass() == oldClass) {
                            r.setMethodRef(Scene.v().makeMethodRef(newClass,
                                    methodRef.name(),
                                    methodRef.parameterTypes(),
                                    methodRef.returnType(),
                                    methodRef.isStatic()));
                            // System.out.println("newValue = " +
                            // box.getValue());
                        } else if (methodRef.declaringClass().getName()
                                .startsWith(oldClass.getName())) {
                            SootClass changeClass = _getInnerClassCopy(
                                    oldClass, methodRef.declaringClass(),
                                    newClass);
                            r.setMethodRef(Scene.v().makeMethodRef(changeClass,
                                    methodRef.name(),
                                    methodRef.parameterTypes(),
                                    methodRef.returnType(),
                                    methodRef.isStatic()));
                        }
                    } else if (value instanceof NewExpr) {
                        // Fix up the object creations.
                        NewExpr r = (NewExpr) value;
View Full Code Here

                        }
                    }
                }
                if (stmt.containsInvokeExpr()) {
                    InvokeExpr invoke = stmt.getInvokeExpr();
                    SootMethodRef invokeMethodRef = invoke.getMethodRef();
                    SootMethod invokeMethod = invoke.getMethod();

                    if (invokeMethod.getDeclaringClass() == superClass) {

                        // Force the body of the thing we are inlining to be
                        // loaded
                        try {
                            if (invokeMethod.isConcrete()) {
                                invokeMethod.retrieveActiveBody();
                            } else {
                                System.out.println("SootUtilities."
                                        + "foldClass() " + invokeMethod
                                        + " is not concrete!");

                                // javac -target 1.2 and greater
                                // ends up causing problems here when
                                // calling super on a method, but the
                                // direct parent does not have a
                                // method by that name.
                                //
                                // If I have 3 classes A, B and C,
                                // where C extends B which extends A
                                // and A and C define a method foo and
                                // C calls super.foo, then under javac
                                // -target 1.2 the constant pool ends
                                // up with a reference to
                                // [2] methodref=soot/coffi/B.foo
                                // and under javac -target 1.1, we end up with
                                // [2] methodref=soot/coffi/A.foo
                                // So, we look for the method in the superclass
                                SootClass scratchClass = invokeMethod
                                        .getDeclaringClass();

                                while (scratchClass.hasSuperclass()) {
                                    SootClass superC = scratchClass
                                            .getSuperclass();

                                    if (superC.declaresMethod(invokeMethod
                                            .getSubSignature())) {
                                        invokeMethod = superC
                                                .getMethod(invokeMethod
                                                        .getSubSignature());
                                        System.out.println("SootUtilties."
                                                + "foldClass() " + "found "
                                                + superC + " " + invokeMethod);
                                        invokeMethod.retrieveActiveBody();
                                        break;
                                    }

                                    scratchClass = superC;
                                }
                            }
                        } catch (Exception ex) {
                            throw new KernelRuntimeException(ex,
                                    "foldClass: Problem with "
                                            + "retrieveActiveBody()");
                        }

                        SiteInliner.inlineSite(invokeMethod, stmt, newMethod);
                    } else if (invokeMethodRef.declaringClass() == superClass) {
                        // We might also have a reference to a method
                        // which is not actually declared in the
                        // superclass, in which case, we just fix up
                        // the ref to point to the new super class
                        invoke.setMethodRef(Scene.v().makeMethodRef(
                                superClass.getSuperclass(),
                                invokeMethodRef.name(),
                                invokeMethodRef.parameterTypes(),
                                invokeMethodRef.returnType(),
                                invokeMethodRef.isStatic()));
                    }
                }
            }
        }
View Full Code Here

      parmTypes.add(SootTypeUtil.getSootType(parm.type()));
    Type rettp = SootTypeUtil.getSootType(calleeDecl.getReturnType().getDescriptor());
   
    // compute reference to callee
    SootClass calleeSootClass = fcg.getModuleCodeGenerator().getProgramCodeGenerator().getSootClass(calleeModule);
    SootMethodRef callee = Scene.v().makeMethodRef(calleeSootClass, calleeName, parmTypes, rettp, true);
   
    // prepare arguments
    Value[] args = new Value[nd.getNumArgument()];
    for(int i=0;i<args.length;++i)
      args[i] = wrap(nd.getArgument(i).accept(this));
View Full Code Here

        @Override
        public void caseSpecialInvokeExpr(SpecialInvokeExpr v) {
            instanceInvokeExpr(v);
        }
        private void instanceInvokeExpr(InstanceInvokeExpr v) {
            SootMethodRef m = v.getMethodRef();
            if (m.getSignature().equals("<java.lang.String: boolean contains(java.lang.CharSequence)>")) {
                if (expected == true) {
                    Variable base = getBase(v);
                    Variable arg = getArgument(v, 0);
                    makeBinaryAssertion(base, arg, new AssertContainsOther());
                    makeBinaryAssertion(arg, base, new AssertContainedInOther());
                }
            }
            else if (m.getSignature().equals("<java.lang.String: boolean equals(java.lang.Object)>")) {
                Variable base = getBase(v);
                Variable arg = getArgument(v, 0);
                if (expected == true) {
                    makeBinaryAssertion(base, arg, new AssertEquals());
                    makeBinaryAssertion(arg, base, new AssertEquals());
                } else {
                    makeBinaryAssertion(base, arg, new AssertNotEquals());
                    makeBinaryAssertion(arg, base, new AssertNotEquals());
                }
            }
            else if (m.getSignature().equals("<java.lang.String: boolean startsWith(java.lang.String)>")) {
                if (expected == true) {
                    Variable base = getBase(v);
                    Variable arg = getArgument(v, 0);
                    makeBinaryAssertion(base, arg, new AssertStartsWith());
                    makeBinaryAssertion(arg, base, new AssertPrefixOf());
                } else {
                    // TODO negated startsWith assertions [note: it is sound to ignore this]
                }
            }
            else if (m.getSignature().equals("<java.lang.String: boolean endsWith(java.lang.String)>")) {
                if (expected == true) {
                    Variable base = getBase(v);
                    Variable arg = getArgument(v, 0);
                    makeBinaryAssertion(base, arg, new AssertEndsWith());
                    makeBinaryAssertion(arg, base, new AssertSuffixOf());
                } else {
                    // TODO negated endsWith assertions [note: it is sound to ignore this]
                }
            }
            else if (m.getSignature().equals("<java.lang.String: boolean isEmpty()>")) {
                Variable base = getBase(v);
                if (expected == true) {
                    makeUnaryAssertion(base, new AssertEmpty());
                } else {
                    makeUnaryAssertion(base, new AssertNotEmpty());
                }
            }
            else if (m.getSignature().equals("<java.lang.String: boolean contentEquals(java.lang.StringBuffer)>")
                    || m.getSignature().equals("<java.lang.String: boolean contentEquals(java.lang.CharSequence)>")) {
                Variable base = getBase(v);
                Variable arg = getArgument(v, 0);
                if (expected == true) {
                    makeBinaryAssertion(base, arg, new AssertEquals());
                    makeBinaryAssertion(arg, base, new AssertEquals());
View Full Code Here

            }
        }
       
        @Override
        public void caseStaticInvokeExpr(StaticInvokeExpr v) {
            SootMethodRef m = v.getMethodRef();
            if (m.getSignature().equals("<java.lang.Character: boolean isDigit(char)>")) {
              Variable base = getArgument(v, 0);
              if (expected == true) {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeDigits()));
              } else {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeDigits().complement()));
              }
            }
            else if (m.getSignature().equals("<java.lang.Character: boolean isLetter(char)>")) {
              Variable base = getArgument(v, 0);
              if (expected == true) {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeLetters()));
              } else {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeLetters().complement()));
              }
            }
            else if (m.getSignature().equals("<java.lang.Character: boolean isLetterOrDigit(char)>")) {
              Variable base = getArgument(v, 0);
              if (expected == true) {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeLettersAndDigits()));
              } else {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeLettersAndDigits().complement()));
              }
            }
            else if (m.getSignature().equals("<java.lang.Character: boolean isLowerCase(char)>")) {
              Variable base = getArgument(v, 0);
              if (expected == true) {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeLowerCase()));
              } else {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeLowerCase().complement()));
              }
            }
            else if (m.getSignature().equals("<java.lang.Character: boolean isTitleCase(char)>")) {
              Variable base = getArgument(v, 0);
              if (expected == true) {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeTitleCase()));
              } else {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeTitleCase().complement()));
              }
            }
            else if (m.getSignature().equals("<java.lang.Character: boolean isUpperCase(char)>")) {
              Variable base = getArgument(v, 0);
              if (expected == true) {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeUpperCase()));
              } else {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeUpperCase().complement()));
              }
            }
            else if (m.getSignature().equals("<java.lang.Character: boolean isSpaceChar(char)>")) {
              Variable base = getArgument(v, 0);
              if (expected == true) {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeSpaceChars()));
              } else {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeSpaceChars().complement()));
              }
            }
            else if (m.getSignature().equals("<java.lang.Character: boolean isWhitespace(char)>")) {
              Variable base = getArgument(v, 0);
              if (expected == true) {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeWhitespace()));
              } else {
                makeUnaryAssertion(base, new AssertInLanguage(Basic.getUnicodeWhitespace().complement()));
View Full Code Here

        @Override
        public void caseSpecialInvokeExpr(SpecialInvokeExpr v) {
            handleInvoke(v);
        }
        private void handleInvoke(InstanceInvokeExpr v) {
            SootMethodRef m = v.getMethodRef();
            if (m.getSignature().equals("<java.lang.String: int length()>")) {
                switch (relation) {
                case EQUAL:
                    makeUnaryAssertion(getBase(v), new AssertHasLength(expected, expected));
                    break;
                case NOT_EQUAL:
View Full Code Here

TOP

Related Classes of soot.SootMethodRef

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.