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

Function emit_yield

mypyc/irbuild/statement.py:1255–1272  ·  view source on GitHub ↗
(builder: IRBuilder, val: Value, line: int)

Source from the content-addressed store, hash-verified

1253
1254
1255def emit_yield(builder: IRBuilder, val: Value, line: int) -> Value:
1256 retval = builder.coerce(val, builder.ret_types[-1], line)
1257
1258 cls = builder.fn_info.generator_class
1259 # Create a new block for the instructions immediately following the yield expression, and
1260 # set the next label so that the next time '__next__' is called on the generator object,
1261 # the function continues at the new block.
1262 next_block = BasicBlock()
1263 next_label = len(cls.continuation_blocks)
1264 cls.continuation_blocks.append(next_block)
1265 builder.assign(cls.next_label_target, Integer(next_label), line)
1266 builder.add(Return(retval, yield_target=next_block))
1267 builder.activate_block(next_block)
1268
1269 add_raise_exception_blocks_to_generator_class(builder, line)
1270
1271 assert cls.send_arg_reg is not None
1272 return cls.send_arg_reg
1273
1274
1275def emit_yield_from_or_await(

Callers 2

try_bodyFunction · 0.85
transform_yield_exprFunction · 0.85

Calls 10

BasicBlockClass · 0.90
IntegerClass · 0.90
ReturnClass · 0.90
lenFunction · 0.85
appendMethod · 0.80
coerceMethod · 0.45
assignMethod · 0.45
addMethod · 0.45
activate_blockMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…