Ejemplo n.º 1
0
        static int MainWorker(ILanguage lang, string pathSourceFile, string pathFinalOut)
        {
            // Some compilers (like VBC) get confused if the output extension isn't .exe.
            string pathTempOut = Path.ChangeExtension(Path.GetTempFileName(), ".exe");

            // First invoke the high-level compiler
            WriteMarker();
            Console.WriteLine("Compiling input file '" + pathSourceFile + "' with '" + lang.PrettyName + "' to output '" + pathFinalOut + "'");
            Console.WriteLine("Compiling to temporary file:" + pathTempOut);
            lang.Compile(pathSourceFile, pathTempOut);

            // Now, IL-disassemble it.
            WriteMarker();
            ILDocument doc = new ILDocument(pathTempOut);

            InlineILSnippet[] snippets = FindInlineILSnippets(lang, pathSourceFile);

            // Reinject the snippets.
            foreach (InlineILSnippet s in snippets)
            {
                Console.WriteLine("Found:" + s);
                foreach (string x in s.Lines)
                {
                    Console.WriteLine("   :" + x);
                }

                doc.InsertSnippet(s);
            }

            // Now re-emit the new IL.
            WriteMarker();
            doc.EmitToFile(pathFinalOut);

            // Since they're doing direct IL manipulation, we really should run peverify on the output.
            WriteMarker();
            Console.WriteLine("runnning PEVerify on '{0}'.", pathFinalOut);
            Util.Run(SdkDir + @"\bin\PEverify.exe", pathFinalOut);
            Console.WriteLine("PEVerify passed!");

            return(0);
        } // end main
Ejemplo n.º 2
0
 public virtual void DoWork()
 {
     _language.Compile();
     _language.Execute();
 }