diff options
author | Mark Shannon <mark@hotpy.org> | 2022-11-04 23:37:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-04 23:37:53 (GMT) |
commit | 7a020b8e5b1bfabfa57789be489b81eba5baa623 (patch) | |
tree | a4377e1c5ce4c3d22306a7aec721c30cab58d9d6 /Python/bytecodes.c | |
parent | c885623e9fa596cbe4fd359ea4aedfbde0ae2482 (diff) | |
download | cpython-7a020b8e5b1bfabfa57789be489b81eba5baa623.zip cpython-7a020b8e5b1bfabfa57789be489b81eba5baa623.tar.gz cpython-7a020b8e5b1bfabfa57789be489b81eba5baa623.tar.bz2 |
GH-98831: Add some macros definitions to bytecodes.c to reduce IDE warnings. (#99093)
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r-- | Python/bytecodes.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 072eee4..16ac1d9 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -28,10 +28,37 @@ void _PyFloat_ExactDealloc(PyObject *); void _PyUnicode_ExactDealloc(PyObject *); +/* Stack effect macros + * These will be mostly replaced by stack effect descriptions, + * but the tooling need to recognize them. + */ #define SET_TOP(v) (stack_pointer[-1] = (v)) +#define SET_SECOND(v) (stack_pointer[-2] = (v)) #define PEEK(n) (stack_pointer[-(n)]) - +#define PUSH(val) (*(stack_pointer++) = (val)) +#define POP() (*(--stack_pointer)) +#define TOP() PEEK(1) +#define SECOND() PEEK(2) +#define STACK_GROW(n) (stack_pointer += (n)) +#define STACK_SHRINK(n) (stack_pointer -= (n)) +#define EMPTY() 1 +#define STACK_LEVEL() 2 + +/* Local variable macros */ #define GETLOCAL(i) (frame->localsplus[i]) +#define SETLOCAL(i, val) \ +do { \ + PyObject *_tmp = frame->localsplus[i]; \ + frame->localsplus[i] = (val); \ + Py_XDECREF(_tmp); \ +} while (0) + +/* Flow control macros */ +#define DEOPT_IF(cond, instname) ((void)0) +#define JUMPBY(offset) ((void)0) +#define GO_TO_INSTRUCTION(instname) ((void)0) +#define DISPATCH_SAME_OPARG() ((void)0) +#define DISPATCH() ((void)0) #define inst(name) case name: #define family(name) static int family_##name @@ -43,7 +70,7 @@ typedef struct { PyObject *kwnames; } CallShape; -static void +static PyObject * dummy_func( PyThreadState *tstate, _PyInterpreterFrame *frame, |