mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
some fix
This commit is contained in:
parent
6c46705e98
commit
f53ae5e459
@ -30,8 +30,8 @@ void py_finalize();
|
||||
|
||||
/// Run a simple source string. Do not change the stack.
|
||||
int py_exec(const char*);
|
||||
/// Eval a simple expression.
|
||||
int py_eval(const char*, py_Ref out);
|
||||
/// Eval a simple expression. The result is pushed to the stack.
|
||||
int py_eval(const char*);
|
||||
|
||||
/************* Values Creation *************/
|
||||
void py_newint(py_Ref, int64_t);
|
||||
@ -156,8 +156,8 @@ int py_eq(const py_Ref, const py_Ref);
|
||||
int py_le(const py_Ref, const py_Ref);
|
||||
int py_hash(const py_Ref, int64_t* out);
|
||||
|
||||
int py_str(const py_Ref, py_Ref out);
|
||||
int py_repr(const py_Ref, py_Ref out);
|
||||
int py_str(const py_Ref);
|
||||
int py_repr(const py_Ref);
|
||||
|
||||
int py_vectorcall(int argc, int kwargc);
|
||||
int py_call(py_Ref f, ...);
|
||||
|
@ -87,9 +87,10 @@ pk_FrameResult pk_VM__run_top_frame(pk_VM* self) {
|
||||
}
|
||||
case OP_PRINT_EXPR:
|
||||
if(TOP().type != tp_none_type) {
|
||||
int err = py_repr(&TOP(), &TOP());
|
||||
int err = py_repr(&TOP());
|
||||
if(err) goto __ERROR;
|
||||
self->_stdout("%s\n", py_tostr(&TOP()));
|
||||
POP();
|
||||
}
|
||||
POP();
|
||||
DISPATCH();
|
||||
|
@ -7,9 +7,9 @@ int py_le(const py_Ref lhs, const py_Ref rhs) { return 0; }
|
||||
|
||||
int py_hash(const py_Ref val, int64_t* out) { return 0; }
|
||||
|
||||
int py_str(const py_Ref val, py_Ref out) { return 0; }
|
||||
int py_str(const py_Ref val) { return 0; }
|
||||
|
||||
int py_repr(const py_Ref val, py_Ref out) {
|
||||
int py_repr(const py_Ref val) {
|
||||
const pk_TypeInfo* ti = c11__at(pk_TypeInfo, &pk_current_vm->types, val->type);
|
||||
if(ti->m__repr__) return ti->m__repr__(1, val);
|
||||
return py_callmethod(val, __repr__);
|
||||
|
@ -25,7 +25,7 @@ void py_finalize() {
|
||||
|
||||
int py_exec(const char* source) { PK_UNREACHABLE(); }
|
||||
|
||||
int py_eval(const char* source, py_Ref out) {
|
||||
int py_eval(const char* source) {
|
||||
CodeObject co;
|
||||
pk_SourceData_ src = pk_SourceData__rcnew(source, "main.py", EVAL_MODE, false);
|
||||
Error* err = pk_compile(src, &co);
|
||||
|
@ -27,7 +27,7 @@ int main(int argc, char** argv) {
|
||||
py_initialize();
|
||||
const char* source = "[1, 'a']";
|
||||
|
||||
if(py_eval(source, py_pushtmp())){
|
||||
if(py_eval(source)){
|
||||
py_Error* err = py_getlasterror();
|
||||
py_Error__print(err);
|
||||
}else{
|
||||
@ -37,7 +37,7 @@ int main(int argc, char** argv) {
|
||||
int _L0 = py_toint(_0);
|
||||
const char* _L1 = py_tostr(_1);
|
||||
printf("%d, %s\n", _L0, _L1);
|
||||
py_poptmp(1);
|
||||
py_pop();
|
||||
}
|
||||
|
||||
py_finalize();
|
||||
|
Loading…
x
Reference in New Issue
Block a user