mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-105481: Generate the opcode lists in dis from data extracted from bytecodes.c (#106758)
This commit is contained in:
parent
3535ef1eec
commit
40f3f11a77
16 changed files with 402 additions and 158 deletions
|
|
@ -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}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue