mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-23 04:50:17 +00:00
some fix
This commit is contained in:
parent
af040fb6ef
commit
4e9072165b
@ -218,11 +218,11 @@ public:
|
||||
constexpr static Type tp_none_type = Type(kTpNoneTypeIndex), tp_not_implemented_type = Type(kTpNotImplementedTypeIndex);
|
||||
constexpr static Type tp_ellipsis = Type(26);
|
||||
|
||||
inline static PyVar True = pkpy_True;
|
||||
inline static PyVar False = pkpy_False;
|
||||
inline static PyVar None = pkpy_None;
|
||||
inline static PyVar NotImplemented = pkpy_NotImplemented;
|
||||
inline static PyVar Ellipsis = pkpy_Ellipsis;
|
||||
PyVar True;
|
||||
PyVar False;
|
||||
PyVar None;
|
||||
PyVar NotImplemented;
|
||||
PyVar Ellipsis;
|
||||
|
||||
const bool enable_os;
|
||||
VM(bool enable_os = true);
|
||||
|
@ -74,8 +74,6 @@ PK_INLINE bool PyVar__IS_OP(const PyVar* a, const PyVar* b){
|
||||
bool pkpy_Var__eq__(void *vm, PyVar a, PyVar b);
|
||||
int64_t pkpy_Var__hash__(void *vm, PyVar a);
|
||||
|
||||
extern PyVar pkpy_True, pkpy_False, pkpy_None;
|
||||
extern PyVar pkpy_NotImplemented, pkpy_Ellipsis;
|
||||
extern PyVar pkpy_NULL, pkpy_OP_CALL, pkpy_OP_YIELD;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "pocketpy/interpreter/vm.hpp"
|
||||
#include "pocketpy/common/memorypool.h"
|
||||
#include "pocketpy/objects/base.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
@ -84,6 +85,18 @@ struct JsonSerializer {
|
||||
VM::VM(bool enable_os) : heap(this), enable_os(enable_os) {
|
||||
Pools_initialize();
|
||||
pkpy_StrName__initialize();
|
||||
static ::PyObject __true_obj = {.type=tp_bool, .gc_is_large=false, .gc_marked=false, ._attr=NULL};
|
||||
static ::PyObject __false_obj = {.type=tp_bool, .gc_is_large=false, .gc_marked=false, ._attr=NULL};
|
||||
static ::PyObject __none_obj = {.type=tp_none_type, .gc_is_large=false, .gc_marked=false, ._attr=NULL};
|
||||
static ::PyObject __not_implemented_obj = {.type=tp_not_implemented_type, .gc_is_large=false, .gc_marked=false, ._attr=NULL};
|
||||
static ::PyObject __ellipsis_obj = {.type=tp_ellipsis, .gc_is_large=false, .gc_marked=false, ._attr=NULL};
|
||||
|
||||
/* Must be heap objects to support `==` and `is` and `is not` */
|
||||
this->True = (::PyVar){.type=tp_bool, .is_ptr=true, .extra=1, ._obj=&__true_obj};
|
||||
this->False = (::PyVar){.type=tp_bool, .is_ptr=true, .extra=0, ._obj=&__false_obj};
|
||||
this->None = (::PyVar){.type=tp_none_type, .is_ptr=true, ._obj=&__none_obj};
|
||||
this->NotImplemented = (::PyVar){.type=tp_not_implemented_type, .is_ptr=true, ._obj=&__not_implemented_obj};
|
||||
this->Ellipsis = (::PyVar){.type=tp_ellipsis, .is_ptr=true, ._obj=&__ellipsis_obj};
|
||||
|
||||
this->vm = this;
|
||||
this->__c.error = nullptr;
|
||||
|
@ -6,16 +6,3 @@ void PyVar__ctor3(PyVar* self, PyObject* existing){
|
||||
self->is_ptr = true;
|
||||
self->_obj = existing;
|
||||
}
|
||||
|
||||
static PyObject __true_obj = {.type=tp_bool, .gc_is_large=false, .gc_marked=false, ._attr=NULL};
|
||||
static PyObject __false_obj = {.type=tp_bool, .gc_is_large=false, .gc_marked=false, ._attr=NULL};
|
||||
static PyObject __none_obj = {.type=tp_none_type, .gc_is_large=false, .gc_marked=false, ._attr=NULL};
|
||||
static PyObject __not_implemented_obj = {.type=tp_not_implemented_type, .gc_is_large=false, .gc_marked=false, ._attr=NULL};
|
||||
static PyObject __ellipsis_obj = {.type=tp_ellipsis, .gc_is_large=false, .gc_marked=false, ._attr=NULL};
|
||||
|
||||
/* Must be heap objects to support `==` and `is` and `is not` */
|
||||
PyVar pkpy_True = {.type=tp_bool, .is_ptr=true, .extra=1, ._obj=&__true_obj};
|
||||
PyVar pkpy_False = {.type=tp_bool, .is_ptr=true, .extra=0, ._obj=&__false_obj};
|
||||
PyVar pkpy_None = {.type=tp_none_type, .is_ptr=true, ._obj=&__none_obj};
|
||||
PyVar pkpy_NotImplemented = {.type=tp_not_implemented_type, .is_ptr=true, ._obj=&__not_implemented_obj};
|
||||
PyVar pkpy_Ellipsis = {.type=tp_ellipsis, .is_ptr=true, ._obj=&__ellipsis_obj};
|
Loading…
x
Reference in New Issue
Block a user