Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions 36 Include/internal/pycore_opcode_metadata.h

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

3 changes: 2 additions & 1 deletion 3 Tools/cases_generator/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ def analyze_pseudo(self, pseudo: parsing.Pseudo) -> PseudoInstruction:
# Make sure the targets have the same fmt
fmts = list(set([t.instr_fmt for t in targets]))
assert len(fmts) == 1
assert len(list(set([t.instr_flags.bitmap() for t in targets]))) == 1
ignored_flags = {'HAS_EVAL_BREAK_FLAG'}
assert len({t.instr_flags.bitmap(ignore=ignored_flags) for t in targets}) == 1
return PseudoInstruction(pseudo.name, targets, fmts[0], targets[0].instr_flags)

def analyze_instruction(
Expand Down
10 changes: 7 additions & 3 deletions 10 Tools/cases_generator/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from formatting import Formatter
import lexer as lx
import parsing
from typing import AbstractSet


@dataclasses.dataclass
Expand All @@ -15,6 +16,7 @@ class InstructionFlags:
HAS_JUMP_FLAG: bool
HAS_FREE_FLAG: bool
HAS_LOCAL_FLAG: bool
HAS_EVAL_BREAK_FLAG: bool

def __post_init__(self) -> None:
self.bitmask = {name: (1 << i) for i, name in enumerate(self.names())}
Expand All @@ -37,11 +39,12 @@ def fromInstruction(instr: parsing.Node) -> "InstructionFlags":
variable_used(instr, "GETLOCAL") or variable_used(instr, "SETLOCAL")
)
and not has_free,
HAS_EVAL_BREAK_FLAG=variable_used(instr, "CHECK_EVAL_BREAKER"),
)

@staticmethod
def newEmpty() -> "InstructionFlags":
return InstructionFlags(False, False, False, False, False, False)
return InstructionFlags(False, False, False, False, False, False, False)

def add(self, other: "InstructionFlags") -> None:
for name, value in dataclasses.asdict(other).items():
Expand All @@ -53,10 +56,11 @@ def names(self, value: bool | None = None) -> list[str]:
return list(dataclasses.asdict(self).keys())
return [n for n, v in dataclasses.asdict(self).items() if v == value]

def bitmap(self) -> int:
def bitmap(self, ignore: AbstractSet[str] = frozenset()) -> int:
flags = 0
assert all(hasattr(self, name) for name in ignore)
for name in self.names():
if getattr(self, name):
if getattr(self, name) and name not in ignore:
flags |= self.bitmask[name]
return flags

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.