diff options
author | rtk0c <[email protected]> | 2023-06-13 16:47:18 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2023-06-13 16:47:18 -0700 |
commit | a55e98b68735f1e4152a01773f22d28c472138ab (patch) | |
tree | b84f293659f20f2fb6dc6848ee86068c84a298e5 /source | |
parent | 21192a63e1411134b3096da4e5f9a511f913c9b9 (diff) |
Changeset: 96 General maintainance (actually these changes are fro ma while ago, like Jan 2023 and I forgot what they do)
Diffstat (limited to 'source')
-rw-r--r-- | source/20-codegen-compiler/CodegenDecl.cpp | 9 | ||||
-rw-r--r-- | source/20-codegen-compiler/CodegenDecl.hpp | 11 | ||||
-rw-r--r-- | source/20-codegen-compiler/main.cpp | 25 |
3 files changed, 43 insertions, 2 deletions
diff --git a/source/20-codegen-compiler/CodegenDecl.cpp b/source/20-codegen-compiler/CodegenDecl.cpp index 9e88cfb..11e1bb5 100644 --- a/source/20-codegen-compiler/CodegenDecl.cpp +++ b/source/20-codegen-compiler/CodegenDecl.cpp @@ -2,6 +2,7 @@ #include "CodegenUtils.hpp" +#include <fmt/format.h> #include <Utils.hpp> const std::string& DeclStruct::GetMangledName() const { @@ -11,6 +12,14 @@ const std::string& DeclStruct::GetMangledName() const { return mangledName; } +std::string DeclXGlobalVar::MangleCtorName(std::string_view targetName) { + return fmt::format("{}_MANGLED_ctor", targetName); +} + +std::string DeclXGlobalVar::MangleDtorName(std::string_view targetName) { + return fmt::format("{}_MANGLED_dtor", targetName); +} + const std::string& DeclEnum::GetMangledName() const { if (mangledName.empty()) { mangledName = Utils::MakeMangledName(name, container); diff --git a/source/20-codegen-compiler/CodegenDecl.hpp b/source/20-codegen-compiler/CodegenDecl.hpp index e645323..f1ac5b1 100644 --- a/source/20-codegen-compiler/CodegenDecl.hpp +++ b/source/20-codegen-compiler/CodegenDecl.hpp @@ -63,6 +63,17 @@ struct DeclStruct { const std::string& GetMangledName() const; }; +struct DeclXGlobalVar { + std::string name; + bool hasCtor = false; + bool hasDtor = false; + + static std::string MangleCtorName(std::string_view targetName); + std::string GetMangledCtorName() const { return MangleCtorName(name); } + static std::string MangleDtorName(std::string_view targetName); + std::string GetMangledDtorName() const { return MangleDtorName(name); } +}; + enum EnumUnderlyingType { EUT_Int8, EUT_Int16, diff --git a/source/20-codegen-compiler/main.cpp b/source/20-codegen-compiler/main.cpp index 845f2f2..6e4f9a0 100644 --- a/source/20-codegen-compiler/main.cpp +++ b/source/20-codegen-compiler/main.cpp @@ -178,6 +178,9 @@ enum CodegenDirective { CD_ClassProperty, CD_ClassMethod, CD_Enum, + CD_XGlobalVar, + CD_XGlobalVarCtor, + CD_XGlobalVarDtor, CD_COUNT, }; @@ -187,6 +190,9 @@ RSTR_LUT_DECL(CodegenDirective, 0, CD_COUNT) { RSTR_LUT_MAP(CD_ClassProperty, "BRUSSEL_PROPERTY"); RSTR_LUT_MAP(CD_ClassMethod, "BRUSSEL_METHOD"); RSTR_LUT_MAP(CD_Enum, "BRUSSEL_ENUM"); + RSTR_LUT_MAP(CD_XGlobalVar, "BRUSSEL_GLOBAL_DECL"); + RSTR_LUT_MAP(CD_XGlobalVarCtor, "BRUSSEL_GLOBAL_CTOR"); + RSTR_LUT_MAP(CD_XGlobalVarDtor, "BRUSSEL_GLOBAL_DTOR"); } std::vector<std::vector<const StbLexerToken*>> @@ -510,8 +516,8 @@ void GenerateClassFunction(CodegenOutput& headerOutput, CodegenOutput& sourceOut void GenerateForClassMetadata( CodegenOutput& headerOutput, CodegenOutput& sourceOutput, - const DeclStruct& decl) // -{ + const DeclStruct& decl // +) { auto& mangedName = decl.GetMangledName(); auto mangedNameCstr = mangedName.c_str(); @@ -1088,6 +1094,21 @@ void ParseInputFileAndGenerate(AppState& as, CodegenLexer& /*lexingState*/ ls, s goto endCaseCLEX_id; } + case CD_XGlobalVar: { + // TODO + goto endCaseCLEX_id; + } + + case CD_XGlobalVarCtor: { + // TODO + goto endCaseCLEX_id; + } + + case CD_XGlobalVarDtor: { + // TODO + goto endCaseCLEX_id; + } + // This directive always appear inside a enum{} block, which is handled above in the keywords section case CD_Enum: case CD_COUNT: break; |