summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-07-14 17:41:52 (GMT)
committerGitHub <noreply@github.com>2023-07-14 17:41:52 (GMT)
commit6a70edf24ca217c5ed4a556d0df5748fc775c762 (patch)
tree425c753711dd2fee50fe57ac7b7940e8bfc49f8d /Python/compile.c
parent243fdcb40ebeb177ce723911c1f7fad8a1fdf6cb (diff)
downloadcpython-6a70edf24ca217c5ed4a556d0df5748fc775c762.zip
cpython-6a70edf24ca217c5ed4a556d0df5748fc775c762.tar.gz
cpython-6a70edf24ca217c5ed4a556d0df5748fc775c762.tar.bz2
gh-105481: expose opcode metadata via the _opcode module (#106688)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c
index d9e38cf..9e86e06 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -36,7 +36,9 @@
#include "pycore_pystate.h" // _Py_GetConfig()
#include "pycore_symtable.h" // PySTEntryObject, _PyFuture_FromAST()
+#define NEED_OPCODE_METADATA
#include "pycore_opcode_metadata.h" // _PyOpcode_opcode_metadata, _PyOpcode_num_popped/pushed
+#undef NEED_OPCODE_METADATA
#define COMP_GENEXP 0
#define COMP_LISTCOMP 1
@@ -864,6 +866,36 @@ PyCompile_OpcodeStackEffect(int opcode, int oparg)
return stack_effect(opcode, oparg, -1);
}
+int
+PyUnstable_OpcodeIsValid(int opcode)
+{
+ return IS_VALID_OPCODE(opcode);
+}
+
+int
+PyUnstable_OpcodeHasArg(int opcode)
+{
+ return OPCODE_HAS_ARG(opcode);
+}
+
+int
+PyUnstable_OpcodeHasConst(int opcode)
+{
+ return OPCODE_HAS_CONST(opcode);
+}
+
+int
+PyUnstable_OpcodeHasName(int opcode)
+{
+ return OPCODE_HAS_NAME(opcode);
+}
+
+int
+PyUnstable_OpcodeHasJump(int opcode)
+{
+ return OPCODE_HAS_JUMP(opcode);
+}
+
static int
codegen_addop_noarg(instr_sequence *seq, int opcode, location loc)
{