diff options
author | rtk0c <[email protected]> | 2023-10-19 22:50:07 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2023-10-19 22:50:07 -0700 |
commit | 2c92e07f337e42cf58970443f9de678f85a9b2a4 (patch) | |
tree | 075d5407e1e12a9d35cbee6e4c20ad34e0765c42 /source/20-codegen-compiler/CodegenDecl.cpp | |
parent | 615809c036f604bce4582cea8ad49c64693f4f45 (diff) |
The great renaming: switch to "module style"
Diffstat (limited to 'source/20-codegen-compiler/CodegenDecl.cpp')
-rw-r--r-- | source/20-codegen-compiler/CodegenDecl.cpp | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/source/20-codegen-compiler/CodegenDecl.cpp b/source/20-codegen-compiler/CodegenDecl.cpp deleted file mode 100644 index 11e1bb5..0000000 --- a/source/20-codegen-compiler/CodegenDecl.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "CodegenDecl.hpp" - -#include "CodegenUtils.hpp" - -#include <fmt/format.h> -#include <Utils.hpp> - -const std::string& DeclStruct::GetMangledName() const { - if (mangledName.empty()) { - mangledName = Utils::MakeMangledName(name, container); - } - 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); - } - return mangledName; -} - -static EnumValuePattern NextPattern(EnumValuePattern val) { - return (EnumValuePattern)(val + 1); -} - -EnumValuePattern DeclEnum::CalcPattern() const { - if (elements.empty()) return EVP_Continuous; - - auto pattern = EVP_Continuous; -restart: - auto lastVal = elements[0].value; - for (size_t i = 1; i < elements.size(); ++i) { - auto currVal = elements[i].value; - switch (pattern) { - case EVP_Continuous: { - bool satisfy = lastVal + 1 == currVal; - if (!satisfy) { - pattern = NextPattern(pattern); - goto restart; - } - } break; - - case EVP_Bits: { - bool satisfy = (lastVal << 1) == currVal; - if (!satisfy) { - pattern = NextPattern(pattern); - goto restart; - } - } break; - - // A random pattern can match anything - case EVP_Random: - case EVP_COUNT: break; - } - lastVal = currVal; - } - - return pattern; -} - -EnumValuePattern DeclEnum::GetPattern() const { - if (pattern == EVP_COUNT) { - pattern = CalcPattern(); - } - return pattern; -} |