Package soot

Examples of soot.Local


    /** Replace the send command at the given unit in the
     *  given body with a circular array reference.
     */
    public void inlineSend(JimpleBody body, Stmt stmt, InvokeExpr expr,
            TypedIOPort port) {
        Local bufferLocal = Jimple.v().newLocal("buffer",
                ArrayType.v(PtolemyUtilities.tokenType, 1));
        body.getLocals().add(bufferLocal);

        // The first argument is always the channel.
        Value channelValue = expr.getArg(0);

        // We have to repeat for all of the remote types.
        Set typeSet = _getConnectedTypeList(port);

        for (Iterator types = typeSet.iterator(); types.hasNext();) {
            ptolemy.data.type.Type type = (ptolemy.data.type.Type) types.next();
            Local typeLocal = null;

            //   if (!port.getType().equals(type)) {
            typeLocal = PtolemyUtilities.buildConstantTypeLocal(body, stmt,
                    type);

            // }
            _getBuffer(_modelClass, body, stmt, port, port.getType(),
                    bufferLocal, _portToTypeNameToBufferField);

            // A local of type token
            Local tokenLocal = Jimple.v().newLocal("tokenLocal",
                    PtolemyUtilities.tokenType);
            body.getLocals().add(tokenLocal);

            // A local of the appropriate type to store in the
            // buffer.
            Local outputTokenLocal = Jimple.v().newLocal("outputTokenLocal",
                    PtolemyUtilities.getSootTypeForTokenType(type));
            body.getLocals().add(outputTokenLocal);

            // If we are calling with just a channel, then write the value.
            if (expr.getArgCount() == 2) {
                Local sendTokenLocal = (Local) expr.getArg(1);

                // Replace the put() with an array write.
                body.getUnits().insertBefore(
                        _createBufferStoreInstructions(bufferLocal,
                                channelValue, sendTokenLocal, typeLocal,
                                tokenLocal, outputTokenLocal), stmt);
            } else {
                Local sendArrayLocal = (Local) expr.getArg(1);

                /*                Jimple.v().newLocal("sendArray",
                 ArrayType.v(PtolemyUtilities.tokenType, 1));
                 body.getLocals().add(sendArrayLocal);

                 // We must send an array of tokens.
                 body.getUnits().insertBefore(
                 Jimple.v().newAssignStmt(
                 sendArrayLocal,
                 expr.getArg(1)),
                 stmt);*/
                Value countValue = expr.getArg(2);

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

                // Get the value.
                body.getUnits().insertBefore(
View Full Code Here


    /** Replace the send command at the given unit in the
     *  given body with a circular array reference.
     */
    public void inlineSendInside(JimpleBody body, Stmt stmt, InvokeExpr expr,
            TypedIOPort port) {
        Local bufferLocal = Jimple.v().newLocal("buffer",
                ArrayType.v(PtolemyUtilities.tokenType, 1));
        body.getLocals().add(bufferLocal);

        // The first argument is always the channel.
        Value channelValue = expr.getArg(0);

        // We have to repeat for all of the remote types.
        Set typeSet = _getConnectedTypeListInside(port);

        for (Iterator types = typeSet.iterator(); types.hasNext();) {
            ptolemy.data.type.Type type = (ptolemy.data.type.Type) types.next();
            Local typeLocal = null;

            //   if (!port.getType().equals(type)) {
            typeLocal = PtolemyUtilities.buildConstantTypeLocal(body, stmt,
                    type);

            // }
            _getBuffer(_modelClass, body, stmt, port, port.getType(),
                    bufferLocal, _portToTypeNameToInsideBufferField);

            // A local of type token
            Local tokenLocal = Jimple.v().newLocal("tokenLocal",
                    PtolemyUtilities.tokenType);
            body.getLocals().add(tokenLocal);

            // A local of the appropriate type to store in the
            // buffer.
            Local outputTokenLocal = Jimple.v().newLocal("outputTokenLocal",
                    PtolemyUtilities.getSootTypeForTokenType(type));
            body.getLocals().add(outputTokenLocal);

            // If we are calling with just a channel, then write the value.
            if (expr.getArgCount() == 2) {
                Local sendTokenLocal = (Local) expr.getArg(1);

                // Replace the put() with an array write.
                body.getUnits().insertBefore(
                        _createBufferStoreInstructions(bufferLocal,
                                channelValue, sendTokenLocal, typeLocal,
                                tokenLocal, outputTokenLocal), stmt);
            } else {
                Local sendArrayLocal = (Local) expr.getArg(1);

                /*                Jimple.v().newLocal("sendArray",
                 ArrayType.v(PtolemyUtilities.tokenType, 1));
                 body.getLocals().add(sendArrayLocal);

                 // We must send an array of tokens.
                 body.getUnits().insertBefore(
                 Jimple.v().newAssignStmt(
                 sendArrayLocal,
                 expr.getArg(1)),
                 stmt);*/
                Value countValue = expr.getArg(2);

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

                // Get the value.
                body.getUnits().insertBefore(
View Full Code Here

            // Insert code into all the init methods.
            if (!method.getName().equals("<init>")) {
                continue;
            }

            Local channelLocal = Jimple.v().newLocal("channel",
                    ArrayType.v(tokenType, 1));
            body.getLocals().add(channelLocal);

            // Create the array of port channels.
            body.getUnits().insertBefore(
View Full Code Here

            // Insert code into all the init methods.
            if (!method.getName().equals("<init>")) {
                continue;
            }

            Local channelLocal = Jimple.v().newLocal("channel",
                    ArrayType.v(tokenType, 1));
            body.getLocals().add(channelLocal);

            // Create the array of port channels.
            body.getUnits().insertBefore(
View Full Code Here

    public static void createFieldsForAttributes(JimpleBody body,
            NamedObj context, Local contextLocal, NamedObj namedObj,
            Local namedObjLocal, SootClass theClass, HashSet createdSet) {
        // A local that we will use to set the value of our
        // settable attributes.
        Local attributeLocal = Jimple.v().newLocal("attribute",
                PtolemyUtilities.attributeType);
        body.getLocals().add(attributeLocal);

        Local settableLocal = Jimple.v().newLocal("settable",
                PtolemyUtilities.settableType);
        body.getLocals().add(settableLocal);

        for (Iterator attributes = namedObj.attributeList().iterator(); attributes
                .hasNext();) {
            Attribute attribute = (Attribute) attributes.next();

            // Ignore things like Variable.
            if (!attribute.isPersistent()
                    || attribute instanceof GeneratorAttribute) {
                continue;
            }

            String className = attribute.getClass().getName();
            Scene.v().loadClassAndSupport(className);

            Type attributeType = RefType.v(className);
            String attributeName = attribute.getName(context);
            String fieldName = getFieldNameForAttribute(attribute, context);

            Local local;

            if (createdSet.contains(attribute.getFullName())) {
                // If the class for the object already creates the
                // attribute, then get a reference to the existing attribute.
                local = attributeLocal;
View Full Code Here

        JimpleBody body = Jimple.v().newBody(initMethod);
        initMethod.setActiveBody(body);
        body.insertIdentityStmts();

        Chain units = body.getUnits();
        Local thisLocal = body.getThisLocal();

        _entityLocalMap = new HashMap();
        _portLocalMap = new HashMap();

        // Now instantiate all the stuff inside the model.
View Full Code Here

    private void _entities(JimpleBody body, Local containerLocal,
            CompositeEntity container, Local thisLocal,
            CompositeEntity composite, EntitySootClass modelClass,
            HashSet createdSet) {
        // A local that we will use to get existing entities
        Local entityLocal = Jimple.v().newLocal("entity",
                RefType.v(PtolemyUtilities.entityClass));
        body.getLocals().add(entityLocal);

        for (Iterator entities = composite.entityList().iterator(); entities
                .hasNext();) {
            Entity entity = (Entity) entities.next();
            System.out.println("ShallowModelTransformer: entity: " + entity);

            Local local;

            // If we are doing shallow, then use the base actor
            // classes.  Note that the entity might actually be
            // a MoML class (like Sinewave).
            String className = entity.getClass().getName();
View Full Code Here

    private void _ports(JimpleBody body, Local containerLocal,
            CompositeEntity container, Local entityLocal, Entity entity,
            EntitySootClass modelClass, HashSet createdSet) {
        // This local is used to store the return from the getPort
        // method, before it is stored in a type-specific local variable.
        Local tempPortLocal = Jimple.v().newLocal("tempPort",
                RefType.v("ptolemy.kernel.Port"));
        body.getLocals().add(tempPortLocal);

        for (Iterator ports = entity.portList().iterator(); ports.hasNext();) {
            Port port = (Port) ports.next();
            String className = port.getClass().getName();
            String fieldName = getFieldNameForPort(port, container);
            Local portLocal;

            Scene.v().loadClassAndSupport(className);
            portLocal = Jimple.v().newLocal("port",
                    PtolemyUtilities.componentPortType);
            body.getLocals().add(portLocal);

            if (createdSet.contains(port.getFullName())) {
                // If the class for the object already creates the
                // attribute, then get a reference to the existing attribute.
                // First assign to temp
                body.getUnits().add(
                        Jimple.v().newAssignStmt(
                                tempPortLocal,
                                Jimple.v().newVirtualInvokeExpr(
                                        entityLocal,
                                        PtolemyUtilities.getPortMethod
                                                .makeRef(),
                                        StringConstant.v(port.getName()))));

                if (port instanceof TypedIOPort) {
                    TypedIOPort ioPort = (TypedIOPort) port;

                    if (ioPort.isInput()) {
                        body.getUnits().add(
                                Jimple.v().newInvokeStmt(
                                        Jimple.v().newVirtualInvokeExpr(
                                                tempPortLocal,
                                                PtolemyUtilities.setInputMethod
                                                        .makeRef(),
                                                IntConstant.v(1))));
                    }

                    if (ioPort.isOutput()) {
                        body
                                .getUnits()
                                .add(
                                        Jimple
                                                .v()
                                                .newInvokeStmt(
                                                        Jimple
                                                                .v()
                                                                .newVirtualInvokeExpr(
                                                                        tempPortLocal,
                                                                        PtolemyUtilities.setOutputMethod
                                                                                .makeRef(),
                                                                        IntConstant
                                                                                .v(1))));
                    }

                    if (ioPort.isMultiport()) {
                        body
                                .getUnits()
                                .add(
                                        Jimple
                                                .v()
                                                .newInvokeStmt(
                                                        Jimple
                                                                .v()
                                                                .newVirtualInvokeExpr(
                                                                        tempPortLocal,
                                                                        PtolemyUtilities.setMultiportMethod
                                                                                .makeRef(),
                                                                        IntConstant
                                                                                .v(1))));
                    }
                }

                // and then cast to portLocal
                body.getUnits().add(
                        Jimple.v().newAssignStmt(
                                portLocal,
                                Jimple.v().newCastExpr(tempPortLocal,
                                        RefType.v(className))));
            } else {
                // If the class does not create the attribute,
                // then create a new attribute with the right name.
                Local local = PtolemyUtilities.createNamedObjAndLocal(body,
                        className, entityLocal, port.getName());

                Port classPort = (Port) _findDeferredInstance(port);
                _updateCreatedSet(entity.getFullName() + "." + port.getName(),
                        classPort, classPort, createdSet);
View Full Code Here

                    // Gap in the links.  The next link has to use an
                    // explicit index.
                    continue;
                }

                Local portLocal = (Local) _portLocalMap.get(port);
                Local relationLocal = (Local) _relationLocalMap.get(relation);

                // call the _insertLink method with the current index.
                body.getUnits().add(
                        Jimple.v().newInvokeStmt(
                                Jimple.v().newVirtualInvokeExpr(
View Full Code Here

            Iterator ports = entity.portList().iterator();

            while (ports.hasNext()) {
                ComponentPort port = (ComponentPort) ports.next();

                Local portLocal;

                // If we already have a local reference to the port
                if (_portLocalMap.keySet().contains(port)) {
                    // then just get the reference.
                    portLocal = (Local) _portLocalMap.get(port);
                } else {
                    throw new RuntimeException("Found a port: " + port
                            + " that does not have a local variable!");
                }

                Iterator relations = port.linkedRelationList().iterator();
                int index = -1;

                while (relations.hasNext()) {
                    index++;

                    ComponentRelation relation = (ComponentRelation) relations
                            .next();

                    if (relation == null) {
                        // Gap in the links.  The next link has to use an
                        // explicit index.
                        continue;
                    }

                    Local relationLocal = (Local) _relationLocalMap
                            .get(relation);

                    // Call the _insertLink method with the current index.
                    body
                            .getUnits()
View Full Code Here

TOP

Related Classes of soot.Local

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.