Package soot

Examples of soot.RefType


                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);
                }

                // Otherwise there is nothing to be done.
            } else if (rightOp instanceof FieldRef) {
                // System.out.println("fieldRef stmt = " + stmt);
                FieldRef fieldRef = (FieldRef) rightOp;
                SootField field = fieldRef.getField();
                TypeTag tag = (TypeTag) field.getTag("_CGType");
                Object newType;

                if (tag == null) {
                    //  System.out.println("No Tag... Existing type = " + in.get(rightOp));
                    //                     System.out.println("No Tag... field type = " + field.getType());
                    if (in.get(rightOp) == null) {
                        RefType fieldType = PtolemyUtilities
                                .getBaseTokenType(field.getType());
                        newType = PtolemyUtilities
                                .getTokenTypeForSootType(fieldType);
                    } else {
                        // Then flow the type.
View Full Code Here


        //   System.out.println("equals " + in + " == " + out + " = " + in.equals(out));
    }

    private boolean _isTokenType(Type type) {
        RefType tokenType = PtolemyUtilities.getBaseTokenType(type);
        return tokenType != null;
    }
View Full Code Here

            Unit insertPoint, Token token, String localName) {
        Chain units = body.getUnits();

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

    }

    private static Local _buildConstantTokenLocal(Body body, Unit insertPoint,
            String localName, SootClass tokenClass,
            SootMethod tokenConstructor, List constructorArgs) {
        RefType tokenType = RefType.v(tokenClass);
        Local tokenLocal = Jimple.v().newLocal(localName, tokenType);
        body.getLocals().add(tokenLocal);
        body.getUnits().insertBefore(
                Jimple.v().newAssignStmt(tokenLocal,
                        Jimple.v().newNewExpr(tokenType)), insertPoint);
View Full Code Here

    }

    private static Local _buildConstantTokenLocal(Body body, Unit insertPoint,
            String localName, SootClass tokenClass,
            SootMethod tokenConstructor, Value constructorArg) {
        RefType tokenType = RefType.v(tokenClass);
        Local tokenLocal = Jimple.v().newLocal(localName, tokenType);
        body.getLocals().add(tokenLocal);
        body.getUnits().insertBefore(
                Jimple.v().newAssignStmt(tokenLocal,
                        Jimple.v().newNewExpr(tokenType)), insertPoint);
View Full Code Here

        } else {
            objectClass = Scene.v().loadClassAndSupport(className);
        }

        // System.out.println("done loading support of " + className);
        RefType objectType = RefType.v(objectClass);

        // Create the new local with the given name.
        Local local = Jimple.v().newLocal(name, objectType);

        // Add the local to the body.
View Full Code Here

     *  derives from ptolemy.data.Token, then return that
     *  token type.  Otherwise return null.
     */
    // FIXME: should throw exception.
    public static RefType getBaseTokenType(Type type) {
        RefType returnType;

        if (type instanceof RefType) {
            returnType = (RefType) type;
        } else if (type instanceof ArrayType) {
            ArrayType arrayType = (ArrayType) type;

            if (arrayType.baseType instanceof RefType) {
                returnType = (RefType) arrayType.baseType;
            } else {
                return null;
            }
        } else {
            // If we have a native type, then ignore because it can't
            // be a token type.
            return null;
        }

        SootClass objectClass = returnType.getSootClass();

        if (SootUtilities.derivesFrom(objectClass, PtolemyUtilities.tokenClass)
                || objectClass.getName().equals(
                        "ptolemy.data.BitwiseOperationToken")) {
            return returnType;
View Full Code Here

     *  derives from ptolemy.data.Type, then return that
     *  token type.  Otherwise return null.
     */
    // FIXME: should throw exception.
    public static RefType getBaseTokenTypeType(Type type) {
        RefType returnType;

        if (type instanceof RefType) {
            returnType = (RefType) type;
        } else if (type instanceof ArrayType) {
            ArrayType arrayType = (ArrayType) type;

            if (arrayType.baseType instanceof RefType) {
                returnType = (RefType) arrayType.baseType;
            } else {
                return null;
            }
        } else {
            // If we have a native type, then ignore because it can't
            // be a token type.
            return null;
        }

        SootClass objectClass = returnType.getSootClass();

        if (SootUtilities.derivesFrom(objectClass, PtolemyUtilities.typeClass)) {
            return returnType;
        }

View Full Code Here

     *  reference to a token, or an array of tokens.
     *  This method only returns true if the token is
     *  an instantiable token.
     */
    public static boolean isConcreteTokenType(Type type) {
        RefType refType;

        if (type instanceof RefType) {
            refType = (RefType) type;
        } else if (type instanceof ArrayType) {
            ArrayType arrayType = (ArrayType) type;

            if (arrayType.baseType instanceof RefType) {
                refType = (RefType) arrayType.baseType;
            } else {
                return false;
            }
        } else {
            return false;
        }

        SootClass tokenClass = refType.getSootClass();

        if (tokenClass.equals(PtolemyUtilities.tokenClass)
                || tokenClass.equals(PtolemyUtilities.scalarTokenClass)) {
            return false;
        }

        return SootUtilities.derivesFrom(refType.getSootClass(),
                PtolemyUtilities.tokenClass);
    }
View Full Code Here

    /** Return true if the given type references a
     *  ptolemy token type.  In other words It is either a direct
     *  reference to a token, or an array of tokens.
     */
    public static boolean isArrayTokenType(Type type) {
        RefType refType;

        if (type instanceof RefType) {
            refType = (RefType) type;
        } else if (type instanceof ArrayType) {
            ArrayType arrayType = (ArrayType) type;

            if (arrayType.baseType instanceof RefType) {
                refType = (RefType) arrayType.baseType;
            } else {
                return false;
            }
        } else {
            return false;
        }

        return SootUtilities.derivesFrom(refType.getSootClass(),
                PtolemyUtilities.arrayTokenClass);
    }
View Full Code Here

TOP

Related Classes of soot.RefType

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.