mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
Update vm.h
This commit is contained in:
parent
fcf9dcf41d
commit
c329f83520
23
src/vm.h
23
src/vm.h
@ -3,20 +3,14 @@
|
||||
#include "codeobject.h"
|
||||
#include "error.h"
|
||||
|
||||
#define __DEF_PY_AS_C(type, ctype, ptype) \
|
||||
inline ctype& Py##type##_AS_C(const PyVar& obj) { \
|
||||
check_type(obj, ptype); \
|
||||
return OBJ_GET(ctype, obj); \
|
||||
}
|
||||
|
||||
#define __DEF_PY(type, ctype, ptype) \
|
||||
inline PyVar Py##type(ctype value) { \
|
||||
return new_object(ptype, value); \
|
||||
}
|
||||
|
||||
#define DEF_NATIVE(type, ctype, ptype) \
|
||||
__DEF_PY(type, ctype, ptype) \
|
||||
__DEF_PY_AS_C(type, ctype, ptype)
|
||||
inline ctype& Py##type##_AS_C(const PyVar& obj) { \
|
||||
check_type(obj, ptype); \
|
||||
return OBJ_GET(ctype, obj); \
|
||||
} \
|
||||
inline PyVar Py##type(ctype value) { \
|
||||
return new_object(ptype, value); \
|
||||
}
|
||||
|
||||
|
||||
class VM {
|
||||
@ -55,8 +49,7 @@ class VM {
|
||||
} break;
|
||||
case OP_BUILD_INDEX_REF: {
|
||||
PyVar index = frame->pop_value(this);
|
||||
PyVarRef obj = frame->pop_value(this);
|
||||
frame->push(PyRef(IndexRef(obj, index)));
|
||||
frame->push(PyRef(IndexRef(frame->pop_value(this), index)));
|
||||
} break;
|
||||
case OP_STORE_REF: {
|
||||
PyVar obj = frame->pop_value(this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user