Package ptolemy.kernel

Examples of ptolemy.kernel.Entity


     @exception IllegalActionException If the superclass throws it.
     *  @exception NameDuplicationException If the superclass throws it.
     */
    public void setContainer(Entity entity) throws IllegalActionException,
            NameDuplicationException {
        Entity previousContainer = (Entity) getContainer();
        super.setContainer(entity);

        // If there is an associated port, and the container has changed,
        // break the association.
        if ((_parameter != null) && (entity != previousContainer)) {
View Full Code Here


         @return The (presumably unique) icon contained in the port's
         *   container.
         */
        public Object getParent(Object node) {
            ComponentPort port = (ComponentPort) node;
            Entity entity = (Entity) port.getContainer();

            if (entity == null) {
                return null;
            }

            List locationList = entity.attributeList(Locatable.class);

            if (locationList.size() > 0) {
                return locationList.get(0);
            } else {
                try {
View Full Code Here

            createAttributeComputationFunctions(context, attribute, theClass,
                    constAnalysis);
        }

        if (namedObj instanceof Entity) {
            Entity entity = (Entity) namedObj;

            for (Iterator ports = entity.portList().iterator(); ports.hasNext();) {
                Port port = (Port) ports.next();

                // recurse so that we get all parameters deeply.
                createAttributeComputationFunctions(context, port, theClass,
                        constAnalysis);
View Full Code Here

                                            PtolemyUtilities.validateMethod
                                                    .makeRef())), insertPoint);
        }

        if (namedObj instanceof Entity) {
            Entity entity = (Entity) namedObj;

            for (Iterator ports = entity.portList().iterator(); ports.hasNext();) {
                Port port = (Port) ports.next();
                Local portLocal = Jimple.v().newLocal("port",
                        RefType.v(PtolemyUtilities.portClass));
                body.getLocals().add(portLocal);
View Full Code Here

     *  reference to the instance field created for that entity.
     *  @exception RuntimeException If no field was created for the
     *  given entity.
     */
    public static Entity getEntityForField(SootField field) {
        Entity entity = (Entity) _fieldToEntityMap.get(field);

        if (entity != null) {
            return entity;
        } else {
            throw new RuntimeException("Failed to find entity for field "
View Full Code Here

    /** Return the entity for the given class if the given class is a
     *  class being generated, or null if not.
     */
    public static Entity getActorForClass(SootClass theClass) {
        Entity entity = (Entity) _classToObjectMap.get(theClass);
        return entity;
    }
View Full Code Here

        if (object instanceof CompositeActor) {
            CompositeActor composite = (CompositeActor) object;

            for (Iterator entities = composite.deepEntityList().iterator(); entities
                    .hasNext();) {
                Entity entity = (Entity) entities.next();
                updateCreatedSet(prefix, context, entity,
                        objectNameToCreatorName);
            }

            for (Iterator relations = composite.relationList().iterator(); relations
                    .hasNext();) {
                Relation relation = (Relation) relations.next();
                updateCreatedSet(prefix, context, relation,
                        objectNameToCreatorName);
            }
        }

        if (object instanceof Entity) {
            Entity entity = (Entity) object;

            for (Iterator ports = entity.portList().iterator(); ports.hasNext();) {
                Port port = (Port) ports.next();
                updateCreatedSet(prefix, context, port, objectNameToCreatorName);
            }
        }
View Full Code Here

                PtolemyUtilities.componentEntityType);
        body.getLocals().add(entityLocal);

        for (Iterator entities = composite.deepEntityList().iterator(); entities
                .hasNext();) {
            Entity entity = (Entity) entities.next();

            // System.out.println("ModelTransformer: entity: " + entity);
            // If we are doing deep codegen, then use the actor
            // classes we created earlier.
            String className = getInstanceClassName(entity, options);
            String entityFieldName = getFieldNameForEntity(entity, container);
            Local local;

            if (objectNameToCreatorName.keySet().contains(entity.getFullName())) {
                //     System.out.println("already created!");
                local = Jimple.v().newLocal("entity",
                        PtolemyUtilities.componentEntityType);
                body.getLocals().add(local);
                body.getUnits().add(
                        Jimple.v().newAssignStmt(
                                entityLocal,
                                Jimple.v().newVirtualInvokeExpr(
                                        thisLocal,
                                        PtolemyUtilities.getEntityMethod
                                                .makeRef(),
                                        StringConstant.v(entity
                                                .getName(composite)))));

                // and then cast
                body.getUnits().add(
                        Jimple.v().newAssignStmt(
                                local,
                                Jimple.v().newCastExpr(entityLocal,
                                        PtolemyUtilities.componentEntityType)));

                SootField field = SootUtilities.createAndSetFieldFromLocal(
                        body, local, modelClass, RefType.v(className),
                        entityFieldName);
                field.addTag(new ValueTag(entity));

                _ports(body, thisLocal, composite, local, entity, modelClass,
                        objectNameToCreatorName, false);
            } else {
                //  System.out.println("Creating new!");
                // Create a new local variable.  The name of the local is
                // determined automatically.  The name of the NamedObj is
                // the same as in the model.  (Note that this might not be
                // a valid Java identifier.)
                local = PtolemyUtilities.createNamedObjAndLocal(body,
                        className, thisLocal, entity.getName());

                //Entity classEntity = (Entity) _findDeferredInstance(entity);

                // This class assumes that any entity that is created creates
                // all stuff inside it.
                updateCreatedSet(composite.getFullName() + "."
                        + entity.getName(), entity, entity,
                        objectNameToCreatorName);

                SootField field = SootUtilities.createAndSetFieldFromLocal(
                        body, local, modelClass, RefType.v(className),
                        entityFieldName);
View Full Code Here

    private static void _createActorsIn(CompositeActor model,
            HashMap objectNameToCreatorName, String phaseName,
            ConstVariableModelAnalysis constAnalysis, Map options) {
        // Create an instance class for every actor.
        for (Iterator i = model.deepEntityList().iterator(); i.hasNext();) {
            Entity entity = (Entity) i.next();

            String className = entity.getClass().getName();

            String newClassName = getInstanceClassName(entity, options);

            if (Scene.v().containsClass(newClassName)) {
                continue;
            }

            System.out.println("ModelTransformer: Creating actor class "
                    + newClassName);
            System.out.println("for actor " + entity.getFullName());
            System.out.println("based on " + className);

            // FIXME the code below should probably copy the class and then
            // add init stuff.  EntitySootClass handles this nicely, but
            // doesn't let us use copyClass.  Generally adding this init crap
            // is something we have to do a lot.  How do we handle it nicely?
            //
            //            SootClass newClass =
            //     SootUtilities.copyClass(entityClass, newClassName);
            //  newClass.setApplicationClass();
            if (entity.getClass().getName().equals(
                    "ptolemy.actor.lib.MathFunction")) {
                throw new RuntimeException(
                        "Code Generation for "
                                + "ptolemy.actor.lib.MathFunction not supported, since "
                                + "it dynamically creates ports.");
            } else if (entity.getClass().getName().equals(
                    "ptolemy.actor.lib.ArraySort")
                    || entity.getClass().getName().equals(
                            "ptolemy.actor.lib.ArrayPeakSearch")) {
                throw new RuntimeException("Code Generation for "
                        + "some actors not supported, since "
                        + "they create ArrayTokens from lists.");
            } else if (entity.getClass().getName().equals(
                    "ptolemy.actor.lib.TypeTest")) {
                throw new RuntimeException("Code Generation for "
                        + "ptolemy.actor.lib.TypeTest not supported, since "
                        + "it walks around the model.");
            } else if (entity.getClass().getName().equals(
                    "ptolemy.actor.lib.RecordAssembler")
                    || entity.getClass().getName().equals(
                            "ptolemy.actor.lib.RecordDisassembler")
                    || entity.getClass().getName().equals(
                            "ptolemy.actor.lib.BusAssembler")
                    || entity.getClass().getName().equals(
                            "ptolemy.actor.lib.BusDisassembler")) {
                throw new RuntimeException("Code Generation for "
                        + "some actors not supported, since "
                        + "they iterate over ports.");
            } else if (entity.getClass().getName().equals(
                    "ptolemy.actor.lib.conversions.ExpressionToToken")
                    || entity.getClass().getName().equals(
                            "ptolemy.actor.lib.io.ExpressionReader")) {
                throw new RuntimeException("Code Generation for "
                        + "some actors not supported, since "
                        + "they have dynamic expressions.");
            } else if (entity instanceof CompositeActor) {
View Full Code Here

        ChangeRequest request = new ChangeRequest(this, "Record signal types") {
            protected void _execute() throws KernelException {
                Iterator entities = container.deepEntityList().iterator();

                while (entities.hasNext()) {
                    Entity entity = (Entity) entities.next();

                    for (Iterator ports = entity.portList().iterator(); ports
                            .hasNext();) {
                        IOPort port = (IOPort) ports.next();
                        String typeString = typeMap.getType(port).toString();
                        _setOrCreate(port, "resolvedSignalType", typeString);
                    }
View Full Code Here

TOP

Related Classes of ptolemy.kernel.Entity

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.