blueloveTH пре 2 година
родитељ
комит
fdfe20ead1
4 измењених фајлова са 12 додато и 12 уклоњено
  1. 5 5
      src/base64.h
  2. 3 3
      src/ceval.h
  3. 1 1
      src/common.h
  4. 3 3
      src/vm.h

+ 5 - 5
src/base64.h

@@ -7,12 +7,12 @@ namespace pkpy {
 
 // https://github.com/zhicheng/base64/blob/master/base64.c
 
-inline static const char BASE64_PAD = '=';
-inline static const char BASE64DE_FIRST = '+';
-inline static const char BASE64DE_LAST = 'z';
+const char BASE64_PAD = '=';
+const char BASE64DE_FIRST = '+';
+const char BASE64DE_LAST = 'z';
 
 /* BASE 64 encode table */
-static const char base64en[] = {
+const char base64en[] = {
 	'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
 	'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
 	'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
@@ -24,7 +24,7 @@ static const char base64en[] = {
 };
 
 /* ASCII order for BASE 64 decode, 255 in unused character */
-static const unsigned char base64de[] = {
+const unsigned char base64de[] = {
 	/* nul, soh, stx, etx, eot, enq, ack, bel, */
 	   255, 255, 255, 255, 255, 255, 255, 255,
 

+ 3 - 3
src/ceval.h

@@ -106,7 +106,7 @@ __NEXT_STEP:;
     TARGET(LOAD_FAST) {
         heap._auto_collect();
         _0 = frame->_locals[byte.arg];
-        if(_0 == nullptr) vm->NameError(co->varnames[byte.arg]);
+        if(_0 == PY_NULL) vm->NameError(co->varnames[byte.arg]);
         PUSH(_0);
     } DISPATCH();
     TARGET(LOAD_NAME)
@@ -195,8 +195,8 @@ __NEXT_STEP:;
         DISPATCH();
     TARGET(DELETE_FAST)
         _0 = frame->_locals[byte.arg];
-        if(_0 == nullptr) vm->NameError(co->varnames[byte.arg]);
-        frame->_locals[byte.arg] = nullptr;
+        if(_0 == PY_NULL) vm->NameError(co->varnames[byte.arg]);
+        frame->_locals[byte.arg] = PY_NULL;
         DISPATCH();
     TARGET(DELETE_NAME)
         _name = StrName(byte.arg);

+ 1 - 1
src/common.h

@@ -158,7 +158,7 @@ inline bool is_both_int(PyObject* a, PyObject* b) noexcept {
 }
 
 // special singals, is_tagged() for them is true
-inline PyObject* const PY_NULL = (PyObject*)0b000011;
+inline PyObject* const PY_NULL = (PyObject*)0b000011;		// tagged null
 inline PyObject* const PY_BEGIN_CALL = (PyObject*)0b010011;
 inline PyObject* const PY_OP_CALL = (PyObject*)0b100011;
 inline PyObject* const PY_OP_YIELD = (PyObject*)0b110011;

+ 3 - 3
src/vm.h

@@ -1215,7 +1215,7 @@ inline PyObject* VM::_py_call(PyObject** p0, PyObject* callable, ArgsView args,
     if(fn.is_simple){
         if(args.size() > fn.argc) TypeError("too many positional arguments");
         int spaces = co_nlocals - fn.argc;
-        for(int j=0; j<spaces; j++) PUSH(nullptr);
+        for(int j=0; j<spaces; j++) PUSH(PY_NULL);
         callstack.emplace(&s_data, p0, co, fn._module, callable, FastLocals(co, args.begin()));
         return nullptr;
     }
@@ -1226,7 +1226,7 @@ inline PyObject* VM::_py_call(PyObject** p0, PyObject* callable, ArgsView args,
     // prepare args
     for(int index: fn.decl->args) buffer[index] = args[i++];
     // set extra varnames to nullptr
-    for(int j=i; j<co_nlocals; j++) buffer[j] = nullptr;
+    for(int j=i; j<co_nlocals; j++) buffer[j] = PY_NULL;
 
     // prepare kwdefaults
     for(auto& kv: fn.decl->kwargs) buffer[kv.key] = kv.value;
@@ -1400,7 +1400,7 @@ inline void VM::_error(Exception e){
 inline void ManagedHeap::mark() {
     for(PyObject* obj: _no_gc) OBJ_MARK(obj);
     for(auto& frame : vm->callstack.data()) frame._gc_mark();
-    for(PyObject* obj: vm->s_data) if(obj!=nullptr) OBJ_MARK(obj);
+    for(PyObject* obj: vm->s_data) OBJ_MARK(obj);
     if(vm->_gc_marker_ex != nullptr) vm->_gc_marker_ex(vm);
 }