diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-07-17 16:16:23 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-07-17 16:16:23 +0200 |
| commit | e676e74efbbbf62887b9442326399eebccc4d108 (patch) | |
| tree | 04c51d56a20dd17bb5091895292079504c1dc13e /include | |
| parent | db528ae1fbec5219fa34e1b780590eef89e9618c (diff) | |
| download | elna-e676e74efbbbf62887b9442326399eebccc4d108.tar.gz | |
Handle base type constness
Diffstat (limited to 'include')
| -rw-r--r-- | include/elna/boot/symbol.h | 58 |
1 files changed, 18 insertions, 40 deletions
diff --git a/include/elna/boot/symbol.h b/include/elna/boot/symbol.h index 6884dd7..216021e 100644 --- a/include/elna/boot/symbol.h +++ b/include/elna/boot/symbol.h @@ -18,11 +18,12 @@ along with GCC; see the file COPYING3. If not see #pragma once #include <cstdint> -#include <unordered_map> -#include <string> +#include <forward_list> #include <memory> +#include <string> +#include <unordered_map> +#include <variant> #include <vector> -#include <forward_list> #include "elna/boot/result.h" @@ -39,36 +40,21 @@ namespace elna::boot class type { - enum class type_tag - { - empty, - alias, - primitive, - record, - pointer, - constant, - array, - procedure, - enumeration - }; - type_tag tag{ type_tag::empty }; - union - { - std::weak_ptr<alias_type> alias; - std::shared_ptr<primitive_type> primitive; - std::shared_ptr<record_type> record; - std::shared_ptr<pointer_type> pointer; - std::shared_ptr<constant_type> constant; - std::shared_ptr<array_type> array; - std::shared_ptr<procedure_type> procedure; - std::shared_ptr<enumeration_type> enumeration; - }; - - void copy(const type& other); - void move(type&& other); + std::variant< + std::monostate, + std::weak_ptr<alias_type>, + std::shared_ptr<primitive_type>, + std::shared_ptr<record_type>, + std::shared_ptr<pointer_type>, + std::shared_ptr<constant_type>, + std::shared_ptr<array_type>, + std::shared_ptr<procedure_type>, + std::shared_ptr<enumeration_type> + > payload; public: - type(); + type() = default; + explicit type(std::shared_ptr<alias_type> alias); explicit type(std::shared_ptr<primitive_type> primitive); explicit type(std::shared_ptr<record_type> record); @@ -78,14 +64,6 @@ namespace elna::boot explicit type(std::shared_ptr<procedure_type> procedure); explicit type(std::shared_ptr<enumeration_type> enumeration); - type(const type& other); - type& operator=(const type& other); - - type(type&& other); - type& operator=(type&& other); - - ~type(); - template<typename T> std::shared_ptr<T> get() const; @@ -104,7 +82,7 @@ namespace elna::boot struct alias_type { const std::string name; - type reference; + type referent; explicit alias_type(const std::string& name); }; |
