Package soot.jimple

Examples of soot.jimple.NewExpr


                }
            }
            if( s instanceof AssignStmt ) {
                Value rhs = ((AssignStmt)s).getRightOp();
                if( rhs instanceof NewExpr ) {
                    NewExpr r = (NewExpr) rhs;
                    SootClass cl = r.getBaseType().getSootClass();
                    for (SootMethod clinit : EntryPoints.v().clinitsOf(cl)) {
                        addEdge( source, s, clinit, Kind.CLINIT );
                    }
                } else if( rhs instanceof NewArrayExpr || rhs instanceof NewMultiArrayExpr ) {
                    Type t = rhs.getType();
View Full Code Here


      } else {
        Body body = container.getActiveBody();
       
        //exc = new Error
        RefType runtimeExceptionType = RefType.v("java.lang.Error");
        NewExpr newExpr = Jimple.v().newNewExpr(runtimeExceptionType);
        LocalGenerator lg = new LocalGenerator(body);
        Local exceptionLocal = lg.generateLocal(runtimeExceptionType);
        AssignStmt assignStmt = Jimple.v().newAssignStmt(exceptionLocal, newExpr);
        body.getUnits().insertBefore(assignStmt, insertionPoint);
       
View Full Code Here

          JimpleBody body = Jimple.v().newBody(m);
      m.setActiveBody(body);
     
      //exc = new Error
      RefType runtimeExceptionType = RefType.v("java.lang.Error");
      NewExpr newExpr = Jimple.v().newNewExpr(runtimeExceptionType);
      LocalGenerator lg = new LocalGenerator(body);
      Local exceptionLocal = lg.generateLocal(runtimeExceptionType);
      AssignStmt assignStmt = Jimple.v().newAssignStmt(exceptionLocal, newExpr);
      body.getUnits().add(assignStmt);
     
View Full Code Here

                            //                             r.setMethod(changeClass.getMethod(
                            //                                     r.getMethod().getSubSignature()));
                        }
                    } else if (value instanceof NewExpr) {
                        // Fix up the object creations.
                        NewExpr r = (NewExpr) value;

                        if (!(unit instanceof AssignStmt)) {
                            continue;
                        }

                        AssignStmt stmt = (AssignStmt) unit;

                        try {
                            if (object != analysis.getObject((Local) stmt
                                    .getLeftOp())) {
                                continue;
                            }
                        } catch (Exception ex) {
                            if (_debug) {
                                System.out.println("Exception on new = " + ex);
                            }

                            continue;
                        }

                        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())) {
View Full Code Here

                                    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

        // method.  Perhaps we can copy the method and inline the static
        // methods inside.  Even worse, what if we pass to an
        // object constructor?  We really need to create a static instance
        // of that class as well, and recurse.
        // First copy the class.
        NewExpr newExpr = (NewExpr) newStmt.getRightOp();
        SootClass instanceClass = newExpr.getBaseType().getSootClass();
        SootClass staticClass = copyClass(instanceClass, className);
        staticClass.setApplicationClass();

        // some reason when writing out BAF.
        // fold the class up to object.
View Full Code Here

            } else if (rightOp instanceof Local) {
                Local local = (Local) rightOp;

                _updateTypeInAssignment(leftOp, in.get(local), out);
            } else if (rightOp instanceof NewExpr) {
                NewExpr newExpr = (NewExpr) rightOp;
                RefType type = newExpr.getBaseType();
                SootClass castClass = type.getSootClass();

                // If we are creating a Token type...
                if (SootUtilities.derivesFrom(castClass,
                        PtolemyUtilities.tokenClass)) {
                    // Then the rightOp of the expression is the type of the
                    // constructor.
                    _updateTypeInAssignment(leftOp, PtolemyUtilities
                            .getTokenTypeForSootType(type), out);
                } else {
                    // Otherwise there is nothing to be done.
                }
            } else if (rightOp instanceof NewArrayExpr) {
                // Since arrays are aliasable, we must update their types.
                NewArrayExpr newExpr = (NewArrayExpr) rightOp;
                Type type = newExpr.getBaseType();
                RefType tokenType = PtolemyUtilities.getBaseTokenType(type);

                if (tokenType != null) {
                    _updateTypeInAssignment(leftOp, PtolemyUtilities
                            .getTokenTypeForSootType(tokenType), out);
View Full Code Here

            // of the cast.
            InequalityTerm baseTerm = (InequalityTerm) objectToInequalityTerm
                    .get(castExpr.getOp());
            return baseTerm;
        } else if (value instanceof NewExpr) {
            NewExpr newExpr = (NewExpr) value;
            RefType type = newExpr.getBaseType();
            SootClass castClass = type.getSootClass();

            // If we are creating a Token type...
            if (SootUtilities.derivesFrom(castClass,
                    PtolemyUtilities.tokenClass)) {
                InequalityTerm typeTerm = new ConstantTerm(PtolemyUtilities
                        .getTokenTypeForSootType(type), newExpr);

                // Then the value of the expression is the type of the
                // constructor.
                return typeTerm;
            } else {
                // Otherwise there is nothing to be done.
                return null;
            }
        } else if (value instanceof NewArrayExpr) {
            // Since arrays are aliasable, we must update their types.
            NewArrayExpr newExpr = (NewArrayExpr) value;
            Type type = newExpr.getBaseType();
            RefType tokenType = PtolemyUtilities.getBaseTokenType(type);

            if ((tokenType != null)
                    && (objectToInequalityTerm.get(newExpr) == null)) {
                InequalityTerm typeTerm = new VariableTerm(PtolemyUtilities
                        .getTokenTypeForSootType(tokenType), newExpr);

                // This is something we update, so put an entry
                // in the map used for updating
                objectToInequalityTerm.put(newExpr, typeTerm);

                // Then the value of the expression is the type of the
                // constructor.
                return typeTerm;
            }

            // Otherwise there is nothing to be done.
            return null;
        } else if (value instanceof NewMultiArrayExpr) {
            // Since arrays are aliasable, we must update their types.
            NewMultiArrayExpr newExpr = (NewMultiArrayExpr) value;
            Type type = newExpr.getBaseType();
            RefType tokenType = PtolemyUtilities.getBaseTokenType(type);

            if ((tokenType != null)
                    && (objectToInequalityTerm.get(newExpr) == null)) {
                InequalityTerm typeTerm = new VariableTerm(PtolemyUtilities
View Full Code Here

                Value value = box.getValue();
                /*Type type = */value.getType();

                if (value instanceof NewExpr) {
                    // Fix kernel exceptions to be runtime exceptions.
                    NewExpr expr = (NewExpr) value;
                    SootClass exceptionClass = expr.getBaseType()
                            .getSootClass();

                    if (_isPtolemyException(exceptionClass)) {
                        expr.setBaseType(RefType
                                .v(PtolemyUtilities.runtimeExceptionClass));
                    }
                } else if (value instanceof CastExpr) {
                    CastExpr expr = (CastExpr) value;
                    Type castType = expr.getCastType();

                    if (castType instanceof RefType
                            && _isPtolemyException(((RefType) castType)
                                    .getSootClass())) {
                        expr.setCastType(RefType
                                .v(PtolemyUtilities.runtimeExceptionClass));
                    }
                } else if (value instanceof SpecialInvokeExpr) {
                    // Fix the exception constructors.
                    SpecialInvokeExpr expr = (SpecialInvokeExpr) value;
                    SootClass exceptionClass = ((RefType) expr.getBase()
                            .getType()).getSootClass();

                    if (_isPtolemyException(exceptionClass)) {
                        Value foundArg = null;

                        for (Iterator args = expr.getArgs().iterator(); args
                                .hasNext();) {
                            Value arg = (Value) args.next();

                            if (arg.getType().equals(
                                    RefType.v(PtolemyUtilities.stringClass))) {
                                foundArg = arg;
                                break;
                            }
                        }

                        if ((foundArg == null) || _obfuscate) {
                            box
                                    .setValue(Jimple
                                            .v()
                                            .newSpecialInvokeExpr(
                                                    (Local) expr.getBase(),
                                                    PtolemyUtilities.runtimeExceptionConstructor
                                                            .makeRef(),
                                                    Collections.EMPTY_LIST));
                        } else {
                            box
                                    .setValue(Jimple
                                            .v()
                                            .newSpecialInvokeExpr(
                                                    (Local) expr.getBase(),
                                                    PtolemyUtilities.runtimeExceptionStringConstructor
                                                            .makeRef(),
                                                    foundArg));
                        }
                    }
                } else if (value instanceof VirtualInvokeExpr) {
                    VirtualInvokeExpr expr = (VirtualInvokeExpr) value;
                    Type exceptionType = expr.getBase().getType();

                    if (exceptionType instanceof RefType) {
                        SootClass exceptionClass = ((RefType) exceptionType)
                                .getSootClass();

                        if (_isPtolemyException(exceptionClass)) {
                            SootMethod method = expr.getMethod();

                            if (method.getName().equals("getMessage")) {
                                if (unit instanceof InvokeStmt) {
                                    body.getUnits().remove(unit);
                                } else {
View Full Code Here

TOP

Related Classes of soot.jimple.NewExpr

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.