Package ptolemy.data.type

Examples of ptolemy.data.type.Type


         * @return An array type for the associated typeable.
         * @exception IllegalActionException If the type of the typeable
         * cannot be determined.
         */
        private ArrayType _getArrayTypeRaw(int length) throws IllegalActionException  {
            Type type = input.getType();
            if (_arrayType == null || !_arrayType.getElementType().equals(type)) {
                $ASSIGN$_arrayType(new ArrayType(type, length));
            }
            return _arrayType;
        }
View Full Code Here


        // Convert up to LUB.
        ptolemy.data.type.Type elementType = tokens[0].getType();

        for (int i = 0; i < numChildren; i++) {
            Type valueType = tokens[i].getType();

            if (!elementType.equals(valueType)) {
                elementType = TypeLattice.leastUpperBound(elementType,
                        valueType);
            }
View Full Code Here

        }

        tokenChild.visit(this);

        ptolemy.data.Token token = _evaluatedChildToken;
        Type type = _typeInference.inferTypes(typeChild, _scope);

        Type conversionType = (Type) TypeLattice.lattice().leastUpperBound(
                type, token.getType());

        token = conversionType.convert(token);
        _evaluatedChildToken = (token);

        if (node.isConstant()) {
            node.setToken(_evaluatedChildToken);
        }
View Full Code Here

        ArrayList args = new ArrayList();

        ptolemy.actor.lib.Pulse actor = (ptolemy.actor.lib.Pulse) getComponent();

        Type type = ((ArrayToken) actor.values.getToken()).getElementType();

        if (!isPrimitive(type)) {
            args.add("\\$tokenFunc(\\$ref(values, 0)::zero())");
        } else {
            args.add("0");
View Full Code Here

        ArrayList args = new ArrayList();

        ptolemy.actor.lib.Pulse actor = (ptolemy.actor.lib.Pulse) getComponent();

        Type type = ((ArrayToken) actor.values.getToken()).getElementType();

        args.add(targetType(type));

        code.append(_generateBlockCode("preinitBlock", args));
        return code.toString();
View Full Code Here

            if (castPredicateType.getArgCount() != 1) {
                throw new IllegalActionException(
                        "filter() can only be used on functions that take "
                                + "one argument.");
            } else {
                Type argType = castPredicateType.getArgType(0);
                int comparison = TypeLattice.compare(
                        ((ArrayType) arrayTokenType).getElementType(), argType);

                if ((comparison != CPO.LOWER) && (comparison != CPO.SAME)) {
                    throw new IllegalActionException(
View Full Code Here

            if (castFunctionType.getArgCount() != 1) {
                throw new IllegalActionException(
                        "iterate() can only be used on functions that take "
                                + "one argument.");
            } else {
                Type argType = castFunctionType.getArgType(0);
                int comparison = TypeLattice.compare(initialType, argType);

                if ((comparison != CPO.LOWER) && (comparison != CPO.SAME)) {
                    throw new IllegalActionException(
                            "iterate(): specified initial value is not "
                                    + "compatible with function argument type.");
                }

                Type resultType = castFunctionType.getReturnType();
                int comparison2 = TypeLattice.compare(resultType, argType);

                if ((comparison2 != CPO.LOWER) && (comparison2 != CPO.SAME)) {
                    throw new IllegalActionException(
                            "iterate(): invalid function: function return "
View Full Code Here

            throws IllegalActionException {
        if (functionType instanceof FunctionType) {
            FunctionType castFunctionType = (FunctionType) functionType;

            if (castFunctionType.getArgCount() == 1) {
                Type argType = castFunctionType.getArgType(0);
                int comparison = TypeLattice.compare(
                        ((ArrayType) arrayTokenType).getElementType(), argType);

                if ((comparison != CPO.LOWER) && (comparison != CPO.SAME)) {
                    throw new IllegalActionException(
                            "map(): specified array token is not compatible "
                                    + "with function argument type.");
                }
            } else if (castFunctionType.getArgCount() > 1) {
                Type firstArgType = castFunctionType.getArgType(0);
                boolean flag = true;

                for (int i = 1; i < castFunctionType.getArgCount(); i++) {
                    Type argType = castFunctionType.getArgType(i);

                    if (argType != firstArgType) {
                        i = castFunctionType.getArgCount();
                        flag = false;
                        throw new IllegalActionException("map() can only work "
                                + "for functions whose arguments are all of "
                                + "the same type.");
                    }
                }

                if (flag) {
                    Type argType = castFunctionType.getArgType(0);
                    Type elementType = ((ArrayType) arrayTokenType)
                            .getElementType();

                    if (!(elementType instanceof ArrayType)) {
                        throw new IllegalActionException(
                                "map(): specified array token is not "
                                        + "compatible with function arity.");
                    } else {
                        int comparison = TypeLattice.compare(
                                ((ArrayType) elementType).getElementType(),
                                argType);

                        if ((comparison != CPO.LOWER)
                                && (comparison != CPO.SAME)) {
                            throw new IllegalActionException(
                                    "map(): specified array token is not "
                                            + "compatible with function "
                                            + "argument type.");
                        }
                    }
                }
            }

            Type resultType = castFunctionType.getReturnType();
            return new ArrayType(resultType);
        } else {
            return BaseType.UNKNOWN;
        }
    }
View Full Code Here

        // NOTE: This logic indicates which tokens are comparable
        // by the TokenComparator inner class. If that class is changed,
        // then this logic needs to be changed too.
        if (type instanceof ArrayType) {
            ArrayType arrayType = (ArrayType) type;
            Type elementType = arrayType.getElementType();

            if (elementType.equals(BaseType.COMPLEX)) {
                return BaseType.UNKNOWN;
            } else if (elementType.equals(BaseType.STRING)
                    || BaseType.SCALAR.isCompatible(elementType)) {
                return type;
            }
        }
View Full Code Here

        ptolemy.actor.lib.Distributor actor = (ptolemy.actor.lib.Distributor) getComponent();

        ArrayList args = new ArrayList();
        args.add(Integer.valueOf(0));
        Type inputType = actor.input.getType();
        args.add(inputType);
        for (int i = 0; i < actor.output.getWidth(); i++) {
            args.set(0, Integer.valueOf(i));

            String codeBlock = "";
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.