diff options
author | rtk0c <[email protected]> | 2022-07-15 13:30:43 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-07-15 13:30:43 -0700 |
commit | 06ab541057fec82415e612e9ff9a7f4bb11fc420 (patch) | |
tree | 75ee3b580cfc2d91e55f5942225987200d3a314e /source/20-codegen-compiler/main.cpp | |
parent | a417c79a08feeabe555d4ab9e213294599557efc (diff) |
Changeset: 83 Misc bug fixes, planning database readback for inheritance hierarchy generation
Diffstat (limited to 'source/20-codegen-compiler/main.cpp')
-rw-r--r-- | source/20-codegen-compiler/main.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/source/20-codegen-compiler/main.cpp b/source/20-codegen-compiler/main.cpp index dcec0d3..81b5d23 100644 --- a/source/20-codegen-compiler/main.cpp +++ b/source/20-codegen-compiler/main.cpp @@ -30,6 +30,7 @@ namespace fs = std::filesystem; // TOOD maybe switch to libclang, maintaining this parser is just too painful struct AppState { + CodegenModel* model; CodegenModelArchive* modelArchive; robin_hood::unordered_map<std::string, SourceFile, StringHash, StringEqual> sourceFiles; std::string_view outputDir; @@ -1192,10 +1193,8 @@ void ParseInputFileAndGenerate(AppState& as, CodegenLexer& /*lexingState*/ ls, s INPLACE_FMT(generatedCppName, "%.*s/%.*s.g.cpp", PRINTF_STRING_VIEW(as.outputDir), PRINTF_STRING_VIEW(filenameStem)); Utils::WriteOutputFile(po.standaloneSourceOutput, generatedCppName); - if (as.modelArchive) { - as.modelArchive->DeleteDeclsRelatedToFile(filenameStem); - as.modelArchive->Store(po.model); - } + as.modelArchive->DeleteDeclsRelatedToFile(filenameStem); + as.modelArchive->Store(po.model); } void HandleInputFile(AppState& as, const fs::path& path) { @@ -1348,13 +1347,23 @@ where --output-dir=<path>: the *directory* to write generated contents to. Thi DEBUG_PRINTF("Outputting to directory %.*s.\n", PRINTF_STRING_VIEW(as.outputDir)); DEBUG_PRINTF("Databse file: %.*s.\n", PRINTF_STRING_VIEW(as.databaseFilePath)); -#define BRUSSEL_ENABLE_CODEGEN_ARCHIVE 1 -#if BRUSSEL_ENABLE_CODEGEN_ARCHIVE + // TODO make every input command share the same CodegenModel + // TODO move the actual output logic after processing all input commands, based on SQLite batabase model instead of the in-memory CodegenModel model + // this allows better consistency between direct in-file entities (like enums) vs. multi-file entities (like struct inheritance hierarchy) + // this would also mean almost rewriting the whole codegen logic, to work on a changelist fetched from SQLite database instead of being embedded inside the parser loop + // TODO how do we detect the case of + // 1. has: Foo.hpp Bar.hpp + // 2. struct Foo; struct Bar : Foo; + // 3. struct Foo is removed from Foo.hpp, but our parser only recieves Foo.hpp as file changed--and can't figure out that there is still a reference to Foo in Bar.hpp + // possible solutions + // - use some kind of database scanner to review all references to a class when removing (e.g. detect for logic error on foreign key linked columns) + // - follow the file links in database, and propagate parsing to those files in the hierarchy + // - pretty much defeats the purpose of using an incremental parser: some classes like GameObject will have links throughout a very large portion of the project code + CodegenModel model; CodegenModelArchive archive(as.databaseFilePath); + + as.model = &model; as.modelArchive = &archive; -#else - as.modelArchive = nullptr; -#endif // Positional argument pass for (int i = 1; i < argc; ++i) { |