Update vm.h

This commit is contained in:
blueloveTH 2023-02-10 03:27:24 +08:00
parent fcf9dcf41d
commit c329f83520

View File

@ -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);