Ejemplo n.º 1
0
        public override int VisitCompileUnit(CCompileUnit node)
        {
            m_translatedFile = new CFile(CodeBlockType.CB_FILE, 3, null);

            m_translatedFile.AddCode("#include <stdio.h>\n", CFile.CB_PREPROCESSOR);
            m_translatedFile.AddCode("#include <stdlib.h>\n", CFile.CB_PREPROCESSOR);

            m_parents.Push(m_translatedFile.MMainFunctionDefinition);
            m_parentContexts.Push(CCFunctionDefinition.CB_FUNCTIONDEFINITION_BODY);
            // Visit Statements Context and emmit code to main functions
            foreach (ASTVisitableElement child in node.GetChildrenContext(CCompileUnit.CT_COMPILEUNIT_STATEMENTS))
            {
                Visit(child);
            }
            m_parents.Pop();
            m_parentContexts.Pop();

            m_parents.Push(m_translatedFile);
            m_parentContexts.Push(CFile.CB_FUNDEFS);
            // Visit Function Definitions and emmit code to distinct functions
            foreach (ASTVisitableElement child in node.GetChildrenContext(CCompileUnit.CT_COMPILEUNIT_FUNDEFS))
            {
                Visit(child);
            }

            m_parents.Pop();
            m_parentContexts.Pop();

            return(0);
        }
Ejemplo n.º 2
0
        public override int VisitCompileUnit(CCompileUnit node)
        {
            m_ostream.WriteLine("digraph {");

            ExtractSubgraphs(node, CCompileUnit.CT_COMPILEUNIT_STATEMENTS, CCompileUnit.ContextNames);
            ExtractSubgraphs(node, CCompileUnit.CT_COMPILEUNIT_FUNDEFS, CCompileUnit.ContextNames);

            base.VisitCompileUnit(node);

            m_ostream.WriteLine("}");
            m_ostream.Close();

            // Prepare the process to run
            ProcessStartInfo start = new ProcessStartInfo();

            // Enter in the command line arguments, everything you would enter after the executable name itself
            start.Arguments = "-Tgif " + m_dotName + " -o" + m_dotName + ".gif";
            // Enter the executable to run, including the complete path
            start.FileName = "dot";
            // Do you want to show a console window?
            start.WindowStyle    = ProcessWindowStyle.Hidden;
            start.CreateNoWindow = true;
            int exitCode;


            // Run the external process & wait for it to finish
            using (Process proc = Process.Start(start))
            {
                proc.WaitForExit();

                // Retrieve the app's exit code
                exitCode = proc.ExitCode;
            }

            return(0);
        }
Ejemplo n.º 3
0
 public virtual T VisitCompileUnit(CCompileUnit node)
 {
     return(VisitChildren(node));
 }