mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-105481: opcode.h is no longer generated during the build (#108080)
This commit is contained in:
parent
4cb08188e8
commit
0b243c2f66
7 changed files with 99 additions and 72 deletions
|
|
@ -223,6 +223,75 @@ _opcode_get_specialization_stats_impl(PyObject *module)
|
|||
|
||||
/*[clinic input]
|
||||
|
||||
_opcode.get_nb_ops
|
||||
|
||||
Return array of symbols of binary ops.
|
||||
|
||||
Indexed by the BINARY_OP oparg value.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_opcode_get_nb_ops_impl(PyObject *module)
|
||||
/*[clinic end generated code: output=d997d306cc15426f input=9462fc544c823176]*/
|
||||
{
|
||||
PyObject *list = PyList_New(NB_OPARG_LAST + 1);
|
||||
if (list == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
#define ADD_NB_OP(NUM, STR) \
|
||||
do { \
|
||||
PyObject *pair = Py_BuildValue( \
|
||||
"NN", PyUnicode_FromString(#NUM), PyUnicode_FromString(STR)); \
|
||||
if (pair == NULL) { \
|
||||
Py_DECREF(list); \
|
||||
return NULL; \
|
||||
} \
|
||||
PyList_SET_ITEM(list, (NUM), pair); \
|
||||
} while(0);
|
||||
|
||||
ADD_NB_OP(NB_ADD, "+");
|
||||
ADD_NB_OP(NB_AND, "&");
|
||||
ADD_NB_OP(NB_FLOOR_DIVIDE, "//");
|
||||
ADD_NB_OP(NB_LSHIFT, "<<");
|
||||
ADD_NB_OP(NB_MATRIX_MULTIPLY, "@");
|
||||
ADD_NB_OP(NB_MULTIPLY, "*");
|
||||
ADD_NB_OP(NB_REMAINDER, "%");
|
||||
ADD_NB_OP(NB_OR, "|");
|
||||
ADD_NB_OP(NB_POWER, "**");
|
||||
ADD_NB_OP(NB_RSHIFT, ">>");
|
||||
ADD_NB_OP(NB_SUBTRACT, "-");
|
||||
ADD_NB_OP(NB_TRUE_DIVIDE, "/");
|
||||
ADD_NB_OP(NB_XOR, "^");
|
||||
ADD_NB_OP(NB_INPLACE_ADD, "+=");
|
||||
ADD_NB_OP(NB_INPLACE_AND, "&=");
|
||||
ADD_NB_OP(NB_INPLACE_FLOOR_DIVIDE, "//=");
|
||||
ADD_NB_OP(NB_INPLACE_LSHIFT, "<<=");
|
||||
ADD_NB_OP(NB_INPLACE_MATRIX_MULTIPLY, "@=");
|
||||
ADD_NB_OP(NB_INPLACE_MULTIPLY, "*=");
|
||||
ADD_NB_OP(NB_INPLACE_REMAINDER, "%=");
|
||||
ADD_NB_OP(NB_INPLACE_OR, "|=");
|
||||
ADD_NB_OP(NB_INPLACE_POWER, "**=");
|
||||
ADD_NB_OP(NB_INPLACE_RSHIFT, ">>=");
|
||||
ADD_NB_OP(NB_INPLACE_SUBTRACT, "-=");
|
||||
ADD_NB_OP(NB_INPLACE_TRUE_DIVIDE, "/=");
|
||||
ADD_NB_OP(NB_INPLACE_XOR, "^=");
|
||||
|
||||
#undef ADD_NB_OP
|
||||
|
||||
for(int i = 0; i <= NB_OPARG_LAST; i++) {
|
||||
if (PyList_GET_ITEM(list, i) == NULL) {
|
||||
Py_DECREF(list);
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"Missing initialization for NB_OP %d",
|
||||
i);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
|
||||
_opcode.get_intrinsic1_descs
|
||||
|
||||
Return a list of names of the unary intrinsics.
|
||||
|
|
@ -287,6 +356,7 @@ opcode_functions[] = {
|
|||
_OPCODE_HAS_LOCAL_METHODDEF
|
||||
_OPCODE_HAS_EXC_METHODDEF
|
||||
_OPCODE_GET_SPECIALIZATION_STATS_METHODDEF
|
||||
_OPCODE_GET_NB_OPS_METHODDEF
|
||||
_OPCODE_GET_INTRINSIC1_DESCS_METHODDEF
|
||||
_OPCODE_GET_INTRINSIC2_DESCS_METHODDEF
|
||||
{NULL, NULL, 0, NULL}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue