Package soot

Examples of soot.RefType


            if (value instanceof InstanceInvokeExpr) {
                InstanceInvokeExpr r = (InstanceInvokeExpr) value;

                if (r.getBase().getType() instanceof RefType) {
                    RefType type = (RefType) r.getBase().getType();

                    // Inline calls to connections changed.
                    if (r.getMethod().equals(
                            PtolemyUtilities.connectionsChangedMethod)) {
                        // If we are calling connections changed on one of the classes
                        // we are generating code for, then inline it.
                        if (type.getSootClass().isApplicationClass()) {
                            SootMethod inlinee = null;

                            if (r instanceof VirtualInvokeExpr) {
                                // Now inline the resulting call.
                                List methodList = Scene
                                        .v()
                                        .getActiveHierarchy()
                                        .resolveAbstractDispatch(
                                                type.getSootClass(),
                                                PtolemyUtilities.connectionsChangedMethod);

                                if (methodList.size() == 1) {
                                    // Inline the method.
                                    inlinee = (SootMethod) methodList.get(0);
                                } else {
                                    String string = "Can't inline " + stmt
                                            + " in method " + method + "\n";

                                    for (int i = 0; i < methodList.size(); i++) {
                                        string += ("target = "
                                                + methodList.get(i) + "\n");
                                    }

                                    System.out.println(string);
                                }
                            } else if (r instanceof SpecialInvokeExpr) {
                                inlinee = Scene.v().getActiveHierarchy()
                                        .resolveSpecialDispatch(
                                                (SpecialInvokeExpr) r, method);
                            }

                            if (inlinee != null
                                    && !inlinee.getDeclaringClass()
                                            .isApplicationClass()) {
                                inlinee.getDeclaringClass().setLibraryClass();
                            }

                            inlinee.retrieveActiveBody();

                            if (debug) {
                                System.out
                                        .println("Inlining method call: " + r);
                            }

                            SiteInliner.inlineSite(inlinee, stmt, method);

                            doneSomething = true;
                        } else {
                            // FIXME: this is a bit of a hack, but
                            // for right now it seems to work.
                            // How many things that aren't
                            // the actors we are generating
                            // code for do we really care about here?
                            // Can we do this without having to create
                            // a class for the port too????
                            body.getUnits().remove(stmt);
                            doneSomething = true;
                        }
                    }

                    // Statically evaluate constant arguments.
                    Value[] argValues = new Value[r.getArgCount()];
                    int constantArgCount = 0;

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

                        //System.out.println("arg = " + arg);
                        if (Evaluator.isValueConstantValued(arg)) {
                            argValues[constantArgCount++] = Evaluator
                                    .getConstantValueOf(arg);

                            // System.out.println("argument = " + argValues[argCount-1]);
                        } else {
                            break;
                        }
                    }

                    //boolean allArgsAreConstant = (r.getArgCount() == constantArgCount);

                    if (SootUtilities.derivesFrom(type.getSootClass(),
                            PtolemyUtilities.componentPortClass)) {
                        // If we are invoking a method on a port
                        // class, then attempt to get the constant
                        // value of the port.
                        TypedIOPort port = (TypedIOPort) analysis
View Full Code Here


                            // Change the constructor so that it takes an
                            // appropriate container type.
                            SootField containerField = theClass
                                    .getFieldByName(ModelTransformer
                                            .getContainerFieldName());
                            RefType containerType = (RefType) containerField
                                    .getType();
                            List typeList = new LinkedList();
                            typeList.add(containerType);
                            typeList.add(RefType.v("java.lang.String"));
                            method.setParameterTypes(typeList);
View Full Code Here

        if (_debug) {
            System.out.println("creating  buffer reference for " + port
                    + " type = " + type);
        }

        RefType tokenType = PtolemyUtilities.getSootTypeForTokenType(type);

        // Create a field that refers to all the channels of that port.
        SootField bufferField = new SootField("_portbuffer_"
                + StringUtilities.sanitizeName(port.getName()) + "_"
                + StringUtilities.sanitizeName(type.toString()), ArrayType.v(
View Full Code Here

    // class for the given port and the given type.
    private void _createPortInsideBufferReference(SootClass _modelClass,
            TypedIOPort port, ptolemy.data.type.Type type,
            Map typeNameToBufferField) {
        //  System.out.println("creating inside buffer reference for " + port + " type = " + type);
        RefType tokenType = PtolemyUtilities.getSootTypeForTokenType(type);

        // Create a field that refers to all the channels of that port.
        SootField bufferField = new SootField("_portinsidebuffer_"
                + StringUtilities.sanitizeName(port.getName()) + "_"
                + StringUtilities.sanitizeName(type.toString()), ArrayType.v(
View Full Code Here

        if (_debug) {
            System.out.println("replacing getAttribute in " + unit);
        }

        // FIXME: This is not enough.
        RefType type = (RefType) baseLocal.getType();
        NamedObj baseObject = ModelTransformer.getObjectForClass(type
                .getSootClass());

        if (baseObject != null) {
            // Then we are dealing with a getAttribute call on one of the
            // classes we are generating.
View Full Code Here

    // of an port in that object, return a new field ref that
    // refers to that port.  If no reference is found, then return null.
    private Value _createPortField(Local baseLocal, String name, Unit unit,
            LocalDefs localDefs) {
        // FIXME: This is not enough.
        RefType type = (RefType) baseLocal.getType();
        Entity entity = (Entity) ModelTransformer.getObjectForClass(type
                .getSootClass());

        if (entity != null) {
            // Then we are dealing with a getPort call on one of the
            // classes we are generating.
View Full Code Here

                    .iterator(); parameters.hasNext();) {
                PortParameter parameter = (PortParameter) parameters.next();
                String fieldName = ModelTransformer.getFieldNameForAttribute(
                        parameter, model);
                SootField field = modelClass.getFieldByName(fieldName);
                RefType fieldType = (RefType) field.getType();
                Local parameterLocal = Jimple.v().newLocal("parameter",
                        fieldType);
                SootClass fieldClass = fieldType.getSootClass();

                body.getLocals().add(parameterLocal);

                // Get a reference to the port parameter.
                units.insertBefore(Jimple.v().newAssignStmt(
View Full Code Here

                // the hierarchy.
                CompositeEntity container = (CompositeEntity) sourceEntity
                        .getContainer();
                SootClass containerClass = ModelTransformer
                        .getClassForActor(container);
                RefType type = RefType.v(containerClass);
                Local containerLocal = Jimple.v().newLocal("container", type);
                SootField field = sourceClass.getFieldByName(ModelTransformer
                        .getContainerFieldName());
                body.getLocals().add(containerLocal);
                body.getUnits().insertBefore(
                        Jimple.v().newAssignStmt(
                                containerLocal,
                                Jimple.v().newInstanceFieldRef(local,
                                        field.makeRef())), unit);
                return getLocalReferenceForEntity(entity, containerClass,
                        containerLocal, body, unit, options); // FIXME!
            }
        } else {
            // Then the source class must be a class for a settable attribute.
            NamedObj sourceObject = ModelTransformer
                    .getObjectForClass(sourceClass);
            Entity container = (Entity) sourceObject.getContainer();

            //             System.out.println("sourceObject = " + sourceObject);
            //             System.out.println("container = " + container);
            SootClass containerClass = ModelTransformer
                    .getClassForActor(container);
            RefType type = RefType.v(containerClass);
            Local containerLocal = Jimple.v().newLocal("container", type);
            SootField field = sourceClass.getFieldByName(ModelTransformer
                    .getContainerFieldName());
            body.getLocals().add(containerLocal);
            body.getUnits().insertBefore(
View Full Code Here

    }

    private Value _getContainerMethodReplacementFieldRef(SootClass sourceClass,
            Local baseLocal, JimpleBody body, Unit unit, LocalDefs localDefs) {
        // FIXME: This is not enough.
        RefType type = (RefType) baseLocal.getType();
        SootClass theClass = type.getSootClass();
        NamedObj object = ModelTransformer.getObjectForClass(type
                .getSootClass());

        if (object != null) {
            // Then we are dealing with a getContainer call on one of the
            // classes we are generating.
View Full Code Here

    private Value _getEntityMethodReplacementValue(SootClass sourceClass,
            Local baseLocal, String name, JimpleBody body, Unit unit,
            LocalDefs localDefs) {
        // FIXME: This is not enough.
        RefType type = (RefType) baseLocal.getType();
        NamedObj object = ModelTransformer
                .getActorForClass(type.getSootClass());
        Entity entity;

        if (object != null) {
            // Then we are dealing with a getEntity call on one of the
            // classes we are generating.
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.