Package org.openquark.cal.compiler.CompositionNode

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


                for (final CompositionNode.Emitter emitter : subtreeNodeInfo.getEmitters()) {
                  
                    if (emitter.getCollectorNode() == collector) {
                        nEmitterArgs = emitter.getNArguments();
                        for (int i = 0; i < nEmitterArgs; i++) {
                            CompositionArgument emitterArgument = emitter.getNodeArgument(i);

                            if (emitterArgument.getConnectedNode() == null && !emitterArgument.isBurnt()) {
                                collectorEmitterArgumentToIndexMap.put(emitterArgument, Integer.valueOf(i));
                            }
                        }
                    }
                }
               
                // Another check for nothing to do..
                if (nEmitterArgs < 0 || collectorEmitterArgumentToIndexMap.isEmpty()) {
                    continue;
                }
               
                // Calculate the reflected inputs for the collector.
                // These are the target arguments which are also descendant free unburnt args, but which are not recursive emitter args.
                List<CompositionArgument> descendantFreeUnburntArguments = subtreeNodeInfo.getFreeUnburntArguments();
                Set<CompositionArgument> reflectedArguments = new LinkedHashSet<CompositionArgument>(collector.getTargetArguments());
                reflectedArguments.retainAll(descendantFreeUnburntArguments);
                reflectedArguments.removeAll(collectorEmitterArgumentToIndexMap.keySet());
               
                if (nEmitterArgs != reflectedArguments.size()) {
                    throw new IllegalStateException("The number of reflected arguments must be equal to the number of emitter args.  "
                                                    + nEmitterArgs + " != " + reflectedArguments.size());
                }
               
                // Map from emitter arg index to the argument reflected at that index.
                Map<Integer, CompositionArgument> indexToReflectedArgumentMap = new HashMap<Integer, CompositionArgument>();
                int index = 0;
                for (final CompositionArgument arg : reflectedArguments) {
                    indexToReflectedArgumentMap.put(Integer.valueOf(index), arg);
                    index++;
                }

                // Now add all recursive args to the recursiveEmitterArgumentToReflectedInputMap.
                for (final Map.Entry<CompositionArgument, Integer> entry : collectorEmitterArgumentToIndexMap.entrySet()) {                  
                    final CompositionArgument collectorEmitterArgument = entry.getKey();
                    Integer argIndex = entry.getValue();
                    recursiveEmitterArgumentToReflectedInputMap.put(collectorEmitterArgument, indexToReflectedArgumentMap.get(argIndex));
                }
            }
           
View Full Code Here


            // This is true if it's a) unconnected and b) has no arguments. 
            //   b) should be true if the collector is not targeted by its input, and has no inner collectors. 
            //   In practice, we only have to perform the first check, since if it has inner collectors,
            //     we will be generating check graph source, which does not optimize out naked collectors.
            if (inputToNakedCollectorMap != null) {
                CompositionArgument collectorInput = collector.getNodeArgument(0);
                if (collector.getDeclaredType() == null && collectorInput.getConnectedNode() == null &&
                        getArgumentCollectorTarget(collectorInput, collector, collectorTargetInfo) != collector) {
                   
                    inputToNakedCollectorMap.put(collectorInput, collector);
                }
            }
View Full Code Here

         * @param argument the argument in question.
         * @return the name calculated for the given argument.
         */
        public String getArgumentName(CompositionArgument argument) {
            // Check for the case where it's a recursive emitter argument.
            CompositionArgument recursivelyReflectedArgument = recursiveEmitterArgumentToReflectedInputMap.get(argument);
            if (recursivelyReflectedArgument != null) {
                argument = recursivelyReflectedArgument;
            }
           
            return argumentToNameMap.get(argument);
View Full Code Here

TOP

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

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.