From 848cb4e18c9a6f253c2223af2df2f1ec228c04ad Mon Sep 17 00:00:00 2001 From: triton Date: Sat, 13 Jul 2013 20:20:22 +0100 Subject: [PATCH] Remove ILibrary out of the driver code and only call it from the ConsoleDriver. --- src/Generator/Driver.cs | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs index 30d88ac3..291a3157 100644 --- a/src/Generator/Driver.cs +++ b/src/Generator/Driver.cs @@ -29,20 +29,17 @@ namespace CppSharp public IDiagnosticConsumer Diagnostics { get; private set; } public Parser Parser { get; private set; } public TypeMapDatabase TypeDatabase { get; private set; } - public ILibrary Transform { get; private set; } public Generator Generator { get; private set; } public Library Library { get; private set; } public Library LibrarySymbols { get; private set; } - public Driver(DriverOptions options, IDiagnosticConsumer diagnostics, - ILibrary transform) + public Driver(DriverOptions options, IDiagnosticConsumer diagnostics) { Options = options; Diagnostics = diagnostics; Parser = new Parser(Options); TypeDatabase = new TypeMapDatabase(); - Transform = transform; } static void ValidateOptions(DriverOptions options) @@ -100,13 +97,26 @@ namespace CppSharp return true; } - public void ProcessCode() + public void AddPrePasses() { - TypeDatabase.SetupTypeMaps(); + Passes.CleanUnit(Options); + Passes.SortDeclarations(); + Passes.ResolveIncompleteDecls(); + } - if (Transform != null) - Transform.Preprocess(this, Library); + public void AddPostPasses() + { + Passes.CleanInvalidDeclNames(); + Passes.CheckIgnoredDecls(); + Passes.CheckTypeReferences(); + Passes.CheckFlagEnums(); + Passes.CheckAmbiguousOverloads(); + Generator.SetupPasses(Passes); + } + public void ProcessCode() + { + TypeDatabase.SetupTypeMaps(); var passes = new PassBuilder(this); passes.CleanUnit(Options); passes.SortDeclarations(); @@ -252,8 +262,7 @@ namespace CppSharp Console.BufferHeight = 1999; var options = new DriverOptions(); - var driver = new Driver(options, new TextDiagnosticPrinter(), - library); + var driver = new Driver(options, new TextDiagnosticPrinter()); library.Setup(driver); driver.Setup(); @@ -272,7 +281,14 @@ namespace CppSharp return; Console.WriteLine("Processing code..."); + library.Preprocess(driver, driver.Library); + + driver.AddPrePasses(); + library.SetupPasses(driver, driver.Passes); + driver.AddPostPasses(); + driver.ProcessCode(); + library.Postprocess(driver.Library); Console.WriteLine("Generating code..."); driver.GenerateCode();