From f138311d2d2e0cc9ba0496d523bb46f2c1c9fb73 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Wed, 20 Sep 2023 23:58:58 -0700 Subject: Copy from the PlasticSCM repo, replace vendored glm wtih conan --- source/20-codegen-compiler/CodegenModel.hpp | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 source/20-codegen-compiler/CodegenModel.hpp (limited to 'source/20-codegen-compiler/CodegenModel.hpp') diff --git a/source/20-codegen-compiler/CodegenModel.hpp b/source/20-codegen-compiler/CodegenModel.hpp new file mode 100644 index 0000000..99c345d --- /dev/null +++ b/source/20-codegen-compiler/CodegenModel.hpp @@ -0,0 +1,61 @@ +#pragma once + +#include "CodegenConfig.hpp" +#include "CodegenDecl.hpp" +#include "CodegenModel.hpp" +#include "CodegenUtils.hpp" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +class CodegenRuntimeModel { +private: + class Private; + Private* m; + +public: + CodegenRuntimeModel(); + ~CodegenRuntimeModel(); + + // Implementation detail helper, don't use outside + Private& GetPimpl() const { return *m; } + + DeclEnum* AddEnum(std::string fullname, DeclEnum decl); + DeclStruct* AddStruct(std::string fullname, DeclStruct decl); + + const DeclEnum* FindEnum(std::string_view name) const; + const DeclStruct* FindStruct(std::string_view name) const; + + DeclNamespace* AddNamespace(DeclNamespace ns); + + const DeclNamespace* FindNamespace(std::string_view fullname) const; + DeclNamespace* FindNamespace(std::string_view name); +}; + +class CodegenArchiveModel { +private: + class Private; + Private* m; + +public: + CodegenArchiveModel(std::string_view dbPath); + ~CodegenArchiveModel(); + + // Implementation detail helper, don't use outside + Private& GetPimpl() const { return *m; } + + void DeleteDeclsRelatedToFile(std::string_view filename); + + void Store(const CodegenRuntimeModel& model); + void LoadInto(CodegenRuntimeModel& model) const; + CodegenRuntimeModel Load() const; + + void StoreStruct(const DeclStruct& decl); + void StoreFunction(const DeclFunction& decl); + void StoreEnum(const DeclEnum& decl); +}; -- cgit v1.2.3-70-g09d2