Package ptolemy.data.expr

Examples of ptolemy.data.expr.Variable


     @exception IllegalActionException If the parameter cannot
     *   contain the specified value.
     */
    private static void _setOrCreate(NamedObj container, String name,
            String value) throws IllegalActionException {
        Variable parameter = (Variable) container.getAttribute(name);

        if (parameter == null) {
            // Parameter does not exist, so create it.
            try {
                parameter = new Variable(container, name);
                parameter.setVisibility(Settable.NOT_EDITABLE);
                parameter.setPersistent(false);
            } catch (KernelException ex) {
                // Should not occur.
                throw new InternalErrorException(ex.toString());
            }
        }

        parameter.setToken(new StringToken(value));
    }
View Full Code Here


                    }

                    if (showRate) {
                        // Infer the rate.  See DFUtilities.
                        String rateString = "";
                        Variable rateParameter = null;

                        if (((IOPort) port).isInput()) {
                            rateParameter = (Variable) port
                                    .getAttribute("tokenConsumptionRate");

                            if (rateParameter == null) {
                                String altName = "_tokenConsumptionRate";
                                rateParameter = (Variable) port
                                        .getAttribute(altName);
                            }
                        } else if (((IOPort) port).isOutput()) {
                            rateParameter = (Variable) port
                                    .getAttribute("tokenProductionRate");

                            if (rateParameter == null) {
                                String altName = "_tokenProductionRate";
                                rateParameter = (Variable) port
                                        .getAttribute(altName);
                            }
                        }

                        if (rateParameter != null) {
                            try {
                                rateString = rateParameter.getToken()
                                        .toString();
                            } catch (KernelException ex) {
                                // Ignore.
                            }
                        }
View Full Code Here

                        // A method invocation with a null base is bogus,
                        // so don't create a type constraint.
                    }

                    if (attribute instanceof Variable) {
                        Variable parameter = (Variable) attribute;

                        if (methodName.equals("setToken")) {
                            // The type of the argument must be less than the
                            // type of the parameter.
                            // r.getArg(0));
                        } else if (methodName.equals("getToken")) {
                            // Return the type of the parameter.
                            _updateTypeInAssignment(leftOp,
                                    parameter.getType(), out);
                        }
                    }
                }
            } else if (rightOp instanceof ArrayRef) {
                //  System.out.println("arrayRef stmt = " + stmt);
View Full Code Here

                return portLocal;
            }

            // Look for parameter in actor.
            Variable result = null;

            if (_entity != null) {
                result = getScopedVariable(null, _entity, name);
            }

            if (result != null) {
                // Insert code to get a ref to the variable,
                // and to get the token of that variable.
                Local containerLocal = Jimple.v().newLocal("container",
                        RefType.v(PtolemyUtilities.namedObjClass));
                _body.getLocals().add(containerLocal);

                Local attributeLocal = Jimple.v().newLocal("attribute",
                        PtolemyUtilities.attributeType);
                _body.getLocals().add(attributeLocal);

                Local tokenLocal = Jimple.v().newLocal("token",
                        PtolemyUtilities.tokenType);
                _body.getLocals().add(tokenLocal);

                Entity entityContainer = FieldsForEntitiesTransformer
                        .getEntityContainerOfObject(result);
                String deepName = result.getName(entityContainer);

                _units.insertBefore(Jimple.v().newAssignStmt(containerLocal,
                        thisLocal), _insertPoint);

                NamedObj container = _entity;
View Full Code Here

            if (_nameToType.containsKey(name)) {
                return (ptolemy.data.type.Type) _nameToType.get(name);
            }

            Variable result = getScopedVariable(null, _entity, name);

            if (result != null) {
                return result.getType();
            } else {
                return null;

                //  throw new IllegalActionException(
                //         "The ID " + name + " is undefined.");
View Full Code Here

            if (_nameToType.containsKey(name)) {
                return new TypeConstant((ptolemy.data.type.Type) _nameToType
                        .get(name));
            }

            Variable result = getScopedVariable(null, _entity, name);

            if (result != null) {
                return result.getTypeTerm();
            } else {
                return null;

                //  throw new IllegalActionException(
                //         "The ID " + name + " is undefined.");
View Full Code Here

        // icon editor.
        new Location(this, "_location");

        // This must appear before lineColor or cloning could
        // fail if lineColor references it.
        _none = new Variable(this, "none");
        _none.setExpression("{1.0, 1.0, 1.0, 0.0}");

        lineWidth = new Parameter(this, "lineWidth");
        lineWidth.setTypeEquals(BaseType.DOUBLE);
        lineWidth.setExpression("1.0");
View Full Code Here

            if (port != null) {
                return port.getType();
            }

            Variable result = getScopedVariable(null, _actor, name);

            if (result != null) {
                return (Type) result.getTypeTerm().getValue();
            }

            return null;
        }
View Full Code Here

            if (port != null) {
                return port.getTypeTerm();
            }

            Variable result = getScopedVariable(null, _actor, name);

            if (result != null) {
                return result.getTypeTerm();
            }

            return null;
        }
View Full Code Here

            code.append(comment("Generate variable declarations for "
                    + "modified parameters"));
            Iterator modifiedVariables = _modifiedVariables.iterator();
            while (modifiedVariables.hasNext()) {
                // SetVariable needs this to be a Variable, not a Parameter.
                Variable variable = (Variable) modifiedVariables.next();

                code.append("static "
                        + CodeGeneratorHelper.targetType(variable.getType())
                        + " " + generateVariableName(variable) + ";" + _eol);
            }
        }

        return code.toString();
View Full Code Here

TOP

Related Classes of ptolemy.data.expr.Variable

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.