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

Class ImplicitClass

mypyc/irbuild/context.py:114–160  ·  view source on GitHub ↗

Contains information regarding implicitly generated classes. Implicit classes are generated for nested functions and generator functions. They are not explicitly defined in the source code. NOTE: This is both a concrete class and used as a base class.

Source from the content-addressed store, hash-verified

112
113
114class ImplicitClass:
115 """Contains information regarding implicitly generated classes.
116
117 Implicit classes are generated for nested functions and generator
118 functions. They are not explicitly defined in the source code.
119
120 NOTE: This is both a concrete class and used as a base class.
121 """
122
123 def __init__(self, ir: ClassIR) -> None:
124 # The ClassIR instance associated with this class.
125 self.ir = ir
126 # The register associated with the 'self' instance for this generator class.
127 self._self_reg: Value | None = None
128 # Environment class registers are the local registers associated with instances of an
129 # environment class, used for getting and setting attributes. curr_env_reg is the register
130 # associated with the current environment. prev_env_reg is the self.__mypyc_env__ field
131 # associated with the previous environment.
132 self._curr_env_reg: Value | None = None
133 self._prev_env_reg: Value | None = None
134
135 @property
136 def self_reg(self) -> Value:
137 assert self._self_reg is not None
138 return self._self_reg
139
140 @self_reg.setter
141 def self_reg(self, reg: Value) -> None:
142 self._self_reg = reg
143
144 @property
145 def curr_env_reg(self) -> Value:
146 assert self._curr_env_reg is not None
147 return self._curr_env_reg
148
149 @curr_env_reg.setter
150 def curr_env_reg(self, reg: Value) -> None:
151 self._curr_env_reg = reg
152
153 @property
154 def prev_env_reg(self) -> Value:
155 assert self._prev_env_reg is not None
156 return self._prev_env_reg
157
158 @prev_env_reg.setter
159 def prev_env_reg(self, reg: Value) -> None:
160 self._prev_env_reg = reg
161
162
163class GeneratorClass(ImplicitClass):

Callers 1

setup_callable_classFunction · 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…