MCPcopy Index your code
hub / github.com/python/mypy / GeneratorClass

Class GeneratorClass

mypyc/irbuild/context.py:163–206  ·  view source on GitHub ↗

Contains information about implicit generator function classes.

Source from the content-addressed store, hash-verified

161
162
163class GeneratorClass(ImplicitClass):
164 """Contains information about implicit generator function classes."""
165
166 def __init__(self, ir: ClassIR) -> None:
167 super().__init__(ir)
168 # This register holds the label number that the '__next__' function should go to the next
169 # time it is called.
170 self._next_label_reg: Value | None = None
171 self._next_label_target: AssignmentTarget | None = None
172
173 # These registers hold the error values for the generator object for the case that the
174 # 'throw' function is called.
175 self.exc_regs: tuple[Value, Value, Value] | None = None
176
177 # Holds the arg passed to send
178 self.send_arg_reg: Value | None = None
179
180 # Holds the PyObject ** pointer through which return value can be passed
181 # instead of raising StopIteration(ret_value) (only if not NULL). This
182 # is used for faster native-to-native calls.
183 self.stop_iter_value_reg: Value | None = None
184
185 # The switch block is used to decide which instruction to go using the value held in the
186 # next-label register.
187 self.switch_block = BasicBlock()
188 self.continuation_blocks: list[BasicBlock] = []
189
190 @property
191 def next_label_reg(self) -> Value:
192 assert self._next_label_reg is not None
193 return self._next_label_reg
194
195 @next_label_reg.setter
196 def next_label_reg(self, reg: Value) -> None:
197 self._next_label_reg = reg
198
199 @property
200 def next_label_target(self) -> AssignmentTarget:
201 assert self._next_label_target is not None
202 return self._next_label_target
203
204 @next_label_target.setter
205 def next_label_target(self, target: AssignmentTarget) -> None:
206 self._next_label_target = target

Callers 1

gen_func_itemFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…