mirror of
https://github.com/python/cpython.git
synced 2025-07-18 16:55:20 +00:00
bpo-45152: Add HAS_CONST macro and get_const_value() function and use… (#28262)
This commit is contained in:
parent
9f93018b69
commit
c2f1e95337
3 changed files with 53 additions and 7 deletions
|
@ -51,6 +51,7 @@ def main(opcode_py, outfile='Include/opcode.h'):
|
|||
code = fp.read()
|
||||
exec(code, opcode)
|
||||
opmap = opcode['opmap']
|
||||
hasconst = opcode['hasconst']
|
||||
hasjrel = opcode['hasjrel']
|
||||
hasjabs = opcode['hasjabs']
|
||||
used = [ False ] * 256
|
||||
|
@ -65,15 +66,24 @@ def main(opcode_py, outfile='Include/opcode.h'):
|
|||
if name == 'POP_EXCEPT': # Special entry for HAVE_ARGUMENT
|
||||
fobj.write("#define %-23s %3d\n" %
|
||||
('HAVE_ARGUMENT', opcode['HAVE_ARGUMENT']))
|
||||
|
||||
for name in opcode['_specialized_instructions']:
|
||||
while used[next_op]:
|
||||
next_op += 1
|
||||
fobj.write("#define %-23s %3s\n" % (name, next_op))
|
||||
used[next_op] = True
|
||||
|
||||
fobj.write("#ifdef NEED_OPCODE_JUMP_TABLES\n")
|
||||
write_int_array_from_ops("_PyOpcode_RelativeJump", opcode['hasjrel'], fobj)
|
||||
write_int_array_from_ops("_PyOpcode_Jump", opcode['hasjrel'] + opcode['hasjabs'], fobj)
|
||||
fobj.write("#endif /* OPCODE_TABLES */\n")
|
||||
|
||||
fobj.write("\n")
|
||||
fobj.write("#define HAS_CONST(op) (false\\")
|
||||
for op in hasconst:
|
||||
fobj.write(f"\n || ((op) == {op}) \\")
|
||||
fobj.write("\n )\n")
|
||||
|
||||
fobj.write(footer)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue