Address comments
This commit is contained in:
10
bytecode.cpp
10
bytecode.cpp
@@ -604,14 +604,14 @@ void bc_disasm(std::ostream& pyc_output, PycRef<PycCode> code, PycModule* mod,
|
||||
void bc_exceptiontable(std::ostream& pyc_output, PycRef<PycCode> code,
|
||||
int indent)
|
||||
{
|
||||
for (auto tuple: code->exceptTableEntries()) {
|
||||
for (const auto& entry : code->exceptionTableEntries()) {
|
||||
|
||||
for (int i=0; i<indent; i++)
|
||||
pyc_output << " ";
|
||||
|
||||
pyc_output << std::get<0>(tuple) << " to " << std::get<1>(tuple);
|
||||
pyc_output << " -> " << std::get<2>(tuple) << " ";
|
||||
pyc_output << "[" << std::get<3>(tuple) << "] " << (std::get<4>(tuple) ? "lasti": "");
|
||||
pyc_output << "\n";
|
||||
pyc_output << entry.start_offset << " to " << entry.end_offset
|
||||
<< " -> " << entry.target << " [" << entry.stack_depth
|
||||
<< "] " << (entry.push_lasti ? "lasti": "")
|
||||
<< "\n";
|
||||
}
|
||||
}
|
12
pyc_code.cpp
12
pyc_code.cpp
@@ -133,23 +133,23 @@ int _parse_varint(PycBuffer& data, int& pos) {
|
||||
int b = data.getByte();
|
||||
pos += 1;
|
||||
|
||||
int val = b & 63;
|
||||
while (b & 64) {
|
||||
int val = b & 0x3F;
|
||||
while (b & 0x40) {
|
||||
val <<= 6;
|
||||
|
||||
b = data.getByte();
|
||||
pos += 1;
|
||||
|
||||
val |= (b & 63);
|
||||
val |= (b & 0x3F);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
std::vector<PycCode::exception_table_entry_t> PycCode::exceptTableEntries() const
|
||||
std::vector<PycExceptionTableEntry> PycCode::exceptionTableEntries() const
|
||||
{
|
||||
PycBuffer data(m_exceptTable->value(), m_exceptTable->length());
|
||||
|
||||
std::vector<exception_table_entry_t> entries;
|
||||
std::vector<PycExceptionTableEntry> entries;
|
||||
|
||||
int pos = 0;
|
||||
while (!data.atEof()) {
|
||||
@@ -164,7 +164,7 @@ std::vector<PycCode::exception_table_entry_t> PycCode::exceptTableEntries() cons
|
||||
int depth = dl >> 1;
|
||||
bool lasti = bool(dl & 1);
|
||||
|
||||
entries.emplace_back(start, end, target, depth, lasti);
|
||||
entries.push_back(PycExceptionTableEntry(start, end, target, depth, lasti));
|
||||
}
|
||||
|
||||
return entries;
|
||||
|
16
pyc_code.h
16
pyc_code.h
@@ -8,6 +8,18 @@
|
||||
class PycData;
|
||||
class PycModule;
|
||||
|
||||
class PycExceptionTableEntry {
|
||||
public:
|
||||
int start_offset; // inclusive
|
||||
int end_offset; // exclusive
|
||||
int target;
|
||||
int stack_depth;
|
||||
bool push_lasti;
|
||||
|
||||
PycExceptionTableEntry(int m_start_offset, int m_end_offset, int m_target, int m_stack_depth, bool m_push_lasti) :
|
||||
start_offset(m_start_offset), end_offset(m_end_offset), target(m_target), stack_depth(m_stack_depth), push_lasti(m_push_lasti) {};
|
||||
};
|
||||
|
||||
class PycCode : public PycObject {
|
||||
public:
|
||||
typedef std::vector<PycRef<PycString>> globals_t;
|
||||
@@ -87,9 +99,7 @@ public:
|
||||
m_globalsUsed.emplace_back(std::move(varname));
|
||||
}
|
||||
|
||||
typedef std::tuple<int, int, int, int, bool> exception_table_entry_t;
|
||||
|
||||
std::vector<exception_table_entry_t> exceptTableEntries() const;
|
||||
std::vector<PycExceptionTableEntry> exceptionTableEntries() const;
|
||||
|
||||
private:
|
||||
int m_argCount, m_posOnlyArgCount, m_kwOnlyArgCount, m_numLocals;
|
||||
|
Reference in New Issue
Block a user