Package soot.jimple

Examples of soot.jimple.NewArrayExpr


                            if (debug) {
                                System.out
                                        .println("handling as new array object");
                            }

                            NewArrayExpr newExpr = (NewArrayExpr) stmt
                                    .getRightOp();

                            // We have an assignment to a local from a new array.
                            Map map = (Map) localToFieldToLocal.get(stmt
                                    .getLeftOp());

                            if (map != null) {
                                doneSomething = true;

                                Type isNotNullType = SootUtilities
                                        .createIsomorphicType(newExpr
                                                .getBaseType(), BooleanType.v());
                                Local isNotNullLocal = (Local) localToIsNotNullLocal
                                        .get(stmt.getLeftOp());
                                body.getUnits().insertBefore(
                                        Jimple.v().newAssignStmt(
                                                isNotNullLocal,
                                                Jimple.v().newNewArrayExpr(
                                                        isNotNullType,
                                                        newExpr.getSize())),
                                        unit);

                                for (Iterator tokenFields = map.keySet()
                                        .iterator(); tokenFields.hasNext();) {
                                    SootField tokenField = (SootField) tokenFields
                                            .next();

                                    if (debug) {
                                        System.out.println("tokenField = "
                                                + tokenField);
                                    }

                                    Local replacementLocal = (Local) map
                                            .get(tokenField);

                                    Type replacementType = SootUtilities
                                            .createIsomorphicType(newExpr
                                                    .getBaseType(), tokenField
                                                    .getType());

                                    // Initialize fields?
                                    body
                                            .getUnits()
                                            .insertBefore(
                                                    Jimple
                                                            .v()
                                                            .newAssignStmt(
                                                                    replacementLocal,
                                                                    Jimple
                                                                            .v()
                                                                            .newNewArrayExpr(
                                                                                    replacementType,
                                                                                    newExpr
                                                                                            .getSize())),
                                                    unit);
                                }

                                stmt.getRightOpBox().setValue(NullConstant.v());
View Full Code Here


                } 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

                    /*Value value = */box.getValue();

                    // Replace Array creations with a more specific
                    // type, if possible.
                    if (box.getValue() instanceof NewArrayExpr) {
                        NewArrayExpr newArrayExpr = (NewArrayExpr) box
                                .getValue();

                        if (debug) {
                            System.out
                                    .println("newArrayExpr = " + newArrayExpr);
                        }

                        Type baseType = newArrayExpr.getBaseType();
                        Type newType = typeAnalysis
                                .getSpecializedSootType(newArrayExpr);

                        if ((newType != null) && !newType.equals(baseType)) {
                            if (debug) {
                                System.out.println("replacing with " + newType);
                            }

                            box.setValue(Jimple.v().newNewArrayExpr(newType,
                                    newArrayExpr.getSize()));
                        }
                    }
                }

                // Ignore anything that isn't an assignment.
View Full Code Here

                // 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

    // consider new arrays that become live
    if (stmt instanceof DefinitionStmt) {
      DefinitionStmt def = (DefinitionStmt)stmt;
      if (def.getRightOp() instanceof NewArrayExpr) {
        Local left = (Local)def.getLeftOp(); // left side is local because right side is complex expression
        NewArrayExpr expr = (NewArrayExpr)def.getRightOp();
        if (expr.getSize() instanceof IntConstant) {
          int size = ((IntConstant)expr.getSize()).value;
          dest.put(left, new ArrayConstantInfo(new ValueBox[size]));
        } else {
          // unknown length
          dead.add(left);
        }
View Full Code Here

TOP

Related Classes of soot.jimple.NewArrayExpr

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.