Package soot

Examples of soot.Type


        int i = 0;
        Object[] args = new Object[argValues.length];

        for (Iterator parameterTypes = sootMethod.getParameterTypes()
                .iterator(); parameterTypes.hasNext();) {
            Type parameterType = (Type) parameterTypes.next();

            try {
                args[i] = convertConstantValueToArgument(argValues[i]);
                parameterClasses[i] = getClassForType(parameterType);
                i++;
            } catch (Exception ex) {
                ex.printStackTrace();
                throw new RuntimeException("Class not found = "
                        + parameterType.toString());
            }
        }

        Object returned;
View Full Code Here


            throw new RuntimeException(ex.getMessage());
        }

        System.out.println("Inlining director for " + model.getFullName());

        Type actorType = RefType.v(PtolemyUtilities.actorClass);
        //         SootField postfireReturnsField = new SootField("_postfireReturns",
        //                 BooleanType.v(), Modifier.PRIVATE);
        //         modelClass.addField(postfireReturnsField);
        // Inline the director
        {
View Full Code Here

        if (token instanceof ptolemy.data.ArrayToken) {
            ArrayToken arrayToken = (ArrayToken) token;
            RefType tokenType = getSootTypeForTokenType(arrayToken
                    .getElementType());
            Type tokenArrayType = ArrayType.v(tokenType, 1);
            Local tokenArrayLocal = Jimple.v().newLocal(localName + "Array",
                    tokenArrayType);
            body.getLocals().add(tokenArrayLocal);
            Local elementTypeLocal = buildConstantTypeLocal(body, insertPoint,
                    arrayToken.getElementType());
View Full Code Here

                        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.
                if (!(unit instanceof AssignStmt)) {
                    continue;
                }

                AssignStmt assignStmt = (AssignStmt) unit;

                // Ignore anything that isn't an assignment to a field.
                if (assignStmt.getRightOp() instanceof FieldRef) {
                    FieldRef ref = (FieldRef) assignStmt.getRightOp();
                    SootFieldRef fieldRef = ref.getFieldRef();
                    SootField field = ref.getField();

                    Type type = field.getType();

                    if (!PtolemyUtilities.isTokenType(type)) {
                        continue;
                    }
                    // Things that aren't token types are ignored.
                    // Things that are already the same type are ignored.
                    Type newType = typeAnalysis.getSpecializedSootType(field);
                    if ((newType != null) && !newType.equals(type)) {

                        ref.setFieldRef(Scene.v().makeFieldRef(
                                fieldRef.declaringClass(), fieldRef.name(),
                                newType, fieldRef.isStatic()));
                    }
                    continue;
                }
                if (!(assignStmt.getLeftOp() instanceof FieldRef)) {
                    continue;
                }

                if (!PtolemyUtilities.isTokenType(assignStmt.getLeftOp()
                        .getType())) {
                    continue;
                }

                if (debug) {
                    System.out.println("checking assignment " + assignStmt);
                }

                // FIXME: We need to figure out a way to insert casts where appropriate.
                // See RampFiringLimitSDF
                //                 ptolemy.data.type.Type leftType, rightType;
                //                 leftType = _getReplacementTokenType(
                //                         assignStmt.getLeftOp(), typeAnalysis);
                //                 rightType = _getReplacementTokenType(
                //                         assignStmt.getRightOp(), typeAnalysis);
                //                 if (leftType != null && rightType != null && !leftType.equals(rightType)) {
                //                     if (debug) System.out.println("inserting conversion: leftType = " +
                //                             leftType + ", rightType = " + rightType);
                //                     // insert a call to convert(), and a cast.
                //                     FieldRef ref = (FieldRef)assignStmt.getLeftOp();
                //                     SootField field = ref.getField();
                //                     Type newType =
                //                         typeAnalysis.getSpecializedSootType(field);
                //                     Local tempLocal =
                //                         Jimple.v().newLocal("fieldUpdateLocal", newType);
                //                     body.getLocals().add(tempLocal);
                //                     Local tokenLocal =
                //                         Jimple.v().newLocal("tokenLocal", PtolemyUtilities.tokenType);
                //                     body.getLocals().add(tokenLocal);
                //                     Local typeLocal =
                //                         PtolemyUtilities.buildConstantTypeLocal(body, unit, leftType);
                //                     body.getUnits().insertBefore(
                //                             Jimple.v().newAssignStmt(tokenLocal,
                //                                     Jimple.v().newVirtualInvokeExpr(
                //                                             typeLocal,
                //                                             PtolemyUtilities.typeConvertMethod,
                //                                             assignStmt.getRightOp())),
                //                             unit);
                //                     body.getUnits().insertBefore(
                //                             Jimple.v().newAssignStmt(tempLocal,
                //                                     Jimple.v().newCastExpr(
                //                                             tokenLocal,
                //                                             newType)),
                //                             unit);
                //                     assignStmt.setRightOp(tempLocal);
                //                 } else {
                FieldRef ref = (FieldRef) assignStmt.getLeftOp();
                SootFieldRef fieldRef = ref.getFieldRef();
                SootField field = ref.getField();

                Type type = field.getType();

                // Things that aren't token types are ignored.
                // Things that are already the same type are ignored.
                Type newType = typeAnalysis.getSpecializedSootType(field);

                if ((newType != null) && !newType.equals(type)) {
                    if (debug) {
                        System.out.println("inserting cast");
                    }

                    Local tempLocal = Jimple.v().newLocal("fieldUpdateLocal",
View Full Code Here

            if (debug) {
                System.out.println("updating types for " + field);
            }

            Type baseType = field.getType();
            RefType refType = PtolemyUtilities.getBaseTokenType(baseType);

            if ((refType != null)
                    && SootUtilities.derivesFrom(refType.getSootClass(),
                            PtolemyUtilities.tokenClass)) {
                Type type = typeAnalysis.getSpecializedSootType(field);

                if (debug) {
                    System.out.println("replacing with " + type);
                }
View Full Code Here

            code.append(_indent(1) + "/* DUMMY METHOD STUB */\n");

            if (!cReturnType.equals("void")) {
                code.append(_indent(1) + cReturnType + " dummy;\n");

                Type returnType = method.getReturnType();

                if (returnType instanceof RefLikeType) {
                    code.append(_indent(1) + "dummy = NULL;\n");
                } else {
                    code.append(_indent(1) + "dummy = 0;\n");
View Full Code Here

                if (value instanceof CastExpr) {
                    // If the cast is to the same type as the
                    // operand already is, then replace with
                    // simple assignment.
                    CastExpr expr = (CastExpr) value;
                    Type castType = expr.getCastType();
                    Value op = expr.getOp();

                    if (!PtolemyUtilities.isTokenType(op.getType())) {
                        continue;
                    }

                    // Use the token type inference to get the actual
                    // type of the argument.
                    ptolemy.data.type.Type type = tokenTypes.getTypeOfBefore(
                            (Local) op, unit);

                    if (debug) {
                        System.out.println("checking cast in " + unit);
                    }

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

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

                    // Don't try to replace non-instantiable types, since they
                    // might be more refined later.
                    // General, is unfortuantely, considered instantiable.
                    if (type.equals(BaseType.UNKNOWN) //!type.isInstantiable() ||
                            || type.equals(BaseType.GENERAL)) {
                        continue;
                    }

                    Type opType = PtolemyUtilities
                            .getSootTypeForTokenType(type);

                    //                     // Skip locals that are unsafe.
                    //                     if (castType.equals(opType) &&
                    //                             !unsafeLocalSet.contains(op)) {
                    //                         box.setValue(op);
                    //                     }
                    if (unsafeLocalSet.contains(op)) {
                        continue;
                    }

                    Hierarchy hierarchy = Scene.v().getActiveHierarchy();

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

                    CastAndInstanceofEliminator.replaceCast(box, hierarchy,
                            castType, op, opType, debug);
                } else if (value instanceof InstanceOfExpr) {
                    // If the operand of the expression is
                    // declared to be of a type that implies
                    // the instanceof is true, then replace
                    // with true.
                    InstanceOfExpr expr = (InstanceOfExpr) value;
                    Type checkType = expr.getCheckType();
                    Value op = expr.getOp();

                    if (!PtolemyUtilities.isTokenType(op.getType())) {
                        continue;
                    }

                    // Use the token type inference to get the actual
                    // type of the argument.
                    ptolemy.data.type.Type type = tokenTypes.getTypeOfBefore(
                            (Local) op, unit);

                    if (debug) {
                        System.out
                                .println("Checking instanceof check: " + expr);
                    }

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

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

                    // Don't try to replace non-instantiable types, since they
                    // might be more refined later.
                    // General, is unfortuantely, considered instantiable.
                    if (type.equals(BaseType.UNKNOWN) //!type.isInstantiable() ||
                            || type.equals(BaseType.GENERAL)) {
                        continue;
                    }

                    Type opType = PtolemyUtilities
                            .getSootTypeForTokenType(type);

                    if (debug) {
                        System.out.println("opType = " + opType);
                    }
View Full Code Here

        return _solver.variables();
    }

    public Type getSpecializedSootType(Local local) {
        try {
            Type type = local.getType();
            Type type2 = _getUpdateType(local, type);

            if (type2 == null) {
                return type;
            } else {
                return type2;
View Full Code Here

        }
    }

    public Type getSpecializedSootType(NewArrayExpr expr) {
        try {
            Type type = expr.getBaseType();
            Type type2 = _getUpdateType(expr, type);

            if (type2 == null) {
                return type;
            } else {
                return type2;
View Full Code Here

        }
    }

    public Type getSpecializedSootType(SootField field) {
        try {
            Type type = field.getType();
            Type type2 = _getUpdateType(field, type);

            if (type2 == null) {
                return type;
            } else {
                return type2;
View Full Code Here

TOP

Related Classes of soot.Type

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.