MCPcopy Create free account
hub / github.com/python/mypy / add_next_to_generator_class

Function add_next_to_generator_class

mypyc/irbuild/generator.py:257–276  ·  view source on GitHub ↗

Generates the '__next__' method for a generator class.

(builder: IRBuilder, fn_info: FuncInfo, fn_decl: FuncDecl)

Source from the content-addressed store, hash-verified

255
256
257def add_next_to_generator_class(builder: IRBuilder, fn_info: FuncInfo, fn_decl: FuncDecl) -> None:
258 """Generates the '__next__' method for a generator class."""
259 with builder.enter_method(fn_info.generator_class.ir, "__next__", object_rprimitive, fn_info):
260 none_reg = builder.none_object()
261 # Call the helper function with error flags set to Py_None, and return that result.
262 result = builder.add(
263 Call(
264 fn_decl,
265 [
266 builder.self(),
267 none_reg,
268 none_reg,
269 none_reg,
270 none_reg,
271 Integer(0, object_pointer_rprimitive),
272 ],
273 fn_info.fitem.line,
274 )
275 )
276 builder.add(Return(result))
277
278
279def add_send_to_generator_class(builder: IRBuilder, fn_info: FuncInfo, fn_decl: FuncDecl) -> None:

Callers 1

Calls 7

CallClass · 0.90
IntegerClass · 0.90
ReturnClass · 0.90
enter_methodMethod · 0.45
none_objectMethod · 0.45
addMethod · 0.45
selfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…