|
|
@@ -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;
|