diff --git a/include/pocketpy/compiler.h b/include/pocketpy/compiler.h index 499eed8f..92137cb4 100644 --- a/include/pocketpy/compiler.h +++ b/include/pocketpy/compiler.h @@ -62,9 +62,9 @@ class Compiler { Expr_ EXPR_VARS(); // special case for `for loop` and `comp` template - unique_ptr_64 make_expr(Args&&... args) { - void* p = pool64_alloc(sizeof(T)); - unique_ptr_64 expr(new (p) T(std::forward(args)...)); + unique_ptr_128 make_expr(Args&&... args) { + void* p = pool128_alloc(sizeof(T)); + unique_ptr_128 expr(new (p) T(std::forward(args)...)); expr->line = prev().line; return expr; } @@ -72,7 +72,7 @@ class Compiler { template void _consume_comp(Expr_ expr){ static_assert(std::is_base_of::value); - unique_ptr_64 ce = make_expr(); + unique_ptr_128 ce = make_expr(); ce->expr = std::move(expr); ce->vars = EXPR_VARS(); consume(TK("in")); diff --git a/include/pocketpy/expr.h b/include/pocketpy/expr.h index c54da59b..26b02ff0 100644 --- a/include/pocketpy/expr.h +++ b/include/pocketpy/expr.h @@ -11,46 +11,46 @@ namespace pkpy{ struct CodeEmitContext; struct Expr; -#define PK_POOL64_DELETE(ptr) if(ptr != nullptr) { ptr->~T(); pool64_dealloc(ptr); ptr = nullptr; } +#define PK_POOL128_DELETE(ptr) if(ptr != nullptr) { ptr->~T(); pool128_dealloc(ptr); ptr = nullptr; } template -class unique_ptr_64{ +class unique_ptr_128{ T* ptr; public: - unique_ptr_64(): ptr(nullptr) {} - unique_ptr_64(T* ptr): ptr(ptr) {} + unique_ptr_128(): ptr(nullptr) {} + unique_ptr_128(T* ptr): ptr(ptr) {} T* operator->() const { return ptr; } T* get() const { return ptr; } T* release() { T* p = ptr; ptr = nullptr; return p; } - unique_ptr_64(const unique_ptr_64&) = delete; - unique_ptr_64& operator=(const unique_ptr_64&) = delete; + unique_ptr_128(const unique_ptr_128&) = delete; + unique_ptr_128& operator=(const unique_ptr_128&) = delete; bool operator==(std::nullptr_t) const { return ptr == nullptr; } bool operator!=(std::nullptr_t) const { return ptr != nullptr; } - ~unique_ptr_64(){ PK_POOL64_DELETE(ptr) } + ~unique_ptr_128(){ PK_POOL128_DELETE(ptr) } template - unique_ptr_64(unique_ptr_64&& other): ptr(other.release()) {} + unique_ptr_128(unique_ptr_128&& other): ptr(other.release()) {} operator bool() const { return ptr != nullptr; } template - unique_ptr_64& operator=(unique_ptr_64&& other) { - PK_POOL64_DELETE(ptr) + unique_ptr_128& operator=(unique_ptr_128&& other) { + PK_POOL128_DELETE(ptr) ptr = other.release(); return *this; } - unique_ptr_64& operator=(std::nullptr_t) { - PK_POOL64_DELETE(ptr) + unique_ptr_128& operator=(std::nullptr_t) { + PK_POOL128_DELETE(ptr) ptr = nullptr; return *this; } }; -typedef unique_ptr_64 Expr_; +typedef unique_ptr_128 Expr_; typedef small_vector Expr_vector; struct Expr{