aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-dataloader/AbstractSyntaxTree.hpp
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2024-08-11 02:59:55 +0200
committer Spartan322 <Megacake1234@gmail.com>2024-08-11 03:46:58 +0200
commit9617863bbb82fbe5c3c203dec2b9a7d7f6a746d5 (patch)
tree05cb6ce7a3e4f5f5af01498e7ee0f95e4fea1692 /src/openvic-dataloader/AbstractSyntaxTree.hpp
parentefcc544bb36c80efb911390855c0123d5d11f742 (diff)
Fix logger file invalid pointerfix/logger-invalidation
Add explicit move semantics to AbstractSyntaxTree Add explicit move semantics to ParseState
Diffstat (limited to 'src/openvic-dataloader/AbstractSyntaxTree.hpp')
-rw-r--r--src/openvic-dataloader/AbstractSyntaxTree.hpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/openvic-dataloader/AbstractSyntaxTree.hpp b/src/openvic-dataloader/AbstractSyntaxTree.hpp
index f2d941b..156b7d0 100644
--- a/src/openvic-dataloader/AbstractSyntaxTree.hpp
+++ b/src/openvic-dataloader/AbstractSyntaxTree.hpp
@@ -26,6 +26,14 @@ namespace ovdl {
AbstractSyntaxTree() = default;
explicit AbstractSyntaxTree(std::size_t max_elements) : _symbol_interner(max_elements) {}
+ AbstractSyntaxTree(AbstractSyntaxTree&& other) : _symbol_interner { std::move(other._symbol_interner) } {}
+ AbstractSyntaxTree& operator=(AbstractSyntaxTree&& rhs) {
+ this->~AbstractSyntaxTree();
+ new (this) AbstractSyntaxTree(std::move(rhs));
+
+ return *this;
+ }
+
symbol_type intern(const char* str, std::size_t length);
symbol_type intern(std::string_view str);
const char* intern_cstr(const char* str, std::size_t length);
@@ -63,6 +71,21 @@ namespace ovdl {
: AbstractSyntaxTree(buffer.size() * sizeof(Encoding::char_type)),
_file { std::move(buffer) } {}
+ BasicAbstractSyntaxTree(const BasicAbstractSyntaxTree&) = delete;
+ BasicAbstractSyntaxTree& operator=(const BasicAbstractSyntaxTree&) = delete;
+
+ BasicAbstractSyntaxTree(BasicAbstractSyntaxTree&& other)
+ : _tree { std::move(other._tree) },
+ _file { std::move(other._file) },
+ AbstractSyntaxTree(std::move(other)) {}
+
+ BasicAbstractSyntaxTree& operator=(AbstractSyntaxTree&& rhs) {
+ this->~BasicAbstractSyntaxTree();
+ new (this) BasicAbstractSyntaxTree(std::move(rhs));
+
+ return *this;
+ }
+
void set_location(const node_type* n, NodeLocation loc) {
_file.set_location(n, loc);
}