mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
...
This commit is contained in:
parent
816ad3b149
commit
e49e204c28
@ -590,11 +590,6 @@ inline void add_module_time(VM* vm){
|
|||||||
inline void add_module_sys(VM* vm){
|
inline void add_module_sys(VM* vm){
|
||||||
PyObject* mod = vm->new_module("sys");
|
PyObject* mod = vm->new_module("sys");
|
||||||
vm->setattr(mod, "version", VAR(PK_VERSION));
|
vm->setattr(mod, "version", VAR(PK_VERSION));
|
||||||
vm->bind_func<0>(mod, "getrecursionlimit", CPP_LAMBDA(VAR(vm->recursionlimit)));
|
|
||||||
vm->bind_func<1>(mod, "setrecursionlimit", [](VM* vm, ArgsView args) {
|
|
||||||
vm->recursionlimit = CAST(int, args[0]);
|
|
||||||
return vm->None;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void add_module_json(VM* vm){
|
inline void add_module_json(VM* vm){
|
||||||
|
5
src/vm.h
5
src/vm.h
@ -104,8 +104,6 @@ public:
|
|||||||
Type tp_slice, tp_range, tp_module;
|
Type tp_slice, tp_range, tp_module;
|
||||||
Type tp_super, tp_exception;
|
Type tp_super, tp_exception;
|
||||||
|
|
||||||
i64 recursionlimit = 1000;
|
|
||||||
|
|
||||||
VM(bool use_stdio) : heap(this){
|
VM(bool use_stdio) : heap(this){
|
||||||
this->vm = this;
|
this->vm = this;
|
||||||
this->_stdout = use_stdio ? &std::cout : &_stdout_buffer;
|
this->_stdout = use_stdio ? &std::cout : &_stdout_buffer;
|
||||||
@ -331,7 +329,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StackOverflowError() { _error("StackOverflowError", ""); }
|
void StackOverflowError() { _error("StackOverflowError", ""); }
|
||||||
void RecursionError() { _error("RecursionError", "maximum recursion depth exceeded"); }
|
|
||||||
void IOError(const Str& msg) { _error("IOError", msg); }
|
void IOError(const Str& msg) { _error("IOError", msg); }
|
||||||
void NotImplementedError(){ _error("NotImplementedError", ""); }
|
void NotImplementedError(){ _error("NotImplementedError", ""); }
|
||||||
void TypeError(const Str& msg){ _error("TypeError", msg); }
|
void TypeError(const Str& msg){ _error("TypeError", msg); }
|
||||||
@ -866,7 +863,7 @@ inline PyObject* VM::vectorcall(int ARGC, int KWARGC, bool op_call){
|
|||||||
|
|
||||||
inline PyObject* VM::_py_call(PyObject** p0, PyObject* callable, ArgsView args, ArgsView kwargs){
|
inline PyObject* VM::_py_call(PyObject** p0, PyObject* callable, ArgsView args, ArgsView kwargs){
|
||||||
// callable must be a `function` object
|
// callable must be a `function` object
|
||||||
if(callstack.size() >= recursionlimit) RecursionError();
|
if(s_data.is_overflow()) StackOverflowError();
|
||||||
|
|
||||||
const Function& fn = CAST(Function&, callable);
|
const Function& fn = CAST(Function&, callable);
|
||||||
const CodeObject* co = fn.decl->code.get();
|
const CodeObject* co = fn.decl->code.get();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user