summaryrefslogtreecommitdiffstats
path: root/Modules/_opcode.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-07-18 18:42:44 (GMT)
committerGitHub <noreply@github.com>2023-07-18 18:42:44 (GMT)
commit40f3f11a773b854c6d94746aa3b1881c8ac71b0f (patch)
treec82e804e0006a9bd35d0b3715afa51bf035ea7db /Modules/_opcode.c
parent3535ef1eec2563bbd7bff7c830465441fbbf759e (diff)
downloadcpython-40f3f11a773b854c6d94746aa3b1881c8ac71b0f.zip
cpython-40f3f11a773b854c6d94746aa3b1881c8ac71b0f.tar.gz
cpython-40f3f11a773b854c6d94746aa3b1881c8ac71b0f.tar.bz2
gh-105481: Generate the opcode lists in dis from data extracted from bytecodes.c (#106758)
Diffstat (limited to 'Modules/_opcode.c')
-rw-r--r--Modules/_opcode.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/Modules/_opcode.c b/Modules/_opcode.c
index b3b9873..daabdce 100644
--- a/Modules/_opcode.c
+++ b/Modules/_opcode.c
@@ -147,6 +147,63 @@ _opcode_has_jump_impl(PyObject *module, int opcode)
/*[clinic input]
+_opcode.has_free -> bool
+
+ opcode: int
+
+Return True if the opcode accesses a free variable, False otherwise.
+
+Note that 'free' in this context refers to names in the current scope
+that are referenced by inner scopes or names in outer scopes that are
+referenced from this scope. It does not include references to global
+or builtin scopes.
+[clinic start generated code]*/
+
+static int
+_opcode_has_free_impl(PyObject *module, int opcode)
+/*[clinic end generated code: output=d81ae4d79af0ee26 input=117dcd5c19c1139b]*/
+{
+ return PyUnstable_OpcodeIsValid(opcode) &&
+ PyUnstable_OpcodeHasFree(opcode);
+
+}
+
+/*[clinic input]
+
+_opcode.has_local -> bool
+
+ opcode: int
+
+Return True if the opcode accesses a local variable, False otherwise.
+[clinic start generated code]*/
+
+static int
+_opcode_has_local_impl(PyObject *module, int opcode)
+/*[clinic end generated code: output=da5a8616b7a5097b input=9a798ee24aaef49d]*/
+{
+ return PyUnstable_OpcodeIsValid(opcode) &&
+ PyUnstable_OpcodeHasLocal(opcode);
+}
+
+/*[clinic input]
+
+_opcode.has_exc -> bool
+
+ opcode: int
+
+Return True if the opcode sets an exception handler, False otherwise.
+[clinic start generated code]*/
+
+static int
+_opcode_has_exc_impl(PyObject *module, int opcode)
+/*[clinic end generated code: output=41b68dff0ec82a52 input=db0e4bdb9bf13fa5]*/
+{
+ return PyUnstable_OpcodeIsValid(opcode) &&
+ PyUnstable_OpcodeHasExc(opcode);
+}
+
+/*[clinic input]
+
_opcode.get_specialization_stats
Return the specialization stats
@@ -171,6 +228,9 @@ opcode_functions[] = {
_OPCODE_HAS_CONST_METHODDEF
_OPCODE_HAS_NAME_METHODDEF
_OPCODE_HAS_JUMP_METHODDEF
+ _OPCODE_HAS_FREE_METHODDEF
+ _OPCODE_HAS_LOCAL_METHODDEF
+ _OPCODE_HAS_EXC_METHODDEF
_OPCODE_GET_SPECIALIZATION_STATS_METHODDEF
{NULL, NULL, 0, NULL}
};