Package ptolemy.kernel

Examples of ptolemy.kernel.CompositeEntity


                }
            }
        }

        if (actor instanceof CompositeEntity && !(actor instanceof FSMActor)) {
            CompositeEntity model = (CompositeEntity) actor;

            // Loop over all the entity classes and replace getPort calls.
            for (Iterator i = model.deepEntityList().iterator(); i.hasNext();) {
                ComponentEntity entity = (ComponentEntity) i.next();
                String className = ModelTransformer.getInstanceClassName(
                        entity, _options);
                SootClass entityClass = Scene.v()
                        .loadClassAndSupport(className);
View Full Code Here


        // Loop over all the actor instance classes and get
        // fields for ports.
        if (actor instanceof CompositeEntity && !(actor instanceof FSMActor)) {
            // Then recurse
            CompositeEntity model = (CompositeEntity) actor;

            for (Iterator i = model.deepEntityList().iterator(); i.hasNext();) {
                ComponentEntity entity = (ComponentEntity) i.next();
                String className = ModelTransformer.getInstanceClassName(
                        entity, _options);
                SootClass entityClass = Scene.v()
                        .loadClassAndSupport(className);
View Full Code Here

            StringBuffer moml = new StringBuffer("<group>\n");

            moml.append("<deleteEntity name=\"" + deleteObj.getName(container)
                    + "\"/>\n");

            CompositeEntity master = (CompositeEntity) deleteObj.getContainer();

            // Nothing to do if there is no container.
            if (master != null) {
                // Remove any referenced refinements that are not also
                // referenced by other states.
                TypedActor[] refinements = null;

                try {
                    refinements = ((State) deleteObj).getRefinement();
                } catch (IllegalActionException ex) {
                    // Ignore, no refinement to remove.
                }

                if (refinements != null) {
                    for (int i = 0; i < refinements.length; i++) {
                        TypedActor refinement = refinements[i];

                        // By default, if no other state or transition refers
                        // to this refinement, then we will remove it.
                        boolean removeIt = true;
                        Iterator states = master.entityList(State.class)
                                .iterator();

                        while (removeIt && states.hasNext()) {
                            State state = (State) states.next();

                            if (state == deleteObj) {
                                continue;
                            }

                            TypedActor[] stateRefinements = null;

                            try {
                                stateRefinements = state.getRefinement();
                            } catch (IllegalActionException ex) {
                                // Ignore, no refinement to check
                            }

                            if (stateRefinements == null) {
                                continue;
                            }

                            for (int j = 0; j < stateRefinements.length; j++) {
                                if (stateRefinements[j] == refinement) {
                                    removeIt = false;
                                    break;
                                }
                            }
                        }

                        // Next check transitions.
                        Iterator transitions = master.relationList().iterator();

                        while (removeIt && transitions.hasNext()) {
                            Relation transition = (Relation) transitions.next();

                            if (!(transition instanceof Transition)) {
View Full Code Here

    /** Attempt to leak code by parsing MoML that looks for a class
     *  that does not exist.
     */
    public static CompositeEntity leak() throws Exception {
        //MoMLParser parser = new MoMLParser();
        CompositeEntity toplevel = (CompositeEntity) parser
                .parse("<?xml version=\"1.0\" standalone=\"no\"?>\n"
                        + "<!DOCTYPE entity PUBLIC \"-//UC Berkeley//DTD MoML 1//EN\"\n"
                        + "\"http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd\">\n"
                        + "<entity name=\"top\" class=\"ptolemy.kernel.CompositeEntity\">\n"
                        + "<entity name=\"myRamp\" class=\"ptolemy.actor.lib.Ramp\"/>\n"
View Full Code Here

    public static void main(String[] args) throws Exception {
        parser = new MoMLParser();
        //CompositeEntity toptop = new CompositeEntity();
        //parser.setContext(toptop);
        try {
            CompositeEntity toplevel = leak();
            toplevel.setContainer(null);
            toplevel = null;
            // If we don't set parser to null or otherwise force it to
            // go out of scope, then we leak memory.
            System.out.println("Setting parser to null");
            parser = null;
View Full Code Here

     * @param workspace The workspace.
     * @return ComponentEntity
     * @exception Exception
     */
    public CompositeEntity buildLibrary(Workspace workspace) throws Exception {
        return new CompositeEntity(workspace);
    }
View Full Code Here

                                                field.makeRef())), unit);
                return newLocal;
            } else {
                // Otherwise, the source class must be something up
                // the hierarchy.
                CompositeEntity container = (CompositeEntity) sourceEntity
                        .getContainer();
                SootClass containerClass = ModelTransformer
                        .getClassForActor(container);
                RefType type = RefType.v(containerClass);
                Local containerLocal = Jimple.v().newLocal("container", type);
View Full Code Here

            entity = ((CompositeEntity) object).getEntity(name);
        } else {
            DefinitionStmt stmt = _getFieldDef(baseLocal, unit, localDefs);
            FieldRef ref = (FieldRef) stmt.getRightOp();
            SootField field = ref.getField();
            CompositeEntity container = (CompositeEntity) ModelTransformer
                    .getEntityForField(field);
            entity = container.getEntity(name);
        }

        if (_debug) {
            System.out.println("found entity = " + entity.getFullName());
        }
View Full Code Here

            try {
                LibraryAttribute attribute = (LibraryAttribute) toplevel
                        .getAttribute("_library", LibraryAttribute.class);

                if (attribute != null) {
                    CompositeEntity library = attribute.getLibrary();
                    Entity prototype = library.getEntity("state");

                    if (prototype != null) {
                        moml = prototype.exportMoML(stateName);

                        // FIXME: Get location name from prototype.
View Full Code Here

     *  to generate a main loop.
     *  @return The generated body code.
     *  @exception IllegalActionException If there is no director.
     */
    public String generateBodyCode() throws IllegalActionException {
        CompositeEntity model = (CompositeEntity) getContainer();

        // NOTE: The cast is safe because setContainer ensures
        // the container is an Actor.
        ptolemy.actor.Director director = ((Actor) model).getDirector();

View Full Code Here

TOP

Related Classes of ptolemy.kernel.CompositeEntity

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.