mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
some fix
This commit is contained in:
parent
79158fb4cd
commit
2ad01d1b79
@ -1083,7 +1083,7 @@ __LISTCOMP:
|
||||
}
|
||||
|
||||
void __throw_e(_Str type, _Str msg){
|
||||
auto e = _Exception("SyntaxError", msg, false);
|
||||
auto e = _Exception("SyntaxError", msg);
|
||||
e.st_push(getLineSnapshot());
|
||||
throw e;
|
||||
}
|
||||
|
@ -71,11 +71,11 @@ struct SourceData {
|
||||
class _Exception {
|
||||
_Str type;
|
||||
_Str msg;
|
||||
bool is_re;
|
||||
std::stack<_Str> stacktrace;
|
||||
public:
|
||||
_Exception(_Str type, _Str msg, bool is_re): type(type), msg(msg), is_re(is_re) {}
|
||||
_Exception(_Str type, _Str msg): type(type), msg(msg) {}
|
||||
bool match_type(const _Str& type) const { return this->type == type;}
|
||||
bool is_re = true;
|
||||
|
||||
void st_push(_Str snapshot){
|
||||
if(stacktrace.size() >= 8) return;
|
||||
|
@ -6,7 +6,12 @@
|
||||
|
||||
_Code VM::compile(_Str source, _Str filename, CompileMode mode) {
|
||||
Compiler compiler(this, source.c_str(), filename, mode);
|
||||
return compiler.__fillCode();
|
||||
try{
|
||||
return compiler.__fillCode();
|
||||
}catch(_Exception& e){
|
||||
_error(e);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#define BIND_NUM_ARITH_OPT(name, op) \
|
||||
|
9
src/vm.h
9
src/vm.h
@ -908,7 +908,14 @@ public:
|
||||
/***** Error Reporter *****/
|
||||
private:
|
||||
void _error(const _Str& name, const _Str& msg){
|
||||
auto e = _Exception(name, msg, true);
|
||||
_error(_Exception(name, msg));
|
||||
}
|
||||
|
||||
void _error(_Exception e){
|
||||
if(callstack.empty()){
|
||||
e.is_re = false;
|
||||
throw e;
|
||||
}
|
||||
top_frame()->push(PyException(e));
|
||||
_raise();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user