From bd07ae3f4e1bcdedc3e373460671ca9713a03de5 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Thu, 2 Jun 2022 21:34:16 -0700 Subject: Changeset: 60 Add struct/class scanning to codegen --- source/20-codegen-compiler/CodegenInput.inl | 69 ----------------------------- 1 file changed, 69 deletions(-) delete mode 100644 source/20-codegen-compiler/CodegenInput.inl (limited to 'source/20-codegen-compiler/CodegenInput.inl') diff --git a/source/20-codegen-compiler/CodegenInput.inl b/source/20-codegen-compiler/CodegenInput.inl deleted file mode 100644 index 0809e7f..0000000 --- a/source/20-codegen-compiler/CodegenInput.inl +++ /dev/null @@ -1,69 +0,0 @@ -#pragma once - -#include "CodegenConfig.hpp" -#include "CodegenDecl.hpp" - -#include "CodegenUtils.inl" - -#include - -#include -#include -#include -#include -#include - -using namespace std::literals; - -class CodegenInput { -private: - std::vector mEnums; - robin_hood::unordered_flat_map mDeclByName; - robin_hood::unordered_node_map mNamespaces; - -public: - void AddEnum(std::string fullname, DeclEnum decl) { -#if CODEGEN_DEBUG_PRINT - printf("Committed enum '%s'\n", decl.name.c_str()); - for (auto& elm : decl.elements) { - printf(" - element %s = %" PRId64 "\n", elm.name.c_str(), elm.value); - } -#endif - - mDeclByName.try_emplace(std::move(fullname), mEnums.size()); - mEnums.push_back(std::move(decl)); - } - - DeclNamespace* AddNamespace(DeclNamespace ns) { - auto path = Utils::MakeFullName(""sv, &ns); - auto [iter, success] = mNamespaces.try_emplace(std::move(path), std::move(ns)); - auto& nsRef = iter->second; - if (success) { - nsRef.fullname = iter->first; - } - return &nsRef; - } - - const DeclEnum* FindEnumByName(std::string_view name) const { - // TODO handle multiple kinds of decl - auto iter = mDeclByName.find(name); - if (iter != mDeclByName.end()) { - return &mEnums[iter->second]; - } else { - return nullptr; - } - } - - const DeclNamespace* FindNamespace(std::string_view fullname) const { - auto iter = mNamespaces.find(fullname); - if (iter != mNamespaces.end()) { - return &iter->second; - } else { - return nullptr; - } - } - - DeclNamespace* FindNamespace(std::string_view name) { - return const_cast(const_cast(this)->FindNamespace(name)); - } -}; -- cgit v1.2.3-70-g09d2