Add basic opcode (disassembly) support for Python 3.11

This commit is contained in:
Michael Hansen
2022-12-02 16:34:58 -08:00
parent a3e5ebd481
commit 9f1d0f2a21
11 changed files with 558 additions and 362 deletions

View File

@@ -21,7 +21,7 @@ void PycCode::load(PycData* stream, PycModule* mod)
if (mod->verCompare(1, 3) >= 0 && mod->verCompare(2, 3) < 0)
m_numLocals = stream->get16();
else if (mod->verCompare(2, 3) >= 0)
else if (mod->verCompare(2, 3) >= 0 && mod->verCompare(3, 11) < 0)
m_numLocals = stream->get32();
else
m_numLocals = 0;
@@ -44,24 +44,39 @@ void PycCode::load(PycData* stream, PycModule* mod)
m_consts = LoadObject(stream, mod).cast<PycSequence>();
m_names = LoadObject(stream, mod).cast<PycSequence>();
if (mod->verCompare(1, 3) >= 0)
if (mod->verCompare(1, 3) >= 0 && mod->verCompare(3, 11) < 0)
m_varNames = LoadObject(stream, mod).cast<PycSequence>();
else
m_varNames = new PycTuple;
if (mod->verCompare(2, 1) >= 0)
if (mod->verCompare(2, 1) >= 0 && mod->verCompare(3, 11) < 0)
m_freeVars = LoadObject(stream, mod).cast<PycSequence>();
else
m_freeVars = new PycTuple;
if (mod->verCompare(2, 1) >= 0)
if (mod->verCompare(2, 1) >= 0 && mod->verCompare(3, 11) < 0)
m_cellVars = LoadObject(stream, mod).cast<PycSequence>();
else
m_cellVars = new PycTuple;
if (mod->verCompare(3, 11) >= 0)
m_localsAndNames = LoadObject(stream, mod).cast<PycSequence>();
else
m_localsAndNames = new PycTuple;
if (mod->verCompare(3, 11) >= 0)
m_localsAndKinds = LoadObject(stream, mod).cast<PycString>();
else
m_localsAndKinds = new PycString;
m_fileName = LoadObject(stream, mod).cast<PycString>();
m_name = LoadObject(stream, mod).cast<PycString>();
if (mod->verCompare(3, 11) >= 0)
m_qualName = LoadObject(stream, mod).cast<PycString>();
else
m_qualName = new PycString;
if (mod->verCompare(1, 5) >= 0 && mod->verCompare(2, 3) < 0)
m_firstLine = stream->get16();
else if (mod->verCompare(2, 3) >= 0)
@@ -71,4 +86,9 @@ void PycCode::load(PycData* stream, PycModule* mod)
m_lnTable = LoadObject(stream, mod).cast<PycString>();
else
m_lnTable = new PycString;
if (mod->verCompare(3, 11) >= 0)
m_exceptTable = LoadObject(stream, mod).cast<PycString>();
else
m_exceptTable = new PycString;
}