mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 20:10:17 +00:00
...
This commit is contained in:
parent
581a21e407
commit
fdfe20ead1
10
src/base64.h
10
src/base64.h
@ -7,12 +7,12 @@ namespace pkpy {
|
|||||||
|
|
||||||
// https://github.com/zhicheng/base64/blob/master/base64.c
|
// https://github.com/zhicheng/base64/blob/master/base64.c
|
||||||
|
|
||||||
inline static const char BASE64_PAD = '=';
|
const char BASE64_PAD = '=';
|
||||||
inline static const char BASE64DE_FIRST = '+';
|
const char BASE64DE_FIRST = '+';
|
||||||
inline static const char BASE64DE_LAST = 'z';
|
const char BASE64DE_LAST = 'z';
|
||||||
|
|
||||||
/* BASE 64 encode table */
|
/* BASE 64 encode table */
|
||||||
static const char base64en[] = {
|
const char base64en[] = {
|
||||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
'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 */
|
/* 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, */
|
/* nul, soh, stx, etx, eot, enq, ack, bel, */
|
||||||
255, 255, 255, 255, 255, 255, 255, 255,
|
255, 255, 255, 255, 255, 255, 255, 255,
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ __NEXT_STEP:;
|
|||||||
TARGET(LOAD_FAST) {
|
TARGET(LOAD_FAST) {
|
||||||
heap._auto_collect();
|
heap._auto_collect();
|
||||||
_0 = frame->_locals[byte.arg];
|
_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);
|
PUSH(_0);
|
||||||
} DISPATCH();
|
} DISPATCH();
|
||||||
TARGET(LOAD_NAME)
|
TARGET(LOAD_NAME)
|
||||||
@ -195,8 +195,8 @@ __NEXT_STEP:;
|
|||||||
DISPATCH();
|
DISPATCH();
|
||||||
TARGET(DELETE_FAST)
|
TARGET(DELETE_FAST)
|
||||||
_0 = frame->_locals[byte.arg];
|
_0 = frame->_locals[byte.arg];
|
||||||
if(_0 == nullptr) vm->NameError(co->varnames[byte.arg]);
|
if(_0 == PY_NULL) vm->NameError(co->varnames[byte.arg]);
|
||||||
frame->_locals[byte.arg] = nullptr;
|
frame->_locals[byte.arg] = PY_NULL;
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
TARGET(DELETE_NAME)
|
TARGET(DELETE_NAME)
|
||||||
_name = StrName(byte.arg);
|
_name = StrName(byte.arg);
|
||||||
|
@ -158,7 +158,7 @@ inline bool is_both_int(PyObject* a, PyObject* b) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// special singals, is_tagged() for them is true
|
// 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_BEGIN_CALL = (PyObject*)0b010011;
|
||||||
inline PyObject* const PY_OP_CALL = (PyObject*)0b100011;
|
inline PyObject* const PY_OP_CALL = (PyObject*)0b100011;
|
||||||
inline PyObject* const PY_OP_YIELD = (PyObject*)0b110011;
|
inline PyObject* const PY_OP_YIELD = (PyObject*)0b110011;
|
||||||
|
6
src/vm.h
6
src/vm.h
@ -1215,7 +1215,7 @@ inline PyObject* VM::_py_call(PyObject** p0, PyObject* callable, ArgsView args,
|
|||||||
if(fn.is_simple){
|
if(fn.is_simple){
|
||||||
if(args.size() > fn.argc) TypeError("too many positional arguments");
|
if(args.size() > fn.argc) TypeError("too many positional arguments");
|
||||||
int spaces = co_nlocals - fn.argc;
|
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()));
|
callstack.emplace(&s_data, p0, co, fn._module, callable, FastLocals(co, args.begin()));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1226,7 +1226,7 @@ inline PyObject* VM::_py_call(PyObject** p0, PyObject* callable, ArgsView args,
|
|||||||
// prepare args
|
// prepare args
|
||||||
for(int index: fn.decl->args) buffer[index] = args[i++];
|
for(int index: fn.decl->args) buffer[index] = args[i++];
|
||||||
// set extra varnames to nullptr
|
// 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
|
// prepare kwdefaults
|
||||||
for(auto& kv: fn.decl->kwargs) buffer[kv.key] = kv.value;
|
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() {
|
inline void ManagedHeap::mark() {
|
||||||
for(PyObject* obj: _no_gc) OBJ_MARK(obj);
|
for(PyObject* obj: _no_gc) OBJ_MARK(obj);
|
||||||
for(auto& frame : vm->callstack.data()) frame._gc_mark();
|
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);
|
if(vm->_gc_marker_ex != nullptr) vm->_gc_marker_ex(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user