Beispiel #1
0
        private void CheckCopyControl(IControlBlock original, IControlBlock copy)
        {
            IEnumerator <DFG <Block> > oEnumerator = original.GetEnumerator();
            IEnumerator <DFG <Block> > cEnumerator = copy.GetEnumerator();

            while (true)
            {
                bool oHasNext = oEnumerator.MoveNext();
                bool cHasNext = cEnumerator.MoveNext();
                Assert.AreEqual(oHasNext, cHasNext);
                if (!oHasNext)
                {
                    break;
                }

                CheckCopyDFG(oEnumerator.Current, cEnumerator.Current);
            }
        }
Beispiel #2
0
        private void TransformVariableNames(CDFG cdfg, InlineProgramInfo programInfo, string postfix)
        {
            Stack <IEnumerator <DFG <Block> > > stack = new Stack <IEnumerator <DFG <Block> > >();
            HashSet <string> readerBlacklist          = new HashSet <string>();
            HashSet <string> writerBlacklist          = new HashSet <string>();

            programInfo.InputsFromTo.ForEach(x => readerBlacklist.Add(x.Value.OriginalFluidName));
            programInfo.VariablesFromTo.ForEach(x => GetVariableBlockDependencies(x.Value.GetVariableTreeList(new List <VariableBlock>())).ForEach(y => readerBlacklist.Add(y)));
            programInfo.VariablesFromTo.ForEach(x => readerBlacklist.Add(x.Key));
            programInfo.OutputsFromTo.ForEach(x => writerBlacklist.Add(x.Value));

            DFG <Block> currentDFG = cdfg.StartDFG;

            do
            {
                foreach (Node <Block> node in currentDFG.Nodes)
                {
                    Block block = node.value;
                    foreach (FluidInput fluidInput in block.InputFluids)
                    {
                        if (!readerBlacklist.Contains(fluidInput.OriginalFluidName) &&
                            !writerBlacklist.Contains(fluidInput.OriginalFluidName))
                        {
                            fluidInput.OriginalFluidName += postfix;
                        }
                    }

                    for (int i = 0; i < block.InputNumbers.Count; i++)
                    {
                        if (!readerBlacklist.Contains(block.InputNumbers[i]))
                        {
                            block.InputNumbers[i] = block.InputNumbers[i] + postfix;
                        }
                    }

                    if (readerBlacklist.Contains(block.OutputVariable))
                    {
                        readerBlacklist.Remove(block.OutputVariable);
                    }
                    if (!writerBlacklist.Contains(block.OutputVariable))
                    {
                        block.OutputVariable += postfix;
                    }
                }

                IControlBlock control = cdfg.DfgToControl[currentDFG];
                if (control != null)
                {
                    stack.Push(control.GetEnumerator());
                }

                while (stack.Count > 0)
                {
                    if (!stack.Peek().MoveNext())
                    {
                        stack.Pop();
                        continue;
                    }

                    currentDFG = stack.Peek().Current;
                    break;
                }
            } while (stack.Count > 0);
        }