blueloveTH 3 лет назад
Родитель
Сommit
944f98be6f
4 измененных файлов с 5 добавлено и 67 удалено
  1. 1 0
      src/__stl__.h
  2. 2 2
      src/compiler.h
  3. 0 63
      src/memory.h
  4. 2 2
      src/vm.h

+ 1 - 0
src/__stl__.h

@@ -19,6 +19,7 @@
 #include <string_view>
 #include <string_view>
 #include <queue>
 #include <queue>
 #include <iomanip>
 #include <iomanip>
+#include <memory>
 
 
 #include <atomic>
 #include <atomic>
 #include <iostream>
 #include <iostream>

+ 2 - 2
src/compiler.h

@@ -19,7 +19,7 @@ enum StringType { NORMAL_STRING, RAW_STRING, F_STRING };
 
 
 class Compiler {
 class Compiler {
 public:
 public:
-    pkpy::unique_ptr<Parser> parser;
+    std::unique_ptr<Parser> parser;
     std::stack<_Code> codes;
     std::stack<_Code> codes;
     bool isCompilingClass = false;
     bool isCompilingClass = false;
     int lexingCnt = 0;
     int lexingCnt = 0;
@@ -37,7 +37,7 @@ public:
 
 
     Compiler(VM* vm, const char* source, _Str filename, CompileMode mode){
     Compiler(VM* vm, const char* source, _Str filename, CompileMode mode){
         this->vm = vm;
         this->vm = vm;
-        this->parser = pkpy::make_unique<Parser>(
+        this->parser = std::make_unique<Parser>(
             pkpy::make_shared<SourceMetadata>(source, filename, mode)
             pkpy::make_shared<SourceMetadata>(source, filename, mode)
         );
         );
 
 

+ 0 - 63
src/memory.h

@@ -96,67 +96,4 @@ namespace pkpy{
         new(p+1) T(std::forward<Args>(args)...);
         new(p+1) T(std::forward<Args>(args)...);
         return shared_ptr<T>(p);
         return shared_ptr<T>(p);
     }
     }
-
-    template <typename T>
-    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 <typename T, typename... Args>
-    unique_ptr<T> make_unique(Args&&... args) {
-        return unique_ptr<T>(new T(std::forward<Args>(args)...));
-    }
 };
 };

+ 2 - 2
src/vm.h

@@ -26,7 +26,7 @@ class VM {
     PyVarDict _modules;                             // loaded modules
     PyVarDict _modules;                             // loaded modules
     emhash8::HashMap<_Str, _Str> _lazy_modules;     // lazy loaded modules
     emhash8::HashMap<_Str, _Str> _lazy_modules;     // lazy loaded modules
 protected:
 protected:
-    std::deque< pkpy::unique_ptr<Frame> > callstack;
+    std::deque< std::unique_ptr<Frame> > callstack;
     PyVar __py2py_call_signal;
     PyVar __py2py_call_signal;
     
     
     inline void test_stop_flag(){
     inline void test_stop_flag(){
@@ -580,7 +580,7 @@ public:
             throw RuntimeError("RecursionError", "maximum recursion depth exceeded", _cleanErrorAndGetSnapshots());
             throw RuntimeError("RecursionError", "maximum recursion depth exceeded", _cleanErrorAndGetSnapshots());
         }
         }
         Frame* frame = new Frame(code, _module, std::move(locals));
         Frame* frame = new Frame(code, _module, std::move(locals));
-        callstack.emplace_back(pkpy::unique_ptr<Frame>(frame));
+        callstack.emplace_back(std::unique_ptr<Frame>(frame));
         return frame;
         return frame;
     }
     }