Package soot.jimple

Examples of soot.jimple.ParameterRef


                    } else if (unit instanceof IdentityStmt) {
                        IdentityStmt identityStmt = (IdentityStmt) unit;
                        Value value = identityStmt.getRightOp();

                        if (value instanceof ParameterRef) {
                            ParameterRef parameterRef = (ParameterRef) value;

                            if ((parameterRef.getIndex() == 0)
                                    && (method.getParameterCount() == 1)) {
                                //       System.out.println("found = " + identityStmt);
                                ValueBox box = identityStmt.getRightOpBox();
                                box.setValue(Jimple.v().newParameterRef(
                                        method.getParameterType(0), 0));
View Full Code Here


                            box.setValue(Jimple.v().newThisRef(
                                    RefType.v(newClass)));
                        }
                    } else if (value instanceof ParameterRef) {
                        // Fix references to a parameter
                        ParameterRef r = (ParameterRef) value;
                        Type type = r.getType();

                        if (type instanceof RefType
                                && (((RefType) type).getSootClass() == oldClass)) {
                            box.setValue(Jimple.v().newParameterRef(
                                    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;

                        if (r.getBaseType().getSootClass() == oldClass) {
                            r.setBaseType(RefType.v(newClass));

                            //   System.out.println("newValue = " +
                            //           box.getValue());
                        } else if (r.getBaseType().getSootClass().getName()
                                .startsWith(oldClass.getName())) {
                            SootClass changeClass = _getInnerClassCopy(
                                    oldClass, r.getBaseType().getSootClass(),
                                    newClass);
                            r.setBaseType(RefType.v(changeClass));
                        }
                    }

                    //    System.out.println("value = " + value);
                    //   System.out.println("class = " +
View Full Code Here

                                if (unit instanceof IdentityStmt) {
                                    IdentityStmt identityStmt = (IdentityStmt) unit;
                                    Value value = identityStmt.getRightOp();

                                    if (value instanceof ParameterRef) {
                                        ParameterRef parameterRef = (ParameterRef) value;

                                        if (parameterRef.getIndex() == 0) {
                                            ValueBox box = identityStmt
                                                    .getRightOpBox();
                                            box
                                                    .setValue(Jimple
                                                            .v()
View Full Code Here

    int nparm = fn.getNumParameter();
    for(int i=0;i<nparm;++i) {
      Parameter parm = fn.getParameter(i);
      Local sootLocal = getSootLocal(parm);
      Type parmType = SootTypeUtil.getSootType(parm.type());
      ParameterRef soot_parm = Jimple.v().newParameterRef(parmType, i);
      body.getUnits().add(Jimple.v().newIdentityStmt(sootLocal, soot_parm));
    }   
   
    // generate code for statements
    fn.getBody().accept(new StmtCodeGenerator(this));
View Full Code Here

        }
        else if (stmt instanceof IdentityStmt) {
          IdentityStmt iStmt = (IdentityStmt)stmt;
          Value rvalue = iStmt.getRightOp();
          if (rvalue instanceof ParameterRef) {
            ParameterRef parameter = (ParameterRef)rvalue;
            int index = parameter.getIndex();
            stmt.addTag(new StringTag("Type mismatch: cannot convert parameter number " + (index + 1) + " from " + from + " to " + analyzer.getDescription(a)));
          }
        }
        else {
          stmt.addTag(new StringTag("Type mismatch: cannot convert from " + from + " to " + analyzer.getDescription(a)));
View Full Code Here

  @Override
  public void caseIdentityStmt(IdentityStmt stmt) {
    Value rvalue = stmt.getRightOp();
    ValueBox rbox = stmt.getRightOpBox();
    if (rvalue instanceof ParameterRef) {
      ParameterRef parameter = (ParameterRef)rvalue;
      int index = parameter.getIndex();
      Map<Integer,Automaton> pMap = parameterAutomatonMap.get(currentMethod);
      if (pMap != null && pMap.containsKey(index)) {
        Automaton automaton = pMap.get(index);
        createHotspot(stmt, rbox, automaton);
      }
View Full Code Here

TOP

Related Classes of soot.jimple.ParameterRef

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.