diff options
author | rtk0c <[email protected]> | 2022-07-15 14:54:47 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-07-15 14:54:47 -0700 |
commit | c6e57dc94e532442ffa0bd57a16206217adbca92 (patch) | |
tree | 141a50907172f2b6b5986d55ee12c3910f7563da /source/20-codegen-compiler/main.cpp | |
parent | 06ab541057fec82415e612e9ff9a7f4bb11fc420 (diff) |
Changeset: 84 Make all input commands use the same CodegenModel object
- A clean build on the main game still works
- Generating cross-file references works now (only in a clean build, while the child classses are scanned after the parent classes though). This will still need fixing to support 1. reading from database 2. circular dependencies
Diffstat (limited to 'source/20-codegen-compiler/main.cpp')
-rw-r--r-- | source/20-codegen-compiler/main.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/source/20-codegen-compiler/main.cpp b/source/20-codegen-compiler/main.cpp index 81b5d23..5350f8e 100644 --- a/source/20-codegen-compiler/main.cpp +++ b/source/20-codegen-compiler/main.cpp @@ -593,7 +593,6 @@ struct ParserState { }; struct ParserOutput { - CodegenModel model; CodegenOutput headerOutput; CodegenOutput sourceOutput; CodegenOutput standaloneSourceOutput; @@ -745,7 +744,7 @@ void ParseInputFileAndGenerate(AppState& as, CodegenLexer& /*lexingState*/ ls, s break; } - po.currentNamespace = po.model.AddNamespace(DeclNamespace{ + po.currentNamespace = as.model->AddNamespace(DeclNamespace{ .container = po.currentNamespace, .name = tokens[idx].text, }); @@ -817,7 +816,7 @@ void ParseInputFileAndGenerate(AppState& as, CodegenLexer& /*lexingState*/ ls, s // TODO support namespace qualified names auto baseClassFullname = Utils::MakeFullName(idenTok.text, po.currentNamespace); - auto baseClassDecl = po.model.FindStruct(baseClassFullname); + auto baseClassDecl = as.model->FindStruct(baseClassFullname); if (baseClassDecl) { // We silently ignore a non-existent base class, because they may reside in a file that we didn't scan structDecl.baseClasses.push_back(baseClassDecl); @@ -844,7 +843,7 @@ void ParseInputFileAndGenerate(AppState& as, CodegenLexer& /*lexingState*/ ls, s { // Get a pointer to the decl inside CodegenInput's storage - auto decl = po.model.AddStruct(std::move(fullname), std::move(structDecl)); + auto decl = as.model->AddStruct(std::move(fullname), std::move(structDecl)); po.currentStruct = decl; po.currentStructBraceDepth = po.currentBraceDepth; } @@ -946,7 +945,7 @@ void ParseInputFileAndGenerate(AppState& as, CodegenLexer& /*lexingState*/ ls, s } { - auto decl = po.model.AddEnum(std::move(fullname), std::move(enumDecl)); + auto decl = as.model->AddEnum(std::move(fullname), std::move(enumDecl)); po.currentEnum = decl; po.currentEnumBraceDepth = po.currentBraceDepth; } @@ -1194,7 +1193,7 @@ void ParseInputFileAndGenerate(AppState& as, CodegenLexer& /*lexingState*/ ls, s Utils::WriteOutputFile(po.standaloneSourceOutput, generatedCppName); as.modelArchive->DeleteDeclsRelatedToFile(filenameStem); - as.modelArchive->Store(po.model); + // as.modelArchive->Store(po.model); } void HandleInputFile(AppState& as, const fs::path& path) { @@ -1360,10 +1359,10 @@ where --output-dir=<path>: the *directory* to write generated contents to. Thi // - 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); + CodegenModelArchive modelArchive(as.databaseFilePath); as.model = &model; - as.modelArchive = &archive; + as.modelArchive = &modelArchive; // Positional argument pass for (int i = 1; i < argc; ++i) { @@ -1384,6 +1383,8 @@ where --output-dir=<path>: the *directory* to write generated contents to. Thi } } + modelArchive.Store(model); + return 0; } |