(self)
| 201 | return await self._parse(o) |
| 202 | |
| 203 | async def _build_stencils(self) -> dict[str, _stencils.StencilGroup]: |
| 204 | generated_cases = PYTHON_EXECUTOR_CASES_C_H.read_text() |
| 205 | cases_and_opnames = sorted( |
| 206 | re.findall( |
| 207 | r"\n {8}(case (\w+): \{\n.*?\n {8}\})", generated_cases, flags=re.DOTALL |
| 208 | ) |
| 209 | ) |
| 210 | tasks = [] |
| 211 | with tempfile.TemporaryDirectory() as tempdir: |
| 212 | work = pathlib.Path(tempdir).resolve() |
| 213 | async with asyncio.TaskGroup() as group: |
| 214 | coro = self._compile("shim", TOOLS_JIT / "shim.c", work) |
| 215 | tasks.append(group.create_task(coro, name="shim")) |
| 216 | template = TOOLS_JIT_TEMPLATE_C.read_text() |
| 217 | for case, opname in cases_and_opnames: |
| 218 | # Write out a copy of the template with *only* this case |
| 219 | # inserted. This is about twice as fast as #include'ing all |
| 220 | # of executor_cases.c.h each time we compile (since the C |
| 221 | # compiler wastes a bunch of time parsing the dead code for |
| 222 | # all of the other cases): |
| 223 | c = work / f"{opname}.c" |
| 224 | c.write_text(template.replace("CASE", case)) |
| 225 | coro = self._compile(opname, c, work) |
| 226 | tasks.append(group.create_task(coro, name=opname)) |
| 227 | stencil_groups = {task.get_name(): task.result() for task in tasks} |
| 228 | for stencil_group in stencil_groups.values(): |
| 229 | stencil_group.convert_labels_to_relocations() |
| 230 | stencil_group.process_relocations(self.known_symbols) |
| 231 | return stencil_groups |
| 232 | |
| 233 | def build( |
| 234 | self, |
no test coverage detected