Examples of ASTPtRootNode


Examples of ptolemy.data.expr.ASTPtRootNode

        ParseTreeTypeInference inference = new ParseTreeTypeInference();
        inference.inferTypes(node, _scope);

        FunctionType functionType = (FunctionType) node.getType();

        ASTPtRootNode cloneTree = (ASTPtRootNode) node.getExpressionTree(); //.clone();

        //         ParseTreeSpecializer specializer = new ParseTreeSpecializer();
        //         cloneTree = specializer.specialize(node.getExpressionTree(),
        //                 node.getArgumentNameList(), _scope);
        // Generate a new Function class
View Full Code Here

Examples of ptolemy.data.expr.ASTPtRootNode

    /** Visit the child with the given index of the given node.
     *  This is usually called while visiting the given node.
     */
    protected void _generateChild(ASTPtRootNode node, int i)
            throws IllegalActionException {
        ASTPtRootNode child = (ASTPtRootNode) node.jjtGetChild(i);
        child.visit(this);
    }
View Full Code Here

Examples of ptolemy.data.expr.ASTPtRootNode

        try {
            if (_parser == null) {
                _parser = new PtParser();
            }

            ASTPtRootNode parseTree = _parser.generateParseTree(string);

            if (_parseTreeEvaluator == null) {
                _parseTreeEvaluator = new ParseTreeEvaluator();
            }
View Full Code Here

Examples of ptolemy.data.expr.ASTPtRootNode

            throws PtalonRuntimeException {
        try {
            PtParser parser = new PtParser();

            ParseTreeEvaluator _parseTreeEvaluator = new ParseTreeEvaluator();
            ASTPtRootNode _parseTree = parser.generateParseTree(expression);
            Token result = _parseTreeEvaluator.evaluateParseTree(_parseTree,
                    _scope);
            return result;
        } catch (Exception ex) {
            throw new PtalonRuntimeException("Unable to evaluate expression\n"
View Full Code Here

Examples of ptolemy.data.expr.ASTPtRootNode

     */
    public String evaluateString(String expression) {
        try {
            PtParser parser = new PtParser();
            ParseTreeEvaluator _parseTreeEvaluator = new ParseTreeEvaluator();
            ASTPtRootNode _parseTree = parser.generateParseTree(expression);
            Token result = _parseTreeEvaluator.evaluateParseTree(_parseTree,
                    _scope);
            if (result instanceof StringToken) {
                return ((StringToken) result).stringValue();
            }
View Full Code Here

Examples of ptolemy.data.expr.ASTPtRootNode

                if (transition.getName().equals("default")) {
                    codeBuffer.append("true");
                } else {
                    String guard = transition.getGuardExpression();
                    PtParser parser = new PtParser();
                    ASTPtRootNode guardParseTree = parser
                            .generateParseTree(guard);
                    ParseTreeCodeGenerator parseTreeCodeGenerator = getParseTreeCodeGenerator();
                    parseTreeCodeGenerator.evaluateParseTree(guardParseTree,
                            _scope);
                    codeBuffer
                            .append(parseTreeCodeGenerator.generateFireCode());
                }
                codeBuffer.append(") {" + _eol);

                depth++;

                // generate code for choice action
                Iterator actions = transition.choiceActionList().iterator();

                while (actions.hasNext()) {
                    AbstractActionsAttribute action = (AbstractActionsAttribute) actions
                            .next();
                    Iterator destinationNameList = action
                            .getDestinationNameList().iterator();
                    Iterator channelNumberList = action.getChannelNumberList()
                            .iterator();
                    Iterator parseTreeList = action.getParseTreeList()
                            .iterator();

                    while (destinationNameList.hasNext()) {
                        String destinationName = (String) destinationNameList
                                .next();
                        Integer channelNumber = (Integer) channelNumberList
                                .next();
                        ASTPtRootNode parseTree = (ASTPtRootNode) parseTreeList
                                .next();
                        NamedObj destination = action
                                .getDestination(destinationName);

                        int channel = -1;
                        if (channelNumber != null) {
                            channel = channelNumber.intValue();
                        }

                        codeBuffer.append(_getIndentPrefix(depth));

                        // Note in choice action only output can be generated
                        // and no parameter be changed.
                        if (channel >= 0) {
                            codeBuffer.append("$ref(" + destinationName + "#"
                                    + channel + ") = ");

                            // During choice action, an output port
                            // receives token sent by itself when it
                            // is also an input port, i.e., when this
                            // FSMActor is used as a modal controller.

                            if (((IOPort) destination).isInput()) {
                                ComponentCodeGenerator containerHelper = _getHelper(((IOPort) destination)
                                        .getContainer().getContainer());
                                StringBuffer containerReference = new StringBuffer();

                                containerReference.append("$ref("
                                        + destination.getName());

                                if (((IOPort) destination).isMultiport()) {
                                    containerReference.append("#" + channel);
                                }

                                containerReference.append(")");

                                codeBuffer
                                        .append(((CodeGeneratorHelper) containerHelper)
                                                .processCode(containerReference
                                                        .toString())
                                                + " = ");
                            }
                        } else { // broadcast

                            int width = ((IOPort) action
                                    .getDestination(destinationName))
                                    .getWidth();

                            for (int i = 0; i < width; i++) {
                                codeBuffer.append("$ref(" + destinationName
                                        + "#" + i + ") = ");

                                // During choice action, an output
                                // port receives token sent by itself
                                // when it is also an input port,
                                // i.e., when this FSMActor is used as
                                // a modal controller.

                                if (((IOPort) destination).isInput()) {
                                    ComponentCodeGenerator containerHelper = _getHelper(((IOPort) destination)
                                            .getContainer().getContainer());
                                    StringBuffer containerReference = new StringBuffer();

                                    containerReference.append("$ref("
                                            + destination.getName());

                                    if (((IOPort) destination).isMultiport()) {
                                        containerReference.append("#" + i);
                                    }

                                    containerReference.append(")");

                                    codeBuffer
                                            .append(((CodeGeneratorHelper) containerHelper)
                                                    .processCode(containerReference
                                                            .toString())
                                                    + " = ");
                                }
                            }
                        }

                        ParseTreeCodeGenerator parseTreeCodeGenerator = getParseTreeCodeGenerator();
                        parseTreeCodeGenerator.evaluateParseTree(parseTree,
                                _scope);
                        codeBuffer.append(parseTreeCodeGenerator
                                .generateFireCode());
                        codeBuffer.append(";" + _eol);
                    }
                }

                boolean inline = ((BooleanToken) _codeGenerator.inline
                        .getToken()).booleanValue();

                // generate code for transition refinement
                Actor[] actors = transition.getRefinement();

                if (actors != null) {
                    for (int i = 0; i < actors.length; i++) {
                        CodeGeneratorHelper helper = (CodeGeneratorHelper) _getHelper((NamedObj) actors[i]);
                        // fire the actor
                        if (inline) {
                            codeBuffer.append(helper.generateFireCode());
                            codeBuffer.append(helper
                                    .generateTypeConvertFireCode());
                        } else {
                            codeBuffer
                                    .append(generateName((NamedObj) actors[i])
                                            + "();" + _eol);
                        }
                    }
                }

                // generate code for commit action
                actions = transition.commitActionList().iterator();

                while (actions.hasNext()) {
                    AbstractActionsAttribute action = (AbstractActionsAttribute) actions
                            .next();
                    Iterator destinationNameList = action
                            .getDestinationNameList().iterator();
                    Iterator channelNumberList = action.getChannelNumberList()
                            .iterator();
                    Iterator parseTreeList = action.getParseTreeList()
                            .iterator();

                    while (destinationNameList.hasNext()) {
                        String destinationName = (String) destinationNameList
                                .next();
                        Integer channelNumber = (Integer) channelNumberList
                                .next();
                        ASTPtRootNode parseTree = (ASTPtRootNode) parseTreeList
                                .next();
                        NamedObj destination = action
                                .getDestination(destinationName);

                        int channel = -1;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.