summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-12-14 11:12:53 (GMT)
committerGitHub <noreply@github.com>2022-12-14 11:12:53 (GMT)
commit6997e77bdf2297375962aaf82876da4e7ecdd61a (patch)
tree7f6540eecbb66fd373b22e944163bdcb436f245b /Python/compile.c
parent985a71032bf055240e61259285a0b4925c925383 (diff)
downloadcpython-6997e77bdf2297375962aaf82876da4e7ecdd61a.zip
cpython-6997e77bdf2297375962aaf82876da4e7ecdd61a.tar.gz
cpython-6997e77bdf2297375962aaf82876da4e7ecdd61a.tar.bz2
GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code unit. (GH-100223)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 813e0d5..09eb401 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -263,22 +263,32 @@ write_instr(_Py_CODEUNIT *codestr, struct instr *instruction, int ilen)
int caches = _PyOpcode_Caches[opcode];
switch (ilen - caches) {
case 4:
- *codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 24) & 0xFF);
+ codestr->opcode = EXTENDED_ARG;
+ codestr->oparg = (oparg >> 24) & 0xFF;
+ codestr++;
/* fall through */
case 3:
- *codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 16) & 0xFF);
+ codestr->opcode = EXTENDED_ARG;
+ codestr->oparg = (oparg >> 16) & 0xFF;
+ codestr++;
/* fall through */
case 2:
- *codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 8) & 0xFF);
+ codestr->opcode = EXTENDED_ARG;
+ codestr->oparg = (oparg >> 8) & 0xFF;
+ codestr++;
/* fall through */
case 1:
- *codestr++ = _Py_MAKECODEUNIT(opcode, oparg & 0xFF);
+ codestr->opcode = opcode;
+ codestr->oparg = oparg & 0xFF;
+ codestr++;
break;
default:
Py_UNREACHABLE();
}
while (caches--) {
- *codestr++ = _Py_MAKECODEUNIT(CACHE, 0);
+ codestr->opcode = CACHE;
+ codestr->oparg = 0;
+ codestr++;
}
}