MCPcopy Index your code
hub / github.com/python/cpython / generate_opcode_header

Function generate_opcode_header

Tools/cases_generator/opcode_id_generator.py:24–41  ·  view source on GitHub ↗
(
    filenames: list[str], analysis: Analysis, outfile: TextIO
)

Source from the content-addressed store, hash-verified

22
23
24def generate_opcode_header(
25 filenames: list[str], analysis: Analysis, outfile: TextIO
26) -> None:
27 write_header(__file__, filenames, outfile)
28 out = CWriter(outfile, 0, False)
29 with out.header_guard("Py_OPCODE_IDS_H"):
30 out.emit("/* Instruction opcodes for compiled code */\n")
31
32 def write_define(name: str, op: int) -> None:
33 out.emit(f"#define {name:<38} {op:>3}\n")
34
35 for op, name in sorted([(op, name) for (name, op) in analysis.opmap.items()]):
36 write_define(name, op)
37
38 out.emit("\n")
39 write_define("HAVE_ARGUMENT", analysis.have_arg)
40 write_define("MIN_SPECIALIZED_OPCODE", analysis.opmap["RESUME"]+1)
41 write_define("MIN_INSTRUMENTED_OPCODE", analysis.min_instrumented)
42
43
44arg_parser = argparse.ArgumentParser(

Callers 1

Calls 6

header_guardMethod · 0.95
emitMethod · 0.95
write_headerFunction · 0.90
CWriterClass · 0.90
write_defineFunction · 0.85
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…