gh-105481: Generate the opcode lists in dis from data extracted from bytecodes.c (#106758)

This commit is contained in:
Irit Katriel 2023-07-18 19:42:44 +01:00 committed by GitHub
parent 3535ef1eec
commit 40f3f11a77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 402 additions and 158 deletions

View file

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