コード例 #1
0
ファイル: ElementCompiler.cs プロジェクト: zeta1999/CoFRA
        protected static InstructionBlock ConnectOneWithManyResultsToInstructionBlock(IInstructionsContainer first,
                                                                                      IEnumerable <IInstructionsContainer> others)
        {
            if (first == null)
            {
                throw new ArgumentNullException();
            }
            if (others == null)
            {
                throw new ArgumentNullException();
            }

            var notNullOthers = others.Where(res => res != null && !res.IsEmpty()).ToList();

            if (notNullOthers.Count == 0)
            {
                return(first.GetInstructionBlock());
            }

            var newInstructions     = new List <Instruction>();
            var newContinuations    = new List <Continuation>();
            var initialInstructions = new List <InstructionId>();

            foreach (var other in notNullOthers)
            {
                newInstructions.AddRange(other.GetInstructionBlock().Instructions);
                newContinuations.AddRange(other.GetInstructionBlock().Continuations);
            }

            if (first.IsEmpty())
            {
                foreach (var res in notNullOthers)
                {
                    initialInstructions.AddRange(res.GetInstructionBlock().InitialInstructions);
                }

                return(new InstructionBlock(initialInstructions, newInstructions, newContinuations));
            }

            initialInstructions.AddRange(first.GetInstructionBlock().InitialInstructions);
            newInstructions.AddRange(first.GetInstructionBlock().Instructions);

            foreach (var continuation in first.GetInstructionBlock().Continuations)
            {
                foreach (var other in notNullOthers)
                {
                    continuation.NextInstructions.AddRange(other.GetInstructionBlock().InitialInstructions);
                }
            }

            return(new InstructionBlock(initialInstructions, newInstructions, newContinuations));
        }
コード例 #2
0
ファイル: ElementCompiler.cs プロジェクト: zeta1999/CoFRA
 private static void ConnectTwoContainers(IInstructionsContainer first, IInstructionsContainer second)
 {
     foreach (var continuation in first.GetInstructionBlock().Continuations)
     {
         FillContinuation(continuation, second.GetInstructionBlock());
     }
 }