diff --git a/src/__stl__.h b/src/__stl__.h index 8ac76e5a..e4bbc669 100644 --- a/src/__stl__.h +++ b/src/__stl__.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/src/compiler.h b/src/compiler.h index e979b103..b4b496bb 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -19,7 +19,7 @@ enum StringType { NORMAL_STRING, RAW_STRING, F_STRING }; class Compiler { public: - pkpy::unique_ptr parser; + std::unique_ptr parser; std::stack<_Code> codes; bool isCompilingClass = false; int lexingCnt = 0; @@ -37,7 +37,7 @@ public: Compiler(VM* vm, const char* source, _Str filename, CompileMode mode){ this->vm = vm; - this->parser = pkpy::make_unique( + this->parser = std::make_unique( pkpy::make_shared(source, filename, mode) ); diff --git a/src/memory.h b/src/memory.h index ac60d778..78ebed61 100644 --- a/src/memory.h +++ b/src/memory.h @@ -96,67 +96,4 @@ namespace pkpy{ new(p+1) T(std::forward(args)...); return shared_ptr(p); } - - template - class unique_ptr { - T* ptr; - - public: - unique_ptr() : ptr(nullptr) {} - unique_ptr(T* ptr) : ptr(ptr) {} - unique_ptr(const unique_ptr& other) = delete; - unique_ptr(unique_ptr&& other) : ptr(other.ptr) { - other.ptr = nullptr; - } - ~unique_ptr() { - delete ptr; - } - - bool operator==(const unique_ptr& other) const { - return ptr == other.ptr; - } - - bool operator!=(const unique_ptr& other) const { - return ptr != other.ptr; - } - - bool operator==(std::nullptr_t) const { - return ptr == nullptr; - } - - bool operator!=(std::nullptr_t) const { - return ptr != nullptr; - } - - unique_ptr& operator=(const unique_ptr& other) = delete; - - unique_ptr& operator=(unique_ptr&& other) { - if (this != &other) { - delete ptr; - ptr = other.ptr; - other.ptr = nullptr; - } - return *this; - } - - T& operator*() const { - return *ptr; - } - T* operator->() const { - return ptr; - } - T* get() const { - return ptr; - } - - void reset(){ - delete ptr; - ptr = nullptr; - } - }; - - template - unique_ptr make_unique(Args&&... args) { - return unique_ptr(new T(std::forward(args)...)); - } }; \ No newline at end of file diff --git a/src/vm.h b/src/vm.h index 4cd9a645..8617e93c 100644 --- a/src/vm.h +++ b/src/vm.h @@ -26,7 +26,7 @@ class VM { PyVarDict _modules; // loaded modules emhash8::HashMap<_Str, _Str> _lazy_modules; // lazy loaded modules protected: - std::deque< pkpy::unique_ptr > callstack; + std::deque< std::unique_ptr > callstack; PyVar __py2py_call_signal; inline void test_stop_flag(){ @@ -580,7 +580,7 @@ public: throw RuntimeError("RecursionError", "maximum recursion depth exceeded", _cleanErrorAndGetSnapshots()); } Frame* frame = new Frame(code, _module, std::move(locals)); - callstack.emplace_back(pkpy::unique_ptr(frame)); + callstack.emplace_back(std::unique_ptr(frame)); return frame; }