Fix LOAD_GLOBAL and cell var references in Python 3.11+

This commit is contained in:
Michael Hansen
2023-01-19 13:05:06 -08:00
parent 379c0c94d0
commit 5d855f0bd2
4 changed files with 30 additions and 12 deletions

View File

@@ -1606,7 +1606,7 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
}
break;
case Pyc::LOAD_DEREF_A:
stack.push(new ASTName(code->getCellVar(operand)));
stack.push(new ASTName(code->getCellVar(mod, operand)));
break;
case Pyc::LOAD_FAST_A:
if (mod->verCompare(1, 3) < 0)
@@ -2100,7 +2100,7 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
case Pyc::STORE_DEREF_A:
{
if (unpack) {
PycRef<ASTNode> name = new ASTName(code->getCellVar(operand));
PycRef<ASTNode> name = new ASTName(code->getCellVar(mod, operand));
PycRef<ASTNode> tup = stack.top();
if (tup.type() == ASTNode::NODE_TUPLE)
@@ -2122,7 +2122,7 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
} else {
PycRef<ASTNode> value = stack.top();
stack.pop();
PycRef<ASTNode> name = new ASTName(code->getCellVar(operand));
PycRef<ASTNode> name = new ASTName(code->getCellVar(mod, operand));
if (value.type() == ASTNode::NODE_CHAINSTORE) {
append_to_chain_store(value, name, stack, curblock);