Examples of ParseTreeFreeVariableCollector


Examples of ptolemy.data.expr.ParseTreeFreeVariableCollector

        _absentDiscreteVariables = new LinkedList();
        _constructingRelationList = true;
        _errorTolerance = errorTolerance;
        _relationIndex = 0;
        _relationList = relationList;
        _variableCollector = new ParseTreeFreeVariableCollector();
    }
View Full Code Here

Examples of ptolemy.data.expr.ParseTreeFreeVariableCollector

        _outputActionReferredInputPorts.clear();

        String string = transition.outputActions.getExpression();
        PtParser parser = new PtParser();
        ASTPtRootNode parseTree;
        ParseTreeFreeVariableCollector variableCollector = new ParseTreeFreeVariableCollector();
        FSMActor controller = getController();
        ParserScope scope = controller.getPortScope();

        if (!string.equals("")) {
            Map map = parser.generateAssignmentMap(string);
            Set set /* Dead Local Store: = new HashSet()*/;

            for (Iterator names = map.keySet().iterator(); names.hasNext();) {
                String name = (String) names.next();

                ASTPtAssignmentNode node = (ASTPtAssignmentNode) map.get(name);
                parseTree = node.getExpressionTree();
                set = variableCollector.collectFreeVariables(parseTree, scope);
                getReferredInputPorts(set, _outputActionReferredInputPorts);
            }
        }
    }
View Full Code Here

Examples of ptolemy.data.expr.ParseTreeFreeVariableCollector

        _setActionReferredInputPorts.clear();

        String string = transition.setActions.getExpression();
        PtParser parser = new PtParser();
        ASTPtRootNode parseTree;
        ParseTreeFreeVariableCollector variableCollector = new ParseTreeFreeVariableCollector();
        FSMActor controller = getController();
        ParserScope scope = controller.getPortScope();

        if (!string.equals("")) {
            Map map = parser.generateAssignmentMap(string);
            Set set /* Dead Local Store: = new HashSet()*/;

            for (Iterator names = map.keySet().iterator(); names.hasNext();) {
                String name = (String) names.next();

                ASTPtAssignmentNode node = (ASTPtAssignmentNode) map.get(name);
                parseTree = node.getExpressionTree();
                set = variableCollector.collectFreeVariables(parseTree, scope);
                getReferredInputPorts(set, _setActionReferredInputPorts);
            }
        }
    }
View Full Code Here

Examples of ptolemy.data.expr.ParseTreeFreeVariableCollector

                        + transition.getName() + "is null!");
            }

            PtParser parser = new PtParser();
            ASTPtRootNode parseTree = parser.generateParseTree(string);
            ParseTreeFreeVariableCollector variableCollector = new ParseTreeFreeVariableCollector();
            FSMActor controller = getController();
            ParserScope scope = controller.getPortScope();
            Set set = variableCollector.collectFreeVariables(parseTree, scope);
            getReferredInputPorts(set, transitionsReferredInputPorts);
        }

        return transitionsReferredInputPorts;
    }
View Full Code Here

Examples of ptolemy.data.expr.ParseTreeFreeVariableCollector

                            // value dependents (if any) are notified of
                            // the new value, and so that attributeChanged()
                            // is called on the actor.
                            parameter.validate();
                        } catch (IllegalActionException ex) {
                            ParseTreeFreeVariableCollector collector = new ParseTreeFreeVariableCollector();
                            Set expressionVariables = collector
                                    .collectFreeVariables(parseTree);
                            Set scopeVariables = _scope.identifierSet();
                            List<String> excludedVariables = new LinkedList<String>();
                            for (Object variable : expressionVariables) {
                                if (variable instanceof String) {
                                    if (!scopeVariables.contains(variable)) {
                                        excludedVariables
                                                .add((String) variable);
                                    }
                                }
                            }
                            ParseTreeSpecializer specializer = new ParseTreeSpecializer();
                            parseTree = specializer.specialize(parseTree,
                                    excludedVariables, _scope);
                            ParseTreeWriter writer = new ParseTreeWriter();
                            String outputExpression = writer
                                    .printParseTree(parseTree);
                            parameter.setExpression(outputExpression);
                        }
                    } catch (ClassCastException ex) {
                        Settable parameter = (Settable) actor
                                .getAttribute(parameterName);
                        ParseTreeFreeVariableCollector collector = new ParseTreeFreeVariableCollector();
                        Set expressionVariables = collector
                                .collectFreeVariables(parseTree);
                        Set scopeVariables = _scope.identifierSet();
                        List<String> excludedVariables = new LinkedList<String>();
                        for (Object variable : expressionVariables) {
                            if (variable instanceof String) {
View Full Code Here

Examples of ptolemy.data.expr.ParseTreeFreeVariableCollector

        set.removeAll(variableNames);

        // Iterate over all the variables of this container, and add in
        // any free variables they reference.
        PtParser parser = new PtParser();
        ParseTreeFreeVariableCollector collector = new ParseTreeFreeVariableCollector();

        for (Iterator variables = model.attributeList(Variable.class)
                .iterator(); variables.hasNext();) {
            Variable variable = (Variable) variables.next();
            String expression = variable.getExpression();
            ASTPtRootNode root;

            if (variable.isStringMode()) {
                root = parser.generateStringParseTree(expression);
            } else {
                root = parser.generateParseTree(expression);
            }

            Set freeIdentifiers = new HashSet(collector
                    .collectFreeVariables(root));

            // Identifiers that reference other variables in the same container
            // are bound, not free.
            Set tempSet = new HashSet(variableNames);
View Full Code Here

Examples of ptolemy.data.expr.ParseTreeFreeVariableCollector

        // Get the free variables of the function definition.  These
        // will be turned into constructor arguments of the class
        // representing the function closure.  This takes the role of
        // Specialization of parse trees.
        ParseTreeFreeVariableCollector collector = new ParseTreeFreeVariableCollector();
        List freeVariableList = new LinkedList(collector
                .collectFreeVariables(node));
        Collections.sort(freeVariableList);
        System.out.println("freeVariableList = " + freeVariableList);

        // Infer the type of the function.
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.