Package ptolemy.data.type

Examples of ptolemy.data.type.Type


        super.fire();
        startIndex.update();
        endIndex.update();
        if (input.hasToken(0)) {
            ArrayToken inputArray = (ArrayToken)input.get(0);
            Type inputElementType = inputArray.getElementType();
            int inputSize = inputArray.length();
            if (inputSize == 0) {
                peakValues.send(0, inputArray);
                peakIndices.send(0, inputArray);
                return;
View Full Code Here


        for (int i = 0; i < width; i++) {
            System.arraycopy(inputs[i], 0, array, runningPosition,
                    inputs[i].length);
            runningPosition += inputs[i].length;
        }
        Type elementType = ((ArrayType) input.getType()).getElementType();
        output.send(0, new ArrayToken(elementType, array));
    }
View Full Code Here

        boolean isUndeclared = sourcePort.getTypeTerm().isSettable();

        if (!isUndeclared) {
            // sourcePort has a declared type.
            Type srcDeclared = sourcePort.getType();
            Iterator destinationPorts = destinationPortList.iterator();

            while (destinationPorts.hasNext()) {
                TypedIOPort destinationPort = (TypedIOPort) destinationPorts
                        .next();
                isUndeclared = destinationPort.getTypeTerm().isSettable();

                if (!isUndeclared) {
                    // both source/destination ports are declared,
                    // check type
                    Type destinationDeclared = destinationPort.getType();

                    int compare;

                    // If the source port belongs to me, then we want to
                    // compare its array element type to the type of the
                    // destination.
                    if ((sourcePort.getContainer() == this)
                            && (destinationPort.getContainer() != this)) {
                        // The source port belongs to me, but not the
                        // destination.
                        Type srcElementType = ((ArrayType) srcDeclared)
                                .getElementType();
                        compare = TypeLattice.compare(srcElementType,
                                destinationDeclared);
                    } else if ((sourcePort.getContainer() != this)
                            && (destinationPort.getContainer() == this)) {
                        // The destination port belongs to me, but not
                        // the source.
                        Type destinationElementType = ((ArrayType) destinationDeclared)
                                .getElementType();
                        compare = TypeLattice.compare(srcDeclared,
                                destinationElementType);
                    } else {
                        compare = TypeLattice.compare(srcDeclared,
View Full Code Here

        public boolean transferOutputs(IOPort port)
                throws IllegalActionException {
            boolean result = false;

            ArrayType type = (ArrayType) ((TypedIOPort) port).getType();
            Type elementType = type.getElementType();

            for (int i = 0; i < port.getWidthInside(); i++) {
                try {
                    ArrayList list = new ArrayList();
View Full Code Here

        public Token convert(Token token) throws IllegalActionException {
            if (!(getContainer() instanceof IterateOverArray) || !isOutput()) {
                return super.convert(token);
            }

            Type type = ((ArrayType) getType()).getElementType();

            if (type.equals(token.getType())) {
                return token;
            } else {
                Token newToken = type.convert(token);
                return newToken;
            }
        }
View Full Code Here

        // Skip the function port.
        ports.next();

        while (ports.hasNext()) {
            TypedIOPort port = (TypedIOPort) ports.next();
            Type portType = type.getArgType(i);

            if (portType instanceof ArrayType) {
                port.setTypeEquals(((ArrayType) portType).getElementType());
                _rate[i] = DFUtilities.getTokenConsumptionRate(port);
            } else {
View Full Code Here

        /** Return the function result.
         *  @return A Type.
         */
        public Object getValue() {
            Type inputType = _port.getType();

            try {
                return MatrixType.getMatrixTypeForElementType(inputType);
            } catch (IllegalActionException ex) {
                return BaseType.UNKNOWN;
View Full Code Here

            throw new IllegalActionException(this, "setTypeAtMost(): "
                    + "the argument " + type
                    + " is not an instantiable type in the type lattice.");
        }

        Type currentType = getType();
        int typeInfo = TypeLattice.compare(currentType, type);

        if ((typeInfo == CPO.HIGHER) || (typeInfo == CPO.INCOMPARABLE)) {
            throw new IllegalActionException(this, "setTypeAtMost(): "
                    + "the current type " + currentType.toString()
                    + " is not less than the desired bounding type "
                    + type.toString());
        }

        _typeAtMost = type;
View Full Code Here

        // Variable.
        try {
            Token currentToken = getToken();

            if (currentToken != null) {
                Type currentType = currentToken.getType();

                TypeConstant current = new TypeConstant(currentType);
                Inequality ineq = new Inequality(current, getTypeTerm());
                result.add(ineq);
            }
View Full Code Here

            // _declaredType. For structured types, _declaredType and _varType
            // are the same reference, need to initialize this type
            // before checking compatibility. But if the new token is not
            // compatible with the declared type, the current resolved type
            // need to be preserved, so make a clone.
            Type declaredType;

            try {
                declaredType = (Type) _declaredType.clone();
            } catch (CloneNotSupportedException cnse) {
                throw new InternalErrorException("Variable._setToken: "
                        + "Cannot clone the declared type of this Variable.");
            }

            if (declaredType instanceof StructuredType) {
                ((StructuredType) declaredType).initialize(BaseType.UNKNOWN);
            }

            if (declaredType.isCompatible(newToken.getType())) {
                newToken = declaredType.convert(newToken);
            } else {
                throw new IllegalActionException(this,
                        "Variable._setToken: Cannot store a token of type "
                                + newToken.getType().toString()
                                + ", which is incompatible with type "
                                + declaredType.toString());
            }

            // update _varType to the type of the new token.
            if (_declaredType instanceof StructuredType) {
                ((StructuredType) _varType)
                        .updateType((StructuredType) newToken.getType());
            } else {
                // _declaredType is a BaseType
                _varType = newToken.getType();

                // FIXME: This is Edward's array optimization for Rome.
                //                 Type newTokenType = newToken.getType();
                //                 // FIXME: What about other structured types?
                //                 if (_varType instanceof ArrayType && newTokenType instanceof ArrayType) {
                //                     // Need to do an update instead of a replacement of _varType
                //                     // because inequalities may have been set up that refer to this
                //                     // particular instance _varType.
                //                     // NOTE: updateType() won't update to an incompatible type!
                //                     ((ArrayType)_varType).setType((ArrayType)newToken.getType());
                //                 } else {
                //                     // It is OK now to replace _varType because either the
                //                     // type is not a structured type or it was previously
                //                     // not a structured type.
                //                     _varType = newTokenType;
                //                 }
            }

            // Check setTypeAtMost constraint.
            if (_typeAtMost != BaseType.UNKNOWN) {
                // Recalculate this in case the type has changed.
                Type tokenType = newToken.getType();
                int comparison = TypeLattice.compare(tokenType, _typeAtMost);

                if ((comparison == CPO.HIGHER)
                        || (comparison == CPO.INCOMPARABLE)) {
                    // Incompatible type!
                    throw new IllegalActionException(this,
                            "Cannot store a token of type "
                                    + tokenType.toString()
                                    + ", which is not less than or equal to "
                                    + _typeAtMost.toString());
                }
            }
View Full Code Here

TOP

Related Classes of ptolemy.data.type.Type

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.