mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
some move
This commit is contained in:
parent
a55d3a5340
commit
4a5f74b2d2
@ -146,6 +146,13 @@ int py_eq(const py_Ref, const py_Ref);
|
|||||||
int py_le(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_hash(const py_Ref, int64_t* 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, ...);
|
||||||
|
int py_callmethod(py_Ref self, py_Name name, ...);
|
||||||
|
|
||||||
#define py_isnull(self) ((self)->type == 0)
|
#define py_isnull(self) ((self)->type == 0)
|
||||||
|
|
||||||
/* tuple */
|
/* tuple */
|
||||||
@ -175,9 +182,6 @@ void py_dict__setitem(py_Ref self, const py_Ref key, const py_Ref val);
|
|||||||
void py_dict__delitem(py_Ref self, const py_Ref key);
|
void py_dict__delitem(py_Ref self, const py_Ref key);
|
||||||
void py_dict__clear(py_Ref self);
|
void py_dict__clear(py_Ref self);
|
||||||
|
|
||||||
int py_str(const py_Ref, py_Str* out);
|
|
||||||
int py_repr(const py_Ref, py_Str* out);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -83,11 +83,10 @@ 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) {
|
||||||
py_Str out;
|
int err = py_repr(&TOP());
|
||||||
int err = py_repr(&TOP(), &out);
|
|
||||||
if(err) goto __ERROR;
|
if(err) goto __ERROR;
|
||||||
self->_stdout("%s\n", py_Str__data(&out));
|
self->_stdout("%s\n", py_tostr(&TOP()));
|
||||||
py_Str__dtor(&out);
|
POP();
|
||||||
}
|
}
|
||||||
POP();
|
POP();
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#include "pocketpy/interpreter/vm.h"
|
|
||||||
#include "pocketpy/pocketpy.h"
|
|
||||||
|
|
||||||
int py_eq(const py_Ref lhs, const py_Ref rhs){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int py_le(const py_Ref lhs, const py_Ref rhs){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int py_hash(const py_Ref self, int64_t* out){
|
|
||||||
return 0;
|
|
||||||
}
|
|
16
src/public/py_ops.c
Normal file
16
src/public/py_ops.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include "pocketpy/interpreter/vm.h"
|
||||||
|
#include "pocketpy/pocketpy.h"
|
||||||
|
|
||||||
|
int py_eq(const py_Ref lhs, const py_Ref rhs) { return 0; }
|
||||||
|
|
||||||
|
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) { return 0; }
|
||||||
|
|
||||||
|
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__);
|
||||||
|
}
|
@ -95,9 +95,9 @@ void py_pushstr(const char* val) { py_newstr(pk_current_vm->stack.sp++, val); }
|
|||||||
|
|
||||||
void py_pushstrn(const char* val, int size) { py_newstrn(pk_current_vm->stack.sp++, val, size); }
|
void py_pushstrn(const char* val, int size) { py_newstrn(pk_current_vm->stack.sp++, val, size); }
|
||||||
|
|
||||||
void py_push_none() { py_newnone(pk_current_vm->stack.sp++); }
|
void py_pushnone() { py_newnone(pk_current_vm->stack.sp++); }
|
||||||
|
|
||||||
void py_push_null() { py_newnull(pk_current_vm->stack.sp++); }
|
void py_pushnull() { py_newnull(pk_current_vm->stack.sp++); }
|
||||||
|
|
||||||
void py_push_notimplemented() {
|
void py_push_notimplemented() {
|
||||||
pk_VM* vm = pk_current_vm;
|
pk_VM* vm = pk_current_vm;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user