mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-105481: do not auto-generate pycore_intrinsics.h (#106913)
This commit is contained in:
parent
214a25dd81
commit
9c81fc2dbe
11 changed files with 174 additions and 91 deletions
|
@ -698,14 +698,14 @@ dummy_func(
|
|||
|
||||
inst(CALL_INTRINSIC_1, (value -- res)) {
|
||||
assert(oparg <= MAX_INTRINSIC_1);
|
||||
res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value);
|
||||
res = _PyIntrinsics_UnaryFunctions[oparg].func(tstate, value);
|
||||
DECREF_INPUTS();
|
||||
ERROR_IF(res == NULL, error);
|
||||
}
|
||||
|
||||
inst(CALL_INTRINSIC_2, (value2, value1 -- res)) {
|
||||
assert(oparg <= MAX_INTRINSIC_2);
|
||||
res = _PyIntrinsics_BinaryFunctions[oparg](tstate, value2, value1);
|
||||
res = _PyIntrinsics_BinaryFunctions[oparg].func(tstate, value2, value1);
|
||||
DECREF_INPUTS();
|
||||
ERROR_IF(res == NULL, error);
|
||||
}
|
||||
|
|
4
Python/executor_cases.c.h
generated
4
Python/executor_cases.c.h
generated
|
@ -558,7 +558,7 @@
|
|||
PyObject *value = stack_pointer[-1];
|
||||
PyObject *res;
|
||||
assert(oparg <= MAX_INTRINSIC_1);
|
||||
res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value);
|
||||
res = _PyIntrinsics_UnaryFunctions[oparg].func(tstate, value);
|
||||
Py_DECREF(value);
|
||||
if (res == NULL) goto pop_1_error;
|
||||
stack_pointer[-1] = res;
|
||||
|
@ -570,7 +570,7 @@
|
|||
PyObject *value2 = stack_pointer[-2];
|
||||
PyObject *res;
|
||||
assert(oparg <= MAX_INTRINSIC_2);
|
||||
res = _PyIntrinsics_BinaryFunctions[oparg](tstate, value2, value1);
|
||||
res = _PyIntrinsics_BinaryFunctions[oparg].func(tstate, value2, value1);
|
||||
Py_DECREF(value2);
|
||||
Py_DECREF(value1);
|
||||
if (res == NULL) goto pop_2_error;
|
||||
|
|
4
Python/generated_cases.c.h
generated
4
Python/generated_cases.c.h
generated
|
@ -849,7 +849,7 @@
|
|||
PyObject *value = stack_pointer[-1];
|
||||
PyObject *res;
|
||||
assert(oparg <= MAX_INTRINSIC_1);
|
||||
res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value);
|
||||
res = _PyIntrinsics_UnaryFunctions[oparg].func(tstate, value);
|
||||
Py_DECREF(value);
|
||||
if (res == NULL) goto pop_1_error;
|
||||
stack_pointer[-1] = res;
|
||||
|
@ -861,7 +861,7 @@
|
|||
PyObject *value2 = stack_pointer[-2];
|
||||
PyObject *res;
|
||||
assert(oparg <= MAX_INTRINSIC_2);
|
||||
res = _PyIntrinsics_BinaryFunctions[oparg](tstate, value2, value1);
|
||||
res = _PyIntrinsics_BinaryFunctions[oparg].func(tstate, value2, value1);
|
||||
Py_DECREF(value2);
|
||||
Py_DECREF(value1);
|
||||
if (res == NULL) goto pop_2_error;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
/******** Unary functions ********/
|
||||
|
||||
static PyObject *
|
||||
no_intrinsic(PyThreadState* tstate, PyObject *unused)
|
||||
no_intrinsic1(PyThreadState* tstate, PyObject *unused)
|
||||
{
|
||||
_PyErr_SetString(tstate, PyExc_SystemError, "invalid intrinsic function");
|
||||
return NULL;
|
||||
|
@ -203,25 +203,35 @@ make_typevar(PyThreadState* Py_UNUSED(ignored), PyObject *v)
|
|||
return _Py_make_typevar(v, NULL, NULL);
|
||||
}
|
||||
|
||||
const instrinsic_func1
|
||||
|
||||
#define INTRINSIC_FUNC_ENTRY(N, F) \
|
||||
[N] = {F, #N},
|
||||
|
||||
const intrinsic_func1_info
|
||||
_PyIntrinsics_UnaryFunctions[] = {
|
||||
[0] = no_intrinsic,
|
||||
[INTRINSIC_PRINT] = print_expr,
|
||||
[INTRINSIC_IMPORT_STAR] = import_star,
|
||||
[INTRINSIC_STOPITERATION_ERROR] = stopiteration_error,
|
||||
[INTRINSIC_ASYNC_GEN_WRAP] = _PyAsyncGenValueWrapperNew,
|
||||
[INTRINSIC_UNARY_POSITIVE] = unary_pos,
|
||||
[INTRINSIC_LIST_TO_TUPLE] = list_to_tuple,
|
||||
[INTRINSIC_TYPEVAR] = make_typevar,
|
||||
[INTRINSIC_PARAMSPEC] = _Py_make_paramspec,
|
||||
[INTRINSIC_TYPEVARTUPLE] = _Py_make_typevartuple,
|
||||
[INTRINSIC_SUBSCRIPT_GENERIC] = _Py_subscript_generic,
|
||||
[INTRINSIC_TYPEALIAS] = _Py_make_typealias,
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_1_INVALID, no_intrinsic1)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_PRINT, print_expr)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_IMPORT_STAR, import_star)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_STOPITERATION_ERROR, stopiteration_error)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_ASYNC_GEN_WRAP, _PyAsyncGenValueWrapperNew)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_UNARY_POSITIVE, unary_pos)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_LIST_TO_TUPLE, list_to_tuple)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_TYPEVAR, make_typevar)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_PARAMSPEC, _Py_make_paramspec)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_TYPEVARTUPLE, _Py_make_typevartuple)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_SUBSCRIPT_GENERIC, _Py_subscript_generic)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_TYPEALIAS, _Py_make_typealias)
|
||||
};
|
||||
|
||||
|
||||
/******** Binary functions ********/
|
||||
|
||||
static PyObject *
|
||||
no_intrinsic2(PyThreadState* tstate, PyObject *unused1, PyObject *unused2)
|
||||
{
|
||||
_PyErr_SetString(tstate, PyExc_SystemError, "invalid intrinsic function");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
prep_reraise_star(PyThreadState* unused, PyObject *orig, PyObject *excs)
|
||||
|
@ -246,10 +256,31 @@ make_typevar_with_constraints(PyThreadState* Py_UNUSED(ignored), PyObject *name,
|
|||
return _Py_make_typevar(name, NULL, evaluate_constraints);
|
||||
}
|
||||
|
||||
const instrinsic_func2
|
||||
const intrinsic_func2_info
|
||||
_PyIntrinsics_BinaryFunctions[] = {
|
||||
[INTRINSIC_PREP_RERAISE_STAR] = prep_reraise_star,
|
||||
[INTRINSIC_TYPEVAR_WITH_BOUND] = make_typevar_with_bound,
|
||||
[INTRINSIC_TYPEVAR_WITH_CONSTRAINTS] = make_typevar_with_constraints,
|
||||
[INTRINSIC_SET_FUNCTION_TYPE_PARAMS] = _Py_set_function_type_params,
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_2_INVALID, no_intrinsic2)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_PREP_RERAISE_STAR, prep_reraise_star)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_TYPEVAR_WITH_BOUND, make_typevar_with_bound)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_TYPEVAR_WITH_CONSTRAINTS, make_typevar_with_constraints)
|
||||
INTRINSIC_FUNC_ENTRY(INTRINSIC_SET_FUNCTION_TYPE_PARAMS, _Py_set_function_type_params)
|
||||
};
|
||||
|
||||
#undef INTRINSIC_FUNC_ENTRY
|
||||
|
||||
PyObject*
|
||||
_PyUnstable_GetUnaryIntrinsicName(int index)
|
||||
{
|
||||
if (index < 0 || index > MAX_INTRINSIC_1) {
|
||||
return NULL;
|
||||
}
|
||||
return PyUnicode_FromString(_PyIntrinsics_UnaryFunctions[index].name);
|
||||
}
|
||||
|
||||
PyObject*
|
||||
_PyUnstable_GetBinaryIntrinsicName(int index)
|
||||
{
|
||||
if (index < 0 || index > MAX_INTRINSIC_2) {
|
||||
return NULL;
|
||||
}
|
||||
return PyUnicode_FromString(_PyIntrinsics_BinaryFunctions[index].name);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue