mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
some fix
This commit is contained in:
parent
455aa576e5
commit
6c46705e98
@ -87,10 +87,9 @@ pk_FrameResult pk_VM__run_top_frame(pk_VM* self) {
|
|||||||
}
|
}
|
||||||
case OP_PRINT_EXPR:
|
case OP_PRINT_EXPR:
|
||||||
if(TOP().type != tp_none_type) {
|
if(TOP().type != tp_none_type) {
|
||||||
int err = py_repr(&TOP(), NULL);
|
int err = py_repr(&TOP(), &TOP());
|
||||||
if(err) goto __ERROR;
|
if(err) goto __ERROR;
|
||||||
self->_stdout("%s\n", py_tostr(&TOP()));
|
self->_stdout("%s\n", py_tostr(&TOP()));
|
||||||
POP();
|
|
||||||
}
|
}
|
||||||
POP();
|
POP();
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
|
@ -11,10 +11,6 @@ int py_str(const py_Ref val, py_Ref out) { return 0; }
|
|||||||
|
|
||||||
int py_repr(const py_Ref val, py_Ref out) {
|
int py_repr(const py_Ref val, py_Ref out) {
|
||||||
const pk_TypeInfo* ti = c11__at(pk_TypeInfo, &pk_current_vm->types, val->type);
|
const pk_TypeInfo* ti = c11__at(pk_TypeInfo, &pk_current_vm->types, val->type);
|
||||||
int err;
|
if(ti->m__repr__) return ti->m__repr__(1, val);
|
||||||
if(ti->m__repr__) err = ti->m__repr__(1, val);
|
return py_callmethod(val, __repr__);
|
||||||
err = py_callmethod(val, __repr__);
|
|
||||||
if(err) return err;
|
|
||||||
if(out) *out = *--pk_current_vm->stack.sp;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
@ -40,9 +40,6 @@ int py_eval(const char* source, py_Ref out) {
|
|||||||
CodeObject__dtor(&co);
|
CodeObject__dtor(&co);
|
||||||
PK_DECREF(src);
|
PK_DECREF(src);
|
||||||
if(res == RES_ERROR) return vm->last_error->type;
|
if(res == RES_ERROR) return vm->last_error->type;
|
||||||
if(res == RES_RETURN){
|
if(res == RES_RETURN) return 0;
|
||||||
if(out) *out = *--vm->stack.sp;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
PK_UNREACHABLE();
|
PK_UNREACHABLE();
|
||||||
}
|
}
|
@ -27,7 +27,7 @@ int main(int argc, char** argv) {
|
|||||||
py_initialize();
|
py_initialize();
|
||||||
const char* source = "[1, 'a']";
|
const char* source = "[1, 'a']";
|
||||||
|
|
||||||
if(py_eval(source, NULL)){
|
if(py_eval(source, py_pushtmp())){
|
||||||
py_Error* err = py_getlasterror();
|
py_Error* err = py_getlasterror();
|
||||||
py_Error__print(err);
|
py_Error__print(err);
|
||||||
}else{
|
}else{
|
||||||
@ -37,7 +37,7 @@ int main(int argc, char** argv) {
|
|||||||
int _L0 = py_toint(_0);
|
int _L0 = py_toint(_0);
|
||||||
const char* _L1 = py_tostr(_1);
|
const char* _L1 = py_tostr(_1);
|
||||||
printf("%d, %s\n", _L0, _L1);
|
printf("%d, %s\n", _L0, _L1);
|
||||||
py_pop();
|
py_poptmp(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
py_finalize();
|
py_finalize();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user