mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 04:20:17 +00:00
some rename
This commit is contained in:
parent
8795d2c06d
commit
d313257d48
@ -167,9 +167,6 @@ public:
|
|||||||
|
|
||||||
void set_main_argv(int argc, char** argv);
|
void set_main_argv(int argc, char** argv);
|
||||||
|
|
||||||
void __breakpoint();
|
|
||||||
void __pop_frame();
|
|
||||||
|
|
||||||
PyObject* py_str(PyObject* obj);
|
PyObject* py_str(PyObject* obj);
|
||||||
PyObject* py_repr(PyObject* obj);
|
PyObject* py_repr(PyObject* obj);
|
||||||
PyObject* py_json(PyObject* obj);
|
PyObject* py_json(PyObject* obj);
|
||||||
@ -300,29 +297,25 @@ public:
|
|||||||
PyObject* __minmax_reduce(bool (VM::*op)(PyObject*, PyObject*), PyObject* args, PyObject* key);
|
PyObject* __minmax_reduce(bool (VM::*op)(PyObject*, PyObject*), PyObject* args, PyObject* key);
|
||||||
|
|
||||||
/***** Error Reporter *****/
|
/***** Error Reporter *****/
|
||||||
void __raise_exc(bool re_raise=false);
|
void StackOverflowError() { __builtin_error("StackOverflowError"); }
|
||||||
|
void IOError(const Str& msg) { __builtin_error("IOError", msg); }
|
||||||
void _builtin_error(StrName type);
|
void NotImplementedError(){ __builtin_error("NotImplementedError"); }
|
||||||
void _builtin_error(StrName type, PyObject* arg);
|
void TypeError(const Str& msg){ __builtin_error("TypeError", msg); }
|
||||||
void _builtin_error(StrName type, const Str& msg);
|
void IndexError(const Str& msg){ __builtin_error("IndexError", msg); }
|
||||||
|
void ValueError(const Str& msg){ __builtin_error("ValueError", msg); }
|
||||||
void StackOverflowError() { _builtin_error("StackOverflowError"); }
|
void RuntimeError(const Str& msg){ __builtin_error("RuntimeError", msg); }
|
||||||
void IOError(const Str& msg) { _builtin_error("IOError", msg); }
|
void ZeroDivisionError(const Str& msg){ __builtin_error("ZeroDivisionError", msg); }
|
||||||
void NotImplementedError(){ _builtin_error("NotImplementedError"); }
|
void ZeroDivisionError(){ __builtin_error("ZeroDivisionError", "division by zero"); }
|
||||||
void TypeError(const Str& msg){ _builtin_error("TypeError", msg); }
|
void NameError(StrName name){ __builtin_error("NameError", _S("name ", name.escape() + " is not defined")); }
|
||||||
void IndexError(const Str& msg){ _builtin_error("IndexError", msg); }
|
void UnboundLocalError(StrName name){ __builtin_error("UnboundLocalError", _S("local variable ", name.escape() + " referenced before assignment")); }
|
||||||
void ValueError(const Str& msg){ _builtin_error("ValueError", msg); }
|
void KeyError(PyObject* obj){ __builtin_error("KeyError", obj); }
|
||||||
void RuntimeError(const Str& msg){ _builtin_error("RuntimeError", msg); }
|
void ImportError(const Str& msg){ __builtin_error("ImportError", msg); }
|
||||||
void ZeroDivisionError(const Str& msg){ _builtin_error("ZeroDivisionError", msg); }
|
void AssertionError(const Str& msg){ __builtin_error("AssertionError", msg); }
|
||||||
void ZeroDivisionError(){ _builtin_error("ZeroDivisionError", "division by zero"); }
|
void AssertionError(){ __builtin_error("AssertionError"); }
|
||||||
void NameError(StrName name){ _builtin_error("NameError", _S("name ", name.escape() + " is not defined")); }
|
|
||||||
void UnboundLocalError(StrName name){ _builtin_error("UnboundLocalError", _S("local variable ", name.escape() + " referenced before assignment")); }
|
|
||||||
void KeyError(PyObject* obj){ _builtin_error("KeyError", obj); }
|
|
||||||
void ImportError(const Str& msg){ _builtin_error("ImportError", msg); }
|
|
||||||
|
|
||||||
void BinaryOptError(const char* op, PyObject* _0, PyObject* _1);
|
void BinaryOptError(const char* op, PyObject* _0, PyObject* _1);
|
||||||
void AttributeError(PyObject* obj, StrName name);
|
void AttributeError(PyObject* obj, StrName name);
|
||||||
void AttributeError(const Str& msg){ _builtin_error("AttributeError", msg); }
|
void AttributeError(const Str& msg){ __builtin_error("AttributeError", msg); }
|
||||||
|
|
||||||
void check_type(PyObject* obj, Type type){
|
void check_type(PyObject* obj, Type type){
|
||||||
if(is_type(obj, type)) return;
|
if(is_type(obj, type)) return;
|
||||||
@ -376,13 +369,10 @@ public:
|
|||||||
|
|
||||||
ImportContext _import_context;
|
ImportContext _import_context;
|
||||||
PyObject* py_import(Str path, bool throw_err=true);
|
PyObject* py_import(Str path, bool throw_err=true);
|
||||||
virtual ~VM();
|
|
||||||
|
|
||||||
#if PK_DEBUG_CEVAL_STEP
|
#if PK_DEBUG_CEVAL_STEP
|
||||||
void _log_s_data(const char* title = nullptr);
|
void _log_s_data(const char* title = nullptr);
|
||||||
#endif
|
#endif
|
||||||
void __unpack_as_list(ArgsView args, List& list);
|
|
||||||
void __unpack_as_dict(ArgsView args, Dict& dict);
|
|
||||||
PyObject* vectorcall(int ARGC, int KWARGC=0, bool op_call=false);
|
PyObject* vectorcall(int ARGC, int KWARGC=0, bool op_call=false);
|
||||||
PyObject* py_negate(PyObject* obj);
|
PyObject* py_negate(PyObject* obj);
|
||||||
bool py_bool(PyObject* obj);
|
bool py_bool(PyObject* obj);
|
||||||
@ -390,8 +380,6 @@ public:
|
|||||||
PyObject* py_list(PyObject*);
|
PyObject* py_list(PyObject*);
|
||||||
PyObject* new_module(Str name, Str package="");
|
PyObject* new_module(Str name, Str package="");
|
||||||
Str disassemble(CodeObject_ co);
|
Str disassemble(CodeObject_ co);
|
||||||
void __init_builtin_types();
|
|
||||||
void __post_init_builtin_types();
|
|
||||||
PyObject* getattr(PyObject* obj, StrName name, bool throw_err=true);
|
PyObject* getattr(PyObject* obj, StrName name, bool throw_err=true);
|
||||||
void delattr(PyObject* obj, StrName name);
|
void delattr(PyObject* obj, StrName name);
|
||||||
PyObject* get_unbound_method(PyObject* obj, StrName name, PyObject** self, bool throw_err=true, bool fallback=false);
|
PyObject* get_unbound_method(PyObject* obj, StrName name, PyObject** self, bool throw_err=true, bool fallback=false);
|
||||||
@ -404,11 +392,7 @@ public:
|
|||||||
template<int ARGC>
|
template<int ARGC>
|
||||||
PyObject* bind_func(PyObject*, StrName, NativeFuncC, UserData userdata={}, BindType bt=BindType::DEFAULT);
|
PyObject* bind_func(PyObject*, StrName, NativeFuncC, UserData userdata={}, BindType bt=BindType::DEFAULT);
|
||||||
void _error(PyObject*);
|
void _error(PyObject*);
|
||||||
PyObject* __run_top_frame();
|
|
||||||
PyObject* __format_string(Str, PyObject*);
|
|
||||||
PyObject* __py_generator(Frame&& frame, ArgsView buffer);
|
|
||||||
void __op_unpack_sequence(uint16_t arg);
|
|
||||||
void __prepare_py_call(PyObject**, ArgsView, ArgsView, const FuncDecl_&);
|
|
||||||
// new style binding api
|
// new style binding api
|
||||||
PyObject* bind(PyObject*, const char*, const char*, NativeFuncC, UserData userdata={}, BindType bt=BindType::DEFAULT);
|
PyObject* bind(PyObject*, const char*, const char*, NativeFuncC, UserData userdata={}, BindType bt=BindType::DEFAULT);
|
||||||
PyObject* bind(PyObject*, const char*, NativeFuncC, UserData userdata={}, BindType bt=BindType::DEFAULT);
|
PyObject* bind(PyObject*, const char*, NativeFuncC, UserData userdata={}, BindType bt=BindType::DEFAULT);
|
||||||
@ -452,6 +436,25 @@ public:
|
|||||||
}
|
}
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ~VM();
|
||||||
|
|
||||||
|
/***** Private *****/
|
||||||
|
void __breakpoint();
|
||||||
|
void __pop_frame();
|
||||||
|
PyObject* __run_top_frame();
|
||||||
|
PyObject* __format_string(Str, PyObject*);
|
||||||
|
PyObject* __py_generator(Frame&& frame, ArgsView buffer);
|
||||||
|
void __op_unpack_sequence(uint16_t arg);
|
||||||
|
void __prepare_py_call(PyObject**, ArgsView, ArgsView, const FuncDecl_&);
|
||||||
|
void __unpack_as_list(ArgsView args, List& list);
|
||||||
|
void __unpack_as_dict(ArgsView args, Dict& dict);
|
||||||
|
void __raise_exc(bool re_raise=false);
|
||||||
|
void __init_builtin_types();
|
||||||
|
void __post_init_builtin_types();
|
||||||
|
void __builtin_error(StrName type);
|
||||||
|
void __builtin_error(StrName type, PyObject* arg);
|
||||||
|
void __builtin_error(StrName type, const Str& msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -927,16 +927,16 @@ __NEXT_STEP:;
|
|||||||
TOP() = call(TOP());
|
TOP() = call(TOP());
|
||||||
}
|
}
|
||||||
if(!isinstance(TOP(), tp_exception)){
|
if(!isinstance(TOP(), tp_exception)){
|
||||||
_builtin_error("TypeError", "exceptions must derive from Exception");
|
TypeError("exceptions must derive from Exception");
|
||||||
}
|
}
|
||||||
_error(POPX());
|
_error(POPX());
|
||||||
} DISPATCH();
|
} DISPATCH();
|
||||||
case OP_RAISE_ASSERT:
|
case OP_RAISE_ASSERT:
|
||||||
if(byte.arg){
|
if(byte.arg){
|
||||||
PyObject* _0 = py_str(POPX());
|
PyObject* _0 = py_str(POPX());
|
||||||
_builtin_error("AssertionError", CAST(Str, _0));
|
AssertionError(CAST(Str, _0));
|
||||||
}else{
|
}else{
|
||||||
_builtin_error("AssertionError");
|
AssertionError();
|
||||||
}
|
}
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
case OP_RE_RAISE: __raise_exc(true); DISPATCH();
|
case OP_RE_RAISE: __raise_exc(true); DISPATCH();
|
||||||
|
10
src/vm.cpp
10
src/vm.cpp
@ -1268,9 +1268,9 @@ PyObject* VM::bind_property(PyObject* obj, const char* name, NativeFuncC fget, N
|
|||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VM::_builtin_error(StrName type){ _error(call(builtins->attr(type))); }
|
void VM::__builtin_error(StrName type){ _error(call(builtins->attr(type))); }
|
||||||
void VM::_builtin_error(StrName type, PyObject* arg){ _error(call(builtins->attr(type), arg)); }
|
void VM::__builtin_error(StrName type, PyObject* arg){ _error(call(builtins->attr(type), arg)); }
|
||||||
void VM::_builtin_error(StrName type, const Str& msg){ _builtin_error(type, VAR(msg)); }
|
void VM::__builtin_error(StrName type, const Str& msg){ __builtin_error(type, VAR(msg)); }
|
||||||
|
|
||||||
void VM::BinaryOptError(const char* op, PyObject* _0, PyObject* _1) {
|
void VM::BinaryOptError(const char* op, PyObject* _0, PyObject* _1) {
|
||||||
StrName name_0 = _type_name(vm, _tp(_0));
|
StrName name_0 = _type_name(vm, _tp(_0));
|
||||||
@ -1280,9 +1280,9 @@ void VM::BinaryOptError(const char* op, PyObject* _0, PyObject* _1) {
|
|||||||
|
|
||||||
void VM::AttributeError(PyObject* obj, StrName name){
|
void VM::AttributeError(PyObject* obj, StrName name){
|
||||||
if(isinstance(obj, vm->tp_type)){
|
if(isinstance(obj, vm->tp_type)){
|
||||||
_builtin_error("AttributeError", _S("type object ", _type_name(vm, PK_OBJ_GET(Type, obj)).escape(), " has no attribute ", name.escape()));
|
__builtin_error("AttributeError", _S("type object ", _type_name(vm, PK_OBJ_GET(Type, obj)).escape(), " has no attribute ", name.escape()));
|
||||||
}else{
|
}else{
|
||||||
_builtin_error("AttributeError", _S(_type_name(vm, _tp(obj)).escape(), " object has no attribute ", name.escape()));
|
__builtin_error("AttributeError", _S(_type_name(vm, _tp(obj)).escape(), " object has no attribute ", name.escape()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user