(to_name, expression, emit, context)
| 153 | |
| 154 | |
| 155 | def generateMakeGeneratorObjectCode(to_name, expression, emit, context): |
| 156 | generator_object_body = expression.subnode_generator_ref.getFunctionBody() |
| 157 | |
| 158 | closure_variables = expression.getClosureVariableVersions() |
| 159 | |
| 160 | closure_name, closure_copy = getClosureCopyCode( |
| 161 | closure_variables=closure_variables, context=context |
| 162 | ) |
| 163 | |
| 164 | args = ["tstate"] |
| 165 | if closure_name: |
| 166 | args.append(closure_name) |
| 167 | |
| 168 | # Special case empty generators. |
| 169 | if generator_object_body.subnode_body is None: |
| 170 | emit( |
| 171 | template_make_empty_generator |
| 172 | % { |
| 173 | "closure_copy": indented(closure_copy), |
| 174 | "to_name": to_name, |
| 175 | "generator_module": getModuleAccessCode(context), |
| 176 | "generator_name_obj": context.getConstantCode( |
| 177 | constant=generator_object_body.getFunctionName() |
| 178 | ), |
| 179 | "generator_qualname_obj": getFunctionQualnameObj( |
| 180 | generator_object_body, context |
| 181 | ), |
| 182 | "code_identifier": context.getCodeObjectHandle( |
| 183 | code_object=generator_object_body.getCodeObject() |
| 184 | ), |
| 185 | "closure_name": closure_name if closure_name is not None else "NULL", |
| 186 | "closure_count": len(closure_variables), |
| 187 | } |
| 188 | ) |
| 189 | else: |
| 190 | emit( |
| 191 | template_make_generator |
| 192 | % { |
| 193 | "generator_maker_identifier": _getGeneratorMakerIdentifier( |
| 194 | generator_object_body.getCodeName() |
| 195 | ), |
| 196 | "to_name": to_name, |
| 197 | "args": ", ".join(str(arg) for arg in args), |
| 198 | "closure_copy": indented(closure_copy), |
| 199 | } |
| 200 | ) |
| 201 | |
| 202 | context.addCleanupTempName(to_name) |
| 203 | |
| 204 | |
| 205 | # Part of "Nuitka", an optimizing Python compiler that is compatible and |
nothing calls this directly
no test coverage detected
searching dependent graphs…