summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index f0b2dc7..cd8b674 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -83,15 +83,14 @@ dummy_func(
// Dummy labels.
pop_1_error:
// Dummy locals.
- PyObject *annotations;
+ PyObject *dummy;
+ PyObject *attr;
PyObject *attrs;
PyObject *bottom;
PyObject *callable;
PyObject *callargs;
- PyObject *closure;
PyObject *codeobj;
PyObject *cond;
- PyObject *defaults;
PyObject *descr;
_PyInterpreterFrame entry_frame;
PyObject *exc;
@@ -3297,11 +3296,7 @@ dummy_func(
CHECK_EVAL_BREAKER();
}
- inst(MAKE_FUNCTION, (defaults if (oparg & MAKE_FUNCTION_DEFAULTS),
- kwdefaults if (oparg & MAKE_FUNCTION_KWDEFAULTS),
- annotations if (oparg & MAKE_FUNCTION_ANNOTATIONS),
- closure if (oparg & MAKE_FUNCTION_CLOSURE),
- codeobj -- func)) {
+ inst(MAKE_FUNCTION, (codeobj -- func)) {
PyFunctionObject *func_obj = (PyFunctionObject *)
PyFunction_New(codeobj, GLOBALS());
@@ -3311,27 +3306,37 @@ dummy_func(
goto error;
}
- if (oparg & MAKE_FUNCTION_CLOSURE) {
- assert(PyTuple_CheckExact(closure));
- func_obj->func_closure = closure;
- }
- if (oparg & MAKE_FUNCTION_ANNOTATIONS) {
- assert(PyTuple_CheckExact(annotations));
- func_obj->func_annotations = annotations;
- }
- if (oparg & MAKE_FUNCTION_KWDEFAULTS) {
- assert(PyDict_CheckExact(kwdefaults));
- func_obj->func_kwdefaults = kwdefaults;
- }
- if (oparg & MAKE_FUNCTION_DEFAULTS) {
- assert(PyTuple_CheckExact(defaults));
- func_obj->func_defaults = defaults;
- }
-
func_obj->func_version = ((PyCodeObject *)codeobj)->co_version;
func = (PyObject *)func_obj;
}
+ inst(SET_FUNCTION_ATTRIBUTE, (attr, func -- func)) {
+ assert(PyFunction_Check(func));
+ PyFunctionObject *func_obj = (PyFunctionObject *)func;
+ switch(oparg) {
+ case MAKE_FUNCTION_CLOSURE:
+ assert(func_obj->func_closure == NULL);
+ func_obj->func_closure = attr;
+ break;
+ case MAKE_FUNCTION_ANNOTATIONS:
+ assert(func_obj->func_annotations == NULL);
+ func_obj->func_annotations = attr;
+ break;
+ case MAKE_FUNCTION_KWDEFAULTS:
+ assert(PyDict_CheckExact(attr));
+ assert(func_obj->func_kwdefaults == NULL);
+ func_obj->func_kwdefaults = attr;
+ break;
+ case MAKE_FUNCTION_DEFAULTS:
+ assert(PyTuple_CheckExact(attr));
+ assert(func_obj->func_defaults == NULL);
+ func_obj->func_defaults = attr;
+ break;
+ default:
+ Py_UNREACHABLE();
+ }
+ }
+
inst(RETURN_GENERATOR, (--)) {
assert(PyFunction_Check(frame->f_funcobj));
PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj;