MCPcopy Create free account
hub / github.com/python/cpython / as_c

Method as_c

Tools/jit/_stencils.py:174–197  ·  view source on GitHub ↗

Dump this hole as a call to a patch_* function.

(self, where: str)

Source from the content-addressed store, hash-verified

172 self.func = _PATCH_FUNCS[self.kind]
173
174 def as_c(self, where: str) -> str:
175 """Dump this hole as a call to a patch_* function."""
176 if self.custom_location:
177 location = self.custom_location
178 else:
179 location = f"{where} + {self.offset:#x}"
180 if self.custom_value:
181 value = self.custom_value
182 else:
183 value = _HOLE_EXPRS[self.value]
184 if self.symbol:
185 if value:
186 value += " + "
187 if self.symbol.startswith("CONST"):
188 value += f"instruction->{self.symbol[10:].lower()}"
189 else:
190 value += f"(uintptr_t)&{self.symbol}"
191 if _signed(self.addend) or not value:
192 if value:
193 value += " + "
194 value += f"{_signed(self.addend):#x}"
195 if self.need_state:
196 return f"{self.func}({location}, {value}, state);"
197 return f"{self.func}({location}, {value});"
198
199
200@dataclasses.dataclass

Callers 2

_dump_footerFunction · 0.45
_dump_stencilFunction · 0.45

Calls 3

_signedFunction · 0.85
startswithMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected