Ejemplo n.º 1
0
        private bool ReadFlowPoints(string filename, Guid id)
        {
            bool      rc = true;
            ArrayList arr = null;
            ArrayList mcNames, mcGraphTexts;

            FlowPoint = new Dictionary <string, VisualFlowPoint>();
            string graphText;
            string mcText;

            arr = CFGParser.GenerateCFG(filename, out graphText, out mcNames, out mcGraphTexts, out mcText);

            string err = CFGParser.GetLastError();

            if (arr != null && err == "")
            {
                foreach (VisualFlowPoint fp in arr)
                {
                    FlowPoint[fp.Name] = fp;
                }
            }
            else
            {
                rc = false;
            }


            if (rc && graphText != null)
            {
                OnMessage("Writing graph to file");
                WriteGraphToFile(DIGRAPH_FILE, graphText);
                rc = RunDot(id);
            }

            if (rc)
            {
                OnMessage("Writing MC graphs to file");
                for (int i = 0; i < mcNames.Count; ++i)
                {
                    WriteGraphToFile(DIGRAPH_FILE + ".MC_" + (mcNames[i] as string), mcGraphTexts[i] as string);
                }

                OnMCTextUpdated(mcText);
            }

            return(rc);
        }
Ejemplo n.º 2
0
        public bool GenerateCFG(string code)
        {
            bool rc = true;

            CleanTempDir();
            bool   fileRead     = false;
            Guid   id           = Guid.NewGuid();
            string codeFileName = CODE_FILE + "_" + id.ToString();

            OnMessage("Writing temporary code file '" + codeFileName + "'");

            try
            {
                WriteTextFile(codeFileName, code);
                OnMessage("Generating flow points");
                rc = ReadFlowPoints(codeFileName, id);
                if (rc)
                {
                    fileRead = true;
                    OnMessage("loading CFG image");
                    readDotSpec(DOT_LAYOUT_FILE + "_" + id.ToString());
                    OnImageUpdate(DOT_IMAGE_FILE + "_" + id.ToString() + ".png");
                    OnMessage("Cleaning up");
                }
                File.Delete(DIGRAPH_FILE);
                //File.Delete(m_app.CODE_FILE);
                File.Delete(DOT_LAYOUT_FILE);

                OnMessage("");
            }
            catch (System.Exception ex)
            {
                if (!fileRead)
                {
                }
            }
            string err = CFGParser.GetLastError();

            if (err != "")
            {
                rc = false;
                OnError("Code parsing failed. Check syntax:", err);
            }

            return(rc);
        }