| OLD | NEW |
| (Empty) | |
| 1 <%namespace file="base.impl" import="*"/>\ |
| 2 |
| 3 TARGET(FAST_CALL_GENERATOR_${ arity_str(instr) }) |
| 4 { |
| 5 if (oparg != ${ instr.arity() }) goto TARGET_CALL_FUNCTION_SKIP_DISPATCH
; |
| 6 |
| 7 % for operand,accessor in get_enumerated_args(instr.arity()): |
| 8 ${operand}= ${accessor}(); |
| 9 % endfor |
| 10 |
| 11 if (! (PyMethod_Check(v) || PyFunction_Check(v))) { |
| 12 goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; |
| 13 } // if |
| 14 register PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(v); |
| 15 if (!co->co_flags & CO_GENERATOR) { |
| 16 goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; |
| 17 } // if |
| 18 PyObject *globals= PyFunction_GET_GLOBALS(v); |
| 19 PyObject *closure= PyFunction_GET_CLOSURE(v); |
| 20 PyThreadState *tstate= PyThreadState_GET(); |
| 21 if (globals == NULL || closure == NULL || tstate == NULL) |
| 22 goto TARGET_CALL_FUNCTION_SKIP_DISPATCH; |
| 23 |
| 24 % if instr.arity() > 0: |
| 25 STACKADJ(-${ instr.arity() }); |
| 26 % endif |
| 27 register PyFrameObject *generator_frame= PyFrame_New(tstate, co, globals
, NULL); |
| 28 register PyObject **freevars= generator_frame->f_localsplus + co->co_nlo
cals; |
| 29 <% ## copy argument variables... |
| 30 i= 0 |
| 31 revargs= get_enumerated_args(instr.arity()) |
| 32 revargs.reverse() |
| 33 %> |
| 34 % for operand, accessor in revargs: |
| 35 % if operand != 'v': |
| 36 Py_INCREF( ${operand} ); |
| 37 generator_frame->f_localsplus[ ${i} ]= ${ operand }; |
| 38 <% i+= 1 %> |
| 39 % endif |
| 40 % endfor |
| 41 ## co->co_freevars indicates how many variables we need to fetch from th
e |
| 42 ## closue... |
| 43 /* copy closure variables... */ |
| 44 u= PyTuple_GET_ITEM(closure, 0); |
| 45 Py_INCREF(u); |
| 46 freevars[0] = u; /* closure-bound variable */ |
| 47 |
| 48 /* Don't need to keep the reference to f_back, it will be set |
| 49 * when the generator is resumed. */ |
| 50 Py_XDECREF(generator_frame->f_back); |
| 51 generator_frame->f_back = NULL; |
| 52 |
| 53 x= PyGen_New(generator_frame); |
| 54 |
| 55 % for operand, accessor in get_enumerated_args(instr.arity()): |
| 56 Py_DECREF( ${ operand } ); |
| 57 % endfor |
| 58 |
| 59 ${ push_result() } |
| 60 ${ dispatch() } |
| 61 } |
| 62 |
| 63 |
| OLD | NEW |