Package soot

Examples of soot.SootField


                                _getNullValueForType(replacementIsNotNullLocal
                                        .getType())), stmt);

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

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

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

                    // FIXME: ??
                    Value replacementValue = _getNullValueForType(replacementLocal
                            .getType());
                    body.getUnits().insertBefore(
                            Jimple.v().newAssignStmt(replacementLocal,
                                    replacementValue), stmt);
                }

                //body.getUnits().remove(stmt);
            }
        } else {
            // We have an assignment from one local token to another.
            if ((fieldToReplacementLeftLocal != null)
                    && (fieldToReplacementRightLocal != null)) {
                doneSomething = true;
                body.getUnits().insertBefore(
                        Jimple.v().newAssignStmt(
                                (Local) localToIsNotNullLocal.get(leftValue),
                                (Local) localToIsNotNullLocal.get(rightValue)),
                        stmt);

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

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

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


                }
            }

            for (Iterator fields = entityClass.getFields().snapshotIterator(); fields
                    .hasNext();) {
                SootField field = (SootField) fields.next();

                if (unusedFieldSet.contains(field)) {
                    entityClass.removeField(field);
                }
            }
View Full Code Here

        _addClasses(theClass.getInterfaces());

        // Grab the types of all fields.
        for (Iterator fields = theClass.getFields().iterator(); fields
                .hasNext();) {
            SootField field = (SootField) fields.next();
            Type type = field.getType();

            if (type instanceof RefType) {
                _addClass(((RefType) type).getSootClass());
            }
        }

        for (Iterator methods = theClass.getMethods().iterator(); methods
                .hasNext();) {
            SootMethod method = (SootMethod) methods.next();

            System.out.println("processing method = " + method);
            // Grab the classes of all arguments.
            for (Iterator types = method.getParameterTypes().iterator(); types
                    .hasNext();) {
                Type type = (Type) types.next();

                if (type instanceof RefType) {
                    _addClass(((RefType) type).getSootClass());
                }
            }
            // Grab the method return types.
            {
                Type type = method.getReturnType();

                if (type instanceof RefType) {
                    _addClass(((RefType) type).getSootClass());
                }
            }

            // Don't drag in the bodies of abstract methods.
            if (!method.isConcrete()) {
                continue;
            }

            JimpleBody body = (JimpleBody) method.retrieveActiveBody();
            Scene.v().releaseActiveHierarchy();

            // Grab the types of all traps.
            for (Iterator it = body.getTraps().iterator(); it.hasNext();) {
                Trap t = (Trap) it.next();
                _addClass(t.getException());
            }

            // Grab the classes of all referenced fields, invoked
            // methods, and created classes.
            for (Iterator units = body.getUnits().iterator(); units.hasNext();) {
                Unit unit = (Unit) units.next();

                for (Iterator boxes = unit.getUseAndDefBoxes().iterator(); boxes
                        .hasNext();) {
                    ValueBox box = (ValueBox) boxes.next();
                    Value value = box.getValue();

                    if (value instanceof FieldRef) {
                        SootField field = ((FieldRef) value).getField();
                        SootClass refClass = field.getDeclaringClass();

                        if (!refClass.equals(theClass)) {
                            _addClass(refClass);
                        }
                    } else if (value instanceof InvokeExpr) {
View Full Code Here

        StringBuffer fieldCode = new StringBuffer();
        Iterator fields = source.getFields().iterator();
        int insertedFields = 0;

        while (fields.hasNext()) {
            SootField field = (SootField) (fields.next());

            if (Modifier.isStatic(field.getModifiers())
                    && RequiredFileGenerator.isRequired(field)) {
                fieldCode.append(_indent(1) + _generateField(field));
                insertedFields++;
            }
        }
View Full Code Here

                + "/* Public and protected fields for " + source.getName()
                + " */\n";

        // Generate public and protected fields
        while (fields.hasNext()) {
            SootField field = (SootField) (fields.next());

            if ((!field.isPrivate())
                    && (!Modifier.isStatic(field.getModifiers()))
                    && (RequiredFileGenerator.isRequired(field))
                    && (!_doneFields.contains(field.getName()))) {
                if (insertedFields == 0) {
                    fieldCode.append(header);
                }

                fieldCode.append(_generateField(field));
                insertedFields++;
            }
        }

        // Generate private fields
        fieldCode.append("\n" + _indent(1) + "/* Private Fields */\n");
        fields = source.getFields().iterator();

        while (fields.hasNext()) {
            SootField field = (SootField) (fields.next());

            if (field.isPrivate() && !(Modifier.isStatic(field.getModifiers()))
                    && (!_doneFields.contains(field.getName()))) {
                if (insertedFields == 0) {
                    fieldCode.append(header);
                }

                fieldCode.append(_generateField(field));
View Full Code Here

        int insertedFields = 0;
        String header = "\n" + _indent(1)
                + _comment("Fields inherited from " + superClass.getName());

        while (fields.hasNext()) {
            SootField field = (SootField) (fields.next());

            boolean stat = Modifier.isStatic(field.getModifiers());
            boolean priv = field.isPrivate();
            boolean pub = field.isPublic();
            boolean prot = field.isProtected();
            boolean friendly = (!priv) && (!pub) && (!prot);
            boolean samePack = (source.getPackageName().compareTo(
                    superClass.getPackageName()) == 0);

            // Whether this field should be visible to this class.
            boolean visible = (!stat)
                    && (pub || prot || (friendly && samePack));

            // If a field has already been inherited from another class, it
            // need not be declared again.
            if (visible && (!_doneFields.contains(field.getName()))) {
                if (insertedFields == 0) {
                    fieldCode.append(header);
                }

                fieldCode.append(_generateField(field));
View Full Code Here

        source = Scene.v().getSootClass("java.lang.System");
        method = source.getMethodByName("initializeSystemClass");
        compulsoryNodes.add(method);

        // System.out is required by initializeSystemClass
        SootField field = source.getFieldByName("out");
        compulsoryNodes.add(field);

        // System.err is required by initializeSystemClass
        field = source.getFieldByName("err");
        compulsoryNodes.add(field);
View Full Code Here

                    Stmt stmt = (Stmt) unit;

                    // Add accessed fields.
                    if (stmt.containsFieldRef()) {
                        FieldRef fieldRef = stmt.getFieldRef();
                        SootField field = fieldRef.getField();
                        nodes.add(field);
                    }

                    // Add directly called methods.
                    if (!leaf && stmt.containsInvokeExpr()) {
View Full Code Here

        Local returnLocal = Jimple.v().newLocal("return",
                PtolemyUtilities.tokenType);
        body.getLocals().add(returnLocal);

        SootField indexArrayField = (SootField) _portToIndexArrayField
                .get(port);

        if (indexArrayField == null) {
            throw new RuntimeException("indexArrayField is null!");
        }

        // Load the array of indexes.
        body.getUnits().insertBefore(
                Jimple.v().newAssignStmt(
                        indexArrayLocal,
                        Jimple.v().newInstanceFieldRef(body.getThisLocal(),
                                indexArrayField.makeRef())), stmt);

        Value bufferSizeValue = null;

        // Refer directly to the buffer in the _model
        int channel = 0;

        for (Iterator relations = port.linkedRelationList().iterator(); relations
                .hasNext();) {
            TypedIORelation relation = (TypedIORelation) relations.next();

            int bufferSize = _getBufferSize(relation);

            // remember the size of the buffer.
            bufferSizeValue = IntConstant.v(bufferSize);

            for (int i = 0; i < relation.getWidth(); i++, channel++) {
                Value channelValue = IntConstant.v(channel);

                // Load the correct index into indexLocal
                body.getUnits().insertBefore(
                        Jimple.v().newAssignStmt(
                                indexLocal,
                                Jimple.v().newArrayRef(indexArrayLocal,
                                        channelValue)), stmt);

                SootField arrayField = _modelClass
                        .getFieldByName(InlinePortTransformer
                                .getBufferFieldName(relation, i, port.getType()));
                Local containerLocal = FieldsForEntitiesTransformer
                        .getLocalReferenceForEntity(_model, theClass, body
                                .getThisLocal(), body, stmt, _options);

                // load the buffer array.
                body.getUnits().insertBefore(
                        Jimple.v().newAssignStmt(
                                bufferLocal,
                                Jimple.v().newInstanceFieldRef(containerLocal,
                                        arrayField.makeRef())), stmt);

                // If we are calling with just a token, then send the token.
                if (expr.getArgCount() == 1) {
                    // Write to the buffer.
                    body.getUnits().insertBefore(
View Full Code Here

                        .getSootTypeForTokenType(type);
                Type arrayType = ArrayType.v(tokenType, 1);
                String fieldName = relation.getName() + "_bufferLocal";

                for (int i = 0; i < relation.getWidth(); i++) {
                    SootField field = new SootField(InlinePortTransformer
                            .getBufferFieldName(relation, i, type), arrayType,
                            Modifier.PUBLIC);
                    _modelClass.addField(field);

                    if (_debug) {
                        System.out.println("creating field = " + field
                                + " of size " + bufferSize);
                    }

                    // Tag the field with the type.
                    field.addTag(new TypeTag(type));

                    // Add initialization code to each constructor
                    for (Iterator methods = _modelClass.getMethods().iterator(); methods
                            .hasNext();) {
                        SootMethod initMethod = (SootMethod) methods.next();

                        // Only look at constructors.
                        if (!initMethod.getName().equals("<init>")) {
                            continue;
                        }

                        JimpleBody initBody = (JimpleBody) initMethod
                                .getActiveBody();
                        Chain initUnits = initBody.getUnits();
                        Local arrayLocal = Jimple.v().newLocal(fieldName,
                                arrayType);
                        initBody.getLocals().add(arrayLocal);

                        // Create the new buffer
                        Stmt insertPoint = initBody.getFirstNonIdentityStmt();

                        // This *should* be the statment after the constructor.
                        insertPoint = (Stmt) initUnits.getSuccOf(insertPoint);

                        Local containerLocal = FieldsForEntitiesTransformer
                                .getLocalReferenceForEntity(_model,
                                        _modelClass, initBody.getThisLocal(),
                                        initBody, insertPoint, _options);

                        initUnits.insertBefore(Jimple.v().newAssignStmt(
                                arrayLocal,
                                Jimple.v().newNewArrayExpr(tokenType,
                                        IntConstant.v(bufferSize))),
                                insertPoint);
                        initUnits.insertBefore(Jimple.v().newAssignStmt(
                                Jimple.v().newInstanceFieldRef(containerLocal,
                                        field.makeRef()), arrayLocal),
                                insertPoint);
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of soot.SootField

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.