Skip to content

Commit

Permalink
Replace opcode defines with enum in pycore_opcode_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
arhadthedev committed Nov 14, 2023
1 parent 0ff6368 commit ce52bc9
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 96 deletions.
192 changes: 97 additions & 95 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion Tools/cases_generator/generate_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,15 @@ def write_metadata(self, metadata_filename: str, pymetadata_filename: str) -> No
self.write_pseudo_instrs()

self.out.emit("")
self.write_uop_items(lambda name, counter: f"#define {name} {counter}")
self.out.emit("enum _Py_OPCODES {")
next_uop_id = 0
def define_uop(name, uop_id):
nonlocal next_uop_id
value = "" if uop_id == next_uop_id else f" = {uop_id}"
next_uop_id = uop_id + 1
return f" {name}{value},"
self.write_uop_items(define_uop)
self.out.emit("};")

self.write_stack_effect_functions()

Expand Down

0 comments on commit ce52bc9

Please sign in to comment.