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