Update operand documentation for new opcodes and oparg changes.

Also extends the disassembly oparg decoding for new 3.13 additions.
This commit is contained in:
Michael Hansen
2024-08-07 15:44:36 -07:00
parent 75de28decc
commit b939aeb87c
4 changed files with 181 additions and 114 deletions

View File

@@ -645,8 +645,10 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
PycRef<ASTNode> left = stack.top();
stack.pop();
auto arg = operand;
if (mod->verCompare(3, 12) >= 0)
if (mod->verCompare(3, 12) == 0)
arg >>= 4; // changed under GH-100923
else if (mod->verCompare(3, 13) >= 0)
arg >>= 5;
stack.push(new ASTCompare(left, right, arg));
}
break;
@@ -1469,7 +1471,7 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
if (mod->verCompare(3, 12) >= 0) {
if (operand & 1) {
/* Changed in version 3.12:
If the low bit of namei is set, then a NULL or self is pushed to the stack
If the low bit of name is set, then a NULL or self is pushed to the stack
before the attribute or unbound method respectively. */
stack.push(nullptr);
}
@@ -1512,6 +1514,10 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
else
stack.push(new ASTName(code->getLocal(operand)));
break;
case Pyc::LOAD_FAST_LOAD_FAST_A:
stack.push(new ASTName(code->getLocal(operand >> 4)));
stack.push(new ASTName(code->getLocal(operand & 0xF)));
break;
case Pyc::LOAD_GLOBAL_A:
if (mod->verCompare(3, 11) >= 0) {
// Loads the global named co_names[namei>>1] onto the stack.