Esempio n. 1
0
        public Direct GetProgram(XmlNode currentProgramXml, ParserInfo parserInfo)
        {
            string            id          = ParseTools.ParseID(currentProgramXml);
            InlineProgramInfo programInfo = GetInlineProgramInfo(currentProgramXml, parserInfo);
            CDFG newProgram = ProgramCDFG.Copy();

            TransformCDFGToFunctionCDFG(newProgram, programInfo);
            TransformVariableNames(newProgram, programInfo, parserInfo.GetUniquePostFix());
            ChangeIDs(newProgram, id);

            //Add new variables that this program added
            programInfo.OutputsFromTo.ForEach(x => parserInfo.AddVariable(string.Empty, VariableType.FLUID, x.Value));
            DFG <Block> nextDFG = XmlParser.ParseNextDFG(currentProgramXml, parserInfo);



            DFG <Block> endDFG = newProgram.GetEndDFGInFirstScope();
            int         i      = newProgram.Nodes.FindIndex(x => x.dfg == endDFG);

            if (newProgram.Nodes[i].control == null)
            {
                newProgram.Nodes[i] = (new Direct(nextDFG), endDFG);
            }
            else
            {
                newProgram.Nodes[i] = (newProgram.Nodes[i].control.GetNewControlWithNewEnd(nextDFG), endDFG);
            }

            //merge the programs together nd return the link between then
            parserInfo.cdfg.AddCDFG(newProgram);

            return(new Direct(newProgram.StartDFG));
        }