public override Process ClearConstant(Dictionary <string, Expression> constMapping)
        {
            List <Process> newnewListProcess = Processes;

            if (Processes == null)
            {
                if (Specification.IsParsing)
                {
                    return(new IndexExternalChoice(IndexedProcessDefinition.ClearConstant(constMapping)));
                }

                newnewListProcess = IndexedProcessDefinition.GetIndexedProcesses(constMapping);
            }

            List <Process> newListProcess = new List <Process>();

            for (int i = 0; i < newnewListProcess.Count; i++)
            {
                Process newProc = newnewListProcess[i].ClearConstant(constMapping);
                if (!(newProc is Stop))
                {
                    newListProcess.Add(newProc);
                }
            }

            //all processes are stop processes
            if (newListProcess.Count == 0)
            {
                return(new Stop());
            }

            return(new IndexExternalChoice(newListProcess));
        }
Beispiel #2
0
        public override Process ClearConstant(Dictionary <string, Expression> constMapping)
        {
            List <Process> newnewProcesses = Processes;

            List <Process> newProceses;
            int            size;

            if (Specification.IsParsing)
            {
                if (Processes == null)
                {
                    return(new IndexParallel(IndexedProcessDefinition.ClearConstant(constMapping)));
                }
                size        = Processes.Count;
                newProceses = new List <Process>(size);
                for (int i = 0; i < size; i++)
                {
                    newProceses.Add(Processes[i].ClearConstant(constMapping));
                }
            }

            if (Processes == null)
            {
                newnewProcesses = IndexedProcessDefinition.GetIndexedProcesses(constMapping);
            }

            size = newnewProcesses.Count;

            newProceses = new List <Process>(size);
            for (int i = 0; i < size; i++)
            {
                Process newProc = newnewProcesses[i].ClearConstant(constMapping);

                if (newProc is IndexParallel && (newProc as IndexParallel).Processes != null)
                {
                    List <Process> processes = (newProc as IndexParallel).Processes;
                    newProceses.AddRange(processes);
                }
                else
                {
                    newProceses.Add(newProc);
                }
            }

            return(new IndexParallel(newProceses));
        }
Beispiel #3
0
        public override Process ClearConstant(Dictionary <string, Expression> constMapping)
        {
            List <Process> newProceses = new List <Process>();

            if (Specification.IsParsing)
            {
                if (Processes == null)
                {
                    return(new IndexInterleave(IndexedProcessDefinition.ClearConstant(constMapping)));
                }

                foreach (Process procese in Processes)
                {
                    newProceses.Add(procese.ClearConstant(constMapping));
                }

                return(new IndexInterleave(newProceses));
            }

            List <Process> newnewProcesses = Processes;

            if (Processes == null)
            {
                //return new IndexInterleave(IndexedProcessDefinition.GetIndexedProcesses(constMapping));
                newnewProcesses = IndexedProcessDefinition.GetIndexedProcesses(constMapping);
            }

            int size = newnewProcesses.Count;
            Dictionary <string, int> processCounters = new Dictionary <string, int>(size);

            for (int i = 0; i < size; i++)
            {
                Process newProc = newnewProcesses[i].ClearConstant(constMapping);

                if (newProc is IndexInterleave)
                {
                    List <Process> processes = (newProc as IndexInterleave).Processes;

                    foreach (var processe in processes)
                    {
                        string tmp = processe.ProcessID;
                        if (!processCounters.ContainsKey(tmp))
                        {
                            newProceses.Add(processe);
                            processCounters.Add(tmp, 1);
                        }
                        else
                        {
                            processCounters[tmp] = processCounters[tmp] + 1;
                        }
                    }
                }
                else if (newProc is IndexInterleaveAbstract)
                {
                    IndexInterleaveAbstract intAbs = newProc as IndexInterleaveAbstract;

                    foreach (var processe in intAbs.Processes)
                    {
                        string tmp = processe.ProcessID;
                        if (!processCounters.ContainsKey(tmp))
                        {
                            newProceses.Add(processe);
                            processCounters.Add(tmp, intAbs.ProcessesActualSize[tmp]);
                        }
                        else
                        {
                            processCounters[tmp] = processCounters[tmp] + intAbs.ProcessesCounter[tmp];
                        }
                    }
                }
                else
                {
                    if (!processCounters.ContainsKey(newProc.ProcessID))
                    {
                        newProceses.Add(newProc);
                        processCounters.Add(newProc.ProcessID, 1);
                    }
                    else
                    {
                        processCounters[newProc.ProcessID] = processCounters[newProc.ProcessID] + 1;
                    }
                }
            }

            foreach (KeyValuePair <string, int> pair in processCounters)
            {
                if (pair.Value > 1 || pair.Value == -1)
                {
                    IndexInterleaveAbstract toReturn = new IndexInterleaveAbstract(newProceses, processCounters);
                    toReturn.ProcessesActualSize = new Dictionary <string, int>(processCounters);
                    return(toReturn);
                }
            }

            return(new IndexInterleave(newProceses));
        }