Package org.openquark.cal.compiler.CompositionNode

Examples of org.openquark.cal.compiler.CompositionNode.Collector


     */
    public static SourceModel.FunctionDefn.Algebraic getFunctionSourceModel(
        String functionName, CompositionNode functionRoot, Scope scope) {

        // Get as a collector root.
        Collector rootNode = getAsCollectorRoot(functionRoot, functionName);

        GraphInfo graphInfo = new GraphInfo(rootNode, functionName);
        SourceModel.Expr functionBody = getFunctionBodySourceModel(rootNode, graphInfo, null);

        // The name of the function is the collector name.
View Full Code Here


     * @return the arguments in the order that they would appear in the source.
     */
    public static CompositionArgument[] getFunctionArguments(CompositionNode rootNode) {
        // Get as a collector root.  This is necessary so that unbound arguments that don't have a target
        // set properly get picked up as arguments on the root
        Collector collectorRoot = getAsCollectorRoot(rootNode, "temp");

        // calculate the graph info, get the args for the node.
        GraphInfo graphInfo = new GraphInfo(collectorRoot, "temp");
        List<CompositionArgument> nodeArgList = graphInfo.getCollectorArguments(collectorRoot);
       
View Full Code Here

     * @return the resulting CAL source.
     */
    public static String getSourceForCodeGem(CompositionNode rootNode) {
        // Note: prevent eta-reduction of the root gem..
       
        Collector collectorRoot = getAsCollectorRoot(rootNode, "tempCollector");
        SourceModel.Expr sourceBody = getFunctionBodySourceModel(collectorRoot, new GraphInfo(collectorRoot, "tempCollector"), null);
       
        return sourceBody.toSourceText();
    }
View Full Code Here

     */
    static CheckGraphSource getCheckGraphSource(Set<? extends CompositionNode> rootNodes) {
       
        Map<String, Collector> rootTypeCollectorNameToCollectorMap = new LinkedHashMap<String, Collector>();
        GraphInfo graphInfo = new GraphInfo(rootNodes);
        Collector graphTarget = graphInfo.getGraphTarget();
        SourceModel.Expr graphTargetSourceModel = getFunctionBodySourceModel(graphTarget, graphInfo, rootTypeCollectorNameToCollectorMap);

        // The root->arguments map which is returned.
        Map<CompositionNode, List<CompositionArgument>> rootToArgumentsMap = new LinkedHashMap<CompositionNode, List<CompositionArgument>>();
       
        List<SourceModel.Parameter> parameters = new ArrayList<SourceModel.Parameter>();
               
        // The root arguments..
        for (final Map.Entry<String, Collector> entry : rootTypeCollectorNameToCollectorMap.entrySet()) {
            final String rootTypeCollectorName = entry.getKey();
            Collector correspondingCollector = entry.getValue();
           
            // Get the original root corresponding to the collected root.
            CompositionNode correspondingRoot = graphInfo.getOriginalRoot(correspondingCollector);
           
            // Get the arguments, add to the map (but only if it's not one of the synthetically created enclosing collectors..).
View Full Code Here

           
            // Iterate over the targeting collectors, generating the inner let definitions used for type checking.
            for (final Map.Entry<String, Collector> entry : targetingCollectorNameToCollectorMap.entrySet()) {
               
                final String targetingCollectorName = entry.getKey();
                Collector targetingCollector = entry.getValue();
               
                // Skip if it's an excluded collector.
                if (graphInfo.isExcludedCollectorReplacement(targetingCollector)) {
                    continue;
                }
View Full Code Here

//            tupleDimension = TypeExpr.getTupleDimension(functionName);

        } else if (node instanceof CompositionNode.Emitter) {

            // This node invokes a local function
            Collector collector = ((CompositionNode.Emitter)node).getCollectorNode();
            applyable = SourceModel.Expr.Var.makeUnqualified(graphInfo.getCollectorName(collector));
           
        } else {
            // something bad happened
            throw new IllegalArgumentException("Can't handle this type of node: " + node.getClass());
View Full Code Here

            excludedCollectorReplacementMap = getExcludedCollectors(inputRootNodes);
            Set<CompositionNode> rootNodesToAnalyze = new HashSet<CompositionNode>(inputRootNodes);
            rootNodesToAnalyze.addAll(excludedCollectorReplacementMap.values());
           
            // Calculate the target for the CompositionNode graph.
            Collector rootNodeTarget = getGraphTarget(rootNodesToAnalyze, excludedCollectorReplacementMap);
           
            // Ensure the target is a member of the root nodes set.
            rootNodesToAnalyze.add(rootNodeTarget);
           
            // Create a dummy collector for which the body will be the check graph expression.  Set this as the graph target.
            CompositionNode checkGraphConnectedNode = new CompositionNode.Value() {
                public String getStringValue() {
                    return "0.0";
                }
                public SourceModel.Expr getSourceModel() {
                    return SourceModel.Expr.Literal.Double.make(0.0);
                }
                public int getNArguments() {
                    return 0;
                }
                public CompositionArgument getNodeArgument(int i) {
                    return null;
                }
            };
            Collector graphTarget = new SyntheticCollector("dummyCollector", Collections.<CompositionArgument>emptyList(), checkGraphConnectedNode);
            rootNodesToAnalyze.add(graphTarget);
           
            // The set of all collector names.
            Set<String> collectorNames = new HashSet<String>();
View Full Code Here

         *   This may be modified if the graph target is not already found to be in either the set or the map.
         * @return the first collector root in the set which has a null target.
         *   If there are no such collectors, a new temporary collector will be returned.
         */
        private static Collector getGraphTarget(Set<CompositionNode> rootNodes, Map<Collector, SyntheticCollector> excludedCollectorReplacementMap) {
            Collector graphTarget = null;
           
            // Calculate the target for the CompositionNode graph..
            for (final CompositionNode nextRoot : rootNodes) {             
               
                // When we find the first collector, find its outermost enclosing collector.  This should be the target.
                if (nextRoot instanceof Collector) {
                    graphTarget = (Collector)nextRoot;

                    Collector enclosingCollector = graphTarget.getTargetCollector();
                    while (enclosingCollector != null) {
                        graphTarget = enclosingCollector;
                        enclosingCollector = graphTarget.getTargetCollector();
                    }
                    break;
View Full Code Here

           
            // Calculate args.
            SubtreeNodeInfo collectorSubtreeNodeInfo = getSubtreeNodeInfo(collector);
           
            for (final CompositionArgument freeUnburntArgument : collectorSubtreeNodeInfo.getFreeUnburntArguments()) {              
                Collector argumentTarget = getArgumentCollectorTarget(freeUnburntArgument, collector, collectorTargetInfo);
               
                // Check for the special case where an emitter argument target's the emitter's collector.
                //  In this case, the argument should not appear an an argument on the collector.
                if (recursiveEmitterArgumentToReflectedInputMap.containsKey(freeUnburntArgument)) {
                    continue;
                }

                if (collectorTargetInfo != targetCollectorTargetInfo) {
                    Collector realArgumentTarget = getArgumentCollectorTarget(freeUnburntArgument, collector, targetCollectorTargetInfo);

                    // Check for the case of an argument which isn't used by the collector which it targets.
                    if (argumentTarget != null && realArgumentTarget == null) {
                        unusedArgumentList.add(freeUnburntArgument);
                        continue;
View Full Code Here

            // Iterate over the root nodes, checking targets for any collectors.
            for (final CompositionNode rootNode : rootNodes) {
             
                if (rootNode instanceof Collector) {
                    // If the target isn't in the set of root nodes, call getCollector(), which should create it.
                    Collector targetCollector = ((Collector)rootNode).getTargetCollector();
                    if (targetCollector != null && !rootNodes.contains(targetCollector)) {
                        getCollector(targetCollector, rootNodes, excludedCollectorReplacementMap);
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.CompositionNode.Collector

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.