コード例 #1
0
ファイル: Driver.cs プロジェクト: kitsilanosoftware/CppSharp
        public static void Run(ILibrary library)
        {
            var options = new DriverOptions();

            var Log = new TextDiagnosticPrinter();
            var driver = new Driver(options, Log);

            library.Setup(driver);
            driver.Setup();

            if(driver.Options.Verbose)
                Log.Level = DiagnosticKind.Debug;

            if (!options.Quiet)
                Log.EmitMessage("Parsing libraries...");

            if (!driver.ParseLibraries())
                return;

            if (!options.Quiet)
                Log.EmitMessage("Indexing library symbols...");

            driver.Symbols.IndexSymbols();

            if (!options.Quiet)
                Log.EmitMessage("Parsing code...");

            if (!driver.ParseCode())
                return;

            if (!options.Quiet)
                Log.EmitMessage("Processing code...");

            library.Preprocess(driver, driver.ASTContext);

            driver.SetupPasses(library);

            driver.ProcessCode();
            library.Postprocess(driver, driver.ASTContext);

            if (!options.Quiet)
                Log.EmitMessage("Generating code...");

            var outputs = driver.GenerateCode();

            foreach (var output in outputs)
            {
                foreach (var pass in driver.GeneratorOutputPasses.Passes)
                {
                    pass.Driver = driver;
                    pass.VisitGeneratorOutput(output);
                }
            }

            if (!driver.Options.DryRun)
                driver.WriteCode(outputs);

            if (driver.Options.IsCSharpGenerator)
                driver.CompileCode();
        }
コード例 #2
0
        public static void Run(ILibrary library)
        {
            var options = new DriverOptions();

            var Log    = new TextDiagnosticPrinter();
            var driver = new Driver(options, Log);

            library.Setup(driver);
            driver.Setup();

            Log.Verbose = driver.Options.Verbose;

            if (!options.Quiet)
            {
                Log.EmitMessage("Parsing libraries...");
            }

            if (!driver.ParseLibraries())
            {
                return;
            }

            if (!options.Quiet)
            {
                Log.EmitMessage("Indexing library symbols...");
            }

            driver.Symbols.IndexSymbols();

            if (!options.Quiet)
            {
                Log.EmitMessage("Parsing code...");
            }

            if (!driver.ParseCode())
            {
                return;
            }

            if (!options.Quiet)
            {
                Log.EmitMessage("Processing code...");
            }

            library.Preprocess(driver, driver.ASTContext);

            driver.SetupPasses(library);

            driver.ProcessCode();
            library.Postprocess(driver, driver.ASTContext);

            if (!options.Quiet)
            {
                Log.EmitMessage("Generating code...");
            }

            var outputs = driver.GenerateCode();

            foreach (var output in outputs)
            {
                foreach (var pass in driver.GeneratorOutputPasses.Passes)
                {
                    pass.Driver = driver;
                    pass.VisitGeneratorOutput(output);
                }
            }

            driver.WriteCode(outputs);
            if (driver.Options.IsCSharpGenerator)
            {
                driver.CompileCode();
            }
        }
コード例 #3
0
        public static void Run(ILibrary library)
        {
            var options = new DriverOptions();
            var driver  = new Driver(options, new TextDiagnosticPrinter());

            library.Setup(driver);
            driver.Setup();

            if (!options.Quiet)
            {
                Console.WriteLine("Parsing libraries...");
            }

            if (!driver.ParseLibraries())
            {
                return;
            }

            if (!options.Quiet)
            {
                Console.WriteLine("Indexing library symbols...");
            }

            driver.LibrarySymbols.IndexSymbols();

            if (!options.Quiet)
            {
                Console.WriteLine("Parsing code...");
            }

            if (!driver.ParseCode())
            {
                return;
            }

            if (!options.Quiet)
            {
                Console.WriteLine("Processing code...");
            }

            library.Preprocess(driver, driver.Library);

            driver.SetupPasses(library);

            driver.ProcessCode();
            library.Postprocess(driver.Library);

            if (!options.Quiet)
            {
                Console.WriteLine("Generating code...");
            }

            var outputs = driver.GenerateCode();

            foreach (var output in outputs)
            {
                foreach (var pass in driver.GeneratorOutputPasses.Passes)
                {
                    pass.Driver = driver;
                    pass.VisitGeneratorOutput(output);
                }
            }

            driver.WriteCode(outputs);
        }