aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/elna/boot/symbol.h58
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);
};