mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Couple opcode/cache/stack metadata with iterator pairs, generator preambles, ordinary import packing, common constants, compiler lowering and VM/JIT consumers. Pin official source/tool hashes and retain strict raw code and marshal comparisons. Use private development magic 0xDA16 and cache tag devabi2 until serialization and Python integration are coherent. Final clean corpus matches recursive code fields in 111/111 requests; full marshal/header exactness remains 0/111. Eight existing disassembly tests remain blocked by unchanged Lib metadata. Monitoring export and frozendict/update_lib integration remain explicit follow-on gates. Validation: compiler-core 23, codegen 807, CAPI 121 (4 existing ignored), focused certified-controller pytest, release/frozen witnesses, workspace and CAPI all-target Clippy. Independent source/artifact review covers manifest ec1013591ae97b4c519f4a2c78a8200664f3479f0c5452991b5fea4d1be669ea. Assisted-by: OpenAI Codex:model identifier unavailable
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
"""Verify every active public discriminant against pinned final opcode_ids.h."""
|
|
|
|
import argparse
|
|
import re
|
|
from pathlib import Path
|
|
|
|
from target_source import verify_source
|
|
|
|
from utils import DEFAULT_INPUT, to_upper_snake_case
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--source", required=True, type=Path)
|
|
args = parser.parse_args()
|
|
verify_source(args.source)
|
|
ids = {
|
|
name: int(value)
|
|
for name, value in re.findall(
|
|
r"^#define\s+(\w+)\s+(\d+)\s*$",
|
|
(args.source / "Include/opcode_ids.h").read_text(),
|
|
re.M,
|
|
)
|
|
}
|
|
private = {
|
|
"GetYieldFromIter": 219,
|
|
"LoadConstImmortal": 220,
|
|
"LoadConstMortal": 221,
|
|
}
|
|
entries = re.findall(
|
|
r"^ (\w+)(?:\s*\{[^}]*\})?\s*=\s*(\d+),",
|
|
DEFAULT_INPUT.read_text(),
|
|
re.M,
|
|
)
|
|
assert len(entries) == 238
|
|
assert len({int(value) for _, value in entries}) == len(entries)
|
|
for name, value in entries:
|
|
expected = private[name] if name in private else ids[to_upper_snake_case(name)]
|
|
assert int(value) == expected, (name, value, expected)
|
|
print("Verified 235 public and 3 explicitly private opcode discriminants")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|