chore: directory structure
This commit is contained in:
207
pycdc/ASTNode.cpp
Normal file
207
pycdc/ASTNode.cpp
Normal file
@@ -0,0 +1,207 @@
|
||||
#include "ASTNode.h"
|
||||
#include "bytecode.h"
|
||||
|
||||
/* ASTNodeList */
|
||||
void ASTNodeList::removeLast()
|
||||
{
|
||||
list_t::iterator it = m_nodes.end();
|
||||
--it;
|
||||
m_nodes.erase(it);
|
||||
}
|
||||
|
||||
void ASTNodeList::removeFirst()
|
||||
{
|
||||
m_nodes.erase(m_nodes.begin());
|
||||
}
|
||||
|
||||
|
||||
/* ASTUnary */
|
||||
const char* ASTUnary::op_str() const
|
||||
{
|
||||
static const char* s_op_strings[] = {
|
||||
"+", "-", "~", "not "
|
||||
};
|
||||
return s_op_strings[op()];
|
||||
}
|
||||
|
||||
|
||||
/* ASTBinary */
|
||||
const char* ASTBinary::op_str() const
|
||||
{
|
||||
static const char* s_op_strings[] = {
|
||||
".", " ** ", " * ", " / ", " // ", " % ", " + ", " - ",
|
||||
" << ", " >> ", " & ", " ^ ", " | ", " and ", " or ", " @ ",
|
||||
" += ", " -= ", " *= ", " /= ", " %= ", " **= ", " <<= ",
|
||||
" >>= ", " &= ", " ^= ", " |= ", " //= ", " @= ", " <INVALID> "
|
||||
|
||||
};
|
||||
return s_op_strings[op()];
|
||||
}
|
||||
|
||||
ASTBinary::BinOp ASTBinary::from_opcode(int opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case Pyc::BINARY_ADD:
|
||||
return BIN_ADD;
|
||||
case Pyc::BINARY_AND:
|
||||
return BIN_AND;
|
||||
case Pyc::BINARY_DIVIDE:
|
||||
return BIN_DIVIDE;
|
||||
case Pyc::BINARY_FLOOR_DIVIDE:
|
||||
return BIN_FLOOR_DIVIDE;
|
||||
case Pyc::BINARY_LSHIFT:
|
||||
return BIN_LSHIFT;
|
||||
case Pyc::BINARY_MODULO:
|
||||
return BIN_MODULO;
|
||||
case Pyc::BINARY_MULTIPLY:
|
||||
return BIN_MULTIPLY;
|
||||
case Pyc::BINARY_OR:
|
||||
return BIN_OR;
|
||||
case Pyc::BINARY_POWER:
|
||||
return BIN_POWER;
|
||||
case Pyc::BINARY_RSHIFT:
|
||||
return BIN_RSHIFT;
|
||||
case Pyc::BINARY_SUBTRACT:
|
||||
return BIN_SUBTRACT;
|
||||
case Pyc::BINARY_TRUE_DIVIDE:
|
||||
return BIN_DIVIDE;
|
||||
case Pyc::BINARY_XOR:
|
||||
return BIN_XOR;
|
||||
case Pyc::BINARY_MATRIX_MULTIPLY:
|
||||
return BIN_MAT_MULTIPLY;
|
||||
case Pyc::INPLACE_ADD:
|
||||
return BIN_IP_ADD;
|
||||
case Pyc::INPLACE_AND:
|
||||
return BIN_IP_AND;
|
||||
case Pyc::INPLACE_DIVIDE:
|
||||
return BIN_IP_DIVIDE;
|
||||
case Pyc::INPLACE_FLOOR_DIVIDE:
|
||||
return BIN_IP_FLOOR_DIVIDE;
|
||||
case Pyc::INPLACE_LSHIFT:
|
||||
return BIN_IP_LSHIFT;
|
||||
case Pyc::INPLACE_MODULO:
|
||||
return BIN_IP_MODULO;
|
||||
case Pyc::INPLACE_MULTIPLY:
|
||||
return BIN_IP_MULTIPLY;
|
||||
case Pyc::INPLACE_OR:
|
||||
return BIN_IP_OR;
|
||||
case Pyc::INPLACE_POWER:
|
||||
return BIN_IP_POWER;
|
||||
case Pyc::INPLACE_RSHIFT:
|
||||
return BIN_IP_RSHIFT;
|
||||
case Pyc::INPLACE_SUBTRACT:
|
||||
return BIN_IP_SUBTRACT;
|
||||
case Pyc::INPLACE_TRUE_DIVIDE:
|
||||
return BIN_IP_DIVIDE;
|
||||
case Pyc::INPLACE_XOR:
|
||||
return BIN_IP_XOR;
|
||||
case Pyc::INPLACE_MATRIX_MULTIPLY:
|
||||
return BIN_IP_MAT_MULTIPLY;
|
||||
default:
|
||||
return BIN_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
ASTBinary::BinOp ASTBinary::from_binary_op(int operand)
|
||||
{
|
||||
switch (operand) {
|
||||
case 0:
|
||||
return BIN_ADD;
|
||||
case 1:
|
||||
return BIN_AND;
|
||||
case 2:
|
||||
return BIN_FLOOR_DIVIDE;
|
||||
case 3:
|
||||
return BIN_LSHIFT;
|
||||
case 4:
|
||||
return BIN_MAT_MULTIPLY;
|
||||
case 5:
|
||||
return BIN_MULTIPLY;
|
||||
case 6:
|
||||
return BIN_MODULO;
|
||||
case 7:
|
||||
return BIN_OR;
|
||||
case 8:
|
||||
return BIN_POWER;
|
||||
case 9:
|
||||
return BIN_RSHIFT;
|
||||
case 10:
|
||||
return BIN_SUBTRACT;
|
||||
case 11:
|
||||
return BIN_DIVIDE;
|
||||
case 12:
|
||||
return BIN_XOR;
|
||||
case 13:
|
||||
return BIN_IP_ADD;
|
||||
case 14:
|
||||
return BIN_IP_AND;
|
||||
case 15:
|
||||
return BIN_IP_FLOOR_DIVIDE;
|
||||
case 16:
|
||||
return BIN_IP_LSHIFT;
|
||||
case 17:
|
||||
return BIN_MAT_MULTIPLY;
|
||||
case 18:
|
||||
return BIN_IP_MULTIPLY;
|
||||
case 19:
|
||||
return BIN_IP_MODULO;
|
||||
case 20:
|
||||
return BIN_IP_OR;
|
||||
case 21:
|
||||
return BIN_IP_POWER;
|
||||
case 22:
|
||||
return BIN_IP_RSHIFT;
|
||||
case 23:
|
||||
return BIN_IP_SUBTRACT;
|
||||
case 24:
|
||||
return BIN_IP_DIVIDE;
|
||||
case 25:
|
||||
return BIN_IP_XOR;
|
||||
default:
|
||||
return BIN_INVALID; // Return BIN_INVALID for out-of-range operand
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ASTCompare */
|
||||
const char* ASTCompare::op_str() const
|
||||
{
|
||||
static const char* s_cmp_strings[] = {
|
||||
" < ", " <= ", " == ", " != ", " > ", " >= ", " in ", " not in ", " is ", " is not ",
|
||||
"<EXCEPTION MATCH>", "<BAD>"
|
||||
};
|
||||
return s_cmp_strings[op()];
|
||||
}
|
||||
|
||||
|
||||
/* ASTKeyword */
|
||||
const char* ASTKeyword::word_str() const
|
||||
{
|
||||
static const char* s_word_strings[] = {
|
||||
"pass", "break", "continue"
|
||||
};
|
||||
return s_word_strings[key()];
|
||||
}
|
||||
|
||||
|
||||
/* ASTBlock */
|
||||
void ASTBlock::removeLast()
|
||||
{
|
||||
list_t::iterator it = m_nodes.end();
|
||||
--it;
|
||||
m_nodes.erase(it);
|
||||
}
|
||||
|
||||
void ASTBlock::removeFirst()
|
||||
{
|
||||
m_nodes.erase(m_nodes.begin());
|
||||
}
|
||||
|
||||
const char* ASTBlock::type_str() const
|
||||
{
|
||||
static const char* s_type_strings[] = {
|
||||
"", "if", "else", "elif", "try", "CONTAINER", "except",
|
||||
"finally", "while", "for", "with", "async for"
|
||||
};
|
||||
return s_type_strings[blktype()];
|
||||
}
|
||||
760
pycdc/ASTNode.h
Normal file
760
pycdc/ASTNode.h
Normal file
@@ -0,0 +1,760 @@
|
||||
#ifndef _PYC_ASTNODE_H
|
||||
#define _PYC_ASTNODE_H
|
||||
|
||||
#include "pyc_module.h"
|
||||
#include <list>
|
||||
#include <deque>
|
||||
|
||||
/* Similar interface to PycObject, so PycRef can work on it... *
|
||||
* However, this does *NOT* mean the two are interchangeable! */
|
||||
class ASTNode {
|
||||
public:
|
||||
enum Type {
|
||||
NODE_INVALID, NODE_NODELIST, NODE_OBJECT, NODE_UNARY, NODE_BINARY,
|
||||
NODE_COMPARE, NODE_SLICE, NODE_STORE, NODE_RETURN, NODE_NAME,
|
||||
NODE_DELETE, NODE_FUNCTION, NODE_CLASS, NODE_CALL, NODE_IMPORT,
|
||||
NODE_TUPLE, NODE_LIST, NODE_SET, NODE_MAP, NODE_SUBSCR, NODE_PRINT,
|
||||
NODE_CONVERT, NODE_KEYWORD, NODE_RAISE, NODE_EXEC, NODE_BLOCK,
|
||||
NODE_COMPREHENSION, NODE_LOADBUILDCLASS, NODE_AWAITABLE,
|
||||
NODE_FORMATTEDVALUE, NODE_JOINEDSTR, NODE_CONST_MAP,
|
||||
NODE_ANNOTATED_VAR, NODE_CHAINSTORE, NODE_TERNARY,
|
||||
NODE_KW_NAMES_MAP,
|
||||
|
||||
// Empty node types
|
||||
NODE_LOCALS,
|
||||
};
|
||||
|
||||
ASTNode(int type = NODE_INVALID) : m_refs(), m_type(type), m_processed() { }
|
||||
virtual ~ASTNode() { }
|
||||
|
||||
int type() const { return internalGetType(this); }
|
||||
|
||||
bool processed() const { return m_processed; }
|
||||
void setProcessed() { m_processed = true; }
|
||||
|
||||
private:
|
||||
int m_refs;
|
||||
int m_type;
|
||||
bool m_processed;
|
||||
|
||||
// Hack to make clang happy :(
|
||||
static int internalGetType(const ASTNode *node)
|
||||
{
|
||||
return node ? node->m_type : NODE_INVALID;
|
||||
}
|
||||
|
||||
static void internalAddRef(ASTNode *node)
|
||||
{
|
||||
if (node)
|
||||
++node->m_refs;
|
||||
}
|
||||
|
||||
static void internalDelRef(ASTNode *node)
|
||||
{
|
||||
if (node && --node->m_refs == 0)
|
||||
delete node;
|
||||
}
|
||||
|
||||
public:
|
||||
void addRef() { internalAddRef(this); }
|
||||
void delRef() { internalDelRef(this); }
|
||||
};
|
||||
|
||||
|
||||
class ASTNodeList : public ASTNode {
|
||||
public:
|
||||
typedef std::list<PycRef<ASTNode>> list_t;
|
||||
|
||||
ASTNodeList(list_t nodes)
|
||||
: ASTNode(NODE_NODELIST), m_nodes(std::move(nodes)) { }
|
||||
|
||||
const list_t& nodes() const { return m_nodes; }
|
||||
void removeFirst();
|
||||
void removeLast();
|
||||
void append(PycRef<ASTNode> node) { m_nodes.emplace_back(std::move(node)); }
|
||||
|
||||
protected:
|
||||
ASTNodeList(list_t nodes, ASTNode::Type type)
|
||||
: ASTNode(type), m_nodes(std::move(nodes)) { }
|
||||
|
||||
private:
|
||||
list_t m_nodes;
|
||||
};
|
||||
|
||||
|
||||
class ASTChainStore : public ASTNodeList {
|
||||
public:
|
||||
ASTChainStore(list_t nodes, PycRef<ASTNode> src)
|
||||
: ASTNodeList(nodes, NODE_CHAINSTORE), m_src(std::move(src)) { }
|
||||
|
||||
PycRef<ASTNode> src() const { return m_src; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_src;
|
||||
};
|
||||
|
||||
|
||||
class ASTObject : public ASTNode {
|
||||
public:
|
||||
ASTObject(PycRef<PycObject> obj)
|
||||
: ASTNode(NODE_OBJECT), m_obj(std::move(obj)) { }
|
||||
|
||||
PycRef<PycObject> object() const { return m_obj; }
|
||||
|
||||
private:
|
||||
PycRef<PycObject> m_obj;
|
||||
};
|
||||
|
||||
|
||||
class ASTUnary : public ASTNode {
|
||||
public:
|
||||
enum UnOp {
|
||||
UN_POSITIVE, UN_NEGATIVE, UN_INVERT, UN_NOT
|
||||
};
|
||||
|
||||
ASTUnary(PycRef<ASTNode> operand, int op)
|
||||
: ASTNode(NODE_UNARY), m_op(op), m_operand(std::move(operand)) { }
|
||||
|
||||
PycRef<ASTNode> operand() const { return m_operand; }
|
||||
int op() const { return m_op; }
|
||||
virtual const char* op_str() const;
|
||||
|
||||
protected:
|
||||
int m_op;
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_operand;
|
||||
};
|
||||
|
||||
|
||||
class ASTBinary : public ASTNode {
|
||||
public:
|
||||
enum BinOp {
|
||||
BIN_ATTR, BIN_POWER, BIN_MULTIPLY, BIN_DIVIDE, BIN_FLOOR_DIVIDE,
|
||||
BIN_MODULO, BIN_ADD, BIN_SUBTRACT, BIN_LSHIFT, BIN_RSHIFT, BIN_AND,
|
||||
BIN_XOR, BIN_OR, BIN_LOG_AND, BIN_LOG_OR, BIN_MAT_MULTIPLY,
|
||||
/* Inplace operations */
|
||||
BIN_IP_ADD, BIN_IP_SUBTRACT, BIN_IP_MULTIPLY, BIN_IP_DIVIDE,
|
||||
BIN_IP_MODULO, BIN_IP_POWER, BIN_IP_LSHIFT, BIN_IP_RSHIFT, BIN_IP_AND,
|
||||
BIN_IP_XOR, BIN_IP_OR, BIN_IP_FLOOR_DIVIDE, BIN_IP_MAT_MULTIPLY,
|
||||
/* Error Case */
|
||||
BIN_INVALID
|
||||
};
|
||||
|
||||
ASTBinary(PycRef<ASTNode> left, PycRef<ASTNode> right, int op,
|
||||
int type = NODE_BINARY)
|
||||
: ASTNode(type), m_op(op), m_left(std::move(left)), m_right(std::move(right)) { }
|
||||
|
||||
PycRef<ASTNode> left() const { return m_left; }
|
||||
PycRef<ASTNode> right() const { return m_right; }
|
||||
int op() const { return m_op; }
|
||||
bool is_inplace() const { return m_op >= BIN_IP_ADD; }
|
||||
virtual const char* op_str() const;
|
||||
|
||||
static BinOp from_opcode(int opcode);
|
||||
static BinOp from_binary_op(int operand);
|
||||
|
||||
protected:
|
||||
int m_op;
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_left;
|
||||
PycRef<ASTNode> m_right;
|
||||
};
|
||||
|
||||
|
||||
class ASTCompare : public ASTBinary {
|
||||
public:
|
||||
enum CompareOp {
|
||||
CMP_LESS, CMP_LESS_EQUAL, CMP_EQUAL, CMP_NOT_EQUAL, CMP_GREATER,
|
||||
CMP_GREATER_EQUAL, CMP_IN, CMP_NOT_IN, CMP_IS, CMP_IS_NOT,
|
||||
CMP_EXCEPTION, CMP_BAD
|
||||
};
|
||||
|
||||
ASTCompare(PycRef<ASTNode> left, PycRef<ASTNode> right, int op)
|
||||
: ASTBinary(std::move(left), std::move(right), op, NODE_COMPARE) { }
|
||||
|
||||
const char* op_str() const override;
|
||||
};
|
||||
|
||||
|
||||
class ASTSlice : public ASTBinary {
|
||||
public:
|
||||
enum SliceOp {
|
||||
SLICE0, SLICE1, SLICE2, SLICE3
|
||||
};
|
||||
|
||||
ASTSlice(int op, PycRef<ASTNode> left = {}, PycRef<ASTNode> right = {})
|
||||
: ASTBinary(std::move(left), std::move(right), op, NODE_SLICE) { }
|
||||
};
|
||||
|
||||
|
||||
class ASTStore : public ASTNode {
|
||||
public:
|
||||
ASTStore(PycRef<ASTNode> src, PycRef<ASTNode> dest)
|
||||
: ASTNode(NODE_STORE), m_src(std::move(src)), m_dest(std::move(dest)) { }
|
||||
|
||||
PycRef<ASTNode> src() const { return m_src; }
|
||||
PycRef<ASTNode> dest() const { return m_dest; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_src;
|
||||
PycRef<ASTNode> m_dest;
|
||||
};
|
||||
|
||||
|
||||
class ASTReturn : public ASTNode {
|
||||
public:
|
||||
enum RetType {
|
||||
RETURN, YIELD, YIELD_FROM
|
||||
};
|
||||
|
||||
ASTReturn(PycRef<ASTNode> value, RetType rettype = RETURN)
|
||||
: ASTNode(NODE_RETURN), m_value(std::move(value)), m_rettype(rettype) { }
|
||||
|
||||
PycRef<ASTNode> value() const { return m_value; }
|
||||
RetType rettype() const { return m_rettype; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_value;
|
||||
RetType m_rettype;
|
||||
};
|
||||
|
||||
|
||||
class ASTName : public ASTNode {
|
||||
public:
|
||||
ASTName(PycRef<PycString> name)
|
||||
: ASTNode(NODE_NAME), m_name(std::move(name)) { }
|
||||
|
||||
PycRef<PycString> name() const { return m_name; }
|
||||
|
||||
private:
|
||||
PycRef<PycString> m_name;
|
||||
};
|
||||
|
||||
|
||||
class ASTDelete : public ASTNode {
|
||||
public:
|
||||
ASTDelete(PycRef<ASTNode> value)
|
||||
: ASTNode(NODE_DELETE), m_value(std::move(value)) { }
|
||||
|
||||
PycRef<ASTNode> value() const { return m_value; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_value;
|
||||
};
|
||||
|
||||
|
||||
class ASTFunction : public ASTNode {
|
||||
public:
|
||||
typedef std::list<PycRef<ASTNode>> defarg_t;
|
||||
|
||||
ASTFunction(PycRef<ASTNode> code, defarg_t defArgs, defarg_t kwDefArgs)
|
||||
: ASTNode(NODE_FUNCTION), m_code(std::move(code)),
|
||||
m_defargs(std::move(defArgs)), m_kwdefargs(std::move(kwDefArgs)) { }
|
||||
|
||||
PycRef<ASTNode> code() const { return m_code; }
|
||||
const defarg_t& defargs() const { return m_defargs; }
|
||||
const defarg_t& kwdefargs() const { return m_kwdefargs; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_code;
|
||||
defarg_t m_defargs;
|
||||
defarg_t m_kwdefargs;
|
||||
};
|
||||
|
||||
|
||||
class ASTClass : public ASTNode {
|
||||
public:
|
||||
ASTClass(PycRef<ASTNode> code, PycRef<ASTNode> bases, PycRef<ASTNode> name)
|
||||
: ASTNode(NODE_CLASS), m_code(std::move(code)), m_bases(std::move(bases)),
|
||||
m_name(std::move(name)) { }
|
||||
|
||||
PycRef<ASTNode> code() const { return m_code; }
|
||||
PycRef<ASTNode> bases() const { return m_bases; }
|
||||
PycRef<ASTNode> name() const { return m_name; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_code;
|
||||
PycRef<ASTNode> m_bases;
|
||||
PycRef<ASTNode> m_name;
|
||||
};
|
||||
|
||||
|
||||
class ASTCall : public ASTNode {
|
||||
public:
|
||||
typedef std::list<PycRef<ASTNode>> pparam_t;
|
||||
typedef std::list<std::pair<PycRef<ASTNode>, PycRef<ASTNode>>> kwparam_t;
|
||||
|
||||
ASTCall(PycRef<ASTNode> func, pparam_t pparams, kwparam_t kwparams)
|
||||
: ASTNode(NODE_CALL), m_func(std::move(func)), m_pparams(std::move(pparams)),
|
||||
m_kwparams(std::move(kwparams)) { }
|
||||
|
||||
PycRef<ASTNode> func() const { return m_func; }
|
||||
const pparam_t& pparams() const { return m_pparams; }
|
||||
const kwparam_t& kwparams() const { return m_kwparams; }
|
||||
PycRef<ASTNode> var() const { return m_var; }
|
||||
PycRef<ASTNode> kw() const { return m_kw; }
|
||||
|
||||
bool hasVar() const { return m_var != nullptr; }
|
||||
bool hasKW() const { return m_kw != nullptr; }
|
||||
|
||||
void setVar(PycRef<ASTNode> var) { m_var = std::move(var); }
|
||||
void setKW(PycRef<ASTNode> kw) { m_kw = std::move(kw); }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_func;
|
||||
pparam_t m_pparams;
|
||||
kwparam_t m_kwparams;
|
||||
PycRef<ASTNode> m_var;
|
||||
PycRef<ASTNode> m_kw;
|
||||
};
|
||||
|
||||
|
||||
class ASTImport : public ASTNode {
|
||||
public:
|
||||
typedef std::list<PycRef<ASTStore>> list_t;
|
||||
|
||||
ASTImport(PycRef<ASTNode> name, PycRef<ASTNode> fromlist)
|
||||
: ASTNode(NODE_IMPORT), m_name(std::move(name)), m_fromlist(std::move(fromlist)) { }
|
||||
|
||||
PycRef<ASTNode> name() const { return m_name; }
|
||||
list_t stores() const { return m_stores; }
|
||||
void add_store(PycRef<ASTStore> store) { m_stores.emplace_back(std::move(store)); }
|
||||
|
||||
PycRef<ASTNode> fromlist() const { return m_fromlist; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_name;
|
||||
list_t m_stores;
|
||||
|
||||
PycRef<ASTNode> m_fromlist;
|
||||
};
|
||||
|
||||
|
||||
class ASTTuple : public ASTNode {
|
||||
public:
|
||||
typedef std::vector<PycRef<ASTNode>> value_t;
|
||||
|
||||
ASTTuple(value_t values)
|
||||
: ASTNode(NODE_TUPLE), m_values(std::move(values)),
|
||||
m_requireParens(true) { }
|
||||
|
||||
const value_t& values() const { return m_values; }
|
||||
void add(PycRef<ASTNode> name) { m_values.emplace_back(std::move(name)); }
|
||||
|
||||
void setRequireParens(bool require) { m_requireParens = require; }
|
||||
bool requireParens() const { return m_requireParens; }
|
||||
|
||||
private:
|
||||
value_t m_values;
|
||||
bool m_requireParens;
|
||||
};
|
||||
|
||||
|
||||
class ASTList : public ASTNode {
|
||||
public:
|
||||
typedef std::list<PycRef<ASTNode>> value_t;
|
||||
|
||||
ASTList(value_t values)
|
||||
: ASTNode(NODE_LIST), m_values(std::move(values)) { }
|
||||
|
||||
const value_t& values() const { return m_values; }
|
||||
|
||||
private:
|
||||
value_t m_values;
|
||||
};
|
||||
|
||||
class ASTSet : public ASTNode {
|
||||
public:
|
||||
typedef std::deque<PycRef<ASTNode>> value_t;
|
||||
|
||||
ASTSet(value_t values)
|
||||
: ASTNode(NODE_SET), m_values(std::move(values)) { }
|
||||
|
||||
const value_t& values() const { return m_values; }
|
||||
|
||||
private:
|
||||
value_t m_values;
|
||||
};
|
||||
|
||||
class ASTMap : public ASTNode {
|
||||
public:
|
||||
typedef std::list<std::pair<PycRef<ASTNode>, PycRef<ASTNode>>> map_t;
|
||||
|
||||
ASTMap() : ASTNode(NODE_MAP) { }
|
||||
|
||||
void add(PycRef<ASTNode> key, PycRef<ASTNode> value)
|
||||
{
|
||||
m_values.emplace_back(std::move(key), std::move(value));
|
||||
}
|
||||
|
||||
const map_t& values() const { return m_values; }
|
||||
|
||||
private:
|
||||
map_t m_values;
|
||||
};
|
||||
|
||||
class ASTKwNamesMap : public ASTNode {
|
||||
public:
|
||||
typedef std::list<std::pair<PycRef<ASTNode>, PycRef<ASTNode>>> map_t;
|
||||
|
||||
ASTKwNamesMap() : ASTNode(NODE_KW_NAMES_MAP) { }
|
||||
|
||||
void add(PycRef<ASTNode> key, PycRef<ASTNode> value)
|
||||
{
|
||||
m_values.emplace_back(std::move(key), std::move(value));
|
||||
}
|
||||
|
||||
const map_t& values() const { return m_values; }
|
||||
|
||||
private:
|
||||
map_t m_values;
|
||||
};
|
||||
|
||||
class ASTConstMap : public ASTNode {
|
||||
public:
|
||||
typedef std::vector<PycRef<ASTNode>> values_t;
|
||||
|
||||
ASTConstMap(PycRef<ASTNode> keys, const values_t& values)
|
||||
: ASTNode(NODE_CONST_MAP), m_keys(std::move(keys)), m_values(std::move(values)) { }
|
||||
|
||||
const PycRef<ASTNode>& keys() const { return m_keys; }
|
||||
const values_t& values() const { return m_values; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_keys;
|
||||
values_t m_values;
|
||||
};
|
||||
|
||||
|
||||
class ASTSubscr : public ASTNode {
|
||||
public:
|
||||
ASTSubscr(PycRef<ASTNode> name, PycRef<ASTNode> key)
|
||||
: ASTNode(NODE_SUBSCR), m_name(std::move(name)), m_key(std::move(key)) { }
|
||||
|
||||
PycRef<ASTNode> name() const { return m_name; }
|
||||
PycRef<ASTNode> key() const { return m_key; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_name;
|
||||
PycRef<ASTNode> m_key;
|
||||
};
|
||||
|
||||
|
||||
class ASTPrint : public ASTNode {
|
||||
public:
|
||||
typedef std::list<PycRef<ASTNode>> values_t;
|
||||
|
||||
ASTPrint(PycRef<ASTNode> value, PycRef<ASTNode> stream = {})
|
||||
: ASTNode(NODE_PRINT), m_stream(std::move(stream)), m_eol()
|
||||
{
|
||||
if (value != nullptr)
|
||||
m_values.emplace_back(std::move(value));
|
||||
else
|
||||
m_eol = true;
|
||||
}
|
||||
|
||||
values_t values() const { return m_values; }
|
||||
PycRef<ASTNode> stream() const { return m_stream; }
|
||||
bool eol() const { return m_eol; }
|
||||
|
||||
void add(PycRef<ASTNode> value) { m_values.emplace_back(std::move(value)); }
|
||||
void setEol(bool eol) { m_eol = eol; }
|
||||
|
||||
private:
|
||||
values_t m_values;
|
||||
PycRef<ASTNode> m_stream;
|
||||
bool m_eol;
|
||||
};
|
||||
|
||||
|
||||
class ASTConvert : public ASTNode {
|
||||
public:
|
||||
ASTConvert(PycRef<ASTNode> name)
|
||||
: ASTNode(NODE_CONVERT), m_name(std::move(name)) { }
|
||||
|
||||
PycRef<ASTNode> name() const { return m_name; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_name;
|
||||
};
|
||||
|
||||
|
||||
class ASTKeyword : public ASTNode {
|
||||
public:
|
||||
enum Word {
|
||||
KW_PASS, KW_BREAK, KW_CONTINUE
|
||||
};
|
||||
|
||||
ASTKeyword(Word key) : ASTNode(NODE_KEYWORD), m_key(key) { }
|
||||
|
||||
Word key() const { return m_key; }
|
||||
const char* word_str() const;
|
||||
|
||||
private:
|
||||
Word m_key;
|
||||
};
|
||||
|
||||
|
||||
class ASTRaise : public ASTNode {
|
||||
public:
|
||||
typedef std::list<PycRef<ASTNode>> param_t;
|
||||
|
||||
ASTRaise(param_t params) : ASTNode(NODE_RAISE), m_params(std::move(params)) { }
|
||||
|
||||
const param_t& params() const { return m_params; }
|
||||
|
||||
private:
|
||||
param_t m_params;
|
||||
};
|
||||
|
||||
|
||||
class ASTExec : public ASTNode {
|
||||
public:
|
||||
ASTExec(PycRef<ASTNode> stmt, PycRef<ASTNode> glob, PycRef<ASTNode> loc)
|
||||
: ASTNode(NODE_EXEC), m_stmt(std::move(stmt)), m_glob(std::move(glob)),
|
||||
m_loc(std::move(loc)) { }
|
||||
|
||||
PycRef<ASTNode> statement() const { return m_stmt; }
|
||||
PycRef<ASTNode> globals() const { return m_glob; }
|
||||
PycRef<ASTNode> locals() const { return m_loc; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_stmt;
|
||||
PycRef<ASTNode> m_glob;
|
||||
PycRef<ASTNode> m_loc;
|
||||
};
|
||||
|
||||
|
||||
class ASTBlock : public ASTNode {
|
||||
public:
|
||||
typedef std::list<PycRef<ASTNode>> list_t;
|
||||
|
||||
enum BlkType {
|
||||
BLK_MAIN, BLK_IF, BLK_ELSE, BLK_ELIF, BLK_TRY,
|
||||
BLK_CONTAINER, BLK_EXCEPT, BLK_FINALLY,
|
||||
BLK_WHILE, BLK_FOR, BLK_WITH, BLK_ASYNCFOR
|
||||
};
|
||||
|
||||
ASTBlock(BlkType blktype, int end = 0, int inited = 0)
|
||||
: ASTNode(NODE_BLOCK), m_blktype(blktype), m_end(end), m_inited(inited) { }
|
||||
|
||||
BlkType blktype() const { return m_blktype; }
|
||||
int end() const { return m_end; }
|
||||
const list_t& nodes() const { return m_nodes; }
|
||||
list_t::size_type size() const { return m_nodes.size(); }
|
||||
void removeFirst();
|
||||
void removeLast();
|
||||
void append(PycRef<ASTNode> node) { m_nodes.emplace_back(std::move(node)); }
|
||||
const char* type_str() const;
|
||||
|
||||
virtual int inited() const { return m_inited; }
|
||||
virtual void init() { m_inited = 1; }
|
||||
virtual void init(int init) { m_inited = init; }
|
||||
|
||||
void setEnd(int end) { m_end = end; }
|
||||
|
||||
private:
|
||||
BlkType m_blktype;
|
||||
int m_end;
|
||||
list_t m_nodes;
|
||||
|
||||
protected:
|
||||
int m_inited; /* Is the block's definition "complete" */
|
||||
};
|
||||
|
||||
|
||||
class ASTCondBlock : public ASTBlock {
|
||||
public:
|
||||
enum InitCond {
|
||||
UNINITED, POPPED, PRE_POPPED
|
||||
};
|
||||
|
||||
ASTCondBlock(ASTBlock::BlkType blktype, int end, PycRef<ASTNode> cond,
|
||||
bool negative = false)
|
||||
: ASTBlock(blktype, end), m_cond(std::move(cond)), m_negative(negative) { }
|
||||
|
||||
PycRef<ASTNode> cond() const { return m_cond; }
|
||||
bool negative() const { return m_negative; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_cond;
|
||||
bool m_negative;
|
||||
};
|
||||
|
||||
|
||||
class ASTIterBlock : public ASTBlock {
|
||||
public:
|
||||
ASTIterBlock(ASTBlock::BlkType blktype, int start, int end, PycRef<ASTNode> iter)
|
||||
: ASTBlock(blktype, end), m_iter(std::move(iter)), m_idx(), m_comp(), m_start(start) { }
|
||||
|
||||
PycRef<ASTNode> iter() const { return m_iter; }
|
||||
PycRef<ASTNode> index() const { return m_idx; }
|
||||
PycRef<ASTNode> condition() const { return m_cond; }
|
||||
bool isComprehension() const { return m_comp; }
|
||||
int start() const { return m_start; }
|
||||
|
||||
void setIndex(PycRef<ASTNode> idx) { m_idx = std::move(idx); init(); }
|
||||
void setCondition(PycRef<ASTNode> cond) { m_cond = std::move(cond); }
|
||||
void setComprehension(bool comp) { m_comp = comp; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_iter;
|
||||
PycRef<ASTNode> m_idx;
|
||||
PycRef<ASTNode> m_cond;
|
||||
bool m_comp;
|
||||
int m_start;
|
||||
};
|
||||
|
||||
class ASTContainerBlock : public ASTBlock {
|
||||
public:
|
||||
ASTContainerBlock(int finally, int except = 0)
|
||||
: ASTBlock(ASTBlock::BLK_CONTAINER, 0), m_finally(finally), m_except(except) { }
|
||||
|
||||
bool hasFinally() const { return m_finally != 0; }
|
||||
bool hasExcept() const { return m_except != 0; }
|
||||
int finally() const { return m_finally; }
|
||||
int except() const { return m_except; }
|
||||
|
||||
void setExcept(int except) { m_except = except; }
|
||||
|
||||
private:
|
||||
int m_finally;
|
||||
int m_except;
|
||||
};
|
||||
|
||||
class ASTWithBlock : public ASTBlock {
|
||||
public:
|
||||
ASTWithBlock(int end)
|
||||
: ASTBlock(ASTBlock::BLK_WITH, end) { }
|
||||
|
||||
PycRef<ASTNode> expr() const { return m_expr; }
|
||||
PycRef<ASTNode> var() const { return m_var; }
|
||||
|
||||
void setExpr(PycRef<ASTNode> expr) { m_expr = std::move(expr); init(); }
|
||||
void setVar(PycRef<ASTNode> var) { m_var = std::move(var); }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_expr;
|
||||
PycRef<ASTNode> m_var; // optional value
|
||||
};
|
||||
|
||||
class ASTComprehension : public ASTNode {
|
||||
public:
|
||||
typedef std::list<PycRef<ASTIterBlock>> generator_t;
|
||||
|
||||
ASTComprehension(PycRef<ASTNode> result)
|
||||
: ASTNode(NODE_COMPREHENSION), m_result(std::move(result)) { }
|
||||
|
||||
PycRef<ASTNode> result() const { return m_result; }
|
||||
generator_t generators() const { return m_generators; }
|
||||
|
||||
void addGenerator(PycRef<ASTIterBlock> gen) {
|
||||
m_generators.emplace_front(std::move(gen));
|
||||
}
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_result;
|
||||
generator_t m_generators;
|
||||
|
||||
};
|
||||
|
||||
class ASTLoadBuildClass : public ASTNode {
|
||||
public:
|
||||
ASTLoadBuildClass(PycRef<PycObject> obj)
|
||||
: ASTNode(NODE_LOADBUILDCLASS), m_obj(std::move(obj)) { }
|
||||
|
||||
PycRef<PycObject> object() const { return m_obj; }
|
||||
|
||||
private:
|
||||
PycRef<PycObject> m_obj;
|
||||
};
|
||||
|
||||
class ASTAwaitable : public ASTNode {
|
||||
public:
|
||||
ASTAwaitable(PycRef<ASTNode> expr)
|
||||
: ASTNode(NODE_AWAITABLE), m_expr(std::move(expr)) { }
|
||||
|
||||
PycRef<ASTNode> expression() const { return m_expr; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_expr;
|
||||
};
|
||||
|
||||
class ASTFormattedValue : public ASTNode {
|
||||
public:
|
||||
enum ConversionFlag {
|
||||
NONE = 0,
|
||||
STR = 1,
|
||||
REPR = 2,
|
||||
ASCII = 3,
|
||||
CONVERSION_MASK = 0x03,
|
||||
|
||||
HAVE_FMT_SPEC = 4,
|
||||
};
|
||||
|
||||
ASTFormattedValue(PycRef<ASTNode> val, ConversionFlag conversion,
|
||||
PycRef<ASTNode> format_spec)
|
||||
: ASTNode(NODE_FORMATTEDVALUE),
|
||||
m_val(std::move(val)),
|
||||
m_conversion(conversion),
|
||||
m_format_spec(std::move(format_spec))
|
||||
{ }
|
||||
|
||||
PycRef<ASTNode> val() const { return m_val; }
|
||||
ConversionFlag conversion() const { return m_conversion; }
|
||||
PycRef<ASTNode> format_spec() const { return m_format_spec; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_val;
|
||||
ConversionFlag m_conversion;
|
||||
PycRef<ASTNode> m_format_spec;
|
||||
};
|
||||
|
||||
// Same as ASTList
|
||||
class ASTJoinedStr : public ASTNode {
|
||||
public:
|
||||
typedef std::list<PycRef<ASTNode>> value_t;
|
||||
|
||||
ASTJoinedStr(value_t values)
|
||||
: ASTNode(NODE_JOINEDSTR), m_values(std::move(values)) { }
|
||||
|
||||
const value_t& values() const { return m_values; }
|
||||
|
||||
private:
|
||||
value_t m_values;
|
||||
};
|
||||
|
||||
class ASTAnnotatedVar : public ASTNode {
|
||||
public:
|
||||
ASTAnnotatedVar(PycRef<ASTNode> name, PycRef<ASTNode> type)
|
||||
: ASTNode(NODE_ANNOTATED_VAR), m_name(std::move(name)), m_type(std::move(type)) { }
|
||||
|
||||
PycRef<ASTNode> name() const noexcept { return m_name; }
|
||||
PycRef<ASTNode> annotation() const noexcept { return m_type; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_name;
|
||||
PycRef<ASTNode> m_type;
|
||||
};
|
||||
|
||||
class ASTTernary : public ASTNode
|
||||
{
|
||||
public:
|
||||
ASTTernary(PycRef<ASTNode> if_block, PycRef<ASTNode> if_expr,
|
||||
PycRef<ASTNode> else_expr)
|
||||
: ASTNode(NODE_TERNARY), m_if_block(std::move(if_block)),
|
||||
m_if_expr(std::move(if_expr)), m_else_expr(std::move(else_expr)) { }
|
||||
|
||||
PycRef<ASTNode> if_block() const noexcept { return m_if_block; }
|
||||
PycRef<ASTNode> if_expr() const noexcept { return m_if_expr; }
|
||||
PycRef<ASTNode> else_expr() const noexcept { return m_else_expr; }
|
||||
|
||||
private:
|
||||
PycRef<ASTNode> m_if_block; // contains "condition" and "negative"
|
||||
PycRef<ASTNode> m_if_expr;
|
||||
PycRef<ASTNode> m_else_expr;
|
||||
};
|
||||
|
||||
#endif
|
||||
3952
pycdc/ASTree.cpp
Normal file
3952
pycdc/ASTree.cpp
Normal file
File diff suppressed because it is too large
Load Diff
11
pycdc/ASTree.h
Normal file
11
pycdc/ASTree.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef _PYC_ASTREE_H
|
||||
#define _PYC_ASTREE_H
|
||||
|
||||
#include "ASTNode.h"
|
||||
|
||||
PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod);
|
||||
void print_src(PycRef<ASTNode> node, PycModule* mod, std::ostream& pyc_output);
|
||||
|
||||
void decompyle(PycRef<PycCode> code, PycModule* mod, std::ostream& pyc_output);
|
||||
|
||||
#endif
|
||||
72
pycdc/CMakeLists.txt
Normal file
72
pycdc/CMakeLists.txt
Normal file
@@ -0,0 +1,72 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(pycdc)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Debug options.
|
||||
option(ENABLE_BLOCK_DEBUG "Enable block debugging" OFF)
|
||||
option(ENABLE_STACK_DEBUG "Enable stack debugging" OFF)
|
||||
|
||||
# Turn debug defs on if they're enabled.
|
||||
if (ENABLE_BLOCK_DEBUG)
|
||||
add_definitions(-DBLOCK_DEBUG)
|
||||
endif()
|
||||
if (ENABLE_STACK_DEBUG)
|
||||
add_definitions(-DSTACK_DEBUG)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-error=shadow ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++ ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_executable(pyarmor-1shot
|
||||
pyarmor-1shot.cpp
|
||||
ASTree.cpp
|
||||
ASTNode.cpp
|
||||
bytecode.cpp
|
||||
data.cpp
|
||||
pyc_code.cpp
|
||||
pyc_module.cpp
|
||||
pyc_numeric.cpp
|
||||
pyc_object.cpp
|
||||
pyc_sequence.cpp
|
||||
pyc_string.cpp
|
||||
bytes/python_1_0.cpp
|
||||
bytes/python_1_1.cpp
|
||||
bytes/python_1_3.cpp
|
||||
bytes/python_1_4.cpp
|
||||
bytes/python_1_5.cpp
|
||||
bytes/python_1_6.cpp
|
||||
bytes/python_2_0.cpp
|
||||
bytes/python_2_1.cpp
|
||||
bytes/python_2_2.cpp
|
||||
bytes/python_2_3.cpp
|
||||
bytes/python_2_4.cpp
|
||||
bytes/python_2_5.cpp
|
||||
bytes/python_2_6.cpp
|
||||
bytes/python_2_7.cpp
|
||||
bytes/python_3_0.cpp
|
||||
bytes/python_3_1.cpp
|
||||
bytes/python_3_2.cpp
|
||||
bytes/python_3_3.cpp
|
||||
bytes/python_3_4.cpp
|
||||
bytes/python_3_5.cpp
|
||||
bytes/python_3_6.cpp
|
||||
bytes/python_3_7.cpp
|
||||
bytes/python_3_8.cpp
|
||||
bytes/python_3_9.cpp
|
||||
bytes/python_3_10.cpp
|
||||
bytes/python_3_11.cpp
|
||||
bytes/python_3_12.cpp
|
||||
bytes/python_3_13.cpp
|
||||
)
|
||||
|
||||
install(TARGETS pyarmor-1shot
|
||||
RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../oneshot)
|
||||
71
pycdc/FastStack.h
Normal file
71
pycdc/FastStack.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef _PYC_FASTSTACK_H
|
||||
#define _PYC_FASTSTACK_H
|
||||
|
||||
#include "ASTNode.h"
|
||||
#include <stack>
|
||||
|
||||
class FastStack {
|
||||
public:
|
||||
FastStack(int size) : m_ptr(-1) { m_stack.resize(size); }
|
||||
|
||||
FastStack(const FastStack& copy)
|
||||
: m_stack(copy.m_stack), m_ptr(copy.m_ptr) { }
|
||||
|
||||
FastStack& operator=(const FastStack& copy)
|
||||
{
|
||||
m_stack = copy.m_stack;
|
||||
m_ptr = copy.m_ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void push(PycRef<ASTNode> node)
|
||||
{
|
||||
if (static_cast<int>(m_stack.size()) == m_ptr + 1)
|
||||
m_stack.emplace_back(nullptr);
|
||||
|
||||
m_stack[++m_ptr] = std::move(node);
|
||||
}
|
||||
|
||||
void pop()
|
||||
{
|
||||
if (m_ptr > -1)
|
||||
m_stack[m_ptr--] = nullptr;
|
||||
else {
|
||||
#ifdef BLOCK_DEBUG
|
||||
fprintf(stderr, "pop from empty stack\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
PycRef<ASTNode> top(int i = 1) const
|
||||
{
|
||||
if (i > 0) {
|
||||
int idx = m_ptr + 1 - i;
|
||||
if ((m_ptr > -1) && (idx >= 0))
|
||||
return m_stack[idx];
|
||||
else {
|
||||
#ifdef BLOCK_DEBUG
|
||||
fprintf(stderr, "insufficient values on stack\n");
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "incorrect operand %i\n", i);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return m_ptr == -1;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<PycRef<ASTNode>> m_stack;
|
||||
int m_ptr;
|
||||
};
|
||||
|
||||
typedef std::stack<FastStack> stackhist_t;
|
||||
|
||||
#endif
|
||||
674
pycdc/LICENSE
Normal file
674
pycdc/LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
57
pycdc/README-Decompyle++.markdown
Normal file
57
pycdc/README-Decompyle++.markdown
Normal file
@@ -0,0 +1,57 @@
|
||||
# Decompyle++
|
||||
***A Python Byte-code Disassembler/Decompiler***
|
||||
|
||||
Decompyle++ aims to translate compiled Python byte-code back into valid
|
||||
and human-readable Python source code. While other projects have achieved
|
||||
this with varied success, Decompyle++ is unique in that it seeks to
|
||||
support byte-code from any version of Python.
|
||||
|
||||
Decompyle++ includes both a byte-code disassembler (pycdas) and a
|
||||
decompiler (pycdc).
|
||||
|
||||
As the name implies, Decompyle++ is written in C++.
|
||||
If you wish to contribute, please fork us on github at
|
||||
https://github.com/zrax/pycdc
|
||||
|
||||
## Building Decompyle++
|
||||
* Generate a project or makefile with [CMake](http://www.cmake.org) (See CMake's documentation for details)
|
||||
* The following options can be passed to CMake to control debug features:
|
||||
|
||||
| Option | Description |
|
||||
| --- | --- |
|
||||
| `-DCMAKE_BUILD_TYPE=Debug` | Produce debugging symbols |
|
||||
| `-DENABLE_BLOCK_DEBUG=ON` | Enable block debugging output |
|
||||
| `-DENABLE_STACK_DEBUG=ON` | Enable stack debugging output |
|
||||
|
||||
* Build the generated project or makefile
|
||||
* For projects (e.g. MSVC), open the generated project file and build it
|
||||
* For makefiles, just run `make`
|
||||
* To run tests (on \*nix or MSYS), run `make check JOBS=4` (optional
|
||||
`FILTER=xxxx` to run only certain tests)
|
||||
|
||||
## Usage
|
||||
**To run pycdas**, the PYC Disassembler:
|
||||
`./pycdas [PATH TO PYC FILE]`
|
||||
The byte-code disassembly is printed to stdout.
|
||||
|
||||
**To run pycdc**, the PYC Decompiler:
|
||||
`./pycdc [PATH TO PYC FILE]`
|
||||
The decompiled Python source is printed to stdout.
|
||||
Any errors are printed to stderr.
|
||||
|
||||
**Marshalled code objects**:
|
||||
Both tools support Python marshalled code objects, as output from `marshal.dumps(compile(...))`.
|
||||
|
||||
To use this feature, specify `-c -v <version>` on the command line - the version must be specified as the objects themselves do not contain version metadata.
|
||||
|
||||
## Authors, Licence, Credits
|
||||
Decompyle++ is the work of Michael Hansen and Darryl Pogue.
|
||||
|
||||
Additional contributions from:
|
||||
* charlietang98
|
||||
* Kunal Parmar
|
||||
* Olivier Iffrig
|
||||
* Zlodiy
|
||||
|
||||
It is released under the terms of the GNU General Public License, version 3;
|
||||
See LICENSE file for details.
|
||||
619
pycdc/bytecode.cpp
Normal file
619
pycdc/bytecode.cpp
Normal file
@@ -0,0 +1,619 @@
|
||||
#include "pyc_numeric.h"
|
||||
#include "bytecode.h"
|
||||
#include <stdexcept>
|
||||
#include <cstdint>
|
||||
#include <cmath>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#define DECLARE_PYTHON(maj, min) \
|
||||
extern int python_##maj##_##min##_map(int);
|
||||
|
||||
DECLARE_PYTHON(1, 0)
|
||||
DECLARE_PYTHON(1, 1)
|
||||
DECLARE_PYTHON(1, 3)
|
||||
DECLARE_PYTHON(1, 4)
|
||||
DECLARE_PYTHON(1, 5)
|
||||
DECLARE_PYTHON(1, 6)
|
||||
DECLARE_PYTHON(2, 0)
|
||||
DECLARE_PYTHON(2, 1)
|
||||
DECLARE_PYTHON(2, 2)
|
||||
DECLARE_PYTHON(2, 3)
|
||||
DECLARE_PYTHON(2, 4)
|
||||
DECLARE_PYTHON(2, 5)
|
||||
DECLARE_PYTHON(2, 6)
|
||||
DECLARE_PYTHON(2, 7)
|
||||
DECLARE_PYTHON(3, 0)
|
||||
DECLARE_PYTHON(3, 1)
|
||||
DECLARE_PYTHON(3, 2)
|
||||
DECLARE_PYTHON(3, 3)
|
||||
DECLARE_PYTHON(3, 4)
|
||||
DECLARE_PYTHON(3, 5)
|
||||
DECLARE_PYTHON(3, 6)
|
||||
DECLARE_PYTHON(3, 7)
|
||||
DECLARE_PYTHON(3, 8)
|
||||
DECLARE_PYTHON(3, 9)
|
||||
DECLARE_PYTHON(3, 10)
|
||||
DECLARE_PYTHON(3, 11)
|
||||
DECLARE_PYTHON(3, 12)
|
||||
DECLARE_PYTHON(3, 13)
|
||||
|
||||
const char* Pyc::OpcodeName(int opcode)
|
||||
{
|
||||
static const char* opcode_names[] = {
|
||||
#define OPCODE(x) #x,
|
||||
#define OPCODE_A_FIRST(x) #x,
|
||||
#define OPCODE_A(x) #x,
|
||||
#include "bytecode_ops.inl"
|
||||
#undef OPCODE_A
|
||||
#undef OPCODE_A_FIRST
|
||||
#undef OPCODE
|
||||
};
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
static_assert(sizeof(opcode_names) / sizeof(opcode_names[0]) == PYC_LAST_OPCODE,
|
||||
"Pyc::OpcodeName opcode_names not in sync with opcode enum");
|
||||
#endif
|
||||
|
||||
if (opcode < 0)
|
||||
return "<INVALID>";
|
||||
|
||||
if (opcode < PYC_LAST_OPCODE)
|
||||
return opcode_names[opcode];
|
||||
|
||||
static char badcode[16];
|
||||
snprintf(badcode, sizeof(badcode), "<%d>", opcode);
|
||||
return badcode;
|
||||
};
|
||||
|
||||
int Pyc::ByteToOpcode(int maj, int min, int opcode)
|
||||
{
|
||||
switch (maj) {
|
||||
case 1:
|
||||
switch (min) {
|
||||
case 0: return python_1_0_map(opcode);
|
||||
case 1: return python_1_1_map(opcode);
|
||||
case 3: return python_1_3_map(opcode);
|
||||
case 4: return python_1_4_map(opcode);
|
||||
case 5: return python_1_5_map(opcode);
|
||||
case 6: return python_1_6_map(opcode);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (min) {
|
||||
case 0: return python_2_0_map(opcode);
|
||||
case 1: return python_2_1_map(opcode);
|
||||
case 2: return python_2_2_map(opcode);
|
||||
case 3: return python_2_3_map(opcode);
|
||||
case 4: return python_2_4_map(opcode);
|
||||
case 5: return python_2_5_map(opcode);
|
||||
case 6: return python_2_6_map(opcode);
|
||||
case 7: return python_2_7_map(opcode);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
switch (min) {
|
||||
case 0: return python_3_0_map(opcode);
|
||||
case 1: return python_3_1_map(opcode);
|
||||
case 2: return python_3_2_map(opcode);
|
||||
case 3: return python_3_3_map(opcode);
|
||||
case 4: return python_3_4_map(opcode);
|
||||
case 5: return python_3_5_map(opcode);
|
||||
case 6: return python_3_6_map(opcode);
|
||||
case 7: return python_3_7_map(opcode);
|
||||
case 8: return python_3_8_map(opcode);
|
||||
case 9: return python_3_9_map(opcode);
|
||||
case 10: return python_3_10_map(opcode);
|
||||
case 11: return python_3_11_map(opcode);
|
||||
case 12: return python_3_12_map(opcode);
|
||||
case 13: return python_3_13_map(opcode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return PYC_INVALID_OPCODE;
|
||||
}
|
||||
|
||||
void print_const(std::ostream& pyc_output, PycRef<PycObject> obj, PycModule* mod,
|
||||
const char* parent_f_string_quote, bool das_decrypt_print)
|
||||
{
|
||||
if (obj == NULL) {
|
||||
pyc_output << "<NULL>";
|
||||
return;
|
||||
}
|
||||
|
||||
switch (obj->type()) {
|
||||
case PycObject::TYPE_STRING:
|
||||
case PycObject::TYPE_UNICODE:
|
||||
case PycObject::TYPE_INTERNED:
|
||||
case PycObject::TYPE_ASCII:
|
||||
case PycObject::TYPE_ASCII_INTERNED:
|
||||
case PycObject::TYPE_SHORT_ASCII:
|
||||
case PycObject::TYPE_SHORT_ASCII_INTERNED:
|
||||
das_decrypt_print
|
||||
? obj.cast<PycString>()->dasPrintAndDecrypt(pyc_output, mod, false, parent_f_string_quote)
|
||||
: obj.cast<PycString>()->print(pyc_output, mod, false, parent_f_string_quote);
|
||||
break;
|
||||
case PycObject::TYPE_TUPLE:
|
||||
case PycObject::TYPE_SMALL_TUPLE:
|
||||
{
|
||||
pyc_output << "(";
|
||||
PycTuple::value_t values = obj.cast<PycTuple>()->values();
|
||||
auto it = values.cbegin();
|
||||
if (it != values.cend()) {
|
||||
print_const(pyc_output, *it, mod);
|
||||
while (++it != values.cend()) {
|
||||
pyc_output << ", ";
|
||||
print_const(pyc_output, *it, mod);
|
||||
}
|
||||
}
|
||||
if (values.size() == 1)
|
||||
pyc_output << ",)";
|
||||
else
|
||||
pyc_output << ")";
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_LIST:
|
||||
{
|
||||
pyc_output << "[";
|
||||
PycList::value_t values = obj.cast<PycList>()->values();
|
||||
auto it = values.cbegin();
|
||||
if (it != values.cend()) {
|
||||
print_const(pyc_output, *it, mod);
|
||||
while (++it != values.cend()) {
|
||||
pyc_output << ", ";
|
||||
print_const(pyc_output, *it, mod);
|
||||
}
|
||||
}
|
||||
pyc_output << "]";
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_DICT:
|
||||
{
|
||||
pyc_output << "{";
|
||||
PycDict::value_t values = obj.cast<PycDict>()->values();
|
||||
auto it = values.cbegin();
|
||||
if (it != values.cend()) {
|
||||
print_const(pyc_output, std::get<0>(*it), mod);
|
||||
pyc_output << ": ";
|
||||
print_const(pyc_output, std::get<1>(*it), mod);
|
||||
while (++it != values.cend()) {
|
||||
pyc_output << ", ";
|
||||
print_const(pyc_output, std::get<0>(*it), mod);
|
||||
pyc_output << ": ";
|
||||
print_const(pyc_output, std::get<1>(*it), mod);
|
||||
}
|
||||
}
|
||||
pyc_output << "}";
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_SET:
|
||||
{
|
||||
pyc_output << "{";
|
||||
PycSet::value_t values = obj.cast<PycSet>()->values();
|
||||
auto it = values.cbegin();
|
||||
if (it != values.cend()) {
|
||||
print_const(pyc_output, *it, mod);
|
||||
while (++it != values.cend()) {
|
||||
pyc_output << ", ";
|
||||
print_const(pyc_output, *it, mod);
|
||||
}
|
||||
}
|
||||
pyc_output << "}";
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_FROZENSET:
|
||||
{
|
||||
pyc_output << "frozenset({";
|
||||
PycSet::value_t values = obj.cast<PycSet>()->values();
|
||||
auto it = values.cbegin();
|
||||
if (it != values.cend()) {
|
||||
print_const(pyc_output, *it, mod);
|
||||
while (++it != values.cend()) {
|
||||
pyc_output << ", ";
|
||||
print_const(pyc_output, *it, mod);
|
||||
}
|
||||
}
|
||||
pyc_output << "})";
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_NONE:
|
||||
pyc_output << "None";
|
||||
break;
|
||||
case PycObject::TYPE_TRUE:
|
||||
pyc_output << "True";
|
||||
break;
|
||||
case PycObject::TYPE_FALSE:
|
||||
pyc_output << "False";
|
||||
break;
|
||||
case PycObject::TYPE_ELLIPSIS:
|
||||
pyc_output << "...";
|
||||
break;
|
||||
case PycObject::TYPE_INT:
|
||||
formatted_print(pyc_output, "%d", obj.cast<PycInt>()->value());
|
||||
break;
|
||||
case PycObject::TYPE_LONG:
|
||||
formatted_print(pyc_output, "%s", obj.cast<PycLong>()->repr(mod).c_str());
|
||||
break;
|
||||
case PycObject::TYPE_FLOAT:
|
||||
formatted_print(pyc_output, "%s", obj.cast<PycFloat>()->value());
|
||||
break;
|
||||
case PycObject::TYPE_COMPLEX:
|
||||
formatted_print(pyc_output, "(%s+%sj)", obj.cast<PycComplex>()->value(),
|
||||
obj.cast<PycComplex>()->imag());
|
||||
break;
|
||||
case PycObject::TYPE_BINARY_FLOAT:
|
||||
{
|
||||
// Wrap any nan/inf values in float('').
|
||||
double value = obj.cast<PycCFloat>()->value();
|
||||
bool is_negative = std::signbit(value);
|
||||
if (std::isnan(value)) {
|
||||
if (is_negative) {
|
||||
pyc_output << "float('-nan')";
|
||||
} else {
|
||||
pyc_output << "float('nan')";
|
||||
}
|
||||
} else if (std::isinf(value)) {
|
||||
if (is_negative) {
|
||||
pyc_output << "float('-inf')";
|
||||
} else {
|
||||
pyc_output << "float('inf')";
|
||||
}
|
||||
} else {
|
||||
formatted_print(pyc_output, "%g", value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_BINARY_COMPLEX:
|
||||
formatted_print(pyc_output, "(%g+%gj)", obj.cast<PycCComplex>()->value(),
|
||||
obj.cast<PycCComplex>()->imag());
|
||||
break;
|
||||
case PycObject::TYPE_CODE:
|
||||
case PycObject::TYPE_CODE2:
|
||||
pyc_output << "<CODE> " << obj.cast<PycCode>()->name()->value();
|
||||
break;
|
||||
default:
|
||||
formatted_print(pyc_output, "<TYPE: %d>\n", obj->type());
|
||||
}
|
||||
}
|
||||
|
||||
void bc_next(PycBuffer& source, PycModule* mod, int& opcode, int& operand, int& pos)
|
||||
{
|
||||
opcode = Pyc::ByteToOpcode(mod->majorVer(), mod->minorVer(), source.getByte());
|
||||
if (mod->verCompare(3, 6) >= 0) {
|
||||
operand = source.getByte();
|
||||
pos += 2;
|
||||
if (opcode == Pyc::EXTENDED_ARG_A) {
|
||||
opcode = Pyc::ByteToOpcode(mod->majorVer(), mod->minorVer(), source.getByte());
|
||||
operand = (operand << 8) | source.getByte();
|
||||
pos += 2;
|
||||
}
|
||||
} else {
|
||||
operand = 0;
|
||||
pos += 1;
|
||||
if (opcode == Pyc::EXTENDED_ARG_A) {
|
||||
operand = source.get16() << 16;
|
||||
opcode = Pyc::ByteToOpcode(mod->majorVer(), mod->minorVer(), source.getByte());
|
||||
pos += 3;
|
||||
}
|
||||
if (opcode >= Pyc::PYC_HAVE_ARG) {
|
||||
operand |= source.get16();
|
||||
pos += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bc_disasm(std::ostream& pyc_output, PycRef<PycCode> code, PycModule* mod,
|
||||
int indent, unsigned flags)
|
||||
{
|
||||
static const char *cmp_strings[] = {
|
||||
"<", "<=", "==", "!=", ">", ">=", "in", "not in", "is", "is not",
|
||||
"<EXCEPTION MATCH>", "<BAD>"
|
||||
};
|
||||
static const size_t cmp_strings_len = sizeof(cmp_strings) / sizeof(cmp_strings[0]);
|
||||
|
||||
static const char *binop_strings[] = {
|
||||
"+", "&", "//", "<<", "@", "*", "%", "|", "**", ">>", "-", "/", "^",
|
||||
"+=", "&=", "//=", "<<=", "@=", "*=", "%=", "|=", "**=", ">>=", "-=", "/=", "^=",
|
||||
};
|
||||
static const size_t binop_strings_len = sizeof(binop_strings) / sizeof(binop_strings[0]);
|
||||
|
||||
static const char *intrinsic1_names[] = {
|
||||
"INTRINSIC_1_INVALID", "INTRINSIC_PRINT", "INTRINSIC_IMPORT_STAR",
|
||||
"INTRINSIC_STOPITERATION_ERROR", "INTRINSIC_ASYNC_GEN_WRAP",
|
||||
"INTRINSIC_UNARY_POSITIVE", "INTRINSIC_LIST_TO_TUPLE", "INTRINSIC_TYPEVAR",
|
||||
"INTRINSIC_PARAMSPEC", "INTRINSIC_TYPEVARTUPLE",
|
||||
"INTRINSIC_SUBSCRIPT_GENERIC", "INTRINSIC_TYPEALIAS",
|
||||
};
|
||||
static const size_t intrinsic1_names_len = sizeof(intrinsic1_names) / sizeof(intrinsic1_names[0]);
|
||||
|
||||
static const char *intrinsic2_names[] = {
|
||||
"INTRINSIC_2_INVALID", "INTRINSIC_PREP_RERAISE_STAR",
|
||||
"INTRINSIC_TYPEVAR_WITH_BOUND", "INTRINSIC_TYPEVAR_WITH_CONSTRAINTS",
|
||||
"INTRINSIC_SET_FUNCTION_TYPE_PARAMS", "INTRINSIC_SET_TYPEPARAM_DEFAULT",
|
||||
};
|
||||
static const size_t intrinsic2_names_len = sizeof(intrinsic2_names) / sizeof(intrinsic2_names[0]);
|
||||
|
||||
static const char *format_value_names[] = {
|
||||
"FVC_NONE", "FVC_STR", "FVC_REPR", "FVC_ASCII",
|
||||
};
|
||||
static const size_t format_value_names_len = sizeof(format_value_names) / sizeof(format_value_names[0]);
|
||||
|
||||
PycBuffer source(code->code()->value(), code->code()->length());
|
||||
|
||||
int opcode, operand;
|
||||
int pos = 0;
|
||||
while (!source.atEof()) {
|
||||
int start_pos = pos;
|
||||
bc_next(source, mod, opcode, operand, pos);
|
||||
if (opcode == Pyc::CACHE && (flags & Pyc::DISASM_SHOW_CACHES) == 0)
|
||||
continue;
|
||||
|
||||
for (int i=0; i<indent; i++)
|
||||
pyc_output << " ";
|
||||
formatted_print(pyc_output, "%-7d %-30s ", start_pos, Pyc::OpcodeName(opcode));
|
||||
|
||||
if (opcode >= Pyc::PYC_HAVE_ARG) {
|
||||
switch (opcode) {
|
||||
case Pyc::LOAD_CONST_A:
|
||||
case Pyc::RESERVE_FAST_A:
|
||||
case Pyc::KW_NAMES_A:
|
||||
case Pyc::RETURN_CONST_A:
|
||||
case Pyc::INSTRUMENTED_RETURN_CONST_A:
|
||||
try {
|
||||
auto constParam = code->getConst(operand);
|
||||
formatted_print(pyc_output, "%d: ", operand);
|
||||
print_const(pyc_output, constParam, mod, nullptr, true);
|
||||
} catch (const std::out_of_range &) {
|
||||
formatted_print(pyc_output, "%d <INVALID>", operand);
|
||||
}
|
||||
break;
|
||||
case Pyc::LOAD_GLOBAL_A:
|
||||
try {
|
||||
// Special case for Python 3.11+
|
||||
if (mod->verCompare(3, 11) >= 0) {
|
||||
if (operand & 1)
|
||||
formatted_print(pyc_output, "%d: NULL + %s", operand, code->getName(operand >> 1)->value());
|
||||
else
|
||||
formatted_print(pyc_output, "%d: %s", operand, code->getName(operand >> 1)->value());
|
||||
} else {
|
||||
formatted_print(pyc_output, "%d: %s", operand, code->getName(operand)->value());
|
||||
}
|
||||
} catch (const std::out_of_range &) {
|
||||
formatted_print(pyc_output, "%d <INVALID>", operand);
|
||||
}
|
||||
break;
|
||||
case Pyc::DELETE_ATTR_A:
|
||||
case Pyc::DELETE_GLOBAL_A:
|
||||
case Pyc::DELETE_NAME_A:
|
||||
case Pyc::IMPORT_FROM_A:
|
||||
case Pyc::IMPORT_NAME_A:
|
||||
case Pyc::LOAD_ATTR_A:
|
||||
case Pyc::LOAD_LOCAL_A:
|
||||
case Pyc::LOAD_NAME_A:
|
||||
case Pyc::STORE_ATTR_A:
|
||||
case Pyc::STORE_GLOBAL_A:
|
||||
case Pyc::STORE_NAME_A:
|
||||
case Pyc::STORE_ANNOTATION_A:
|
||||
case Pyc::LOAD_METHOD_A:
|
||||
case Pyc::LOAD_FROM_DICT_OR_GLOBALS_A:
|
||||
try {
|
||||
auto arg = operand;
|
||||
if (opcode == Pyc::LOAD_ATTR_A && mod->verCompare(3, 12) >= 0)
|
||||
arg >>= 1;
|
||||
formatted_print(pyc_output, "%d: %s", operand, code->getName(arg)->value());
|
||||
} catch (const std::out_of_range &) {
|
||||
formatted_print(pyc_output, "%d <INVALID>", operand);
|
||||
}
|
||||
break;
|
||||
case Pyc::LOAD_SUPER_ATTR_A:
|
||||
case Pyc::INSTRUMENTED_LOAD_SUPER_ATTR_A:
|
||||
try {
|
||||
formatted_print(pyc_output, "%d: %s", operand, code->getName(operand >> 2)->value());
|
||||
} catch (const std::out_of_range &) {
|
||||
formatted_print(pyc_output, "%d <INVALID>", operand);
|
||||
}
|
||||
break;
|
||||
case Pyc::DELETE_FAST_A:
|
||||
case Pyc::LOAD_FAST_A:
|
||||
case Pyc::STORE_FAST_A:
|
||||
case Pyc::LOAD_FAST_CHECK_A:
|
||||
case Pyc::LOAD_FAST_AND_CLEAR_A:
|
||||
try {
|
||||
formatted_print(pyc_output, "%d: %s", operand, code->getLocal(operand)->value());
|
||||
} catch (const std::out_of_range &) {
|
||||
formatted_print(pyc_output, "%d <INVALID>", operand);
|
||||
}
|
||||
break;
|
||||
case Pyc::LOAD_FAST_LOAD_FAST_A:
|
||||
case Pyc::STORE_FAST_LOAD_FAST_A:
|
||||
case Pyc::STORE_FAST_STORE_FAST_A:
|
||||
try {
|
||||
formatted_print(pyc_output, "%d: %s, %s", operand,
|
||||
code->getLocal(operand >> 4)->value(),
|
||||
code->getLocal(operand & 0xF)->value());
|
||||
} catch (const std::out_of_range &) {
|
||||
formatted_print(pyc_output, "%d <INVALID>", operand);
|
||||
}
|
||||
break;
|
||||
case Pyc::LOAD_CLOSURE_A:
|
||||
case Pyc::LOAD_DEREF_A:
|
||||
case Pyc::STORE_DEREF_A:
|
||||
case Pyc::DELETE_DEREF_A:
|
||||
case Pyc::MAKE_CELL_A:
|
||||
case Pyc::CALL_FINALLY_A:
|
||||
case Pyc::LOAD_FROM_DICT_OR_DEREF_A:
|
||||
try {
|
||||
formatted_print(pyc_output, "%d: %s", operand, code->getCellVar(mod, operand)->value());
|
||||
} catch (const std::out_of_range &) {
|
||||
formatted_print(pyc_output, "%d <INVALID>", operand);
|
||||
}
|
||||
break;
|
||||
case Pyc::JUMP_FORWARD_A:
|
||||
case Pyc::JUMP_IF_FALSE_A:
|
||||
case Pyc::JUMP_IF_TRUE_A:
|
||||
case Pyc::SETUP_LOOP_A:
|
||||
case Pyc::SETUP_FINALLY_A:
|
||||
case Pyc::SETUP_EXCEPT_A:
|
||||
case Pyc::FOR_LOOP_A:
|
||||
case Pyc::FOR_ITER_A:
|
||||
case Pyc::SETUP_WITH_A:
|
||||
case Pyc::SETUP_ASYNC_WITH_A:
|
||||
case Pyc::POP_JUMP_FORWARD_IF_FALSE_A:
|
||||
case Pyc::POP_JUMP_FORWARD_IF_TRUE_A:
|
||||
case Pyc::SEND_A:
|
||||
case Pyc::POP_JUMP_FORWARD_IF_NOT_NONE_A:
|
||||
case Pyc::POP_JUMP_FORWARD_IF_NONE_A:
|
||||
case Pyc::POP_JUMP_IF_NOT_NONE_A:
|
||||
case Pyc::POP_JUMP_IF_NONE_A:
|
||||
case Pyc::INSTRUMENTED_POP_JUMP_IF_NOT_NONE_A:
|
||||
case Pyc::INSTRUMENTED_POP_JUMP_IF_NONE_A:
|
||||
case Pyc::INSTRUMENTED_JUMP_FORWARD_A:
|
||||
case Pyc::INSTRUMENTED_FOR_ITER_A:
|
||||
case Pyc::INSTRUMENTED_POP_JUMP_IF_FALSE_A:
|
||||
case Pyc::INSTRUMENTED_POP_JUMP_IF_TRUE_A:
|
||||
{
|
||||
/* TODO: Fix offset based on CACHE instructions.
|
||||
Offset is relative to next non-CACHE instruction
|
||||
and thus will be printed lower than actual value.
|
||||
See TODO @ END_FOR ASTree.cpp */
|
||||
int offs = operand;
|
||||
if (mod->verCompare(3, 10) >= 0)
|
||||
offs *= sizeof(uint16_t); // BPO-27129
|
||||
formatted_print(pyc_output, "%d (to %d)", operand, pos+offs);
|
||||
}
|
||||
break;
|
||||
case Pyc::JUMP_BACKWARD_NO_INTERRUPT_A:
|
||||
case Pyc::JUMP_BACKWARD_A:
|
||||
case Pyc::POP_JUMP_BACKWARD_IF_NOT_NONE_A:
|
||||
case Pyc::POP_JUMP_BACKWARD_IF_NONE_A:
|
||||
case Pyc::POP_JUMP_BACKWARD_IF_FALSE_A:
|
||||
case Pyc::POP_JUMP_BACKWARD_IF_TRUE_A:
|
||||
case Pyc::INSTRUMENTED_JUMP_BACKWARD_A:
|
||||
{
|
||||
// BACKWARD jumps were only introduced in Python 3.11
|
||||
int offs = operand * sizeof(uint16_t); // BPO-27129
|
||||
formatted_print(pyc_output, "%d (to %d)", operand, pos-offs);
|
||||
}
|
||||
break;
|
||||
case Pyc::POP_JUMP_IF_FALSE_A:
|
||||
case Pyc::POP_JUMP_IF_TRUE_A:
|
||||
case Pyc::JUMP_IF_FALSE_OR_POP_A:
|
||||
case Pyc::JUMP_IF_TRUE_OR_POP_A:
|
||||
case Pyc::JUMP_ABSOLUTE_A:
|
||||
case Pyc::JUMP_IF_NOT_EXC_MATCH_A:
|
||||
if (mod->verCompare(3, 12) >= 0) {
|
||||
// These are now relative as well
|
||||
int offs = operand * sizeof(uint16_t);
|
||||
formatted_print(pyc_output, "%d (to %d)", operand, pos+offs);
|
||||
} else if (mod->verCompare(3, 10) >= 0) {
|
||||
// BPO-27129
|
||||
formatted_print(pyc_output, "%d (to %d)", operand,
|
||||
int(operand * sizeof(uint16_t)));
|
||||
} else {
|
||||
formatted_print(pyc_output, "%d", operand);
|
||||
}
|
||||
break;
|
||||
case Pyc::COMPARE_OP_A:
|
||||
{
|
||||
auto arg = operand;
|
||||
if (mod->verCompare(3, 12) == 0)
|
||||
arg >>= 4; // changed under GH-100923
|
||||
else if (mod->verCompare(3, 13) >= 0)
|
||||
arg >>= 5;
|
||||
if (static_cast<size_t>(arg) < cmp_strings_len)
|
||||
formatted_print(pyc_output, "%d (%s)", operand, cmp_strings[arg]);
|
||||
else
|
||||
formatted_print(pyc_output, "%d (UNKNOWN)", operand);
|
||||
}
|
||||
break;
|
||||
case Pyc::BINARY_OP_A:
|
||||
if (static_cast<size_t>(operand) < binop_strings_len)
|
||||
formatted_print(pyc_output, "%d (%s)", operand, binop_strings[operand]);
|
||||
else
|
||||
formatted_print(pyc_output, "%d (UNKNOWN)", operand);
|
||||
break;
|
||||
case Pyc::IS_OP_A:
|
||||
formatted_print(pyc_output, "%d (%s)", operand, (operand == 0) ? "is"
|
||||
: (operand == 1) ? "is not"
|
||||
: "UNKNOWN");
|
||||
break;
|
||||
case Pyc::CONTAINS_OP_A:
|
||||
formatted_print(pyc_output, "%d (%s)", operand, (operand == 0) ? "in"
|
||||
: (operand == 1) ? "not in"
|
||||
: "UNKNOWN");
|
||||
break;
|
||||
case Pyc::CALL_INTRINSIC_1_A:
|
||||
if (static_cast<size_t>(operand) < intrinsic1_names_len)
|
||||
formatted_print(pyc_output, "%d (%s)", operand, intrinsic1_names[operand]);
|
||||
else
|
||||
formatted_print(pyc_output, "%d (UNKNOWN)", operand);
|
||||
break;
|
||||
case Pyc::CALL_INTRINSIC_2_A:
|
||||
if (static_cast<size_t>(operand) < intrinsic2_names_len)
|
||||
formatted_print(pyc_output, "%d (%s)", operand, intrinsic2_names[operand]);
|
||||
else
|
||||
formatted_print(pyc_output, "%d (UNKNOWN)", operand);
|
||||
break;
|
||||
case Pyc::FORMAT_VALUE_A:
|
||||
{
|
||||
auto conv = static_cast<size_t>(operand & 0x03);
|
||||
const char *flag = (operand & 0x04) ? " | FVS_HAVE_SPEC" : "";
|
||||
if (conv < format_value_names_len) {
|
||||
formatted_print(pyc_output, "%d (%s%s)", operand,
|
||||
format_value_names[conv], flag);
|
||||
} else {
|
||||
formatted_print(pyc_output, "%d (UNKNOWN)", operand);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Pyc::CONVERT_VALUE_A:
|
||||
if (static_cast<size_t>(operand) < format_value_names_len)
|
||||
formatted_print(pyc_output, "%d (%s)", operand, format_value_names[operand]);
|
||||
else
|
||||
formatted_print(pyc_output, "%d (UNKNOWN)", operand);
|
||||
break;
|
||||
case Pyc::SET_FUNCTION_ATTRIBUTE_A:
|
||||
// This looks like a bitmask, but CPython treats it as an exclusive lookup...
|
||||
switch (operand) {
|
||||
case 0x01:
|
||||
formatted_print(pyc_output, "%d (MAKE_FUNCTION_DEFAULTS)", operand);
|
||||
break;
|
||||
case 0x02:
|
||||
formatted_print(pyc_output, "%d (MAKE_FUNCTION_KWDEFAULTS)", operand);
|
||||
break;
|
||||
case 0x04:
|
||||
formatted_print(pyc_output, "%d (MAKE_FUNCTION_ANNOTATIONS)", operand);
|
||||
break;
|
||||
case 0x08:
|
||||
formatted_print(pyc_output, "%d (MAKE_FUNCTION_CLOSURE)", operand);
|
||||
break;
|
||||
default:
|
||||
formatted_print(pyc_output, "%d (UNKNOWN)", operand);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
formatted_print(pyc_output, "%d", operand);
|
||||
break;
|
||||
}
|
||||
}
|
||||
pyc_output << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void bc_exceptiontable(std::ostream& pyc_output, PycRef<PycCode> code,
|
||||
int indent)
|
||||
{
|
||||
for (const auto& entry : code->exceptionTableEntries()) {
|
||||
|
||||
for (int i=0; i<indent; i++)
|
||||
pyc_output << " ";
|
||||
|
||||
pyc_output << entry.start_offset << " to " << entry.end_offset
|
||||
<< " -> " << entry.target << " [" << entry.stack_depth
|
||||
<< "] " << (entry.push_lasti ? "lasti": "")
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
36
pycdc/bytecode.h
Normal file
36
pycdc/bytecode.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "pyc_code.h"
|
||||
#include "pyc_module.h"
|
||||
#include "data.h"
|
||||
|
||||
namespace Pyc {
|
||||
|
||||
enum Opcode {
|
||||
#define OPCODE(x) x,
|
||||
#define OPCODE_A_FIRST(x) PYC_HAVE_ARG, x##_A = PYC_HAVE_ARG,
|
||||
#define OPCODE_A(x) x##_A,
|
||||
#include "bytecode_ops.inl"
|
||||
#undef OPCODE_A
|
||||
#undef OPCODE_A_FIRST
|
||||
#undef OPCODE
|
||||
|
||||
PYC_LAST_OPCODE,
|
||||
PYC_INVALID_OPCODE = -1,
|
||||
};
|
||||
|
||||
enum DisassemblyFlags {
|
||||
DISASM_PYCODE_VERBOSE = 0x1,
|
||||
DISASM_SHOW_CACHES = 0x2,
|
||||
};
|
||||
|
||||
const char* OpcodeName(int opcode);
|
||||
int ByteToOpcode(int maj, int min, int opcode);
|
||||
|
||||
}
|
||||
|
||||
void print_const(std::ostream& pyc_output, PycRef<PycObject> obj, PycModule* mod,
|
||||
const char* parent_f_string_quote = nullptr, bool das_decrypt_print = false);
|
||||
void bc_next(PycBuffer& source, PycModule* mod, int& opcode, int& operand, int& pos);
|
||||
void bc_disasm(std::ostream& pyc_output, PycRef<PycCode> code, PycModule* mod,
|
||||
int indent, unsigned flags);
|
||||
void bc_exceptiontable(std::ostream& pyc_output, PycRef<PycCode> code,
|
||||
int indent);
|
||||
292
pycdc/bytecode_ops.inl
Normal file
292
pycdc/bytecode_ops.inl
Normal file
@@ -0,0 +1,292 @@
|
||||
/* No parameter word */
|
||||
OPCODE(STOP_CODE) // Python 1.0 - 3.2
|
||||
OPCODE(POP_TOP) // Python 1.0 ->
|
||||
OPCODE(ROT_TWO) // Python 1.0 - 3.10
|
||||
OPCODE(ROT_THREE) // Python 1.0 - 3.10
|
||||
OPCODE(DUP_TOP) // Python 1.0 - 3.10
|
||||
OPCODE(DUP_TOP_TWO) // Python 3.2 - 3.10
|
||||
OPCODE(UNARY_POSITIVE) // Python 1.0 - 3.11
|
||||
OPCODE(UNARY_NEGATIVE) // Python 1.0 ->
|
||||
OPCODE(UNARY_NOT) // Python 1.0 ->
|
||||
OPCODE(UNARY_CONVERT) // Python 1.0 - 2.7
|
||||
OPCODE(UNARY_CALL) // Python 1.0 - 1.2
|
||||
OPCODE(UNARY_INVERT) // Python 1.0 ->
|
||||
OPCODE(BINARY_POWER) // Python 1.4 - 3.10
|
||||
OPCODE(BINARY_MULTIPLY) // Python 1.0 - 3.10
|
||||
OPCODE(BINARY_DIVIDE) // Python 1.0 - 2.7
|
||||
OPCODE(BINARY_MODULO) // Python 1.0 - 3.10
|
||||
OPCODE(BINARY_ADD) // Python 1.0 - 3.10
|
||||
OPCODE(BINARY_SUBTRACT) // Python 1.0 - 3.10
|
||||
OPCODE(BINARY_SUBSCR) // Python 1.0 ->
|
||||
OPCODE(BINARY_CALL) // Python 1.0 - 1.2
|
||||
OPCODE(SLICE_0) // Python 1.0 - 2.7
|
||||
OPCODE(SLICE_1) // Python 1.0 - 2.7
|
||||
OPCODE(SLICE_2) // Python 1.0 - 2.7
|
||||
OPCODE(SLICE_3) // Python 1.0 - 2.7
|
||||
OPCODE(STORE_SLICE_0) // Python 1.0 - 2.7
|
||||
OPCODE(STORE_SLICE_1) // Python 1.0 - 2.7
|
||||
OPCODE(STORE_SLICE_2) // Python 1.0 - 2.7
|
||||
OPCODE(STORE_SLICE_3) // Python 1.0 - 2.7
|
||||
OPCODE(DELETE_SLICE_0) // Python 1.0 - 2.7
|
||||
OPCODE(DELETE_SLICE_1) // Python 1.0 - 2.7
|
||||
OPCODE(DELETE_SLICE_2) // Python 1.0 - 2.7
|
||||
OPCODE(DELETE_SLICE_3) // Python 1.0 - 2.7
|
||||
OPCODE(STORE_SUBSCR) // Python 1.0 ->
|
||||
OPCODE(DELETE_SUBSCR) // Python 1.0 ->
|
||||
OPCODE(BINARY_LSHIFT) // Python 1.0 - 3.10
|
||||
OPCODE(BINARY_RSHIFT) // Python 1.0 - 3.10
|
||||
OPCODE(BINARY_AND) // Python 1.0 - 3.10
|
||||
OPCODE(BINARY_XOR) // Python 1.0 - 3.10
|
||||
OPCODE(BINARY_OR) // Python 1.0 - 3.10
|
||||
OPCODE(PRINT_EXPR) // Python 1.0 - 3.11
|
||||
OPCODE(PRINT_ITEM) // Python 1.0 - 2.7
|
||||
OPCODE(PRINT_NEWLINE) // Python 1.0 - 2.7
|
||||
OPCODE(BREAK_LOOP) // Python 1.0 - 3.7
|
||||
OPCODE(RAISE_EXCEPTION) // Python 1.0 - 1.2
|
||||
OPCODE(LOAD_LOCALS) // Python 1.0 - 2.7, 3.12 ->
|
||||
OPCODE(RETURN_VALUE) // Python 1.0 ->
|
||||
OPCODE(LOAD_GLOBALS) // Python 1.0 - 1.2
|
||||
OPCODE(EXEC_STMT) // Python 1.0 - 2.7
|
||||
OPCODE(BUILD_FUNCTION) // Python 1.0 - 1.2
|
||||
OPCODE(POP_BLOCK) // Python 1.0 - 3.10
|
||||
OPCODE(END_FINALLY) // Python 1.0 - 3.8
|
||||
OPCODE(BUILD_CLASS) // Python 1.0 - 2.7
|
||||
OPCODE(ROT_FOUR) // Python 2.0 - 3.1, 3.8 - 3.10
|
||||
OPCODE(NOP) // Python 2.4 ->
|
||||
OPCODE(LIST_APPEND) // Python 2.4 - 2.6, 3.0
|
||||
OPCODE(BINARY_FLOOR_DIVIDE) // Python 2.2 - 3.10
|
||||
OPCODE(BINARY_TRUE_DIVIDE) // Python 2.2 - 3.10
|
||||
OPCODE(INPLACE_FLOOR_DIVIDE) // Python 2.2 - 3.10
|
||||
OPCODE(INPLACE_TRUE_DIVIDE) // Python 2.2 - 3.10
|
||||
OPCODE(GET_LEN) // Python 3.10 ->
|
||||
OPCODE(MATCH_MAPPING) // Python 3.10 ->
|
||||
OPCODE(MATCH_SEQUENCE) // Python 3.10 ->
|
||||
OPCODE(MATCH_KEYS) // Python 3.10 ->
|
||||
OPCODE(COPY_DICT_WITHOUT_KEYS) // Python 3.10
|
||||
OPCODE(STORE_MAP) // Python 2.6 - 3.4
|
||||
OPCODE(INPLACE_ADD) // Python 2.0 - 3.10
|
||||
OPCODE(INPLACE_SUBTRACT) // Python 2.0 - 3.10
|
||||
OPCODE(INPLACE_MULTIPLY) // Python 2.0 - 3.10
|
||||
OPCODE(INPLACE_DIVIDE) // Python 2.0 - 2.7
|
||||
OPCODE(INPLACE_MODULO) // Python 2.0 - 3.10
|
||||
OPCODE(INPLACE_POWER) // Python 2.0 - 3.10
|
||||
OPCODE(GET_ITER) // Python 2.2 ->
|
||||
OPCODE(PRINT_ITEM_TO) // Python 2.0 - 2.7
|
||||
OPCODE(PRINT_NEWLINE_TO) // Python 2.0 - 2.7
|
||||
OPCODE(INPLACE_LSHIFT) // Python 2.0 - 3.10
|
||||
OPCODE(INPLACE_RSHIFT) // Python 2.0 - 3.10
|
||||
OPCODE(INPLACE_AND) // Python 2.0 - 3.10
|
||||
OPCODE(INPLACE_XOR) // Python 2.0 - 3.10
|
||||
OPCODE(INPLACE_OR) // Python 2.0 - 3.10
|
||||
OPCODE(WITH_CLEANUP) // Python 2.5 - 3.4
|
||||
OPCODE(WITH_CLEANUP_START) // Python 3.5 - 3.8
|
||||
OPCODE(WITH_CLEANUP_FINISH) // Python 3.5 - 3.8
|
||||
OPCODE(IMPORT_STAR) // Python 2.0 - 3.11
|
||||
OPCODE(SETUP_ANNOTATIONS) // Python 3.6 ->
|
||||
OPCODE(YIELD_VALUE) // Python 2.2 - 3.11
|
||||
OPCODE(LOAD_BUILD_CLASS) // Python 3.0 ->
|
||||
OPCODE(STORE_LOCALS) // Python 3.0 - 3.3
|
||||
OPCODE(POP_EXCEPT) // Python 3.0 ->
|
||||
OPCODE(SET_ADD) // Python 3.0
|
||||
OPCODE(YIELD_FROM) // Python 3.3 - 3.10
|
||||
OPCODE(BINARY_MATRIX_MULTIPLY) // Python 3.5 - 3.10
|
||||
OPCODE(INPLACE_MATRIX_MULTIPLY) // Python 3.5 - 3.10
|
||||
OPCODE(GET_AITER) // Python 3.5 ->
|
||||
OPCODE(GET_ANEXT) // Python 3.5 ->
|
||||
OPCODE(BEFORE_ASYNC_WITH) // Python 3.5 ->
|
||||
OPCODE(GET_YIELD_FROM_ITER) // Python 3.5 ->
|
||||
OPCODE(GET_AWAITABLE) // Python 3.5 - 3.10
|
||||
OPCODE(BEGIN_FINALLY) // Python 3.8
|
||||
OPCODE(END_ASYNC_FOR) // Python 3.8 ->
|
||||
OPCODE(RERAISE) // Python 3.9
|
||||
OPCODE(WITH_EXCEPT_START) // Python 3.9 ->
|
||||
OPCODE(LOAD_ASSERTION_ERROR) // Python 3.9 ->
|
||||
OPCODE(LIST_TO_TUPLE) // Python 3.9 - 3.11
|
||||
OPCODE(CACHE) // Python 3.11 ->
|
||||
OPCODE(PUSH_NULL) // Python 3.11 ->
|
||||
OPCODE(PUSH_EXC_INFO) // Python 3.11 ->
|
||||
OPCODE(CHECK_EXC_MATCH) // Python 3.11 ->
|
||||
OPCODE(CHECK_EG_MATCH) // Python 3.11 ->
|
||||
OPCODE(BEFORE_WITH) // Python 3.11 ->
|
||||
OPCODE(RETURN_GENERATOR) // Python 3.11 ->
|
||||
OPCODE(ASYNC_GEN_WRAP) // Python 3.11
|
||||
OPCODE(PREP_RERAISE_STAR) // Python 3.11
|
||||
OPCODE(INTERPRETER_EXIT) // Python 3.12 ->
|
||||
OPCODE(END_FOR) // Python 3.12 ->
|
||||
OPCODE(END_SEND) // Python 3.12 ->
|
||||
OPCODE(RESERVED) // Python 3.12 ->
|
||||
OPCODE(BINARY_SLICE) // Python 3.12 ->
|
||||
OPCODE(STORE_SLICE) // Python 3.12 ->
|
||||
OPCODE(CLEANUP_THROW) // Python 3.12 ->
|
||||
OPCODE(EXIT_INIT_CHECK) // Python 3.13 ->
|
||||
OPCODE(FORMAT_SIMPLE) // Python 3.13 ->
|
||||
OPCODE(FORMAT_WITH_SPEC) // Python 3.13 ->
|
||||
OPCODE(MAKE_FUNCTION) // Python 3.13 ->
|
||||
OPCODE(TO_BOOL) // Python 3.13 ->
|
||||
|
||||
/* Has parameter word */
|
||||
OPCODE_A_FIRST(STORE_NAME) // Python 1.0 -> names[A]
|
||||
OPCODE_A(DELETE_NAME) // Python 1.0 -> names[A]
|
||||
OPCODE_A(UNPACK_TUPLE) // Python 1.0 - 1.6 A=count
|
||||
OPCODE_A(UNPACK_LIST) // Python 1.0 - 1.6 A=count
|
||||
OPCODE_A(UNPACK_ARG) // Python 1.0 - 1.4 A=count
|
||||
OPCODE_A(STORE_ATTR) // Python 1.0 -> names[A]
|
||||
OPCODE_A(DELETE_ATTR) // Python 1.0 -> names[A]
|
||||
OPCODE_A(STORE_GLOBAL) // Python 1.0 -> names[A]
|
||||
OPCODE_A(DELETE_GLOBAL) // Python 1.0 -> names[A]
|
||||
OPCODE_A(ROT_N) // Python 3.10 A=count
|
||||
OPCODE_A(UNPACK_VARARG) // Python 1.0 - 1.4 A=count
|
||||
OPCODE_A(LOAD_CONST) // Python 1.0 -> consts[A]
|
||||
OPCODE_A(LOAD_NAME) // Python 1.0 -> names[A]
|
||||
OPCODE_A(BUILD_TUPLE) // Python 1.0 -> A=size
|
||||
OPCODE_A(BUILD_LIST) // Python 1.0 -> A=size
|
||||
OPCODE_A(BUILD_MAP) // Python 1.0 -> A=size
|
||||
OPCODE_A(LOAD_ATTR) // Python 1.0 - 3.11 names[A]
|
||||
// Python 3.12 -> A=(names[A<<1])+(flag)
|
||||
OPCODE_A(COMPARE_OP) // Python 1.0 - 3.11 cmp_ops[A]
|
||||
// Python 3.12 A=(cmp_ops[A<<4])+(flags)
|
||||
// Python 3.13 -> A=(cmp_ops[A<<5])+(flags)
|
||||
OPCODE_A(IMPORT_NAME) // Python 1.0 -> names[A]
|
||||
OPCODE_A(IMPORT_FROM) // Python 1.0 -> names[A]
|
||||
OPCODE_A(ACCESS_MODE) // Python 1.0 - 1.4 names[A]
|
||||
OPCODE_A(JUMP_FORWARD) // Python 1.0 -> rel jmp +A
|
||||
OPCODE_A(JUMP_IF_FALSE) // Python 1.0 - 2.6, 3.0 rel jmp +A
|
||||
OPCODE_A(JUMP_IF_TRUE) // Python 1.0 - 2.6, 3.0 rel jmp +A
|
||||
OPCODE_A(JUMP_ABSOLUTE) // Python 1.0 - 3.10 abs jmp A
|
||||
OPCODE_A(FOR_LOOP) // Python 1.0 - 2.2 rel jmp +A
|
||||
OPCODE_A(LOAD_LOCAL) // Python 1.0 - 1.4 names[A]
|
||||
OPCODE_A(LOAD_GLOBAL) // Python 1.0 - 3.10 names[A]
|
||||
// Python 3.11 -> A=(names[A<<1])+(flag)
|
||||
OPCODE_A(SET_FUNC_ARGS) // Python 1.1 - 1.4 A=count
|
||||
OPCODE_A(SETUP_LOOP) // Python 1.0 - 3.7 rel jmp +A
|
||||
OPCODE_A(SETUP_EXCEPT) // Python 1.0 - 3.7 rel jmp +A
|
||||
OPCODE_A(SETUP_FINALLY) // Python 1.0 - 3.10 rel jmp +A
|
||||
OPCODE_A(RESERVE_FAST) // Python 1.0 - 1.2 A=count
|
||||
OPCODE_A(LOAD_FAST) // Python 1.0 -> locals[A]
|
||||
OPCODE_A(STORE_FAST) // Python 1.0 -> locals[A]
|
||||
OPCODE_A(DELETE_FAST) // Python 1.0 -> locals[A]
|
||||
OPCODE_A(GEN_START) // Python 3.10 ???
|
||||
OPCODE_A(SET_LINENO) // Python 1.0 - 2.2 A=line
|
||||
OPCODE_A(STORE_ANNOTATION) // Python 3.6 names[A]
|
||||
OPCODE_A(RAISE_VARARGS) // Python 1.3 -> A=count
|
||||
OPCODE_A(CALL_FUNCTION) // Python 1.3 - 3.5 A=(#args)+(#kwargs<<8)
|
||||
// Python 3.6 - 3.10 A=#args
|
||||
OPCODE_A(MAKE_FUNCTION) // Python 1.3 - 2.7 A=#defaults
|
||||
// Python 3.0 - 3.5 A=(#defaults)+(#kwdefaults<<8)+(#annotations<<16)
|
||||
// Python 3.6 - 3.12 A=flags
|
||||
OPCODE_A(BUILD_SLICE) // Python 1.4 -> A=count
|
||||
OPCODE_A(CALL_FUNCTION_VAR) // Python 1.6 - 3.5 A=(#args)+(#kwargs<<8)
|
||||
OPCODE_A(CALL_FUNCTION_KW) // Python 1.6 - 3.5 A=(#args)+(#kwargs<<8)
|
||||
// Python 3.6 - 3.10 A=#args
|
||||
OPCODE_A(CALL_FUNCTION_VAR_KW) // Python 1.6 - 3.5 A=(#args)+(#kwargs<<8)
|
||||
OPCODE_A(CALL_FUNCTION_EX) // Python 3.6 -> A=flags
|
||||
OPCODE_A(UNPACK_SEQUENCE) // Python 2.0 -> A=count
|
||||
OPCODE_A(FOR_ITER) // Python 2.0 -> rel jmp +A
|
||||
OPCODE_A(DUP_TOPX) // Python 2.0 - 3.1 A=count
|
||||
OPCODE_A(BUILD_SET) // Python 2.7 -> A=size
|
||||
OPCODE_A(JUMP_IF_FALSE_OR_POP) // Python 2.7, 3.1 - 3.11 abs jmp A
|
||||
OPCODE_A(JUMP_IF_TRUE_OR_POP) // Python 2.7, 3.1 - 3.11 abs jmp A
|
||||
OPCODE_A(POP_JUMP_IF_FALSE) // Python 2.7, 3.1 - 3.10 abs jmp A
|
||||
// Python 3.12 -> rel jmp +A
|
||||
OPCODE_A(POP_JUMP_IF_TRUE) // Python 2.7, 3.1 - 3.10 abs jmp A
|
||||
// Python 3.12 -> rel jmp +A
|
||||
OPCODE_A(CONTINUE_LOOP) // Python 2.1 - 3.7 abs jmp A
|
||||
OPCODE_A(MAKE_CLOSURE) // Python 2.1 - 2.7 A=#defaults
|
||||
// Python 3.0 - 3.5 A=(#defaults)+(#kwdefaults<<8)+(#annotations<<16)
|
||||
OPCODE_A(LOAD_CLOSURE) // Python 2.1 -> freevars[A]
|
||||
OPCODE_A(LOAD_DEREF) // Python 2.1 -> freevars[A]
|
||||
OPCODE_A(STORE_DEREF) // Python 2.1 -> freevars[A]
|
||||
OPCODE_A(DELETE_DEREF) // Python 3.2 -> freevars[A]
|
||||
OPCODE_A(EXTENDED_ARG) // Python 2.0 -> A=extended_arg
|
||||
OPCODE_A(SETUP_WITH) // Python 2.7, 3.2 - 3.10 rel jmp +A
|
||||
OPCODE_A(SET_ADD) // Python 2.7, 3.1 -> stack[A]
|
||||
OPCODE_A(MAP_ADD) // Python 2.7, 3.1 -> stack[A]
|
||||
OPCODE_A(UNPACK_EX) // Python 3.0 -> A=(before)+(after<<8)
|
||||
OPCODE_A(LIST_APPEND) // Python 2.7, 3.1 -> stack[A]
|
||||
OPCODE_A(LOAD_CLASSDEREF) // Python 3.4 - 3.10 (cellvars+freevars)[A]
|
||||
// Python 3.11 localsplusnames[A]
|
||||
OPCODE_A(MATCH_CLASS) // Python 3.10 -> A=#args
|
||||
OPCODE_A(BUILD_LIST_UNPACK) // Python 3.5 - 3.8 A=count
|
||||
OPCODE_A(BUILD_MAP_UNPACK) // Python 3.5 - 3.8 A=count
|
||||
OPCODE_A(BUILD_MAP_UNPACK_WITH_CALL) // Python 3.5 A=(count)+(fnloc<<8)
|
||||
// Python 3.6 - 3.8 A=count
|
||||
OPCODE_A(BUILD_TUPLE_UNPACK) // Python 3.5 - 3.8 A=count
|
||||
OPCODE_A(BUILD_SET_UNPACK) // Python 3.5 - 3.8 A=count
|
||||
OPCODE_A(SETUP_ASYNC_WITH) // Python 3.5 - 3.10 rel jmp +A
|
||||
OPCODE_A(FORMAT_VALUE) // Python 3.6 - 3.12 A=(conversion_type&0x3)+(flags)
|
||||
OPCODE_A(BUILD_CONST_KEY_MAP) // Python 3.6 -> A=count
|
||||
OPCODE_A(BUILD_STRING) // Python 3.6 -> A=count
|
||||
OPCODE_A(BUILD_TUPLE_UNPACK_WITH_CALL) // Python 3.6 - 3.8 A=count
|
||||
OPCODE_A(LOAD_METHOD) // Python 3.7 - 3.11 names[A]
|
||||
OPCODE_A(CALL_METHOD) // Python 3.7 - 3.10 A=#args
|
||||
OPCODE_A(CALL_FINALLY) // Python 3.8 rel jmp +A
|
||||
OPCODE_A(POP_FINALLY) // Python 3.8 A=flags
|
||||
OPCODE_A(IS_OP) // Python 3.9 -> A=inverted
|
||||
OPCODE_A(CONTAINS_OP) // Python 3.9 -> A=inverted
|
||||
OPCODE_A(RERAISE) // Python 3.10 -> A=count
|
||||
OPCODE_A(JUMP_IF_NOT_EXC_MATCH) // Python 3.9 - 3.10 abs jmp A
|
||||
OPCODE_A(LIST_EXTEND) // Python 3.9 -> stack[A]
|
||||
OPCODE_A(SET_UPDATE) // Python 3.9 -> stack[A]
|
||||
OPCODE_A(DICT_MERGE) // Python 3.9 -> stack[A]
|
||||
OPCODE_A(DICT_UPDATE) // Python 3.9 -> stack[A]
|
||||
OPCODE_A(SWAP) // Python 3.11 -> stack[A]
|
||||
OPCODE_A(POP_JUMP_FORWARD_IF_FALSE) // Python 3.11 rel jmp +A
|
||||
OPCODE_A(POP_JUMP_FORWARD_IF_TRUE) // Python 3.11 rel jmp +A
|
||||
OPCODE_A(COPY) // Python 3.11 -> stack[A]
|
||||
OPCODE_A(BINARY_OP) // Python 3.11 -> bin_ops[A]
|
||||
OPCODE_A(SEND) // Python 3.11 -> rel jmp +A
|
||||
OPCODE_A(POP_JUMP_FORWARD_IF_NOT_NONE) // Python 3.11 rel jmp +A
|
||||
OPCODE_A(POP_JUMP_FORWARD_IF_NONE) // Python 3.11 rel jmp +A
|
||||
OPCODE_A(GET_AWAITABLE) // Python 3.11 -> A=awaitable_type
|
||||
OPCODE_A(JUMP_BACKWARD_NO_INTERRUPT) // Python 3.11 -> rel jmp -A
|
||||
OPCODE_A(MAKE_CELL) // Python 3.11 -> locals[A]
|
||||
OPCODE_A(JUMP_BACKWARD) // Python 3.11 -> rel jmp -A
|
||||
OPCODE_A(COPY_FREE_VARS) // Python 3.11 -> A=count
|
||||
OPCODE_A(RESUME) // Python 3.11 -> ???
|
||||
OPCODE_A(PRECALL) // Python 3.11 A=#args
|
||||
OPCODE_A(CALL) // Python 3.11 -> A=#args
|
||||
OPCODE_A(KW_NAMES) // Python 3.11 - 3.12 consts[A]
|
||||
OPCODE_A(POP_JUMP_BACKWARD_IF_NOT_NONE) // Python 3.11 jmp rel -A
|
||||
OPCODE_A(POP_JUMP_BACKWARD_IF_NONE) // Python 3.11 jmp rel -A
|
||||
OPCODE_A(POP_JUMP_BACKWARD_IF_FALSE) // Python 3.11 jmp rel -A
|
||||
OPCODE_A(POP_JUMP_BACKWARD_IF_TRUE) // Python 3.11 jmp rel -A
|
||||
OPCODE_A(RETURN_CONST) // Python 3.12 -> consts[A]
|
||||
OPCODE_A(LOAD_FAST_CHECK) // Python 3.12 -> locals[A]
|
||||
OPCODE_A(POP_JUMP_IF_NOT_NONE) // Python 3.12 -> rel jmp +A
|
||||
OPCODE_A(POP_JUMP_IF_NONE) // Python 3.12 -> rel jmp +A
|
||||
OPCODE_A(LOAD_SUPER_ATTR) // Python 3.12 -> A=(flags&0x3)+names[A<<2]
|
||||
OPCODE_A(LOAD_FAST_AND_CLEAR) // Python 3.12 -> locals[A]
|
||||
OPCODE_A(YIELD_VALUE) // Python 3.12 A=stack_depth (ignored)
|
||||
// Python 3.13 -> A=type
|
||||
OPCODE_A(CALL_INTRINSIC_1) // Python 3.12 -> intrinsics_1[A]
|
||||
OPCODE_A(CALL_INTRINSIC_2) // Python 3.12 -> intrinsics_2[A]
|
||||
OPCODE_A(LOAD_FROM_DICT_OR_GLOBALS) // Python 3.12 -> names[A]
|
||||
OPCODE_A(LOAD_FROM_DICT_OR_DEREF) // Python 3.12 -> localsplusnames[A]
|
||||
OPCODE_A(CALL_KW) // Python 3.13 -> A=#args
|
||||
OPCODE_A(CONVERT_VALUE) // Python 3.13 -> A=conversion_type
|
||||
OPCODE_A(ENTER_EXECUTOR) // Python 3.13 -> executors[A&0xff]
|
||||
OPCODE_A(LOAD_FAST_LOAD_FAST) // Python 3.13 -> A=locals[A<<4]+locals[A&0xf]
|
||||
OPCODE_A(SET_FUNCTION_ATTRIBUTE) // Python 3.13 -> A=attribute_type
|
||||
OPCODE_A(STORE_FAST_LOAD_FAST) // Python 3.13 -> A=locals[A<<4]+locals[A&0xf]
|
||||
OPCODE_A(STORE_FAST_STORE_FAST) // Python 3.13 -> A=locals[A<<4]+locals[A&0xf]
|
||||
|
||||
/* Instrumented opcodes */
|
||||
OPCODE_A(INSTRUMENTED_LOAD_SUPER_ATTR) // Python 3.12 -> (see LOAD_SUPER_ATTR)
|
||||
OPCODE_A(INSTRUMENTED_POP_JUMP_IF_NONE) // Python 3.12 -> (see POP_JUMP_IF_NONE)
|
||||
OPCODE_A(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) // Python 3.12 -> (see POP_JUMP_IF_NOT_NONE)
|
||||
OPCODE_A(INSTRUMENTED_RESUME) // Python 3.12 -> (see RESUME)
|
||||
OPCODE_A(INSTRUMENTED_CALL) // Python 3.12 -> (see CALL)
|
||||
OPCODE_A(INSTRUMENTED_RETURN_VALUE) // Python 3.12 -> (see RETURN_VALUE)
|
||||
OPCODE_A(INSTRUMENTED_YIELD_VALUE) // Python 3.12 -> (see YIELD_VALUE)
|
||||
OPCODE_A(INSTRUMENTED_CALL_FUNCTION_EX) // Python 3.12 -> (see CALL_FUNCTION_EX)
|
||||
OPCODE_A(INSTRUMENTED_JUMP_FORWARD) // Python 3.12 -> (see JUMP_FORWARD)
|
||||
OPCODE_A(INSTRUMENTED_JUMP_BACKWARD) // Python 3.12 -> (see JUMP_BACKWARD)
|
||||
OPCODE_A(INSTRUMENTED_RETURN_CONST) // Python 3.12 -> (see RETURN_CONST)
|
||||
OPCODE_A(INSTRUMENTED_FOR_ITER) // Python 3.12 -> (see FOR_ITER)
|
||||
OPCODE_A(INSTRUMENTED_POP_JUMP_IF_FALSE) // Python 3.12 -> (see POP_JUMP_IF_FALSE)
|
||||
OPCODE_A(INSTRUMENTED_POP_JUMP_IF_TRUE) // Python 3.12 -> (see POP_JUMP_IF_TRUE)
|
||||
OPCODE_A(INSTRUMENTED_END_FOR) // Python 3.12 -> (see END_FOR)
|
||||
OPCODE_A(INSTRUMENTED_END_SEND) // Python 3.12 -> (see END_SEND)
|
||||
OPCODE_A(INSTRUMENTED_INSTRUCTION) // Python 3.12 -> A=(unused)
|
||||
OPCODE_A(INSTRUMENTED_LINE) // Python 3.12 -> ???
|
||||
OPCODE_A(INSTRUMENTED_CALL_KW) // Python 3.13 -> (see CALL_KW)
|
||||
14
pycdc/bytes/bytecode_map.h
Normal file
14
pycdc/bytes/bytecode_map.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "bytecode.h"
|
||||
|
||||
#define BEGIN_MAP(maj, min) \
|
||||
int python_##maj##_##min##_map(int id) \
|
||||
{ \
|
||||
switch (id) {
|
||||
|
||||
#define MAP_OP(op, name) \
|
||||
case op: return Pyc::name;
|
||||
|
||||
#define END_MAP() \
|
||||
default: return Pyc::PYC_INVALID_OPCODE; \
|
||||
} \
|
||||
}
|
||||
89
pycdc/bytes/python_1_0.cpp
Normal file
89
pycdc/bytes/python_1_0.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(1, 0)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(14, UNARY_CALL)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_CALL)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, RAISE_EXCEPTION)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, LOAD_GLOBALS)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(86, BUILD_FUNCTION)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_TUPLE_A)
|
||||
MAP_OP(93, UNPACK_LIST_A)
|
||||
MAP_OP(94, UNPACK_ARG_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, UNPACK_VARARG_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(109, ACCESS_MODE_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, FOR_LOOP_A)
|
||||
MAP_OP(115, LOAD_LOCAL_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(123, RESERVE_FAST_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(127, SET_LINENO_A)
|
||||
END_MAP()
|
||||
90
pycdc/bytes/python_1_1.cpp
Normal file
90
pycdc/bytes/python_1_1.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(1, 1)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(14, UNARY_CALL)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_CALL)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, RAISE_EXCEPTION)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, LOAD_GLOBALS)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(86, BUILD_FUNCTION)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_TUPLE_A)
|
||||
MAP_OP(93, UNPACK_LIST_A)
|
||||
MAP_OP(94, UNPACK_ARG_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, UNPACK_VARARG_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(109, ACCESS_MODE_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, FOR_LOOP_A)
|
||||
MAP_OP(115, LOAD_LOCAL_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(117, SET_FUNC_ARGS_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(123, RESERVE_FAST_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(127, SET_LINENO_A)
|
||||
END_MAP()
|
||||
87
pycdc/bytes/python_1_3.cpp
Normal file
87
pycdc/bytes/python_1_3.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(1, 3)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_TUPLE_A)
|
||||
MAP_OP(93, UNPACK_LIST_A)
|
||||
MAP_OP(94, UNPACK_ARG_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, UNPACK_VARARG_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(109, ACCESS_MODE_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, FOR_LOOP_A)
|
||||
MAP_OP(115, LOAD_LOCAL_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(117, SET_FUNC_ARGS_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(127, SET_LINENO_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
END_MAP()
|
||||
89
pycdc/bytes/python_1_4.cpp
Normal file
89
pycdc/bytes/python_1_4.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(1, 4)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_TUPLE_A)
|
||||
MAP_OP(93, UNPACK_LIST_A)
|
||||
MAP_OP(94, UNPACK_ARG_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, UNPACK_VARARG_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(109, ACCESS_MODE_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, FOR_LOOP_A)
|
||||
MAP_OP(115, LOAD_LOCAL_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(117, SET_FUNC_ARGS_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(127, SET_LINENO_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
END_MAP()
|
||||
84
pycdc/bytes/python_1_5.cpp
Normal file
84
pycdc/bytes/python_1_5.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(1, 5)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_TUPLE_A)
|
||||
MAP_OP(93, UNPACK_LIST_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, FOR_LOOP_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(127, SET_LINENO_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
END_MAP()
|
||||
87
pycdc/bytes/python_1_6.cpp
Normal file
87
pycdc/bytes/python_1_6.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(1, 6)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_TUPLE_A)
|
||||
MAP_OP(93, UNPACK_LIST_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, FOR_LOOP_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(127, SET_LINENO_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
END_MAP()
|
||||
103
pycdc/bytes/python_2_0.cpp
Normal file
103
pycdc/bytes/python_2_0.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(2, 0)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, ROT_FOUR)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(58, INPLACE_DIVIDE)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(73, PRINT_ITEM_TO)
|
||||
MAP_OP(74, PRINT_NEWLINE_TO)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, DUP_TOPX_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, FOR_LOOP_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(127, SET_LINENO_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, EXTENDED_ARG_A)
|
||||
END_MAP()
|
||||
108
pycdc/bytes/python_2_1.cpp
Normal file
108
pycdc/bytes/python_2_1.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(2, 1)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, ROT_FOUR)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(58, INPLACE_DIVIDE)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(73, PRINT_ITEM_TO)
|
||||
MAP_OP(74, PRINT_NEWLINE_TO)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, DUP_TOPX_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, FOR_LOOP_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(127, SET_LINENO_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, EXTENDED_ARG_A)
|
||||
END_MAP()
|
||||
115
pycdc/bytes/python_2_2.cpp
Normal file
115
pycdc/bytes/python_2_2.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(2, 2)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, ROT_FOUR)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(58, INPLACE_DIVIDE)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(73, PRINT_ITEM_TO)
|
||||
MAP_OP(74, PRINT_NEWLINE_TO)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, DUP_TOPX_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, FOR_LOOP_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(127, SET_LINENO_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, EXTENDED_ARG_A)
|
||||
END_MAP()
|
||||
113
pycdc/bytes/python_2_3.cpp
Normal file
113
pycdc/bytes/python_2_3.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(2, 3)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, ROT_FOUR)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(58, INPLACE_DIVIDE)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(73, PRINT_ITEM_TO)
|
||||
MAP_OP(74, PRINT_NEWLINE_TO)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, DUP_TOPX_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, EXTENDED_ARG_A)
|
||||
END_MAP()
|
||||
115
pycdc/bytes/python_2_4.cpp
Normal file
115
pycdc/bytes/python_2_4.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(2, 4)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, ROT_FOUR)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(18, LIST_APPEND)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(58, INPLACE_DIVIDE)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(73, PRINT_ITEM_TO)
|
||||
MAP_OP(74, PRINT_NEWLINE_TO)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, DUP_TOPX_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, EXTENDED_ARG_A)
|
||||
END_MAP()
|
||||
116
pycdc/bytes/python_2_5.cpp
Normal file
116
pycdc/bytes/python_2_5.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(2, 5)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, ROT_FOUR)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(18, LIST_APPEND)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(58, INPLACE_DIVIDE)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(73, PRINT_ITEM_TO)
|
||||
MAP_OP(74, PRINT_NEWLINE_TO)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, WITH_CLEANUP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, DUP_TOPX_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, EXTENDED_ARG_A)
|
||||
END_MAP()
|
||||
117
pycdc/bytes/python_2_6.cpp
Normal file
117
pycdc/bytes/python_2_6.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(2, 6)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, ROT_FOUR)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(18, LIST_APPEND)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(54, STORE_MAP)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(58, INPLACE_DIVIDE)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(73, PRINT_ITEM_TO)
|
||||
MAP_OP(74, PRINT_NEWLINE_TO)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, WITH_CLEANUP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, DUP_TOPX_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_MAP_A)
|
||||
MAP_OP(105, LOAD_ATTR_A)
|
||||
MAP_OP(106, COMPARE_OP_A)
|
||||
MAP_OP(107, IMPORT_NAME_A)
|
||||
MAP_OP(108, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, EXTENDED_ARG_A)
|
||||
END_MAP()
|
||||
123
pycdc/bytes/python_2_7.cpp
Normal file
123
pycdc/bytes/python_2_7.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(2, 7)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, ROT_FOUR)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(13, UNARY_CONVERT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(21, BINARY_DIVIDE)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(30, SLICE_0)
|
||||
MAP_OP(31, SLICE_1)
|
||||
MAP_OP(32, SLICE_2)
|
||||
MAP_OP(33, SLICE_3)
|
||||
MAP_OP(40, STORE_SLICE_0)
|
||||
MAP_OP(41, STORE_SLICE_1)
|
||||
MAP_OP(42, STORE_SLICE_2)
|
||||
MAP_OP(43, STORE_SLICE_3)
|
||||
MAP_OP(50, DELETE_SLICE_0)
|
||||
MAP_OP(51, DELETE_SLICE_1)
|
||||
MAP_OP(52, DELETE_SLICE_2)
|
||||
MAP_OP(53, DELETE_SLICE_3)
|
||||
MAP_OP(54, STORE_MAP)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(58, INPLACE_DIVIDE)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, PRINT_ITEM)
|
||||
MAP_OP(72, PRINT_NEWLINE)
|
||||
MAP_OP(73, PRINT_ITEM_TO)
|
||||
MAP_OP(74, PRINT_NEWLINE_TO)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, WITH_CLEANUP)
|
||||
MAP_OP(82, LOAD_LOCALS)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, EXEC_STMT)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, BUILD_CLASS)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, LIST_APPEND_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, DUP_TOPX_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, SETUP_WITH_A)
|
||||
MAP_OP(145, EXTENDED_ARG_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
END_MAP()
|
||||
101
pycdc/bytes/python_3_0.cpp
Normal file
101
pycdc/bytes/python_3_0.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 0)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, ROT_FOUR)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(17, SET_ADD)
|
||||
MAP_OP(18, LIST_APPEND)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(54, STORE_MAP)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, STORE_LOCALS)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, WITH_CLEANUP)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, DUP_TOPX_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, EXTENDED_ARG_A)
|
||||
END_MAP()
|
||||
104
pycdc/bytes/python_3_1.cpp
Normal file
104
pycdc/bytes/python_3_1.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 1)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, ROT_FOUR)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(54, STORE_MAP)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, STORE_LOCALS)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, WITH_CLEANUP)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, DUP_TOPX_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
END_MAP()
|
||||
131
pycdc/bytes/python_3_10.cpp
Normal file
131
pycdc/bytes/python_3_10.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 10)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, DUP_TOP_TWO)
|
||||
MAP_OP(6, ROT_FOUR)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(16, BINARY_MATRIX_MULTIPLY)
|
||||
MAP_OP(17, INPLACE_MATRIX_MULTIPLY)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(30, GET_LEN)
|
||||
MAP_OP(31, MATCH_MAPPING)
|
||||
MAP_OP(32, MATCH_SEQUENCE)
|
||||
MAP_OP(33, MATCH_KEYS)
|
||||
MAP_OP(34, COPY_DICT_WITHOUT_KEYS)
|
||||
MAP_OP(49, WITH_EXCEPT_START)
|
||||
MAP_OP(50, GET_AITER)
|
||||
MAP_OP(51, GET_ANEXT)
|
||||
MAP_OP(52, BEFORE_ASYNC_WITH)
|
||||
MAP_OP(54, END_ASYNC_FOR)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, GET_YIELD_FROM_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(72, YIELD_FROM)
|
||||
MAP_OP(73, GET_AWAITABLE)
|
||||
MAP_OP(74, LOAD_ASSERTION_ERROR)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(82, LIST_TO_TUPLE)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, SETUP_ANNOTATIONS)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, ROT_N_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(117, IS_OP_A)
|
||||
MAP_OP(118, CONTAINS_OP_A)
|
||||
MAP_OP(119, RERAISE_A)
|
||||
MAP_OP(121, JUMP_IF_NOT_EXC_MATCH_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(129, GEN_START_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(138, DELETE_DEREF_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_EX_A)
|
||||
MAP_OP(143, SETUP_WITH_A)
|
||||
MAP_OP(144, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
MAP_OP(148, LOAD_CLASSDEREF_A)
|
||||
MAP_OP(152, MATCH_CLASS_A)
|
||||
MAP_OP(154, SETUP_ASYNC_WITH_A)
|
||||
MAP_OP(155, FORMAT_VALUE_A)
|
||||
MAP_OP(156, BUILD_CONST_KEY_MAP_A)
|
||||
MAP_OP(157, BUILD_STRING_A)
|
||||
MAP_OP(160, LOAD_METHOD_A)
|
||||
MAP_OP(161, CALL_METHOD_A)
|
||||
MAP_OP(162, LIST_EXTEND_A)
|
||||
MAP_OP(163, SET_UPDATE_A)
|
||||
MAP_OP(164, DICT_MERGE_A)
|
||||
MAP_OP(165, DICT_UPDATE_A)
|
||||
END_MAP()
|
||||
114
pycdc/bytes/python_3_11.cpp
Normal file
114
pycdc/bytes/python_3_11.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 11)
|
||||
MAP_OP(0, CACHE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, PUSH_NULL)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(30, GET_LEN)
|
||||
MAP_OP(31, MATCH_MAPPING)
|
||||
MAP_OP(32, MATCH_SEQUENCE)
|
||||
MAP_OP(33, MATCH_KEYS)
|
||||
MAP_OP(35, PUSH_EXC_INFO)
|
||||
MAP_OP(36, CHECK_EXC_MATCH)
|
||||
MAP_OP(37, CHECK_EG_MATCH)
|
||||
MAP_OP(49, WITH_EXCEPT_START)
|
||||
MAP_OP(50, GET_AITER)
|
||||
MAP_OP(51, GET_ANEXT)
|
||||
MAP_OP(52, BEFORE_ASYNC_WITH)
|
||||
MAP_OP(53, BEFORE_WITH)
|
||||
MAP_OP(54, END_ASYNC_FOR)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, GET_YIELD_FROM_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(74, LOAD_ASSERTION_ERROR)
|
||||
MAP_OP(75, RETURN_GENERATOR)
|
||||
MAP_OP(82, LIST_TO_TUPLE)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, SETUP_ANNOTATIONS)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, ASYNC_GEN_WRAP)
|
||||
MAP_OP(88, PREP_RERAISE_STAR)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, SWAP_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(114, POP_JUMP_FORWARD_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_FORWARD_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(117, IS_OP_A)
|
||||
MAP_OP(118, CONTAINS_OP_A)
|
||||
MAP_OP(119, RERAISE_A)
|
||||
MAP_OP(120, COPY_A)
|
||||
MAP_OP(122, BINARY_OP_A)
|
||||
MAP_OP(123, SEND_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(128, POP_JUMP_FORWARD_IF_NOT_NONE_A)
|
||||
MAP_OP(129, POP_JUMP_FORWARD_IF_NONE_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, GET_AWAITABLE_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, JUMP_BACKWARD_NO_INTERRUPT_A)
|
||||
MAP_OP(135, MAKE_CELL_A)
|
||||
MAP_OP(136, LOAD_CLOSURE_A)
|
||||
MAP_OP(137, LOAD_DEREF_A)
|
||||
MAP_OP(138, STORE_DEREF_A)
|
||||
MAP_OP(139, DELETE_DEREF_A)
|
||||
MAP_OP(140, JUMP_BACKWARD_A)
|
||||
MAP_OP(142, CALL_FUNCTION_EX_A)
|
||||
MAP_OP(144, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
MAP_OP(148, LOAD_CLASSDEREF_A)
|
||||
MAP_OP(149, COPY_FREE_VARS_A)
|
||||
MAP_OP(151, RESUME_A)
|
||||
MAP_OP(152, MATCH_CLASS_A)
|
||||
MAP_OP(155, FORMAT_VALUE_A)
|
||||
MAP_OP(156, BUILD_CONST_KEY_MAP_A)
|
||||
MAP_OP(157, BUILD_STRING_A)
|
||||
MAP_OP(160, LOAD_METHOD_A)
|
||||
MAP_OP(162, LIST_EXTEND_A)
|
||||
MAP_OP(163, SET_UPDATE_A)
|
||||
MAP_OP(164, DICT_MERGE_A)
|
||||
MAP_OP(165, DICT_UPDATE_A)
|
||||
MAP_OP(166, PRECALL_A)
|
||||
MAP_OP(171, CALL_A)
|
||||
MAP_OP(172, KW_NAMES_A)
|
||||
MAP_OP(173, POP_JUMP_BACKWARD_IF_NOT_NONE_A)
|
||||
MAP_OP(174, POP_JUMP_BACKWARD_IF_NONE_A)
|
||||
MAP_OP(175, POP_JUMP_BACKWARD_IF_FALSE_A)
|
||||
MAP_OP(176, POP_JUMP_BACKWARD_IF_TRUE_A)
|
||||
END_MAP()
|
||||
133
pycdc/bytes/python_3_12.cpp
Normal file
133
pycdc/bytes/python_3_12.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 12)
|
||||
MAP_OP(0, CACHE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, PUSH_NULL)
|
||||
MAP_OP(3, INTERPRETER_EXIT)
|
||||
MAP_OP(4, END_FOR)
|
||||
MAP_OP(5, END_SEND)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(17, RESERVED)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_SLICE)
|
||||
MAP_OP(27, STORE_SLICE)
|
||||
MAP_OP(30, GET_LEN)
|
||||
MAP_OP(31, MATCH_MAPPING)
|
||||
MAP_OP(32, MATCH_SEQUENCE)
|
||||
MAP_OP(33, MATCH_KEYS)
|
||||
MAP_OP(35, PUSH_EXC_INFO)
|
||||
MAP_OP(36, CHECK_EXC_MATCH)
|
||||
MAP_OP(37, CHECK_EG_MATCH)
|
||||
MAP_OP(49, WITH_EXCEPT_START)
|
||||
MAP_OP(50, GET_AITER)
|
||||
MAP_OP(51, GET_ANEXT)
|
||||
MAP_OP(52, BEFORE_ASYNC_WITH)
|
||||
MAP_OP(53, BEFORE_WITH)
|
||||
MAP_OP(54, END_ASYNC_FOR)
|
||||
MAP_OP(55, CLEANUP_THROW)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, GET_YIELD_FROM_ITER)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(74, LOAD_ASSERTION_ERROR)
|
||||
MAP_OP(75, RETURN_GENERATOR)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(85, SETUP_ANNOTATIONS)
|
||||
MAP_OP(87, LOAD_LOCALS)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(99, SWAP_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(117, IS_OP_A)
|
||||
MAP_OP(118, CONTAINS_OP_A)
|
||||
MAP_OP(119, RERAISE_A)
|
||||
MAP_OP(120, COPY_A)
|
||||
MAP_OP(121, RETURN_CONST_A)
|
||||
MAP_OP(122, BINARY_OP_A)
|
||||
MAP_OP(123, SEND_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(127, LOAD_FAST_CHECK_A)
|
||||
MAP_OP(128, POP_JUMP_IF_NOT_NONE_A)
|
||||
MAP_OP(129, POP_JUMP_IF_NONE_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, GET_AWAITABLE_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, JUMP_BACKWARD_NO_INTERRUPT_A)
|
||||
MAP_OP(135, MAKE_CELL_A)
|
||||
MAP_OP(136, LOAD_CLOSURE_A)
|
||||
MAP_OP(137, LOAD_DEREF_A)
|
||||
MAP_OP(138, STORE_DEREF_A)
|
||||
MAP_OP(139, DELETE_DEREF_A)
|
||||
MAP_OP(140, JUMP_BACKWARD_A)
|
||||
MAP_OP(141, LOAD_SUPER_ATTR_A)
|
||||
MAP_OP(142, CALL_FUNCTION_EX_A)
|
||||
MAP_OP(143, LOAD_FAST_AND_CLEAR_A)
|
||||
MAP_OP(144, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
MAP_OP(149, COPY_FREE_VARS_A)
|
||||
MAP_OP(150, YIELD_VALUE_A)
|
||||
MAP_OP(151, RESUME_A)
|
||||
MAP_OP(152, MATCH_CLASS_A)
|
||||
MAP_OP(155, FORMAT_VALUE_A)
|
||||
MAP_OP(156, BUILD_CONST_KEY_MAP_A)
|
||||
MAP_OP(157, BUILD_STRING_A)
|
||||
MAP_OP(162, LIST_EXTEND_A)
|
||||
MAP_OP(163, SET_UPDATE_A)
|
||||
MAP_OP(164, DICT_MERGE_A)
|
||||
MAP_OP(165, DICT_UPDATE_A)
|
||||
MAP_OP(171, CALL_A)
|
||||
MAP_OP(172, KW_NAMES_A)
|
||||
MAP_OP(173, CALL_INTRINSIC_1_A)
|
||||
MAP_OP(174, CALL_INTRINSIC_2_A)
|
||||
MAP_OP(175, LOAD_FROM_DICT_OR_GLOBALS_A)
|
||||
MAP_OP(176, LOAD_FROM_DICT_OR_DEREF_A)
|
||||
MAP_OP(237, INSTRUMENTED_LOAD_SUPER_ATTR_A)
|
||||
MAP_OP(238, INSTRUMENTED_POP_JUMP_IF_NONE_A)
|
||||
MAP_OP(239, INSTRUMENTED_POP_JUMP_IF_NOT_NONE_A)
|
||||
MAP_OP(240, INSTRUMENTED_RESUME_A)
|
||||
MAP_OP(241, INSTRUMENTED_CALL_A)
|
||||
MAP_OP(242, INSTRUMENTED_RETURN_VALUE_A)
|
||||
MAP_OP(243, INSTRUMENTED_YIELD_VALUE_A)
|
||||
MAP_OP(244, INSTRUMENTED_CALL_FUNCTION_EX_A)
|
||||
MAP_OP(245, INSTRUMENTED_JUMP_FORWARD_A)
|
||||
MAP_OP(246, INSTRUMENTED_JUMP_BACKWARD_A)
|
||||
MAP_OP(247, INSTRUMENTED_RETURN_CONST_A)
|
||||
MAP_OP(248, INSTRUMENTED_FOR_ITER_A)
|
||||
MAP_OP(249, INSTRUMENTED_POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(250, INSTRUMENTED_POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(251, INSTRUMENTED_END_FOR_A)
|
||||
MAP_OP(252, INSTRUMENTED_END_SEND_A)
|
||||
MAP_OP(253, INSTRUMENTED_INSTRUCTION_A)
|
||||
MAP_OP(254, INSTRUMENTED_LINE_A)
|
||||
END_MAP()
|
||||
142
pycdc/bytes/python_3_13.cpp
Normal file
142
pycdc/bytes/python_3_13.cpp
Normal file
@@ -0,0 +1,142 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 13)
|
||||
MAP_OP(0, CACHE)
|
||||
MAP_OP(1, BEFORE_ASYNC_WITH)
|
||||
MAP_OP(2, BEFORE_WITH)
|
||||
MAP_OP(4, BINARY_SLICE)
|
||||
MAP_OP(5, BINARY_SUBSCR)
|
||||
MAP_OP(6, CHECK_EG_MATCH)
|
||||
MAP_OP(7, CHECK_EXC_MATCH)
|
||||
MAP_OP(8, CLEANUP_THROW)
|
||||
MAP_OP(9, DELETE_SUBSCR)
|
||||
MAP_OP(10, END_ASYNC_FOR)
|
||||
MAP_OP(11, END_FOR)
|
||||
MAP_OP(12, END_SEND)
|
||||
MAP_OP(13, EXIT_INIT_CHECK)
|
||||
MAP_OP(14, FORMAT_SIMPLE)
|
||||
MAP_OP(15, FORMAT_WITH_SPEC)
|
||||
MAP_OP(16, GET_AITER)
|
||||
MAP_OP(17, RESERVED)
|
||||
MAP_OP(18, GET_ANEXT)
|
||||
MAP_OP(19, GET_ITER)
|
||||
MAP_OP(20, GET_LEN)
|
||||
MAP_OP(21, GET_YIELD_FROM_ITER)
|
||||
MAP_OP(22, INTERPRETER_EXIT)
|
||||
MAP_OP(23, LOAD_ASSERTION_ERROR)
|
||||
MAP_OP(24, LOAD_BUILD_CLASS)
|
||||
MAP_OP(25, LOAD_LOCALS)
|
||||
MAP_OP(26, MAKE_FUNCTION)
|
||||
MAP_OP(27, MATCH_KEYS)
|
||||
MAP_OP(28, MATCH_MAPPING)
|
||||
MAP_OP(29, MATCH_SEQUENCE)
|
||||
MAP_OP(30, NOP)
|
||||
MAP_OP(31, POP_EXCEPT)
|
||||
MAP_OP(32, POP_TOP)
|
||||
MAP_OP(33, PUSH_EXC_INFO)
|
||||
MAP_OP(34, PUSH_NULL)
|
||||
MAP_OP(35, RETURN_GENERATOR)
|
||||
MAP_OP(36, RETURN_VALUE)
|
||||
MAP_OP(37, SETUP_ANNOTATIONS)
|
||||
MAP_OP(38, STORE_SLICE)
|
||||
MAP_OP(39, STORE_SUBSCR)
|
||||
MAP_OP(40, TO_BOOL)
|
||||
MAP_OP(41, UNARY_INVERT)
|
||||
MAP_OP(42, UNARY_NEGATIVE)
|
||||
MAP_OP(43, UNARY_NOT)
|
||||
MAP_OP(44, WITH_EXCEPT_START)
|
||||
MAP_OP(45, BINARY_OP_A)
|
||||
MAP_OP(46, BUILD_CONST_KEY_MAP_A)
|
||||
MAP_OP(47, BUILD_LIST_A)
|
||||
MAP_OP(48, BUILD_MAP_A)
|
||||
MAP_OP(49, BUILD_SET_A)
|
||||
MAP_OP(50, BUILD_SLICE_A)
|
||||
MAP_OP(51, BUILD_STRING_A)
|
||||
MAP_OP(52, BUILD_TUPLE_A)
|
||||
MAP_OP(53, CALL_A)
|
||||
MAP_OP(54, CALL_FUNCTION_EX_A)
|
||||
MAP_OP(55, CALL_INTRINSIC_1_A)
|
||||
MAP_OP(56, CALL_INTRINSIC_2_A)
|
||||
MAP_OP(57, CALL_KW_A)
|
||||
MAP_OP(58, COMPARE_OP_A)
|
||||
MAP_OP(59, CONTAINS_OP_A)
|
||||
MAP_OP(60, CONVERT_VALUE_A)
|
||||
MAP_OP(61, COPY_A)
|
||||
MAP_OP(62, COPY_FREE_VARS_A)
|
||||
MAP_OP(63, DELETE_ATTR_A)
|
||||
MAP_OP(64, DELETE_DEREF_A)
|
||||
MAP_OP(65, DELETE_FAST_A)
|
||||
MAP_OP(66, DELETE_GLOBAL_A)
|
||||
MAP_OP(67, DELETE_NAME_A)
|
||||
MAP_OP(68, DICT_MERGE_A)
|
||||
MAP_OP(69, DICT_UPDATE_A)
|
||||
MAP_OP(70, ENTER_EXECUTOR_A)
|
||||
MAP_OP(71, EXTENDED_ARG_A)
|
||||
MAP_OP(72, FOR_ITER_A)
|
||||
MAP_OP(73, GET_AWAITABLE_A)
|
||||
MAP_OP(74, IMPORT_FROM_A)
|
||||
MAP_OP(75, IMPORT_NAME_A)
|
||||
MAP_OP(76, IS_OP_A)
|
||||
MAP_OP(77, JUMP_BACKWARD_A)
|
||||
MAP_OP(78, JUMP_BACKWARD_NO_INTERRUPT_A)
|
||||
MAP_OP(79, JUMP_FORWARD_A)
|
||||
MAP_OP(80, LIST_APPEND_A)
|
||||
MAP_OP(81, LIST_EXTEND_A)
|
||||
MAP_OP(82, LOAD_ATTR_A)
|
||||
MAP_OP(83, LOAD_CONST_A)
|
||||
MAP_OP(84, LOAD_DEREF_A)
|
||||
MAP_OP(85, LOAD_FAST_A)
|
||||
MAP_OP(86, LOAD_FAST_AND_CLEAR_A)
|
||||
MAP_OP(87, LOAD_FAST_CHECK_A)
|
||||
MAP_OP(88, LOAD_FAST_LOAD_FAST_A)
|
||||
MAP_OP(89, LOAD_FROM_DICT_OR_DEREF_A)
|
||||
MAP_OP(90, LOAD_FROM_DICT_OR_GLOBALS_A)
|
||||
MAP_OP(91, LOAD_GLOBAL_A)
|
||||
MAP_OP(92, LOAD_NAME_A)
|
||||
MAP_OP(93, LOAD_SUPER_ATTR_A)
|
||||
MAP_OP(94, MAKE_CELL_A)
|
||||
MAP_OP(95, MAP_ADD_A)
|
||||
MAP_OP(96, MATCH_CLASS_A)
|
||||
MAP_OP(97, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(98, POP_JUMP_IF_NONE_A)
|
||||
MAP_OP(99, POP_JUMP_IF_NOT_NONE_A)
|
||||
MAP_OP(100, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(101, RAISE_VARARGS_A)
|
||||
MAP_OP(102, RERAISE_A)
|
||||
MAP_OP(103, RETURN_CONST_A)
|
||||
MAP_OP(104, SEND_A)
|
||||
MAP_OP(105, SET_ADD_A)
|
||||
MAP_OP(106, SET_FUNCTION_ATTRIBUTE_A)
|
||||
MAP_OP(107, SET_UPDATE_A)
|
||||
MAP_OP(108, STORE_ATTR_A)
|
||||
MAP_OP(109, STORE_DEREF_A)
|
||||
MAP_OP(110, STORE_FAST_A)
|
||||
MAP_OP(111, STORE_FAST_LOAD_FAST_A)
|
||||
MAP_OP(112, STORE_FAST_STORE_FAST_A)
|
||||
MAP_OP(113, STORE_GLOBAL_A)
|
||||
MAP_OP(114, STORE_NAME_A)
|
||||
MAP_OP(115, SWAP_A)
|
||||
MAP_OP(116, UNPACK_EX_A)
|
||||
MAP_OP(117, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(118, YIELD_VALUE_A)
|
||||
MAP_OP(149, RESUME_A)
|
||||
MAP_OP(236, INSTRUMENTED_RESUME_A)
|
||||
MAP_OP(237, INSTRUMENTED_END_FOR_A)
|
||||
MAP_OP(238, INSTRUMENTED_END_SEND_A)
|
||||
MAP_OP(239, INSTRUMENTED_RETURN_VALUE_A)
|
||||
MAP_OP(240, INSTRUMENTED_RETURN_CONST_A)
|
||||
MAP_OP(241, INSTRUMENTED_YIELD_VALUE_A)
|
||||
MAP_OP(242, INSTRUMENTED_LOAD_SUPER_ATTR_A)
|
||||
MAP_OP(243, INSTRUMENTED_FOR_ITER_A)
|
||||
MAP_OP(244, INSTRUMENTED_CALL_A)
|
||||
MAP_OP(245, INSTRUMENTED_CALL_KW_A)
|
||||
MAP_OP(246, INSTRUMENTED_CALL_FUNCTION_EX_A)
|
||||
MAP_OP(247, INSTRUMENTED_INSTRUCTION_A)
|
||||
MAP_OP(248, INSTRUMENTED_JUMP_FORWARD_A)
|
||||
MAP_OP(249, INSTRUMENTED_JUMP_BACKWARD_A)
|
||||
MAP_OP(250, INSTRUMENTED_POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(251, INSTRUMENTED_POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(252, INSTRUMENTED_POP_JUMP_IF_NONE_A)
|
||||
MAP_OP(253, INSTRUMENTED_POP_JUMP_IF_NOT_NONE_A)
|
||||
MAP_OP(254, INSTRUMENTED_LINE_A)
|
||||
END_MAP()
|
||||
105
pycdc/bytes/python_3_2.cpp
Normal file
105
pycdc/bytes/python_3_2.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 2)
|
||||
MAP_OP(0, STOP_CODE)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, DUP_TOP_TWO)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(54, STORE_MAP)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, STORE_LOCALS)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, WITH_CLEANUP)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(138, DELETE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, SETUP_WITH_A)
|
||||
MAP_OP(144, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
END_MAP()
|
||||
105
pycdc/bytes/python_3_3.cpp
Normal file
105
pycdc/bytes/python_3_3.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 3)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, DUP_TOP_TWO)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(54, STORE_MAP)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, STORE_LOCALS)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(72, YIELD_FROM)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, WITH_CLEANUP)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(138, DELETE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, SETUP_WITH_A)
|
||||
MAP_OP(144, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
END_MAP()
|
||||
105
pycdc/bytes/python_3_4.cpp
Normal file
105
pycdc/bytes/python_3_4.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 4)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, DUP_TOP_TWO)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(54, STORE_MAP)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(72, YIELD_FROM)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, WITH_CLEANUP)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(138, DELETE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, SETUP_WITH_A)
|
||||
MAP_OP(144, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
MAP_OP(148, LOAD_CLASSDEREF_A)
|
||||
END_MAP()
|
||||
118
pycdc/bytes/python_3_5.cpp
Normal file
118
pycdc/bytes/python_3_5.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 5)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, DUP_TOP_TWO)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(16, BINARY_MATRIX_MULTIPLY)
|
||||
MAP_OP(17, INPLACE_MATRIX_MULTIPLY)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(50, GET_AITER)
|
||||
MAP_OP(51, GET_ANEXT)
|
||||
MAP_OP(52, BEFORE_ASYNC_WITH)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, GET_YIELD_FROM_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(72, YIELD_FROM)
|
||||
MAP_OP(73, GET_AWAITABLE)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, WITH_CLEANUP_START)
|
||||
MAP_OP(82, WITH_CLEANUP_FINISH)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(134, MAKE_CLOSURE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(138, DELETE_DEREF_A)
|
||||
MAP_OP(140, CALL_FUNCTION_VAR_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_VAR_KW_A)
|
||||
MAP_OP(143, SETUP_WITH_A)
|
||||
MAP_OP(144, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
MAP_OP(148, LOAD_CLASSDEREF_A)
|
||||
MAP_OP(149, BUILD_LIST_UNPACK_A)
|
||||
MAP_OP(150, BUILD_MAP_UNPACK_A)
|
||||
MAP_OP(151, BUILD_MAP_UNPACK_WITH_CALL_A)
|
||||
MAP_OP(152, BUILD_TUPLE_UNPACK_A)
|
||||
MAP_OP(153, BUILD_SET_UNPACK_A)
|
||||
MAP_OP(154, SETUP_ASYNC_WITH_A)
|
||||
END_MAP()
|
||||
122
pycdc/bytes/python_3_6.cpp
Normal file
122
pycdc/bytes/python_3_6.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 6)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, DUP_TOP_TWO)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(16, BINARY_MATRIX_MULTIPLY)
|
||||
MAP_OP(17, INPLACE_MATRIX_MULTIPLY)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(50, GET_AITER)
|
||||
MAP_OP(51, GET_ANEXT)
|
||||
MAP_OP(52, BEFORE_ASYNC_WITH)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, GET_YIELD_FROM_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(72, YIELD_FROM)
|
||||
MAP_OP(73, GET_AWAITABLE)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, WITH_CLEANUP_START)
|
||||
MAP_OP(82, WITH_CLEANUP_FINISH)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, SETUP_ANNOTATIONS)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(127, STORE_ANNOTATION_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(138, DELETE_DEREF_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_EX_A)
|
||||
MAP_OP(143, SETUP_WITH_A)
|
||||
MAP_OP(144, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
MAP_OP(148, LOAD_CLASSDEREF_A)
|
||||
MAP_OP(149, BUILD_LIST_UNPACK_A)
|
||||
MAP_OP(150, BUILD_MAP_UNPACK_A)
|
||||
MAP_OP(151, BUILD_MAP_UNPACK_WITH_CALL_A)
|
||||
MAP_OP(152, BUILD_TUPLE_UNPACK_A)
|
||||
MAP_OP(153, BUILD_SET_UNPACK_A)
|
||||
MAP_OP(154, SETUP_ASYNC_WITH_A)
|
||||
MAP_OP(155, FORMAT_VALUE_A)
|
||||
MAP_OP(156, BUILD_CONST_KEY_MAP_A)
|
||||
MAP_OP(157, BUILD_STRING_A)
|
||||
MAP_OP(158, BUILD_TUPLE_UNPACK_WITH_CALL_A)
|
||||
END_MAP()
|
||||
123
pycdc/bytes/python_3_7.cpp
Normal file
123
pycdc/bytes/python_3_7.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 7)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, DUP_TOP_TWO)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(16, BINARY_MATRIX_MULTIPLY)
|
||||
MAP_OP(17, INPLACE_MATRIX_MULTIPLY)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(50, GET_AITER)
|
||||
MAP_OP(51, GET_ANEXT)
|
||||
MAP_OP(52, BEFORE_ASYNC_WITH)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, GET_YIELD_FROM_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(72, YIELD_FROM)
|
||||
MAP_OP(73, GET_AWAITABLE)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(80, BREAK_LOOP)
|
||||
MAP_OP(81, WITH_CLEANUP_START)
|
||||
MAP_OP(82, WITH_CLEANUP_FINISH)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, SETUP_ANNOTATIONS)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(119, CONTINUE_LOOP_A)
|
||||
MAP_OP(120, SETUP_LOOP_A)
|
||||
MAP_OP(121, SETUP_EXCEPT_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(138, DELETE_DEREF_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_EX_A)
|
||||
MAP_OP(143, SETUP_WITH_A)
|
||||
MAP_OP(144, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
MAP_OP(148, LOAD_CLASSDEREF_A)
|
||||
MAP_OP(149, BUILD_LIST_UNPACK_A)
|
||||
MAP_OP(150, BUILD_MAP_UNPACK_A)
|
||||
MAP_OP(151, BUILD_MAP_UNPACK_WITH_CALL_A)
|
||||
MAP_OP(152, BUILD_TUPLE_UNPACK_A)
|
||||
MAP_OP(153, BUILD_SET_UNPACK_A)
|
||||
MAP_OP(154, SETUP_ASYNC_WITH_A)
|
||||
MAP_OP(155, FORMAT_VALUE_A)
|
||||
MAP_OP(156, BUILD_CONST_KEY_MAP_A)
|
||||
MAP_OP(157, BUILD_STRING_A)
|
||||
MAP_OP(158, BUILD_TUPLE_UNPACK_WITH_CALL_A)
|
||||
MAP_OP(160, LOAD_METHOD_A)
|
||||
MAP_OP(161, CALL_METHOD_A)
|
||||
END_MAP()
|
||||
124
pycdc/bytes/python_3_8.cpp
Normal file
124
pycdc/bytes/python_3_8.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 8)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, DUP_TOP_TWO)
|
||||
MAP_OP(6, ROT_FOUR)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(16, BINARY_MATRIX_MULTIPLY)
|
||||
MAP_OP(17, INPLACE_MATRIX_MULTIPLY)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(50, GET_AITER)
|
||||
MAP_OP(51, GET_ANEXT)
|
||||
MAP_OP(52, BEFORE_ASYNC_WITH)
|
||||
MAP_OP(53, BEGIN_FINALLY)
|
||||
MAP_OP(54, END_ASYNC_FOR)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, GET_YIELD_FROM_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(72, YIELD_FROM)
|
||||
MAP_OP(73, GET_AWAITABLE)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(81, WITH_CLEANUP_START)
|
||||
MAP_OP(82, WITH_CLEANUP_FINISH)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, SETUP_ANNOTATIONS)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(88, END_FINALLY)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(138, DELETE_DEREF_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_EX_A)
|
||||
MAP_OP(143, SETUP_WITH_A)
|
||||
MAP_OP(144, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
MAP_OP(148, LOAD_CLASSDEREF_A)
|
||||
MAP_OP(149, BUILD_LIST_UNPACK_A)
|
||||
MAP_OP(150, BUILD_MAP_UNPACK_A)
|
||||
MAP_OP(151, BUILD_MAP_UNPACK_WITH_CALL_A)
|
||||
MAP_OP(152, BUILD_TUPLE_UNPACK_A)
|
||||
MAP_OP(153, BUILD_SET_UNPACK_A)
|
||||
MAP_OP(154, SETUP_ASYNC_WITH_A)
|
||||
MAP_OP(155, FORMAT_VALUE_A)
|
||||
MAP_OP(156, BUILD_CONST_KEY_MAP_A)
|
||||
MAP_OP(157, BUILD_STRING_A)
|
||||
MAP_OP(158, BUILD_TUPLE_UNPACK_WITH_CALL_A)
|
||||
MAP_OP(160, LOAD_METHOD_A)
|
||||
MAP_OP(161, CALL_METHOD_A)
|
||||
MAP_OP(162, CALL_FINALLY_A)
|
||||
MAP_OP(163, POP_FINALLY_A)
|
||||
END_MAP()
|
||||
123
pycdc/bytes/python_3_9.cpp
Normal file
123
pycdc/bytes/python_3_9.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
#include "bytecode_map.h"
|
||||
|
||||
BEGIN_MAP(3, 9)
|
||||
MAP_OP(1, POP_TOP)
|
||||
MAP_OP(2, ROT_TWO)
|
||||
MAP_OP(3, ROT_THREE)
|
||||
MAP_OP(4, DUP_TOP)
|
||||
MAP_OP(5, DUP_TOP_TWO)
|
||||
MAP_OP(6, ROT_FOUR)
|
||||
MAP_OP(9, NOP)
|
||||
MAP_OP(10, UNARY_POSITIVE)
|
||||
MAP_OP(11, UNARY_NEGATIVE)
|
||||
MAP_OP(12, UNARY_NOT)
|
||||
MAP_OP(15, UNARY_INVERT)
|
||||
MAP_OP(16, BINARY_MATRIX_MULTIPLY)
|
||||
MAP_OP(17, INPLACE_MATRIX_MULTIPLY)
|
||||
MAP_OP(19, BINARY_POWER)
|
||||
MAP_OP(20, BINARY_MULTIPLY)
|
||||
MAP_OP(22, BINARY_MODULO)
|
||||
MAP_OP(23, BINARY_ADD)
|
||||
MAP_OP(24, BINARY_SUBTRACT)
|
||||
MAP_OP(25, BINARY_SUBSCR)
|
||||
MAP_OP(26, BINARY_FLOOR_DIVIDE)
|
||||
MAP_OP(27, BINARY_TRUE_DIVIDE)
|
||||
MAP_OP(28, INPLACE_FLOOR_DIVIDE)
|
||||
MAP_OP(29, INPLACE_TRUE_DIVIDE)
|
||||
MAP_OP(48, RERAISE)
|
||||
MAP_OP(49, WITH_EXCEPT_START)
|
||||
MAP_OP(50, GET_AITER)
|
||||
MAP_OP(51, GET_ANEXT)
|
||||
MAP_OP(52, BEFORE_ASYNC_WITH)
|
||||
MAP_OP(54, END_ASYNC_FOR)
|
||||
MAP_OP(55, INPLACE_ADD)
|
||||
MAP_OP(56, INPLACE_SUBTRACT)
|
||||
MAP_OP(57, INPLACE_MULTIPLY)
|
||||
MAP_OP(59, INPLACE_MODULO)
|
||||
MAP_OP(60, STORE_SUBSCR)
|
||||
MAP_OP(61, DELETE_SUBSCR)
|
||||
MAP_OP(62, BINARY_LSHIFT)
|
||||
MAP_OP(63, BINARY_RSHIFT)
|
||||
MAP_OP(64, BINARY_AND)
|
||||
MAP_OP(65, BINARY_XOR)
|
||||
MAP_OP(66, BINARY_OR)
|
||||
MAP_OP(67, INPLACE_POWER)
|
||||
MAP_OP(68, GET_ITER)
|
||||
MAP_OP(69, GET_YIELD_FROM_ITER)
|
||||
MAP_OP(70, PRINT_EXPR)
|
||||
MAP_OP(71, LOAD_BUILD_CLASS)
|
||||
MAP_OP(72, YIELD_FROM)
|
||||
MAP_OP(73, GET_AWAITABLE)
|
||||
MAP_OP(74, LOAD_ASSERTION_ERROR)
|
||||
MAP_OP(75, INPLACE_LSHIFT)
|
||||
MAP_OP(76, INPLACE_RSHIFT)
|
||||
MAP_OP(77, INPLACE_AND)
|
||||
MAP_OP(78, INPLACE_XOR)
|
||||
MAP_OP(79, INPLACE_OR)
|
||||
MAP_OP(82, LIST_TO_TUPLE)
|
||||
MAP_OP(83, RETURN_VALUE)
|
||||
MAP_OP(84, IMPORT_STAR)
|
||||
MAP_OP(85, SETUP_ANNOTATIONS)
|
||||
MAP_OP(86, YIELD_VALUE)
|
||||
MAP_OP(87, POP_BLOCK)
|
||||
MAP_OP(89, POP_EXCEPT)
|
||||
MAP_OP(90, STORE_NAME_A)
|
||||
MAP_OP(91, DELETE_NAME_A)
|
||||
MAP_OP(92, UNPACK_SEQUENCE_A)
|
||||
MAP_OP(93, FOR_ITER_A)
|
||||
MAP_OP(94, UNPACK_EX_A)
|
||||
MAP_OP(95, STORE_ATTR_A)
|
||||
MAP_OP(96, DELETE_ATTR_A)
|
||||
MAP_OP(97, STORE_GLOBAL_A)
|
||||
MAP_OP(98, DELETE_GLOBAL_A)
|
||||
MAP_OP(100, LOAD_CONST_A)
|
||||
MAP_OP(101, LOAD_NAME_A)
|
||||
MAP_OP(102, BUILD_TUPLE_A)
|
||||
MAP_OP(103, BUILD_LIST_A)
|
||||
MAP_OP(104, BUILD_SET_A)
|
||||
MAP_OP(105, BUILD_MAP_A)
|
||||
MAP_OP(106, LOAD_ATTR_A)
|
||||
MAP_OP(107, COMPARE_OP_A)
|
||||
MAP_OP(108, IMPORT_NAME_A)
|
||||
MAP_OP(109, IMPORT_FROM_A)
|
||||
MAP_OP(110, JUMP_FORWARD_A)
|
||||
MAP_OP(111, JUMP_IF_FALSE_OR_POP_A)
|
||||
MAP_OP(112, JUMP_IF_TRUE_OR_POP_A)
|
||||
MAP_OP(113, JUMP_ABSOLUTE_A)
|
||||
MAP_OP(114, POP_JUMP_IF_FALSE_A)
|
||||
MAP_OP(115, POP_JUMP_IF_TRUE_A)
|
||||
MAP_OP(116, LOAD_GLOBAL_A)
|
||||
MAP_OP(117, IS_OP_A)
|
||||
MAP_OP(118, CONTAINS_OP_A)
|
||||
MAP_OP(121, JUMP_IF_NOT_EXC_MATCH_A)
|
||||
MAP_OP(122, SETUP_FINALLY_A)
|
||||
MAP_OP(124, LOAD_FAST_A)
|
||||
MAP_OP(125, STORE_FAST_A)
|
||||
MAP_OP(126, DELETE_FAST_A)
|
||||
MAP_OP(130, RAISE_VARARGS_A)
|
||||
MAP_OP(131, CALL_FUNCTION_A)
|
||||
MAP_OP(132, MAKE_FUNCTION_A)
|
||||
MAP_OP(133, BUILD_SLICE_A)
|
||||
MAP_OP(135, LOAD_CLOSURE_A)
|
||||
MAP_OP(136, LOAD_DEREF_A)
|
||||
MAP_OP(137, STORE_DEREF_A)
|
||||
MAP_OP(138, DELETE_DEREF_A)
|
||||
MAP_OP(141, CALL_FUNCTION_KW_A)
|
||||
MAP_OP(142, CALL_FUNCTION_EX_A)
|
||||
MAP_OP(143, SETUP_WITH_A)
|
||||
MAP_OP(144, EXTENDED_ARG_A)
|
||||
MAP_OP(145, LIST_APPEND_A)
|
||||
MAP_OP(146, SET_ADD_A)
|
||||
MAP_OP(147, MAP_ADD_A)
|
||||
MAP_OP(148, LOAD_CLASSDEREF_A)
|
||||
MAP_OP(154, SETUP_ASYNC_WITH_A)
|
||||
MAP_OP(155, FORMAT_VALUE_A)
|
||||
MAP_OP(156, BUILD_CONST_KEY_MAP_A)
|
||||
MAP_OP(157, BUILD_STRING_A)
|
||||
MAP_OP(160, LOAD_METHOD_A)
|
||||
MAP_OP(161, CALL_METHOD_A)
|
||||
MAP_OP(162, LIST_EXTEND_A)
|
||||
MAP_OP(163, SET_UPDATE_A)
|
||||
MAP_OP(164, DICT_MERGE_A)
|
||||
MAP_OP(165, DICT_UPDATE_A)
|
||||
END_MAP()
|
||||
118
pycdc/data.cpp
Normal file
118
pycdc/data.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
#include "data.h"
|
||||
#include <cstring>
|
||||
#include <cstdarg>
|
||||
#include <vector>
|
||||
|
||||
/* PycData */
|
||||
int PycData::get16()
|
||||
{
|
||||
/* Ensure endianness */
|
||||
int result = getByte() & 0xFF;
|
||||
result |= (getByte() & 0xFF) << 8;
|
||||
return result;
|
||||
}
|
||||
|
||||
int PycData::get32()
|
||||
{
|
||||
/* Ensure endianness */
|
||||
int result = getByte() & 0xFF;
|
||||
result |= (getByte() & 0xFF) << 8;
|
||||
result |= (getByte() & 0xFF) << 16;
|
||||
result |= (getByte() & 0xFF) << 24;
|
||||
return result;
|
||||
}
|
||||
|
||||
Pyc_INT64 PycData::get64()
|
||||
{
|
||||
/* Ensure endianness */
|
||||
Pyc_INT64 result = (Pyc_INT64)(getByte() & 0xFF);
|
||||
result |= (Pyc_INT64)(getByte() & 0xFF) << 8;
|
||||
result |= (Pyc_INT64)(getByte() & 0xFF) << 16;
|
||||
result |= (Pyc_INT64)(getByte() & 0xFF) << 24;
|
||||
result |= (Pyc_INT64)(getByte() & 0xFF) << 32;
|
||||
result |= (Pyc_INT64)(getByte() & 0xFF) << 40;
|
||||
result |= (Pyc_INT64)(getByte() & 0xFF) << 48;
|
||||
result |= (Pyc_INT64)(getByte() & 0xFF) << 56;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* PycFile */
|
||||
PycFile::PycFile(const char* filename)
|
||||
{
|
||||
m_stream = fopen(filename, "rb");
|
||||
}
|
||||
|
||||
bool PycFile::atEof() const
|
||||
{
|
||||
int ch = fgetc(m_stream);
|
||||
ungetc(ch, m_stream);
|
||||
return (ch == EOF);
|
||||
}
|
||||
|
||||
int PycFile::getByte()
|
||||
{
|
||||
int ch = fgetc(m_stream);
|
||||
if (ch == EOF) {
|
||||
fputs("PycFile::getByte(): Unexpected end of stream\n", stderr);
|
||||
std::exit(1);
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
void PycFile::getBuffer(int bytes, void* buffer)
|
||||
{
|
||||
if (fread(buffer, 1, bytes, m_stream) != (size_t)bytes) {
|
||||
fputs("PycFile::getBuffer(): Unexpected end of stream\n", stderr);
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* PycBuffer */
|
||||
int PycBuffer::getByte()
|
||||
{
|
||||
if (atEof()) {
|
||||
fputs("PycBuffer::getByte(): Unexpected end of stream\n", stderr);
|
||||
std::exit(1);
|
||||
}
|
||||
int ch = (int)(*(m_buffer + m_pos));
|
||||
++m_pos;
|
||||
return ch & 0xFF; // Make sure it's just a byte!
|
||||
}
|
||||
|
||||
void PycBuffer::getBuffer(int bytes, void* buffer)
|
||||
{
|
||||
if (m_pos + bytes > m_size) {
|
||||
fputs("PycBuffer::getBuffer(): Unexpected end of stream\n", stderr);
|
||||
std::exit(1);
|
||||
}
|
||||
if (bytes != 0)
|
||||
memcpy(buffer, (m_buffer + m_pos), bytes);
|
||||
m_pos += bytes;
|
||||
}
|
||||
|
||||
int formatted_print(std::ostream& stream, const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
int result = formatted_printv(stream, format, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
|
||||
int formatted_printv(std::ostream& stream, const char* format, va_list args)
|
||||
{
|
||||
va_list saved_args;
|
||||
va_copy(saved_args, args);
|
||||
int len = std::vsnprintf(nullptr, 0, format, args);
|
||||
if (len < 0)
|
||||
return len;
|
||||
std::vector<char> vec(static_cast<size_t>(len) + 1);
|
||||
int written = std::vsnprintf(&vec[0], vec.size(), format, saved_args);
|
||||
va_end(saved_args);
|
||||
|
||||
if (written >= 0)
|
||||
stream << &vec[0];
|
||||
return written;
|
||||
}
|
||||
63
pycdc/data.h
Normal file
63
pycdc/data.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef _PYC_FILE_H
|
||||
#define _PYC_FILE_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <ostream>
|
||||
|
||||
#ifdef WIN32
|
||||
typedef __int64 Pyc_INT64;
|
||||
#else
|
||||
typedef long long Pyc_INT64;
|
||||
#endif
|
||||
|
||||
class PycData {
|
||||
public:
|
||||
PycData() { }
|
||||
virtual ~PycData() { }
|
||||
|
||||
virtual bool isOpen() const = 0;
|
||||
virtual bool atEof() const = 0;
|
||||
|
||||
virtual int getByte() = 0;
|
||||
virtual void getBuffer(int bytes, void* buffer) = 0;
|
||||
int get16();
|
||||
int get32();
|
||||
Pyc_INT64 get64();
|
||||
};
|
||||
|
||||
class PycFile : public PycData {
|
||||
public:
|
||||
PycFile(const char* filename);
|
||||
~PycFile() { if (m_stream) fclose(m_stream); }
|
||||
|
||||
bool isOpen() const override { return (m_stream != 0); }
|
||||
bool atEof() const override;
|
||||
|
||||
int getByte() override;
|
||||
void getBuffer(int bytes, void* buffer) override;
|
||||
|
||||
private:
|
||||
FILE* m_stream;
|
||||
};
|
||||
|
||||
class PycBuffer : public PycData {
|
||||
public:
|
||||
PycBuffer(const void* buffer, int size)
|
||||
: m_buffer((const unsigned char*)buffer), m_size(size), m_pos(0) { }
|
||||
~PycBuffer() { }
|
||||
|
||||
bool isOpen() const override { return (m_buffer != 0); }
|
||||
bool atEof() const override { return (m_pos == m_size); }
|
||||
|
||||
int getByte() override;
|
||||
void getBuffer(int bytes, void* buffer) override;
|
||||
|
||||
private:
|
||||
const unsigned char* m_buffer;
|
||||
int m_size, m_pos;
|
||||
};
|
||||
|
||||
int formatted_print(std::ostream& stream, const char* format, ...);
|
||||
int formatted_printv(std::ostream& stream, const char* format, va_list args);
|
||||
|
||||
#endif
|
||||
1340
pycdc/plusaes.hpp
Normal file
1340
pycdc/plusaes.hpp
Normal file
File diff suppressed because it is too large
Load Diff
107
pycdc/pyarmor-1shot.cpp
Normal file
107
pycdc/pyarmor-1shot.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/** I want to use functions in pycdas.cpp directly, but not moving them to
|
||||
* another file, to sync with upstream in the future easily.
|
||||
*/
|
||||
#define main pycdas_main
|
||||
# include "pycdas.cpp"
|
||||
#undef main
|
||||
|
||||
#include "ASTree.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* infile = nullptr;
|
||||
unsigned disasm_flags = 0;
|
||||
std::ofstream dc_out_file;
|
||||
std::ofstream das_out_file;
|
||||
|
||||
for (int arg = 1; arg < argc; ++arg) {
|
||||
if (strcmp(argv[arg], "--pycode-extra") == 0) {
|
||||
disasm_flags |= Pyc::DISASM_PYCODE_VERBOSE;
|
||||
} else if (strcmp(argv[arg], "--show-caches") == 0) {
|
||||
disasm_flags |= Pyc::DISASM_SHOW_CACHES;
|
||||
} else if (strcmp(argv[arg], "--help") == 0 || strcmp(argv[arg], "-h") == 0) {
|
||||
fprintf(stderr, "Usage: %s [options] input.1shot.seq\n\n", argv[0]);
|
||||
fputs("Options:\n", stderr);
|
||||
fputs(" --pycode-extra Show extra fields in PyCode object dumps\n", stderr);
|
||||
fputs(" --show-caches Don't suprress CACHE instructions in Python 3.11+ disassembly\n", stderr);
|
||||
fputs(" --help Show this help text and then exit\n", stderr);
|
||||
return 0;
|
||||
} else if (argv[arg][0] == '-') {
|
||||
fprintf(stderr, "Error: Unrecognized argument %s\n", argv[arg]);
|
||||
return 1;
|
||||
} else {
|
||||
infile = argv[arg];
|
||||
}
|
||||
}
|
||||
|
||||
if (!infile) {
|
||||
fputs("No input file specified\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string prefix_name;
|
||||
const char *prefix_name_pos = strstr(infile, ".1shot.seq");
|
||||
if (prefix_name_pos == NULL) {
|
||||
prefix_name = infile;
|
||||
} else {
|
||||
prefix_name = std::string(infile, prefix_name_pos - infile + 6);
|
||||
}
|
||||
|
||||
dc_out_file.open(prefix_name + ".cdc.py", std::ios_base::out);
|
||||
if (dc_out_file.fail()) {
|
||||
fprintf(stderr, "Error opening file '%s' for writing\n", (prefix_name + ".cdc.py").c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
das_out_file.open(prefix_name + ".das", std::ios_base::out);
|
||||
if (das_out_file.fail()) {
|
||||
fprintf(stderr, "Error opening file '%s' for writing\n", (prefix_name + ".das").c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
PycModule mod;
|
||||
try {
|
||||
mod.loadFromOneshotSequenceFile(infile);
|
||||
} catch (std::exception &ex) {
|
||||
fprintf(stderr, "Error disassembling %s: %s\n", infile, ex.what());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!mod.isValid()) {
|
||||
fprintf(stderr, "Could not load file %s\n", infile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* dispname = strrchr(infile, PATHSEP);
|
||||
dispname = (dispname == NULL) ? infile : dispname + 1;
|
||||
|
||||
formatted_print(das_out_file, "%s (Python %d.%d%s)\n", dispname,
|
||||
mod.majorVer(), mod.minorVer(),
|
||||
(mod.majorVer() < 3 && mod.isUnicode()) ? " -U" : "");
|
||||
try {
|
||||
output_object(mod.code().try_cast<PycObject>(), &mod, 0, disasm_flags,
|
||||
das_out_file);
|
||||
} catch (std::exception& ex) {
|
||||
fprintf(stderr, "Error disassembling %s: %s\n", infile, ex.what());
|
||||
return 1;
|
||||
}
|
||||
|
||||
das_out_file.flush();
|
||||
das_out_file.close();
|
||||
|
||||
dc_out_file << "# Source Generated with Decompyle++\n";
|
||||
formatted_print(dc_out_file, "# File: %s (Python %d.%d%s)\n\n", dispname,
|
||||
mod.majorVer(), mod.minorVer(),
|
||||
(mod.majorVer() < 3 && mod.isUnicode()) ? " Unicode" : "");
|
||||
try {
|
||||
decompyle(mod.code(), &mod, dc_out_file);
|
||||
} catch (std::exception& ex) {
|
||||
fprintf(stderr, "Error decompyling %s: %s\n", infile, ex.what());
|
||||
return 1;
|
||||
}
|
||||
|
||||
dc_out_file.flush();
|
||||
dc_out_file.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
283
pycdc/pyc_code.cpp
Normal file
283
pycdc/pyc_code.cpp
Normal file
@@ -0,0 +1,283 @@
|
||||
#include "pyc_code.h"
|
||||
#include "pyc_module.h"
|
||||
#include "data.h"
|
||||
#include "plusaes.hpp"
|
||||
|
||||
/* == Marshal structure for Code object ==
|
||||
1.0 1.3 1.5 2.1 2.3 3.0 3.8 3.11
|
||||
argcount short short short long long long long
|
||||
posonlyargc long long
|
||||
kwonlyargc long long long
|
||||
nlocals short short short long long long
|
||||
stacksize short short long long long long
|
||||
flags short short short long long long long
|
||||
code Obj Obj Obj Obj Obj Obj Obj Obj
|
||||
consts Obj Obj Obj Obj Obj Obj Obj Obj
|
||||
names Obj Obj Obj Obj Obj Obj Obj Obj
|
||||
varnames Obj Obj Obj Obj Obj Obj
|
||||
freevars Obj Obj Obj Obj
|
||||
cellvars Obj Obj Obj Obj
|
||||
locals+names Obj
|
||||
locals+kinds Obj
|
||||
filename Obj Obj Obj Obj Obj Obj Obj Obj
|
||||
name Obj Obj Obj Obj Obj Obj Obj Obj
|
||||
qualname Obj
|
||||
firstline short short long long long long
|
||||
lntable Obj Obj Obj Obj Obj Obj
|
||||
exceptiontable Obj
|
||||
*/
|
||||
|
||||
void PycCode::load(PycData* stream, PycModule* mod)
|
||||
{
|
||||
if (mod->verCompare(1, 3) >= 0 && mod->verCompare(2, 3) < 0)
|
||||
m_argCount = stream->get16();
|
||||
else if (mod->verCompare(2, 3) >= 0)
|
||||
m_argCount = stream->get32();
|
||||
|
||||
if (mod->verCompare(3, 8) >= 0)
|
||||
m_posOnlyArgCount = stream->get32();
|
||||
else
|
||||
m_posOnlyArgCount = 0;
|
||||
|
||||
if (mod->majorVer() >= 3)
|
||||
m_kwOnlyArgCount = stream->get32();
|
||||
else
|
||||
m_kwOnlyArgCount = 0;
|
||||
|
||||
if (mod->verCompare(1, 3) >= 0 && mod->verCompare(2, 3) < 0)
|
||||
m_numLocals = stream->get16();
|
||||
else if (mod->verCompare(2, 3) >= 0 && mod->verCompare(3, 11) < 0)
|
||||
m_numLocals = stream->get32();
|
||||
else
|
||||
m_numLocals = 0;
|
||||
|
||||
if (mod->verCompare(1, 5) >= 0 && mod->verCompare(2, 3) < 0)
|
||||
m_stackSize = stream->get16();
|
||||
else if (mod->verCompare(2, 3) >= 0)
|
||||
m_stackSize = stream->get32();
|
||||
else
|
||||
m_stackSize = 0;
|
||||
|
||||
if (mod->verCompare(1, 3) >= 0 && mod->verCompare(2, 3) < 0)
|
||||
m_flags = stream->get16();
|
||||
else if (mod->verCompare(2, 3) >= 0)
|
||||
m_flags = stream->get32();
|
||||
else
|
||||
m_flags = 0;
|
||||
|
||||
bool pyarmor_co_obfuscated_flag = m_flags & 0x20000000;
|
||||
|
||||
if (mod->verCompare(3, 8) < 0) {
|
||||
// Remap flags to new values introduced in 3.8
|
||||
// Pyarmor CO_OBFUSCATED flag always locates at 0x20000000
|
||||
if (m_flags & 0xD0000000)
|
||||
fprintf(stderr, "Remapping flags (%08X) may not be correct\n", m_flags);
|
||||
m_flags = (m_flags & 0x1FFF) | ((m_flags & 0xFFFE000) << 4) | (m_flags & 0x20000000);
|
||||
}
|
||||
|
||||
m_code = LoadObject(stream, mod).cast<PycString>();
|
||||
m_consts = LoadObject(stream, mod).cast<PycSequence>();
|
||||
m_names = LoadObject(stream, mod).cast<PycSequence>();
|
||||
|
||||
if (mod->verCompare(1, 3) >= 0)
|
||||
m_localNames = LoadObject(stream, mod).cast<PycSequence>();
|
||||
else
|
||||
m_localNames = new PycTuple;
|
||||
|
||||
if (mod->verCompare(3, 11) >= 0)
|
||||
m_localKinds = LoadObject(stream, mod).cast<PycString>();
|
||||
else
|
||||
m_localKinds = new PycString;
|
||||
|
||||
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 && mod->verCompare(3, 11) < 0)
|
||||
m_cellVars = LoadObject(stream, mod).cast<PycSequence>();
|
||||
else
|
||||
m_cellVars = new PycTuple;
|
||||
|
||||
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)
|
||||
m_firstLine = stream->get32();
|
||||
|
||||
if (mod->verCompare(1, 5) >= 0)
|
||||
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;
|
||||
|
||||
// Pyarmor extra fields
|
||||
|
||||
if (!pyarmor_co_obfuscated_flag)
|
||||
return;
|
||||
|
||||
unsigned char extra_data[256] = {0};
|
||||
unsigned char extra_length = stream->getByte();
|
||||
stream->getBuffer(extra_length, extra_data);
|
||||
|
||||
unsigned char pyarmor_fn_count = extra_data[0] & 3;
|
||||
unsigned char pyarmor_co_descriptor_count = (extra_data[0] >> 2) & 3;
|
||||
// bool _pyarmor_bcc = (extra_data[0] >> 4) & 1;
|
||||
if (extra_data[0] & 0xE0)
|
||||
{
|
||||
fprintf(stderr, "Unsupported Pyarmor CO extra flag (0x%02X)\n", extra_data[0]);
|
||||
fprintf(stderr, "Please open an issue at https://github.com/Lil-House/Pyarmor-Static-Unpack-1shot/issues to request support and help to make this tool better.\n");
|
||||
}
|
||||
if (pyarmor_co_descriptor_count > 1)
|
||||
{
|
||||
fprintf(stderr, "Do not support multiple Pyarmor CO descriptors (%d in total)\n", pyarmor_co_descriptor_count);
|
||||
fprintf(stderr, "Please open an issue at https://github.com/Lil-House/Pyarmor-Static-Unpack-1shot/issues to request support and help to make this tool better.\n");
|
||||
}
|
||||
|
||||
unsigned char *extra_ptr = extra_data + 4;
|
||||
for (unsigned char i = 0; i < pyarmor_fn_count; i++)
|
||||
{
|
||||
unsigned char item_length = (*extra_ptr >> 6) + 2;
|
||||
// Ignore the details
|
||||
extra_ptr += item_length;
|
||||
}
|
||||
for (unsigned char i = 0; i < pyarmor_co_descriptor_count; i++)
|
||||
{
|
||||
unsigned char item_length = (*extra_ptr >> 6) + 2;
|
||||
unsigned char *item_end = extra_ptr + item_length;
|
||||
// Ignore low 6 bits
|
||||
extra_ptr++;
|
||||
unsigned long consts_index = 0;
|
||||
while (extra_ptr < item_end)
|
||||
{
|
||||
consts_index = (consts_index << 8) | *extra_ptr;
|
||||
extra_ptr++;
|
||||
}
|
||||
|
||||
pyarmorDecryptCoCode(consts_index, mod);
|
||||
}
|
||||
}
|
||||
|
||||
void PycCode::pyarmorDecryptCoCode(unsigned long consts_index, PycModule *mod)
|
||||
{
|
||||
PycRef<PycString> descriptor = getConst(consts_index).cast<PycString>();
|
||||
const std::string &descriptor_str = descriptor->strValue();
|
||||
if (descriptor_str.length() < 20)
|
||||
{
|
||||
fprintf(stderr, "Pyarmor CO descriptor is too short\n");
|
||||
return;
|
||||
}
|
||||
|
||||
const PyarmorCoDescriptor *desc = (const PyarmorCoDescriptor *)(descriptor_str.data() + 8);
|
||||
bool copy_prologue = desc->flags & 0x8;
|
||||
bool xor_aes_nonce = desc->flags & 0x4;
|
||||
bool short_code = desc->flags & 0x2;
|
||||
|
||||
unsigned int nonce_index = short_code
|
||||
? desc->short_nonce_index
|
||||
: desc->short_nonce_index + desc->decrypt_begin_index + desc->decrypt_length;
|
||||
unsigned char nonce[16] = {0};
|
||||
memcpy(nonce, m_code->value() + nonce_index, 12);
|
||||
nonce[15] = 2;
|
||||
if (xor_aes_nonce)
|
||||
{
|
||||
if (!mod->pyarmor_co_code_aes_nonce_xor_enabled)
|
||||
{
|
||||
fprintf(stderr, "FATAL: Pyarmor CO code AES nonce XOR is not enabled but used\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char *xor_key = mod->pyarmor_co_code_aes_nonce_xor_key;
|
||||
for (int i = 0; i < 12; i++)
|
||||
nonce[i] ^= xor_key[i];
|
||||
}
|
||||
}
|
||||
|
||||
std::string &code_bytes = (std::string &)m_code->strValue();
|
||||
|
||||
plusaes::crypt_ctr(
|
||||
(unsigned char *)&code_bytes[desc->decrypt_begin_index],
|
||||
desc->decrypt_length,
|
||||
mod->pyarmor_aes_key,
|
||||
16,
|
||||
&nonce);
|
||||
|
||||
if (copy_prologue)
|
||||
{
|
||||
memcpy(
|
||||
&code_bytes[0],
|
||||
&code_bytes[desc->decrypt_length],
|
||||
desc->decrypt_begin_index);
|
||||
// Assume tail of code is not used there
|
||||
memset(
|
||||
&code_bytes[desc->decrypt_length],
|
||||
9, // NOP
|
||||
desc->decrypt_begin_index);
|
||||
}
|
||||
|
||||
// When running, the first 8 bytes are set to &PyCodeObject
|
||||
std::string new_str = "<COAddr>" + descriptor_str.substr(8);
|
||||
descriptor->setValue(new_str);
|
||||
}
|
||||
|
||||
PycRef<PycString> PycCode::getCellVar(PycModule* mod, int idx) const
|
||||
{
|
||||
if (mod->verCompare(3, 11) >= 0)
|
||||
return getLocal(idx);
|
||||
|
||||
return (idx >= m_cellVars->size())
|
||||
? m_freeVars->get(idx - m_cellVars->size()).cast<PycString>()
|
||||
: m_cellVars->get(idx).cast<PycString>();
|
||||
}
|
||||
|
||||
int _parse_varint(PycBuffer& data, int& pos) {
|
||||
int b = data.getByte();
|
||||
pos += 1;
|
||||
|
||||
int val = b & 0x3F;
|
||||
while (b & 0x40) {
|
||||
val <<= 6;
|
||||
|
||||
b = data.getByte();
|
||||
pos += 1;
|
||||
|
||||
val |= (b & 0x3F);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
std::vector<PycExceptionTableEntry> PycCode::exceptionTableEntries() const
|
||||
{
|
||||
PycBuffer data(m_exceptTable->value(), m_exceptTable->length());
|
||||
|
||||
std::vector<PycExceptionTableEntry> entries;
|
||||
|
||||
int pos = 0;
|
||||
while (!data.atEof()) {
|
||||
|
||||
int start = _parse_varint(data, pos) * 2;
|
||||
int length = _parse_varint(data, pos) * 2;
|
||||
int end = start + length;
|
||||
|
||||
int target = _parse_varint(data, pos) * 2;
|
||||
int dl = _parse_varint(data, pos);
|
||||
|
||||
int depth = dl >> 1;
|
||||
bool lasti = bool(dl & 1);
|
||||
|
||||
entries.push_back(PycExceptionTableEntry(start, end, target, depth, lasti));
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
137
pycdc/pyc_code.h
Normal file
137
pycdc/pyc_code.h
Normal file
@@ -0,0 +1,137 @@
|
||||
#ifndef _PYC_CODE_H
|
||||
#define _PYC_CODE_H
|
||||
|
||||
#include "pyc_sequence.h"
|
||||
#include "pyc_string.h"
|
||||
#include <vector>
|
||||
|
||||
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) {};
|
||||
};
|
||||
|
||||
struct PyarmorCoDescriptor
|
||||
{
|
||||
unsigned char flags;
|
||||
unsigned char short_nonce_index;
|
||||
unsigned char _;
|
||||
unsigned char decrypt_begin_index;
|
||||
unsigned int decrypt_length;
|
||||
unsigned int _enter_count;
|
||||
};
|
||||
|
||||
class PycCode : public PycObject {
|
||||
public:
|
||||
typedef std::vector<PycRef<PycString>> globals_t;
|
||||
enum CodeFlags {
|
||||
CO_OPTIMIZED = 0x1, // 1.3 ->
|
||||
CO_NEWLOCALS = 0x2, // 1.3 ->
|
||||
CO_VARARGS = 0x4, // 1.3 ->
|
||||
CO_VARKEYWORDS = 0x8, // 1.3 ->
|
||||
CO_NESTED = 0x10, // 2.1 ->
|
||||
CO_GENERATOR = 0x20, // 2.2 ->
|
||||
CO_NOFREE = 0x40, // 2.3 ->
|
||||
CO_COROUTINE = 0x80, // 3.5 ->
|
||||
CO_ITERABLE_COROUTINE = 0x100, // 3.5 ->
|
||||
CO_ASYNC_GENERATOR = 0x200, // 3.6 ->
|
||||
CO_GENERATOR_ALLOWED = 0x1000, // 2.3 only
|
||||
|
||||
// The FUTURE flags are shifted left 4 bits starting from Python 3.8
|
||||
// Older versions are automatically mapped to the new values in load()
|
||||
CO_FUTURE_DIVISION = 0x20000, // 2.3 - 2.7, 3.1 ->
|
||||
CO_FUTURE_ABSOLUTE_IMPORT = 0x40000, // 2.5 - 2.7, 3.1 ->
|
||||
CO_FUTURE_WITH_STATEMENT = 0x80000, // 2.5 - 2.7, 3.1 ->
|
||||
CO_FUTURE_PRINT_FUNCTION = 0x100000, // 2.6 - 2.7, 3.1 ->
|
||||
CO_FUTURE_UNICODE_LITERALS = 0x200000, // 2.6 - 2.7, 3.1 ->
|
||||
CO_FUTURE_BARRY_AS_BDFL = 0x400000, // 3.1 ->
|
||||
CO_FUTURE_GENERATOR_STOP = 0x800000, // 3.5 ->
|
||||
CO_FUTURE_ANNOTATIONS = 0x1000000, // 3.7 ->
|
||||
CO_NO_MONITORING_EVENTS = 0x2000000, // 3.13 ->
|
||||
|
||||
CO_PYARMOR_OBFUSCATED = 0x20000000, // Pyarmor all
|
||||
};
|
||||
|
||||
PycCode(int type = TYPE_CODE)
|
||||
: PycObject(type), m_argCount(), m_posOnlyArgCount(), m_kwOnlyArgCount(),
|
||||
m_numLocals(), m_stackSize(), m_flags(), m_firstLine() { }
|
||||
|
||||
void load(PycData* stream, PycModule* mod) override;
|
||||
|
||||
void pyarmorDecryptCoCode(unsigned long consts_index, PycModule *mod);
|
||||
|
||||
int argCount() const { return m_argCount; }
|
||||
int posOnlyArgCount() const { return m_posOnlyArgCount; }
|
||||
int kwOnlyArgCount() const { return m_kwOnlyArgCount; }
|
||||
int numLocals() const { return m_numLocals; }
|
||||
int stackSize() const { return m_stackSize; }
|
||||
int flags() const { return m_flags; }
|
||||
PycRef<PycString> code() const { return m_code; }
|
||||
PycRef<PycSequence> consts() const { return m_consts; }
|
||||
PycRef<PycSequence> names() const { return m_names; }
|
||||
PycRef<PycSequence> localNames() const { return m_localNames; }
|
||||
PycRef<PycString> localKinds() const { return m_localKinds; }
|
||||
PycRef<PycSequence> freeVars() const { return m_freeVars; }
|
||||
PycRef<PycSequence> cellVars() const { return m_cellVars; }
|
||||
PycRef<PycString> fileName() const { return m_fileName; }
|
||||
PycRef<PycString> name() const { return m_name; }
|
||||
PycRef<PycString> qualName() const { return m_qualName; }
|
||||
int firstLine() const { return m_firstLine; }
|
||||
PycRef<PycString> lnTable() const { return m_lnTable; }
|
||||
PycRef<PycString> exceptTable() const { return m_exceptTable; }
|
||||
|
||||
PycRef<PycObject> getConst(int idx) const
|
||||
{
|
||||
return m_consts->get(idx);
|
||||
}
|
||||
|
||||
PycRef<PycString> getName(int idx) const
|
||||
{
|
||||
return m_names->get(idx).cast<PycString>();
|
||||
}
|
||||
|
||||
PycRef<PycString> getLocal(int idx) const
|
||||
{
|
||||
return m_localNames->get(idx).cast<PycString>();
|
||||
}
|
||||
|
||||
PycRef<PycString> getCellVar(PycModule* mod, int idx) const;
|
||||
|
||||
const globals_t& getGlobals() const { return m_globalsUsed; }
|
||||
|
||||
void markGlobal(PycRef<PycString> varname)
|
||||
{
|
||||
m_globalsUsed.emplace_back(std::move(varname));
|
||||
}
|
||||
|
||||
std::vector<PycExceptionTableEntry> exceptionTableEntries() const;
|
||||
|
||||
private:
|
||||
int m_argCount, m_posOnlyArgCount, m_kwOnlyArgCount, m_numLocals;
|
||||
int m_stackSize, m_flags;
|
||||
PycRef<PycString> m_code;
|
||||
PycRef<PycSequence> m_consts;
|
||||
PycRef<PycSequence> m_names;
|
||||
PycRef<PycSequence> m_localNames;
|
||||
PycRef<PycString> m_localKinds;
|
||||
PycRef<PycSequence> m_freeVars;
|
||||
PycRef<PycSequence> m_cellVars;
|
||||
PycRef<PycString> m_fileName;
|
||||
PycRef<PycString> m_name;
|
||||
PycRef<PycString> m_qualName;
|
||||
int m_firstLine;
|
||||
PycRef<PycString> m_lnTable;
|
||||
PycRef<PycString> m_exceptTable;
|
||||
globals_t m_globalsUsed; /* Global vars used in this code */
|
||||
};
|
||||
|
||||
#endif
|
||||
514
pycdc/pyc_module.cpp
Normal file
514
pycdc/pyc_module.cpp
Normal file
@@ -0,0 +1,514 @@
|
||||
#include "pyc_module.h"
|
||||
#include "data.h"
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
|
||||
void PycModule::setVersion(unsigned int magic)
|
||||
{
|
||||
// Default for versions that don't support unicode selection
|
||||
m_unicode = false;
|
||||
|
||||
switch (magic) {
|
||||
case MAGIC_1_0:
|
||||
m_maj = 1;
|
||||
m_min = 0;
|
||||
break;
|
||||
case MAGIC_1_1:
|
||||
m_maj = 1;
|
||||
m_min = 1;
|
||||
break;
|
||||
case MAGIC_1_3:
|
||||
m_maj = 1;
|
||||
m_min = 3;
|
||||
break;
|
||||
case MAGIC_1_4:
|
||||
m_maj = 1;
|
||||
m_min = 4;
|
||||
break;
|
||||
case MAGIC_1_5:
|
||||
m_maj = 1;
|
||||
m_min = 5;
|
||||
break;
|
||||
|
||||
/* Starting with 1.6, Python adds +1 for unicode mode (-U) */
|
||||
case MAGIC_1_6+1:
|
||||
m_unicode = true;
|
||||
/* Fall through */
|
||||
case MAGIC_1_6:
|
||||
m_maj = 1;
|
||||
m_min = 6;
|
||||
break;
|
||||
case MAGIC_2_0+1:
|
||||
m_unicode = true;
|
||||
/* Fall through */
|
||||
case MAGIC_2_0:
|
||||
m_maj = 2;
|
||||
m_min = 0;
|
||||
break;
|
||||
case MAGIC_2_1+1:
|
||||
m_unicode = true;
|
||||
/* Fall through */
|
||||
case MAGIC_2_1:
|
||||
m_maj = 2;
|
||||
m_min = 1;
|
||||
break;
|
||||
case MAGIC_2_2+1:
|
||||
m_unicode = true;
|
||||
/* Fall through */
|
||||
case MAGIC_2_2:
|
||||
m_maj = 2;
|
||||
m_min = 2;
|
||||
break;
|
||||
case MAGIC_2_3+1:
|
||||
m_unicode = true;
|
||||
/* Fall through */
|
||||
case MAGIC_2_3:
|
||||
m_maj = 2;
|
||||
m_min = 3;
|
||||
break;
|
||||
case MAGIC_2_4+1:
|
||||
m_unicode = true;
|
||||
/* Fall through */
|
||||
case MAGIC_2_4:
|
||||
m_maj = 2;
|
||||
m_min = 4;
|
||||
break;
|
||||
case MAGIC_2_5+1:
|
||||
m_unicode = true;
|
||||
/* Fall through */
|
||||
case MAGIC_2_5:
|
||||
m_maj = 2;
|
||||
m_min = 5;
|
||||
break;
|
||||
case MAGIC_2_6+1:
|
||||
m_unicode = true;
|
||||
/* Fall through */
|
||||
case MAGIC_2_6:
|
||||
m_maj = 2;
|
||||
m_min = 6;
|
||||
break;
|
||||
case MAGIC_2_7+1:
|
||||
m_unicode = true;
|
||||
/* Fall through */
|
||||
case MAGIC_2_7:
|
||||
m_maj = 2;
|
||||
m_min = 7;
|
||||
break;
|
||||
|
||||
/* 3.0 and above are always unicode */
|
||||
case MAGIC_3_0+1:
|
||||
m_maj = 3;
|
||||
m_min = 0;
|
||||
m_unicode = true;
|
||||
break;
|
||||
case MAGIC_3_1+1:
|
||||
m_maj = 3;
|
||||
m_min = 1;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
/* 3.2 stops using the unicode increment */
|
||||
case MAGIC_3_2:
|
||||
m_maj = 3;
|
||||
m_min = 2;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
case MAGIC_3_3:
|
||||
m_maj = 3;
|
||||
m_min = 3;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
case MAGIC_3_4:
|
||||
m_maj = 3;
|
||||
m_min = 4;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
case MAGIC_3_5:
|
||||
/* fall through */
|
||||
|
||||
case MAGIC_3_5_3:
|
||||
m_maj = 3;
|
||||
m_min = 5;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
case MAGIC_3_6:
|
||||
m_maj = 3;
|
||||
m_min = 6;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
case MAGIC_3_7:
|
||||
m_maj = 3;
|
||||
m_min = 7;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
case MAGIC_3_8:
|
||||
m_maj = 3;
|
||||
m_min = 8;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
case MAGIC_3_9:
|
||||
m_maj = 3;
|
||||
m_min = 9;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
case MAGIC_3_10:
|
||||
m_maj = 3;
|
||||
m_min = 10;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
case MAGIC_3_11:
|
||||
m_maj = 3;
|
||||
m_min = 11;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
case MAGIC_3_12:
|
||||
m_maj = 3;
|
||||
m_min = 12;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
case MAGIC_3_13:
|
||||
m_maj = 3;
|
||||
m_min = 13;
|
||||
m_unicode = true;
|
||||
break;
|
||||
|
||||
/* Bad Magic detected */
|
||||
default:
|
||||
m_maj = -1;
|
||||
m_min = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool PycModule::isSupportedVersion(int major, int minor)
|
||||
{
|
||||
switch (major) {
|
||||
case 1:
|
||||
return (minor >= 0 && minor <= 6);
|
||||
case 2:
|
||||
return (minor >= 0 && minor <= 7);
|
||||
case 3:
|
||||
return (minor >= 0 && minor <= 12);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void PycModule::loadFromFile(const char* filename)
|
||||
{
|
||||
PycFile in(filename);
|
||||
if (!in.isOpen()) {
|
||||
fprintf(stderr, "Error opening file %s\n", filename);
|
||||
return;
|
||||
}
|
||||
setVersion(in.get32());
|
||||
if (!isValid()) {
|
||||
fputs("Bad MAGIC!\n", stderr);
|
||||
return;
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
if (verCompare(3, 7) >= 0)
|
||||
flags = in.get32();
|
||||
|
||||
if (flags & 0x1) {
|
||||
// Optional checksum added in Python 3.7
|
||||
in.get32();
|
||||
in.get32();
|
||||
} else {
|
||||
in.get32(); // Timestamp -- who cares?
|
||||
|
||||
if (verCompare(3, 3) >= 0)
|
||||
in.get32(); // Size parameter added in Python 3.3
|
||||
}
|
||||
|
||||
m_code = LoadObject(&in, this).cast<PycCode>();
|
||||
}
|
||||
|
||||
void PycModule::loadFromMarshalledFile(const char* filename, int major, int minor)
|
||||
{
|
||||
PycFile in (filename);
|
||||
if (!in.isOpen()) {
|
||||
fprintf(stderr, "Error opening file %s\n", filename);
|
||||
return;
|
||||
}
|
||||
if (!isSupportedVersion(major, minor)) {
|
||||
fprintf(stderr, "Unsupported version %d.%d\n", major, minor);
|
||||
return;
|
||||
}
|
||||
m_maj = major;
|
||||
m_min = minor;
|
||||
m_unicode = (major >= 3);
|
||||
m_code = LoadObject(&in, this).cast<PycCode>();
|
||||
}
|
||||
|
||||
void PycModule::loadFromOneshotSequenceFile(const char *filename)
|
||||
{
|
||||
PycFile in(filename);
|
||||
if (!in.isOpen())
|
||||
{
|
||||
fprintf(stderr, "Error opening file %s\n", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
bool oneshot_seq_header = true;
|
||||
while (oneshot_seq_header)
|
||||
{
|
||||
int indicator = in.getByte();
|
||||
switch (indicator)
|
||||
{
|
||||
case 0xA1:
|
||||
in.getBuffer(16, this->pyarmor_aes_key);
|
||||
break;
|
||||
case 0xA2:
|
||||
in.getBuffer(12, this->pyarmor_mix_str_aes_nonce);
|
||||
break;
|
||||
case 0xF0:
|
||||
break;
|
||||
case 0xFF:
|
||||
oneshot_seq_header = false;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown 1-shot sequence indicator %02X\n", indicator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Write only. Some fields unknown to us or not needed for decryption are discarded.
|
||||
char discard_buffer[64];
|
||||
|
||||
char pyarmor_header[64];
|
||||
in.getBuffer(64, pyarmor_header);
|
||||
this->m_maj = pyarmor_header[9];
|
||||
this->m_min = pyarmor_header[10];
|
||||
this->m_unicode = (m_maj >= 3);
|
||||
|
||||
unsigned int remain_header_length = *(unsigned int *)(pyarmor_header + 28) - 64;
|
||||
while (remain_header_length)
|
||||
{
|
||||
unsigned int discard_length = (remain_header_length > 64) ? 64 : remain_header_length;
|
||||
in.getBuffer(discard_length, discard_buffer);
|
||||
remain_header_length -= discard_length;
|
||||
}
|
||||
|
||||
// For 1-shot sequence, the following part has been decrypted once.
|
||||
unsigned int code_object_offset = in.get32();
|
||||
unsigned int xor_key_procedure_length = in.get32();
|
||||
this->pyarmor_co_code_aes_nonce_xor_enabled = (xor_key_procedure_length > 0);
|
||||
unsigned int remain_second_part_length = code_object_offset - 8;
|
||||
while (remain_second_part_length)
|
||||
{
|
||||
unsigned int discard_length = (remain_second_part_length > 64) ? 64 : remain_second_part_length;
|
||||
in.getBuffer(discard_length, discard_buffer);
|
||||
remain_second_part_length -= discard_length;
|
||||
}
|
||||
|
||||
if (this->pyarmor_co_code_aes_nonce_xor_enabled)
|
||||
{
|
||||
char *procedure_buffer = (char *)malloc(xor_key_procedure_length);
|
||||
in.getBuffer(xor_key_procedure_length, procedure_buffer);
|
||||
pyarmorCoCodeAesNonceXorKeyCalculate(
|
||||
procedure_buffer,
|
||||
xor_key_procedure_length,
|
||||
this->pyarmor_co_code_aes_nonce_xor_key);
|
||||
free(procedure_buffer);
|
||||
}
|
||||
|
||||
m_code = LoadObject(&in, this).cast<PycCode>();
|
||||
}
|
||||
|
||||
void PycModule::copyFrom(const PycModule& mod)
|
||||
{
|
||||
this->m_maj = mod.m_maj;
|
||||
this->m_min = mod.m_min;
|
||||
this->m_unicode = mod.m_unicode;
|
||||
std::memcpy(this->pyarmor_aes_key, mod.pyarmor_aes_key, 16);
|
||||
std::memcpy(this->pyarmor_mix_str_aes_nonce, mod.pyarmor_mix_str_aes_nonce, 12);
|
||||
this->pyarmor_co_code_aes_nonce_xor_enabled = mod.pyarmor_co_code_aes_nonce_xor_enabled;
|
||||
std::memcpy(this->pyarmor_co_code_aes_nonce_xor_key, mod.pyarmor_co_code_aes_nonce_xor_key, 12);
|
||||
}
|
||||
|
||||
#define GET_REAL_OPERAND_2_AND_ADD_CURRENT_PTR(CUR, REF) \
|
||||
do \
|
||||
{ \
|
||||
unsigned char _INSIDE_LOW_NIBBLE = (CUR)[1] & 0xF; \
|
||||
if (valid_index[_INSIDE_LOW_NIBBLE] != -1) \
|
||||
{ \
|
||||
(REF) = registers[_INSIDE_LOW_NIBBLE]; \
|
||||
(CUR) += 2; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
unsigned int _INSIDE_SIZE = (CUR)[1] & 0x7; \
|
||||
if (_INSIDE_SIZE == 1) \
|
||||
{ \
|
||||
(REF) = *(char *)((CUR) + 2); \
|
||||
(CUR) += 3; \
|
||||
} \
|
||||
else if (_INSIDE_SIZE == 2) \
|
||||
{ \
|
||||
(REF) = *(short *)((CUR) + 2); \
|
||||
(CUR) += 4; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(REF) = *(int *)((CUR) + 2); \
|
||||
(CUR) += 6; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void pyarmorCoCodeAesNonceXorKeyCalculate(const char *in_buffer, unsigned int in_buffer_length, unsigned char *out_buffer)
|
||||
{
|
||||
unsigned char *cur = (unsigned char *)in_buffer + 16;
|
||||
unsigned char *end = (unsigned char *)in_buffer + in_buffer_length;
|
||||
int registers[8] = {0};
|
||||
const int valid_index[16] = {
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
-1,
|
||||
7, /* origin is 15 */
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
};
|
||||
|
||||
while (cur < end)
|
||||
{
|
||||
int operand_2 = 0;
|
||||
unsigned char high_nibble = 0;
|
||||
unsigned char reg = 0;
|
||||
switch (*cur)
|
||||
{
|
||||
case 1:
|
||||
// terminator
|
||||
cur++;
|
||||
break;
|
||||
case 2:
|
||||
high_nibble = cur[1] >> 4;
|
||||
GET_REAL_OPERAND_2_AND_ADD_CURRENT_PTR(cur, operand_2);
|
||||
registers[high_nibble] += operand_2;
|
||||
break;
|
||||
case 3:
|
||||
high_nibble = cur[1] >> 4;
|
||||
GET_REAL_OPERAND_2_AND_ADD_CURRENT_PTR(cur, operand_2);
|
||||
registers[high_nibble] -= operand_2;
|
||||
break;
|
||||
case 4:
|
||||
high_nibble = cur[1] >> 4;
|
||||
GET_REAL_OPERAND_2_AND_ADD_CURRENT_PTR(cur, operand_2);
|
||||
registers[high_nibble] *= operand_2;
|
||||
/** We found that in x86_64, machine code is
|
||||
* imul reg64, reg/imm
|
||||
* so we get the low bits of the result.
|
||||
*/
|
||||
break;
|
||||
case 5:
|
||||
high_nibble = cur[1] >> 4;
|
||||
GET_REAL_OPERAND_2_AND_ADD_CURRENT_PTR(cur, operand_2);
|
||||
registers[high_nibble] /= operand_2;
|
||||
/** We found that in x86_64, machine code is
|
||||
* mov r10d, imm32 ; when necessary
|
||||
* mov rax, reg64
|
||||
* cqo
|
||||
* idiv r10/reg64 ; r10/reg64 is the operand_2
|
||||
* mov reg64, rax
|
||||
* so rax (0) is tampered.
|
||||
*/
|
||||
registers[0] = registers[high_nibble];
|
||||
break;
|
||||
case 6:
|
||||
high_nibble = cur[1] >> 4;
|
||||
GET_REAL_OPERAND_2_AND_ADD_CURRENT_PTR(cur, operand_2);
|
||||
registers[high_nibble] ^= operand_2;
|
||||
break;
|
||||
case 7:
|
||||
high_nibble = cur[1] >> 4;
|
||||
GET_REAL_OPERAND_2_AND_ADD_CURRENT_PTR(cur, operand_2);
|
||||
registers[high_nibble] = operand_2;
|
||||
break;
|
||||
case 8:
|
||||
/** We found that in x86_64, machine code is
|
||||
* mov reg1, ptr [reg2]
|
||||
* This hardly happens.
|
||||
*/
|
||||
cur += 2;
|
||||
break;
|
||||
case 9:
|
||||
reg = cur[1] & 0x7;
|
||||
*(int *)out_buffer = registers[reg];
|
||||
cur += 2;
|
||||
break;
|
||||
case 0xA:
|
||||
/**
|
||||
* This happens when 4 bytes of total 12 bytes nonce are calculated,
|
||||
* and the result is to be stored in the memory. So the address from
|
||||
* register 7 (15) is moved to one of the registers.
|
||||
*
|
||||
* We don't really care about the address and the register number.
|
||||
* So we just skip 6 bytes (0A ... and 02 ...).
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* [0A [1F] 00] - [00][011][111] - mov rbx<3>, [rbp<7>-18h]
|
||||
* [rbp-18h] is the address
|
||||
* [02 [39] 0C] - [0011][1][001] - add rbx<3>, 0Ch
|
||||
* 0Ch is a fixed offset
|
||||
* [09 [98] ] - [10][011][000] - mov [rbx<3>], eax<0>
|
||||
* eax<0> is the value to be stored
|
||||
*
|
||||
* Another example:
|
||||
*
|
||||
* [0A [07] 00] - [00][000][111] - mov rax<0>, [rbp<7>-18h]
|
||||
* [02 [09] 0C] - [0000][1][001] - add rax<0>, 0Ch
|
||||
* [0B [83] 04] - [10][000][011] - mov [rax<0>+4], ebx<3>
|
||||
* 4 means [4..8] of 12 bytes nonce
|
||||
*/
|
||||
cur += 6;
|
||||
break;
|
||||
case 0xB:
|
||||
reg = cur[1] & 0x7;
|
||||
*(int *)(out_buffer + cur[2]) = registers[reg];
|
||||
cur += 3;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "FATAL: Unknown opcode %d at %lld\n", *cur, (long long)(cur - (unsigned char *)in_buffer));
|
||||
memset(out_buffer, 0, 12);
|
||||
cur = end;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PycRef<PycString> PycModule::getIntern(int ref) const
|
||||
{
|
||||
if (ref < 0 || (size_t)ref >= m_interns.size())
|
||||
throw std::out_of_range("Intern index out of range");
|
||||
return m_interns[(size_t)ref];
|
||||
}
|
||||
|
||||
PycRef<PycObject> PycModule::getRef(int ref) const
|
||||
{
|
||||
if (ref < 0 || (size_t)ref >= m_refs.size())
|
||||
throw std::out_of_range("Ref index out of range");
|
||||
return m_refs[(size_t)ref];
|
||||
}
|
||||
104
pycdc/pyc_module.h
Normal file
104
pycdc/pyc_module.h
Normal file
@@ -0,0 +1,104 @@
|
||||
#ifndef _PYC_MODULE_H
|
||||
#define _PYC_MODULE_H
|
||||
|
||||
#include "pyc_code.h"
|
||||
#include <vector>
|
||||
|
||||
enum PycMagic {
|
||||
MAGIC_1_0 = 0x00999902,
|
||||
MAGIC_1_1 = 0x00999903, /* Also covers 1.2 */
|
||||
MAGIC_1_3 = 0x0A0D2E89,
|
||||
MAGIC_1_4 = 0x0A0D1704,
|
||||
MAGIC_1_5 = 0x0A0D4E99,
|
||||
MAGIC_1_6 = 0x0A0DC4FC,
|
||||
|
||||
MAGIC_2_0 = 0x0A0DC687,
|
||||
MAGIC_2_1 = 0x0A0DEB2A,
|
||||
MAGIC_2_2 = 0x0A0DED2D,
|
||||
MAGIC_2_3 = 0x0A0DF23B,
|
||||
MAGIC_2_4 = 0x0A0DF26D,
|
||||
MAGIC_2_5 = 0x0A0DF2B3,
|
||||
MAGIC_2_6 = 0x0A0DF2D1,
|
||||
MAGIC_2_7 = 0x0A0DF303,
|
||||
|
||||
MAGIC_3_0 = 0x0A0D0C3A,
|
||||
MAGIC_3_1 = 0x0A0D0C4E,
|
||||
MAGIC_3_2 = 0x0A0D0C6C,
|
||||
MAGIC_3_3 = 0x0A0D0C9E,
|
||||
MAGIC_3_4 = 0x0A0D0CEE,
|
||||
MAGIC_3_5 = 0x0A0D0D16,
|
||||
MAGIC_3_5_3 = 0x0A0D0D17,
|
||||
MAGIC_3_6 = 0x0A0D0D33,
|
||||
MAGIC_3_7 = 0x0A0D0D42,
|
||||
MAGIC_3_8 = 0x0A0D0D55,
|
||||
MAGIC_3_9 = 0x0A0D0D61,
|
||||
MAGIC_3_10 = 0x0A0D0D6F,
|
||||
MAGIC_3_11 = 0x0A0D0DA7,
|
||||
MAGIC_3_12 = 0x0A0D0DCB,
|
||||
MAGIC_3_13 = 0x0A0D0DF3,
|
||||
|
||||
INVALID = 0,
|
||||
};
|
||||
|
||||
class PycModule {
|
||||
public:
|
||||
PycModule() : m_maj(-1), m_min(-1), m_unicode(false) { }
|
||||
|
||||
void loadFromFile(const char* filename);
|
||||
void loadFromMarshalledFile(const char *filename, int major, int minor);
|
||||
void loadFromOneshotSequenceFile(const char* filename);
|
||||
void copyFrom(const PycModule& mod);
|
||||
bool isValid() const { return (m_maj >= 0) && (m_min >= 0); }
|
||||
|
||||
int majorVer() const { return m_maj; }
|
||||
int minorVer() const { return m_min; }
|
||||
|
||||
int verCompare(int maj, int min) const
|
||||
{
|
||||
if (m_maj == maj)
|
||||
return m_min - min;
|
||||
return m_maj - maj;
|
||||
}
|
||||
|
||||
bool isUnicode() const { return m_unicode; }
|
||||
|
||||
bool strIsUnicode() const
|
||||
{
|
||||
return (m_maj >= 3) || (m_code->flags() & PycCode::CO_FUTURE_UNICODE_LITERALS) != 0;
|
||||
}
|
||||
|
||||
bool internIsBytes() const
|
||||
{
|
||||
return (m_maj < 3) && (m_code->flags() & PycCode::CO_FUTURE_UNICODE_LITERALS) != 0;
|
||||
}
|
||||
|
||||
PycRef<PycCode> code() const { return m_code; }
|
||||
|
||||
void intern(PycRef<PycString> str) { m_interns.emplace_back(std::move(str)); }
|
||||
PycRef<PycString> getIntern(int ref) const;
|
||||
|
||||
void refObject(PycRef<PycObject> obj) { m_refs.emplace_back(std::move(obj)); }
|
||||
PycRef<PycObject> getRef(int ref) const;
|
||||
|
||||
static bool isSupportedVersion(int major, int minor);
|
||||
|
||||
unsigned char pyarmor_aes_key[16];
|
||||
unsigned char pyarmor_mix_str_aes_nonce[12];
|
||||
bool pyarmor_co_code_aes_nonce_xor_enabled;
|
||||
unsigned char pyarmor_co_code_aes_nonce_xor_key[12];
|
||||
|
||||
private:
|
||||
void setVersion(unsigned int magic);
|
||||
|
||||
private:
|
||||
int m_maj, m_min;
|
||||
bool m_unicode;
|
||||
|
||||
PycRef<PycCode> m_code;
|
||||
std::vector<PycRef<PycString>> m_interns;
|
||||
std::vector<PycRef<PycObject>> m_refs;
|
||||
};
|
||||
|
||||
void pyarmorCoCodeAesNonceXorKeyCalculate(const char *in_buffer, unsigned int in_buffer_length, unsigned char *out_buffer);
|
||||
|
||||
#endif
|
||||
160
pycdc/pyc_numeric.cpp
Normal file
160
pycdc/pyc_numeric.cpp
Normal file
@@ -0,0 +1,160 @@
|
||||
#include "pyc_numeric.h"
|
||||
#include "pyc_module.h"
|
||||
#include "data.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf sprintf_s
|
||||
#endif
|
||||
|
||||
/* PycInt */
|
||||
void PycInt::load(PycData* stream, PycModule*)
|
||||
{
|
||||
m_value = stream->get32();
|
||||
}
|
||||
|
||||
|
||||
/* PycLong */
|
||||
void PycLong::load(PycData* stream, PycModule*)
|
||||
{
|
||||
if (type() == TYPE_INT64) {
|
||||
m_value.reserve(4);
|
||||
int lo = stream->get32();
|
||||
int hi = stream->get32();
|
||||
m_value.push_back((lo ) & 0xFFFF);
|
||||
m_value.push_back((lo >> 16) & 0xFFFF);
|
||||
m_value.push_back((hi ) & 0xFFFF);
|
||||
m_value.push_back((hi >> 16) & 0xFFFF);
|
||||
m_size = (hi & 0x80000000) != 0 ? -4 : 4;
|
||||
} else {
|
||||
m_size = stream->get32();
|
||||
int actualSize = m_size >= 0 ? m_size : -m_size;
|
||||
m_value.reserve(actualSize);
|
||||
for (int i=0; i<actualSize; i++)
|
||||
m_value.push_back(stream->get16());
|
||||
}
|
||||
}
|
||||
|
||||
bool PycLong::isEqual(PycRef<PycObject> obj) const
|
||||
{
|
||||
if (type() != obj.type())
|
||||
return false;
|
||||
|
||||
PycRef<PycLong> longObj = obj.cast<PycLong>();
|
||||
if (m_size != longObj->m_size)
|
||||
return false;
|
||||
auto it1 = m_value.cbegin();
|
||||
auto it2 = longObj->m_value.cbegin();
|
||||
while (it1 != m_value.cend()) {
|
||||
if (*it1 != *it2)
|
||||
return false;
|
||||
++it1, ++it2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string PycLong::repr(PycModule* mod) const
|
||||
{
|
||||
// Longs are printed as hex, since it's easier (and faster) to convert
|
||||
// arbitrary-length integers to a power of two than an arbitrary base
|
||||
|
||||
if (m_size == 0)
|
||||
return (mod->verCompare(3, 0) >= 0) ? "0x0" : "0x0L";
|
||||
|
||||
// Realign to 32 bits, since Python uses only 15
|
||||
std::vector<unsigned> bits;
|
||||
bits.reserve((m_value.size() + 1) / 2);
|
||||
int shift = 0, temp = 0;
|
||||
for (auto bit : m_value) {
|
||||
temp |= unsigned(bit & 0xFFFF) << shift;
|
||||
shift += 15;
|
||||
if (shift >= 32) {
|
||||
bits.push_back(temp);
|
||||
shift -= 32;
|
||||
temp = unsigned(bit & 0xFFFF) >> (15 - shift);
|
||||
}
|
||||
}
|
||||
if (temp)
|
||||
bits.push_back(temp);
|
||||
|
||||
std::string accum;
|
||||
accum.resize(3 + (bits.size() * 8) + 2);
|
||||
char* aptr = &accum[0];
|
||||
|
||||
if (m_size < 0)
|
||||
*aptr++ = '-';
|
||||
*aptr++ = '0';
|
||||
*aptr++ = 'x';
|
||||
|
||||
auto iter = bits.crbegin();
|
||||
aptr += snprintf(aptr, 9, "%X", *iter++);
|
||||
while (iter != bits.rend())
|
||||
aptr += snprintf(aptr, 9, "%08X", *iter++);
|
||||
if (mod->verCompare(3, 0) < 0)
|
||||
*aptr++ = 'L';
|
||||
*aptr = 0;
|
||||
return accum;
|
||||
}
|
||||
|
||||
|
||||
/* PycFloat */
|
||||
void PycFloat::load(PycData* stream, PycModule*)
|
||||
{
|
||||
int len = stream->getByte();
|
||||
if (len < 0)
|
||||
throw std::bad_alloc();
|
||||
|
||||
m_value.resize(len);
|
||||
if (len > 0)
|
||||
stream->getBuffer(len, &m_value.front());
|
||||
}
|
||||
|
||||
bool PycFloat::isEqual(PycRef<PycObject> obj) const
|
||||
{
|
||||
if (type() != obj.type())
|
||||
return false;
|
||||
|
||||
PycRef<PycFloat> floatObj = obj.cast<PycFloat>();
|
||||
return m_value == floatObj->m_value;
|
||||
}
|
||||
|
||||
|
||||
/* PycComplex */
|
||||
void PycComplex::load(PycData* stream, PycModule* mod)
|
||||
{
|
||||
PycFloat::load(stream, mod);
|
||||
|
||||
int len = stream->getByte();
|
||||
if (len < 0)
|
||||
throw std::bad_alloc();
|
||||
|
||||
m_imag.resize(len);
|
||||
if (len > 0)
|
||||
stream->getBuffer(len, &m_imag.front());
|
||||
}
|
||||
|
||||
bool PycComplex::isEqual(PycRef<PycObject> obj) const
|
||||
{
|
||||
if (!PycFloat::isEqual(obj))
|
||||
return false;
|
||||
|
||||
PycRef<PycComplex> floatObj = obj.cast<PycComplex>();
|
||||
return m_imag == floatObj->m_imag;
|
||||
}
|
||||
|
||||
|
||||
/* PycCFloat */
|
||||
void PycCFloat::load(PycData* stream, PycModule*)
|
||||
{
|
||||
Pyc_INT64 bits = stream->get64();
|
||||
memcpy(&m_value, &bits, sizeof(bits));
|
||||
}
|
||||
|
||||
|
||||
/* PycCComplex */
|
||||
void PycCComplex::load(PycData* stream, PycModule* mod)
|
||||
{
|
||||
PycCFloat::load(stream, mod);
|
||||
Pyc_INT64 bits = stream->get64();
|
||||
memcpy(&m_imag, &bits, sizeof(bits));
|
||||
}
|
||||
115
pycdc/pyc_numeric.h
Normal file
115
pycdc/pyc_numeric.h
Normal file
@@ -0,0 +1,115 @@
|
||||
#ifndef _PYC_NUMERIC_H
|
||||
#define _PYC_NUMERIC_H
|
||||
|
||||
#include "pyc_object.h"
|
||||
#include "data.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class PycInt : public PycObject {
|
||||
public:
|
||||
PycInt(int value = 0, int type = TYPE_INT)
|
||||
: PycObject(type), m_value(value) { }
|
||||
|
||||
bool isEqual(PycRef<PycObject> obj) const override
|
||||
{
|
||||
return (type() == obj.type()) &&
|
||||
(m_value == obj.cast<PycInt>()->m_value);
|
||||
}
|
||||
|
||||
void load(class PycData* stream, class PycModule* mod) override;
|
||||
|
||||
int value() const { return m_value; }
|
||||
|
||||
private:
|
||||
int m_value;
|
||||
};
|
||||
|
||||
class PycLong : public PycObject {
|
||||
public:
|
||||
PycLong(int type = TYPE_LONG)
|
||||
: PycObject(type), m_size(0) { }
|
||||
|
||||
bool isEqual(PycRef<PycObject> obj) const override;
|
||||
|
||||
void load(class PycData* stream, class PycModule* mod) override;
|
||||
|
||||
int size() const { return m_size; }
|
||||
const std::vector<int>& value() const { return m_value; }
|
||||
|
||||
std::string repr(PycModule* mod) const;
|
||||
|
||||
private:
|
||||
int m_size;
|
||||
std::vector<int> m_value;
|
||||
};
|
||||
|
||||
class PycFloat : public PycObject {
|
||||
public:
|
||||
PycFloat(int type = TYPE_FLOAT)
|
||||
: PycObject(type) { }
|
||||
|
||||
bool isEqual(PycRef<PycObject> obj) const override;
|
||||
|
||||
void load(class PycData* stream, class PycModule* mod) override;
|
||||
|
||||
const char* value() const { return m_value.c_str(); }
|
||||
|
||||
private:
|
||||
std::string m_value; // Floats are stored as strings
|
||||
};
|
||||
|
||||
class PycComplex : public PycFloat {
|
||||
public:
|
||||
PycComplex(int type = TYPE_COMPLEX)
|
||||
: PycFloat(type) { }
|
||||
|
||||
bool isEqual(PycRef<PycObject> obj) const override;
|
||||
|
||||
void load(class PycData* stream, class PycModule* mod) override;
|
||||
|
||||
const char* imag() const { return m_imag.c_str(); }
|
||||
|
||||
private:
|
||||
std::string m_imag;
|
||||
};
|
||||
|
||||
class PycCFloat : public PycObject {
|
||||
public:
|
||||
PycCFloat(int type = TYPE_BINARY_FLOAT)
|
||||
: PycObject(type), m_value(0.0) { }
|
||||
|
||||
bool isEqual(PycRef<PycObject> obj) const override
|
||||
{
|
||||
return (type() == obj.type()) &&
|
||||
(m_value == obj.cast<PycCFloat>()->m_value);
|
||||
}
|
||||
|
||||
void load(class PycData* stream, class PycModule* mod) override;
|
||||
|
||||
double value() const { return m_value; }
|
||||
|
||||
private:
|
||||
double m_value;
|
||||
};
|
||||
|
||||
class PycCComplex : public PycCFloat {
|
||||
public:
|
||||
PycCComplex(int type = TYPE_BINARY_COMPLEX)
|
||||
: PycCFloat(type), m_imag(0.0) { }
|
||||
|
||||
bool isEqual(PycRef<PycObject> obj) const override
|
||||
{
|
||||
return (PycCFloat::isEqual(obj)) &&
|
||||
(m_imag == obj.cast<PycCComplex>()->m_imag);
|
||||
}
|
||||
|
||||
void load(class PycData* stream, class PycModule* mod) override;
|
||||
|
||||
double imag() const { return m_imag; }
|
||||
|
||||
private:
|
||||
double m_imag;
|
||||
};
|
||||
|
||||
#endif
|
||||
89
pycdc/pyc_object.cpp
Normal file
89
pycdc/pyc_object.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "pyc_object.h"
|
||||
#include "pyc_module.h"
|
||||
#include "pyc_numeric.h"
|
||||
#include "pyc_code.h"
|
||||
#include "data.h"
|
||||
#include <cstdio>
|
||||
|
||||
PycRef<PycObject> Pyc_None = new PycObject(PycObject::TYPE_NONE);
|
||||
PycRef<PycObject> Pyc_Ellipsis = new PycObject(PycObject::TYPE_ELLIPSIS);
|
||||
PycRef<PycObject> Pyc_StopIteration = new PycObject(PycObject::TYPE_STOPITER);
|
||||
PycRef<PycObject> Pyc_False = new PycObject(PycObject::TYPE_FALSE);
|
||||
PycRef<PycObject> Pyc_True = new PycObject(PycObject::TYPE_TRUE);
|
||||
|
||||
PycRef<PycObject> CreateObject(int type)
|
||||
{
|
||||
switch (type) {
|
||||
case PycObject::TYPE_NULL:
|
||||
return NULL;
|
||||
case PycObject::TYPE_NONE:
|
||||
return Pyc_None;
|
||||
case PycObject::TYPE_FALSE:
|
||||
return Pyc_False;
|
||||
case PycObject::TYPE_TRUE:
|
||||
return Pyc_True;
|
||||
case PycObject::TYPE_STOPITER:
|
||||
return Pyc_StopIteration;
|
||||
case PycObject::TYPE_ELLIPSIS:
|
||||
return Pyc_Ellipsis;
|
||||
case PycObject::TYPE_INT:
|
||||
return new PycInt(type);
|
||||
case PycObject::TYPE_INT64:
|
||||
return new PycLong(type);
|
||||
case PycObject::TYPE_FLOAT:
|
||||
return new PycFloat(type);
|
||||
case PycObject::TYPE_BINARY_FLOAT:
|
||||
return new PycCFloat(type);
|
||||
case PycObject::TYPE_COMPLEX:
|
||||
return new PycComplex(type);
|
||||
case PycObject::TYPE_BINARY_COMPLEX:
|
||||
return new PycCComplex(type);
|
||||
case PycObject::TYPE_LONG:
|
||||
return new PycLong(type);
|
||||
case PycObject::TYPE_STRING:
|
||||
case PycObject::TYPE_INTERNED:
|
||||
case PycObject::TYPE_STRINGREF:
|
||||
case PycObject::TYPE_UNICODE:
|
||||
case PycObject::TYPE_ASCII:
|
||||
case PycObject::TYPE_ASCII_INTERNED:
|
||||
case PycObject::TYPE_SHORT_ASCII:
|
||||
case PycObject::TYPE_SHORT_ASCII_INTERNED:
|
||||
return new PycString(type);
|
||||
case PycObject::TYPE_TUPLE:
|
||||
case PycObject::TYPE_SMALL_TUPLE:
|
||||
return new PycTuple(type);
|
||||
case PycObject::TYPE_LIST:
|
||||
return new PycList(type);
|
||||
case PycObject::TYPE_DICT:
|
||||
return new PycDict(type);
|
||||
case PycObject::TYPE_CODE:
|
||||
case PycObject::TYPE_CODE2:
|
||||
return new PycCode(type);
|
||||
case PycObject::TYPE_SET:
|
||||
case PycObject::TYPE_FROZENSET:
|
||||
return new PycSet(type);
|
||||
default:
|
||||
fprintf(stderr, "CreateObject: Got unsupported type 0x%X\n", type);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PycRef<PycObject> LoadObject(PycData* stream, PycModule* mod)
|
||||
{
|
||||
int type = stream->getByte();
|
||||
PycRef<PycObject> obj;
|
||||
|
||||
if (type == PycObject::TYPE_OBREF) {
|
||||
int index = stream->get32();
|
||||
obj = mod->getRef(index);
|
||||
} else {
|
||||
obj = CreateObject(type & 0x7F);
|
||||
if (obj != NULL) {
|
||||
if (type & 0x80)
|
||||
mod->refObject(obj);
|
||||
obj->load(stream, mod);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
171
pycdc/pyc_object.h
Normal file
171
pycdc/pyc_object.h
Normal file
@@ -0,0 +1,171 @@
|
||||
#ifndef _PYC_OBJECT_H
|
||||
#define _PYC_OBJECT_H
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
template <class _Obj>
|
||||
class PycRef {
|
||||
public:
|
||||
PycRef() noexcept : m_obj() { }
|
||||
|
||||
PycRef(_Obj* obj) noexcept : m_obj(obj)
|
||||
{
|
||||
if (m_obj)
|
||||
m_obj->addRef();
|
||||
}
|
||||
|
||||
PycRef(const PycRef<_Obj>& obj) noexcept : m_obj(obj.m_obj)
|
||||
{
|
||||
if (m_obj)
|
||||
m_obj->addRef();
|
||||
}
|
||||
|
||||
PycRef(PycRef<_Obj>&& obj) noexcept : m_obj(obj.m_obj)
|
||||
{
|
||||
obj.m_obj = nullptr;
|
||||
}
|
||||
|
||||
~PycRef()
|
||||
{
|
||||
if (m_obj)
|
||||
m_obj->delRef();
|
||||
}
|
||||
|
||||
PycRef<_Obj>& operator=(_Obj* obj)
|
||||
{
|
||||
if (obj)
|
||||
obj->addRef();
|
||||
if (m_obj)
|
||||
m_obj->delRef();
|
||||
m_obj = obj;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PycRef<_Obj>& operator=(const PycRef<_Obj>& obj)
|
||||
{
|
||||
if (obj.m_obj)
|
||||
obj.m_obj->addRef();
|
||||
if (m_obj)
|
||||
m_obj->delRef();
|
||||
m_obj = obj.m_obj;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PycRef<_Obj>& operator=(PycRef<_Obj>&& obj) noexcept
|
||||
{
|
||||
m_obj = obj.m_obj;
|
||||
obj.m_obj = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(_Obj* obj) const { return m_obj == obj; }
|
||||
bool operator==(const PycRef<_Obj>& obj) const { return m_obj == obj.m_obj; }
|
||||
bool operator!=(_Obj* obj) const { return m_obj != obj; }
|
||||
bool operator!=(const PycRef<_Obj>& obj) const { return m_obj != obj.m_obj; }
|
||||
|
||||
_Obj& operator*() const { return *m_obj; }
|
||||
_Obj* operator->() const { return m_obj; }
|
||||
operator _Obj*() const { return m_obj; }
|
||||
|
||||
inline int type() const;
|
||||
|
||||
template <class _Cast>
|
||||
PycRef<_Cast> try_cast() const { return dynamic_cast<_Cast*>(m_obj); }
|
||||
|
||||
template <class _Cast>
|
||||
PycRef<_Cast> cast() const
|
||||
{
|
||||
_Cast* result = dynamic_cast<_Cast*>(m_obj);
|
||||
if (!result)
|
||||
throw std::bad_cast();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isIdent(const _Obj* obj) const { return m_obj == obj; }
|
||||
|
||||
private:
|
||||
_Obj* m_obj;
|
||||
};
|
||||
|
||||
|
||||
class PycData;
|
||||
class PycModule;
|
||||
|
||||
/* Please only hold PycObjects inside PycRefs! */
|
||||
class PycObject {
|
||||
public:
|
||||
enum Type {
|
||||
// From the Python Marshallers
|
||||
TYPE_NULL = '0', // Python 1.0 ->
|
||||
TYPE_NONE = 'N', // Python 1.0 ->
|
||||
TYPE_FALSE = 'F', // Python 2.3 ->
|
||||
TYPE_TRUE = 'T', // Python 2.3 ->
|
||||
TYPE_STOPITER = 'S', // Python 2.2 ->
|
||||
TYPE_ELLIPSIS = '.', // Python 1.4 ->
|
||||
TYPE_INT = 'i', // Python 1.0 ->
|
||||
TYPE_INT64 = 'I', // Python 1.5 - 3.3
|
||||
TYPE_FLOAT = 'f', // Python 1.0 ->
|
||||
TYPE_BINARY_FLOAT = 'g', // Python 2.5 ->
|
||||
TYPE_COMPLEX = 'x', // Python 1.4 ->
|
||||
TYPE_BINARY_COMPLEX = 'y', // Python 2.5 ->
|
||||
TYPE_LONG = 'l', // Python 1.0 ->
|
||||
TYPE_STRING = 's', // Python 1.0 ->
|
||||
TYPE_INTERNED = 't', // Python 2.4 - 2.7, 3.4 ->
|
||||
TYPE_STRINGREF = 'R', // Python 2.4 - 2.7
|
||||
TYPE_OBREF = 'r', // Python 3.4 ->
|
||||
TYPE_TUPLE = '(', // Python 1.0 ->
|
||||
TYPE_LIST = '[', // Python 1.0 ->
|
||||
TYPE_DICT = '{', // Python 1.0 ->
|
||||
TYPE_CODE = 'c', // Python 1.3 ->
|
||||
TYPE_CODE2 = 'C', // Python 1.0 - 1.2
|
||||
TYPE_UNICODE = 'u', // Python 1.6 ->
|
||||
TYPE_UNKNOWN = '?', // Python 1.0 ->
|
||||
TYPE_SET = '<', // Python 2.5 ->
|
||||
TYPE_FROZENSET = '>', // Python 2.5 ->
|
||||
TYPE_ASCII = 'a', // Python 3.4 ->
|
||||
TYPE_ASCII_INTERNED = 'A', // Python 3.4 ->
|
||||
TYPE_SMALL_TUPLE = ')', // Python 3.4 ->
|
||||
TYPE_SHORT_ASCII = 'z', // Python 3.4 ->
|
||||
TYPE_SHORT_ASCII_INTERNED = 'Z', // Python 3.4 ->
|
||||
};
|
||||
|
||||
PycObject(int type = TYPE_UNKNOWN) : m_refs(0), m_type(type) { }
|
||||
virtual ~PycObject() { }
|
||||
|
||||
int type() const { return m_type; }
|
||||
|
||||
virtual bool isEqual(PycRef<PycObject> obj) const
|
||||
{
|
||||
return obj.isIdent(this);
|
||||
}
|
||||
|
||||
virtual void load(PycData*, PycModule*) { }
|
||||
|
||||
private:
|
||||
int m_refs;
|
||||
|
||||
protected:
|
||||
int m_type;
|
||||
|
||||
public:
|
||||
void addRef() { ++m_refs; }
|
||||
void delRef() { if (--m_refs == 0) delete this; }
|
||||
};
|
||||
|
||||
template <class _Obj>
|
||||
int PycRef<_Obj>::type() const
|
||||
{
|
||||
return m_obj ? m_obj->type() : PycObject::TYPE_NULL;
|
||||
}
|
||||
|
||||
PycRef<PycObject> CreateObject(int type);
|
||||
PycRef<PycObject> LoadObject(PycData* stream, PycModule* mod);
|
||||
|
||||
/* Static Singleton objects */
|
||||
extern PycRef<PycObject> Pyc_None;
|
||||
extern PycRef<PycObject> Pyc_Ellipsis;
|
||||
extern PycRef<PycObject> Pyc_StopIteration;
|
||||
extern PycRef<PycObject> Pyc_False;
|
||||
extern PycRef<PycObject> Pyc_True;
|
||||
|
||||
#endif
|
||||
80
pycdc/pyc_sequence.cpp
Normal file
80
pycdc/pyc_sequence.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "pyc_sequence.h"
|
||||
#include "pyc_module.h"
|
||||
#include "data.h"
|
||||
#include <stdexcept>
|
||||
|
||||
/* PycSimpleSequence */
|
||||
void PycSimpleSequence::load(PycData* stream, PycModule* mod)
|
||||
{
|
||||
m_size = stream->get32();
|
||||
m_values.reserve(m_size);
|
||||
for (int i=0; i<m_size; i++)
|
||||
m_values.push_back(LoadObject(stream, mod));
|
||||
}
|
||||
|
||||
bool PycSimpleSequence::isEqual(PycRef<PycObject> obj) const
|
||||
{
|
||||
if (type() != obj.type())
|
||||
return false;
|
||||
|
||||
PycRef<PycSimpleSequence> seqObj = obj.cast<PycSimpleSequence>();
|
||||
if (m_size != seqObj->m_size)
|
||||
return false;
|
||||
auto it1 = m_values.cbegin();
|
||||
auto it2 = seqObj->m_values.cbegin();
|
||||
while (it1 != m_values.cend()) {
|
||||
if (!(*it1)->isEqual(*it2))
|
||||
return false;
|
||||
++it1, ++it2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* PycTuple */
|
||||
void PycTuple::load(PycData* stream, PycModule* mod)
|
||||
{
|
||||
if (type() == TYPE_SMALL_TUPLE)
|
||||
m_size = stream->getByte();
|
||||
else
|
||||
m_size = stream->get32();
|
||||
|
||||
m_values.resize(m_size);
|
||||
for (int i=0; i<m_size; i++)
|
||||
m_values[i] = LoadObject(stream, mod);
|
||||
}
|
||||
|
||||
|
||||
/* PycDict */
|
||||
void PycDict::load(PycData* stream, PycModule* mod)
|
||||
{
|
||||
PycRef<PycObject> key, val;
|
||||
for (;;) {
|
||||
key = LoadObject(stream, mod);
|
||||
if (key == NULL)
|
||||
break;
|
||||
val = LoadObject(stream, mod);
|
||||
m_values.emplace_back(std::make_tuple(key, val));
|
||||
}
|
||||
}
|
||||
|
||||
bool PycDict::isEqual(PycRef<PycObject> obj) const
|
||||
{
|
||||
if (type() != obj.type())
|
||||
return false;
|
||||
|
||||
PycRef<PycDict> dictObj = obj.cast<PycDict>();
|
||||
if (m_values.size() != dictObj->m_values.size())
|
||||
return false;
|
||||
|
||||
auto it1 = m_values.cbegin();
|
||||
auto it2 = dictObj->m_values.cbegin();
|
||||
while (it1 != m_values.cend()) {
|
||||
if (!std::get<0>(*it1)->isEqual(std::get<0>(*it2)))
|
||||
return false;
|
||||
if (!std::get<1>(*it1)->isEqual(std::get<1>(*it2)))
|
||||
return false;
|
||||
++it1, ++it2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
73
pycdc/pyc_sequence.h
Normal file
73
pycdc/pyc_sequence.h
Normal file
@@ -0,0 +1,73 @@
|
||||
#ifndef _PYC_SEQUENCE_H
|
||||
#define _PYC_SEQUENCE_H
|
||||
|
||||
#include "pyc_object.h"
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
class PycSequence : public PycObject {
|
||||
public:
|
||||
PycSequence(int type) : PycObject(type), m_size(0) { }
|
||||
|
||||
int size() const { return m_size; }
|
||||
virtual PycRef<PycObject> get(int idx) const = 0;
|
||||
|
||||
protected:
|
||||
int m_size;
|
||||
};
|
||||
|
||||
class PycSimpleSequence : public PycSequence {
|
||||
public:
|
||||
typedef std::vector<PycRef<PycObject>> value_t;
|
||||
|
||||
PycSimpleSequence(int type) : PycSequence(type) { }
|
||||
|
||||
bool isEqual(PycRef<PycObject> obj) const override;
|
||||
|
||||
void load(class PycData* stream, class PycModule* mod) override;
|
||||
|
||||
const value_t& values() const { return m_values; }
|
||||
PycRef<PycObject> get(int idx) const override { return m_values.at(idx); }
|
||||
|
||||
protected:
|
||||
value_t m_values;
|
||||
};
|
||||
|
||||
class PycTuple : public PycSimpleSequence {
|
||||
public:
|
||||
typedef PycSimpleSequence::value_t value_t;
|
||||
PycTuple(int type = TYPE_TUPLE) : PycSimpleSequence(type) { }
|
||||
|
||||
void load(class PycData* stream, class PycModule* mod) override;
|
||||
};
|
||||
|
||||
class PycList : public PycSimpleSequence {
|
||||
public:
|
||||
typedef PycSimpleSequence::value_t value_t;
|
||||
PycList(int type = TYPE_LIST) : PycSimpleSequence(type) { }
|
||||
};
|
||||
|
||||
class PycSet : public PycSimpleSequence {
|
||||
public:
|
||||
typedef PycSimpleSequence::value_t value_t;
|
||||
PycSet(int type = TYPE_SET) : PycSimpleSequence(type) { }
|
||||
};
|
||||
|
||||
class PycDict : public PycObject {
|
||||
public:
|
||||
typedef std::tuple<PycRef<PycObject>, PycRef<PycObject>> item_t;
|
||||
typedef std::vector<item_t> value_t;
|
||||
|
||||
PycDict(int type = TYPE_DICT) : PycObject(type) { }
|
||||
|
||||
bool isEqual(PycRef<PycObject> obj) const override;
|
||||
|
||||
void load(class PycData* stream, class PycModule* mod) override;
|
||||
|
||||
const value_t& values() const { return m_values; }
|
||||
|
||||
private:
|
||||
value_t m_values;
|
||||
};
|
||||
|
||||
#endif
|
||||
182
pycdc/pyc_string.cpp
Normal file
182
pycdc/pyc_string.cpp
Normal file
@@ -0,0 +1,182 @@
|
||||
#include "pyc_string.h"
|
||||
#include "pyc_module.h"
|
||||
#include "data.h"
|
||||
#include <stdexcept>
|
||||
#include "plusaes.hpp"
|
||||
|
||||
static bool check_ascii(const std::string& data)
|
||||
{
|
||||
auto cp = reinterpret_cast<const unsigned char*>(data.c_str());
|
||||
while (*cp) {
|
||||
if (*cp & 0x80)
|
||||
return false;
|
||||
++cp;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* PycString */
|
||||
void PycString::load(PycData* stream, PycModule* mod)
|
||||
{
|
||||
if (type() == TYPE_STRINGREF) {
|
||||
PycRef<PycString> str = mod->getIntern(stream->get32());
|
||||
m_type = str->m_type;
|
||||
m_value = str->m_value;
|
||||
} else {
|
||||
int length;
|
||||
if (type() == TYPE_SHORT_ASCII || type() == TYPE_SHORT_ASCII_INTERNED)
|
||||
length = stream->getByte();
|
||||
else
|
||||
length = stream->get32();
|
||||
|
||||
if (length < 0)
|
||||
throw std::bad_alloc();
|
||||
|
||||
m_value.resize(length);
|
||||
if (length) {
|
||||
stream->getBuffer(length, &m_value.front());
|
||||
if (type() == TYPE_ASCII || type() == TYPE_ASCII_INTERNED ||
|
||||
type() == TYPE_SHORT_ASCII || type() == TYPE_SHORT_ASCII_INTERNED) {
|
||||
if (!check_ascii(m_value))
|
||||
throw std::runtime_error("Invalid bytes in ASCII string");
|
||||
}
|
||||
}
|
||||
|
||||
if (type() == TYPE_INTERNED || type() == TYPE_ASCII_INTERNED ||
|
||||
type() == TYPE_SHORT_ASCII_INTERNED)
|
||||
mod->intern(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool PycString::isEqual(PycRef<PycObject> obj) const
|
||||
{
|
||||
if (type() != obj.type())
|
||||
return false;
|
||||
|
||||
PycRef<PycString> strObj = obj.cast<PycString>();
|
||||
return isEqual(strObj->m_value);
|
||||
}
|
||||
|
||||
void PycString::print(std::ostream &pyc_output, PycModule* mod, bool triple,
|
||||
const char* parent_f_string_quote)
|
||||
{
|
||||
char prefix = 0;
|
||||
switch (type()) {
|
||||
case TYPE_STRING:
|
||||
prefix = mod->strIsUnicode() ? 'b' : 0;
|
||||
break;
|
||||
case PycObject::TYPE_UNICODE:
|
||||
prefix = mod->strIsUnicode() ? 0 : 'u';
|
||||
break;
|
||||
case PycObject::TYPE_INTERNED:
|
||||
prefix = mod->internIsBytes() ? 'b' : 0;
|
||||
break;
|
||||
case PycObject::TYPE_ASCII:
|
||||
case PycObject::TYPE_ASCII_INTERNED:
|
||||
case PycObject::TYPE_SHORT_ASCII:
|
||||
case PycObject::TYPE_SHORT_ASCII_INTERNED:
|
||||
// These types don't exist until Python 3.4
|
||||
prefix = 0;
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("Invalid string type");
|
||||
}
|
||||
|
||||
if (prefix != 0)
|
||||
pyc_output << prefix;
|
||||
|
||||
if (m_value.empty()) {
|
||||
pyc_output << "''";
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine preferred quote style (Emulate Python's method)
|
||||
bool useQuotes = false;
|
||||
if (!parent_f_string_quote) {
|
||||
for (char ch : m_value) {
|
||||
if (ch == '\'') {
|
||||
useQuotes = true;
|
||||
} else if (ch == '"') {
|
||||
useQuotes = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
useQuotes = parent_f_string_quote[0] == '"';
|
||||
}
|
||||
|
||||
// Output the string
|
||||
if (!parent_f_string_quote) {
|
||||
if (triple)
|
||||
pyc_output << (useQuotes ? R"(""")" : "'''");
|
||||
else
|
||||
pyc_output << (useQuotes ? '"' : '\'');
|
||||
}
|
||||
for (char ch : m_value) {
|
||||
if (static_cast<unsigned char>(ch) < 0x20 || ch == 0x7F) {
|
||||
if (ch == '\r') {
|
||||
pyc_output << "\\r";
|
||||
} else if (ch == '\n') {
|
||||
if (triple)
|
||||
pyc_output << '\n';
|
||||
else
|
||||
pyc_output << "\\n";
|
||||
} else if (ch == '\t') {
|
||||
pyc_output << "\\t";
|
||||
} else {
|
||||
formatted_print(pyc_output, "\\x%02x", (ch & 0xFF));
|
||||
}
|
||||
} else if (static_cast<unsigned char>(ch) >= 0x80) {
|
||||
if (type() == TYPE_UNICODE) {
|
||||
// Unicode stored as UTF-8... Let the stream interpret it
|
||||
pyc_output << ch;
|
||||
} else {
|
||||
formatted_print(pyc_output, "\\x%02x", (ch & 0xFF));
|
||||
}
|
||||
} else {
|
||||
if (!useQuotes && ch == '\'')
|
||||
pyc_output << R"(\')";
|
||||
else if (useQuotes && ch == '"')
|
||||
pyc_output << R"(\")";
|
||||
else if (ch == '\\')
|
||||
pyc_output << R"(\\)";
|
||||
else if (parent_f_string_quote && ch == '{')
|
||||
pyc_output << "{{";
|
||||
else if (parent_f_string_quote && ch == '}')
|
||||
pyc_output << "}}";
|
||||
else
|
||||
pyc_output << ch;
|
||||
}
|
||||
}
|
||||
if (!parent_f_string_quote) {
|
||||
if (triple)
|
||||
pyc_output << (useQuotes ? R"(""")" : "'''");
|
||||
else
|
||||
pyc_output << (useQuotes ? '"' : '\'');
|
||||
}
|
||||
}
|
||||
|
||||
void PycString::dasPrintAndDecrypt(std::ostream &stream, PycModule *mod, bool triple, const char *parent_f_string_quote)
|
||||
{
|
||||
if (m_value.empty() || !(m_value[0] & 0x80)
|
||||
|| (m_value[0] & 0x7F) == 0 || (m_value[0] & 0x7F) > 4)
|
||||
return print(stream, mod, triple, parent_f_string_quote);
|
||||
|
||||
std::string result(m_value.substr(1));
|
||||
unsigned char nonce[16] = {0};
|
||||
memcpy(nonce, mod->pyarmor_mix_str_aes_nonce, 12);
|
||||
nonce[15] = 2;
|
||||
|
||||
plusaes::crypt_ctr(
|
||||
(unsigned char *)&result[0],
|
||||
result.length(),
|
||||
mod->pyarmor_aes_key,
|
||||
16,
|
||||
&nonce);
|
||||
|
||||
PycString decrypted(m_value[0] & 1 ? TYPE_UNICODE : TYPE_STRING);
|
||||
decrypted.setValue(result);
|
||||
decrypted.print(stream, mod, triple, parent_f_string_quote);
|
||||
stream << " # ";
|
||||
print(stream, mod, triple, parent_f_string_quote);
|
||||
}
|
||||
41
pycdc/pyc_string.h
Normal file
41
pycdc/pyc_string.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef _PYC_STRING_H
|
||||
#define _PYC_STRING_H
|
||||
|
||||
#include "pyc_object.h"
|
||||
#include "data.h"
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
class PycString : public PycObject {
|
||||
public:
|
||||
PycString(int type = TYPE_STRING)
|
||||
: PycObject(type) { }
|
||||
|
||||
bool isEqual(PycRef<PycObject> obj) const override;
|
||||
bool isEqual(const std::string& str) const { return m_value == str; }
|
||||
|
||||
bool startsWith(const std::string& str) const
|
||||
{
|
||||
return m_value.substr(0, str.size()) == str;
|
||||
}
|
||||
|
||||
void load(class PycData* stream, class PycModule* mod) override;
|
||||
|
||||
int length() const { return (int)m_value.size(); }
|
||||
const char* value() const { return m_value.c_str(); }
|
||||
const std::string &strValue() const { return m_value; }
|
||||
|
||||
void setValue(std::string str) { m_value = std::move(str); }
|
||||
|
||||
void print(std::ostream& stream, class PycModule* mod, bool triple = false,
|
||||
const char* parent_f_string_quote = nullptr);
|
||||
|
||||
void dasPrintAndDecrypt(std::ostream& stream, class PycModule* mod,
|
||||
bool triple = false,
|
||||
const char* parent_f_string_quote = nullptr);
|
||||
|
||||
private:
|
||||
std::string m_value;
|
||||
};
|
||||
|
||||
#endif
|
||||
359
pycdc/pycdas.cpp
Normal file
359
pycdc/pycdas.cpp
Normal file
@@ -0,0 +1,359 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdarg>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <unordered_set>
|
||||
#include "pyc_module.h"
|
||||
#include "pyc_numeric.h"
|
||||
#include "bytecode.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define PATHSEP '\\'
|
||||
#else
|
||||
# define PATHSEP '/'
|
||||
#endif
|
||||
|
||||
static const char* flag_names[] = {
|
||||
"CO_OPTIMIZED", "CO_NEWLOCALS", "CO_VARARGS", "CO_VARKEYWORDS",
|
||||
"CO_NESTED", "CO_GENERATOR", "CO_NOFREE", "CO_COROUTINE",
|
||||
"CO_ITERABLE_COROUTINE", "CO_ASYNC_GENERATOR", "<0x400>", "<0x800>",
|
||||
"CO_GENERATOR_ALLOWED", "<0x2000>", "<0x4000>", "<0x8000>",
|
||||
"<0x10000>", "CO_FUTURE_DIVISION", "CO_FUTURE_ABSOLUTE_IMPORT", "CO_FUTURE_WITH_STATEMENT",
|
||||
"CO_FUTURE_PRINT_FUNCTION", "CO_FUTURE_UNICODE_LITERALS", "CO_FUTURE_BARRY_AS_BDFL",
|
||||
"CO_FUTURE_GENERATOR_STOP",
|
||||
"CO_FUTURE_ANNOTATIONS", "CO_NO_MONITORING_EVENTS", "<0x4000000>", "<0x8000000>",
|
||||
"<0x10000000>", "CO_PYARMOR_OBFUSCATED", "<0x40000000>", "<0x80000000>"
|
||||
};
|
||||
|
||||
static void print_coflags(unsigned long flags, std::ostream& pyc_output)
|
||||
{
|
||||
if (flags == 0) {
|
||||
pyc_output << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
pyc_output << " (";
|
||||
unsigned long f = 1;
|
||||
int k = 0;
|
||||
while (k < 32) {
|
||||
if ((flags & f) != 0) {
|
||||
flags &= ~f;
|
||||
if (flags == 0)
|
||||
pyc_output << flag_names[k];
|
||||
else
|
||||
pyc_output << flag_names[k] << " | ";
|
||||
}
|
||||
++k;
|
||||
f <<= 1;
|
||||
}
|
||||
pyc_output << ")\n";
|
||||
}
|
||||
|
||||
static void iputs(std::ostream& pyc_output, int indent, const char* text)
|
||||
{
|
||||
for (int i=0; i<indent; i++)
|
||||
pyc_output << " ";
|
||||
pyc_output << text;
|
||||
}
|
||||
|
||||
static void ivprintf(std::ostream& pyc_output, int indent, const char* fmt,
|
||||
va_list varargs)
|
||||
{
|
||||
for (int i=0; i<indent; i++)
|
||||
pyc_output << " ";
|
||||
formatted_printv(pyc_output, fmt, varargs);
|
||||
}
|
||||
|
||||
static void iprintf(std::ostream& pyc_output, int indent, const char* fmt, ...)
|
||||
{
|
||||
va_list varargs;
|
||||
va_start(varargs, fmt);
|
||||
ivprintf(pyc_output, indent, fmt, varargs);
|
||||
va_end(varargs);
|
||||
}
|
||||
|
||||
static std::unordered_set<PycObject *> out_seen;
|
||||
|
||||
void output_object(PycRef<PycObject> obj, PycModule* mod, int indent,
|
||||
unsigned flags, std::ostream& pyc_output)
|
||||
{
|
||||
if (obj == NULL) {
|
||||
iputs(pyc_output, indent, "<NULL>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (out_seen.find((PycObject *)obj) != out_seen.end()) {
|
||||
fputs("WARNING: Circular reference detected\n", stderr);
|
||||
return;
|
||||
}
|
||||
out_seen.insert((PycObject *)obj);
|
||||
|
||||
switch (obj->type()) {
|
||||
case PycObject::TYPE_CODE:
|
||||
case PycObject::TYPE_CODE2:
|
||||
{
|
||||
PycRef<PycCode> codeObj = obj.cast<PycCode>();
|
||||
iputs(pyc_output, indent, "[Code]\n");
|
||||
iprintf(pyc_output, indent + 1, "File Name: %s\n", codeObj->fileName()->value());
|
||||
iprintf(pyc_output, indent + 1, "Object Name: %s\n", codeObj->name()->value());
|
||||
if (mod->verCompare(3, 11) >= 0)
|
||||
iprintf(pyc_output, indent + 1, "Qualified Name: %s\n", codeObj->qualName()->value());
|
||||
iprintf(pyc_output, indent + 1, "Arg Count: %d\n", codeObj->argCount());
|
||||
if (mod->verCompare(3, 8) >= 0)
|
||||
iprintf(pyc_output, indent + 1, "Pos Only Arg Count: %d\n", codeObj->posOnlyArgCount());
|
||||
if (mod->majorVer() >= 3)
|
||||
iprintf(pyc_output, indent + 1, "KW Only Arg Count: %d\n", codeObj->kwOnlyArgCount());
|
||||
if (mod->verCompare(3, 11) < 0)
|
||||
iprintf(pyc_output, indent + 1, "Locals: %d\n", codeObj->numLocals());
|
||||
if (mod->verCompare(1, 5) >= 0)
|
||||
iprintf(pyc_output, indent + 1, "Stack Size: %d\n", codeObj->stackSize());
|
||||
if (mod->verCompare(1, 3) >= 0) {
|
||||
unsigned int orig_flags = codeObj->flags();
|
||||
if (mod->verCompare(3, 8) < 0) {
|
||||
// Remap flags back to the value stored in the PyCode object
|
||||
orig_flags = (orig_flags & 0x1FFF) | ((orig_flags & 0xDFFE0000) >> 4) | (orig_flags & 0x20000000);
|
||||
}
|
||||
iprintf(pyc_output, indent + 1, "Flags: 0x%08X", orig_flags);
|
||||
print_coflags(codeObj->flags(), pyc_output);
|
||||
}
|
||||
|
||||
iputs(pyc_output, indent + 1, "[Names]\n");
|
||||
for (int i=0; i<codeObj->names()->size(); i++)
|
||||
output_object(codeObj->names()->get(i), mod, indent + 2, flags, pyc_output);
|
||||
|
||||
if (mod->verCompare(1, 3) >= 0) {
|
||||
if (mod->verCompare(3, 11) >= 0)
|
||||
iputs(pyc_output, indent + 1, "[Locals+Names]\n");
|
||||
else
|
||||
iputs(pyc_output, indent + 1, "[Var Names]\n");
|
||||
for (int i=0; i<codeObj->localNames()->size(); i++)
|
||||
output_object(codeObj->localNames()->get(i), mod, indent + 2, flags, pyc_output);
|
||||
}
|
||||
|
||||
if (mod->verCompare(3, 11) >= 0 && (flags & Pyc::DISASM_PYCODE_VERBOSE) != 0) {
|
||||
iputs(pyc_output, indent + 1, "[Locals+Kinds]\n");
|
||||
output_object(codeObj->localKinds().cast<PycObject>(), mod, indent + 2, flags, pyc_output);
|
||||
}
|
||||
|
||||
if (mod->verCompare(2, 1) >= 0 && mod->verCompare(3, 11) < 0) {
|
||||
iputs(pyc_output, indent + 1, "[Free Vars]\n");
|
||||
for (int i=0; i<codeObj->freeVars()->size(); i++)
|
||||
output_object(codeObj->freeVars()->get(i), mod, indent + 2, flags, pyc_output);
|
||||
|
||||
iputs(pyc_output, indent + 1, "[Cell Vars]\n");
|
||||
for (int i=0; i<codeObj->cellVars()->size(); i++)
|
||||
output_object(codeObj->cellVars()->get(i), mod, indent + 2, flags, pyc_output);
|
||||
}
|
||||
|
||||
iputs(pyc_output, indent + 1, "[Constants]\n");
|
||||
for (int i=0; i<codeObj->consts()->size(); i++)
|
||||
output_object(codeObj->consts()->get(i), mod, indent + 2, flags, pyc_output);
|
||||
|
||||
iputs(pyc_output, indent + 1, "[Disassembly]\n");
|
||||
bc_disasm(pyc_output, codeObj, mod, indent + 2, flags);
|
||||
|
||||
if (mod->verCompare(3, 11) >= 0) {
|
||||
iputs(pyc_output, indent + 1, "[Exception Table]\n");
|
||||
bc_exceptiontable(pyc_output, codeObj, indent+2);
|
||||
}
|
||||
|
||||
if (mod->verCompare(1, 5) >= 0 && (flags & Pyc::DISASM_PYCODE_VERBOSE) != 0) {
|
||||
iprintf(pyc_output, indent + 1, "First Line: %d\n", codeObj->firstLine());
|
||||
iputs(pyc_output, indent + 1, "[Line Number Table]\n");
|
||||
output_object(codeObj->lnTable().cast<PycObject>(), mod, indent + 2, flags, pyc_output);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_STRING:
|
||||
case PycObject::TYPE_UNICODE:
|
||||
case PycObject::TYPE_INTERNED:
|
||||
case PycObject::TYPE_ASCII:
|
||||
case PycObject::TYPE_ASCII_INTERNED:
|
||||
case PycObject::TYPE_SHORT_ASCII:
|
||||
case PycObject::TYPE_SHORT_ASCII_INTERNED:
|
||||
iputs(pyc_output, indent, "");
|
||||
obj.cast<PycString>()->dasPrintAndDecrypt(pyc_output, mod);
|
||||
pyc_output << "\n";
|
||||
break;
|
||||
case PycObject::TYPE_TUPLE:
|
||||
case PycObject::TYPE_SMALL_TUPLE:
|
||||
{
|
||||
iputs(pyc_output, indent, "(\n");
|
||||
for (const auto& val : obj.cast<PycTuple>()->values())
|
||||
output_object(val, mod, indent + 1, flags, pyc_output);
|
||||
iputs(pyc_output, indent, ")\n");
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_LIST:
|
||||
{
|
||||
iputs(pyc_output, indent, "[\n");
|
||||
for (const auto& val : obj.cast<PycList>()->values())
|
||||
output_object(val, mod, indent + 1, flags, pyc_output);
|
||||
iputs(pyc_output, indent, "]\n");
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_DICT:
|
||||
{
|
||||
iputs(pyc_output, indent, "{\n");
|
||||
for (const auto& val : obj.cast<PycDict>()->values()) {
|
||||
output_object(std::get<0>(val), mod, indent + 1, flags, pyc_output);
|
||||
output_object(std::get<1>(val), mod, indent + 2, flags, pyc_output);
|
||||
}
|
||||
iputs(pyc_output, indent, "}\n");
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_SET:
|
||||
{
|
||||
iputs(pyc_output, indent, "{\n");
|
||||
for (const auto& val : obj.cast<PycSet>()->values())
|
||||
output_object(val, mod, indent + 1, flags, pyc_output);
|
||||
iputs(pyc_output, indent, "}\n");
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_FROZENSET:
|
||||
{
|
||||
iputs(pyc_output, indent, "frozenset({\n");
|
||||
for (const auto& val : obj.cast<PycSet>()->values())
|
||||
output_object(val, mod, indent + 1, flags, pyc_output);
|
||||
iputs(pyc_output, indent, "})\n");
|
||||
}
|
||||
break;
|
||||
case PycObject::TYPE_NONE:
|
||||
iputs(pyc_output, indent, "None\n");
|
||||
break;
|
||||
case PycObject::TYPE_FALSE:
|
||||
iputs(pyc_output, indent, "False\n");
|
||||
break;
|
||||
case PycObject::TYPE_TRUE:
|
||||
iputs(pyc_output, indent, "True\n");
|
||||
break;
|
||||
case PycObject::TYPE_ELLIPSIS:
|
||||
iputs(pyc_output, indent, "...\n");
|
||||
break;
|
||||
case PycObject::TYPE_INT:
|
||||
iprintf(pyc_output, indent, "%d\n", obj.cast<PycInt>()->value());
|
||||
break;
|
||||
case PycObject::TYPE_LONG:
|
||||
iprintf(pyc_output, indent, "%s\n", obj.cast<PycLong>()->repr(mod).c_str());
|
||||
break;
|
||||
case PycObject::TYPE_FLOAT:
|
||||
iprintf(pyc_output, indent, "%s\n", obj.cast<PycFloat>()->value());
|
||||
break;
|
||||
case PycObject::TYPE_COMPLEX:
|
||||
iprintf(pyc_output, indent, "(%s+%sj)\n", obj.cast<PycComplex>()->value(),
|
||||
obj.cast<PycComplex>()->imag());
|
||||
break;
|
||||
case PycObject::TYPE_BINARY_FLOAT:
|
||||
iprintf(pyc_output, indent, "%g\n", obj.cast<PycCFloat>()->value());
|
||||
break;
|
||||
case PycObject::TYPE_BINARY_COMPLEX:
|
||||
iprintf(pyc_output, indent, "(%g+%gj)\n", obj.cast<PycCComplex>()->value(),
|
||||
obj.cast<PycCComplex>()->imag());
|
||||
break;
|
||||
default:
|
||||
iprintf(pyc_output, indent, "<TYPE: %d>\n", obj->type());
|
||||
}
|
||||
|
||||
out_seen.erase((PycObject *)obj);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* infile = nullptr;
|
||||
bool marshalled = false;
|
||||
const char* version = nullptr;
|
||||
unsigned disasm_flags = 0;
|
||||
std::ostream* pyc_output = &std::cout;
|
||||
std::ofstream out_file;
|
||||
|
||||
for (int arg = 1; arg < argc; ++arg) {
|
||||
if (strcmp(argv[arg], "-o") == 0) {
|
||||
if (arg + 1 < argc) {
|
||||
const char* filename = argv[++arg];
|
||||
out_file.open(filename, std::ios_base::out);
|
||||
if (out_file.fail()) {
|
||||
fprintf(stderr, "Error opening file '%s' for writing\n",
|
||||
filename);
|
||||
return 1;
|
||||
}
|
||||
pyc_output = &out_file;
|
||||
} else {
|
||||
fputs("Option '-o' requires a filename\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(argv[arg], "-c") == 0) {
|
||||
marshalled = true;
|
||||
} else if (strcmp(argv[arg], "-v") == 0) {
|
||||
if (arg + 1 < argc) {
|
||||
version = argv[++arg];
|
||||
} else {
|
||||
fputs("Option '-v' requires a version\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(argv[arg], "--pycode-extra") == 0) {
|
||||
disasm_flags |= Pyc::DISASM_PYCODE_VERBOSE;
|
||||
} else if (strcmp(argv[arg], "--show-caches") == 0) {
|
||||
disasm_flags |= Pyc::DISASM_SHOW_CACHES;
|
||||
} else if (strcmp(argv[arg], "--help") == 0 || strcmp(argv[arg], "-h") == 0) {
|
||||
fprintf(stderr, "Usage: %s [options] input.pyc\n\n", argv[0]);
|
||||
fputs("Options:\n", stderr);
|
||||
fputs(" -o <filename> Write output to <filename> (default: stdout)\n", stderr);
|
||||
fputs(" -c Specify loading a compiled code object. Requires the version to be set\n", stderr);
|
||||
fputs(" -v <x.y> Specify a Python version for loading a compiled code object\n", stderr);
|
||||
fputs(" --pycode-extra Show extra fields in PyCode object dumps\n", stderr);
|
||||
fputs(" --show-caches Don't suprress CACHE instructions in Python 3.11+ disassembly\n", stderr);
|
||||
fputs(" --help Show this help text and then exit\n", stderr);
|
||||
return 0;
|
||||
} else if (argv[arg][0] == '-') {
|
||||
fprintf(stderr, "Error: Unrecognized argument %s\n", argv[arg]);
|
||||
return 1;
|
||||
} else {
|
||||
infile = argv[arg];
|
||||
}
|
||||
}
|
||||
|
||||
if (!infile) {
|
||||
fputs("No input file specified\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
PycModule mod;
|
||||
if (!marshalled) {
|
||||
try {
|
||||
mod.loadFromFile(infile);
|
||||
} catch (std::exception &ex) {
|
||||
fprintf(stderr, "Error disassembling %s: %s\n", infile, ex.what());
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (!version) {
|
||||
fputs("Opening raw code objects requires a version to be specified\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
std::string s(version);
|
||||
auto dot = s.find('.');
|
||||
if (dot == std::string::npos || dot == s.size()-1) {
|
||||
fputs("Unable to parse version string (use the format x.y)\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
int major = std::stoi(s.substr(0, dot));
|
||||
int minor = std::stoi(s.substr(dot+1, s.size()));
|
||||
mod.loadFromMarshalledFile(infile, major, minor);
|
||||
}
|
||||
const char* dispname = strrchr(infile, PATHSEP);
|
||||
dispname = (dispname == NULL) ? infile : dispname + 1;
|
||||
formatted_print(*pyc_output, "%s (Python %d.%d%s)\n", dispname,
|
||||
mod.majorVer(), mod.minorVer(),
|
||||
(mod.majorVer() < 3 && mod.isUnicode()) ? " -U" : "");
|
||||
try {
|
||||
output_object(mod.code().try_cast<PycObject>(), &mod, 0, disasm_flags,
|
||||
*pyc_output);
|
||||
} catch (std::exception& ex) {
|
||||
fprintf(stderr, "Error disassembling %s: %s\n", infile, ex.what());
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
104
pycdc/pycdc.cpp
Normal file
104
pycdc/pycdc.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "ASTree.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define PATHSEP '\\'
|
||||
#else
|
||||
# define PATHSEP '/'
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const char* infile = nullptr;
|
||||
bool marshalled = false;
|
||||
const char* version = nullptr;
|
||||
std::ostream* pyc_output = &std::cout;
|
||||
std::ofstream out_file;
|
||||
|
||||
for (int arg = 1; arg < argc; ++arg) {
|
||||
if (strcmp(argv[arg], "-o") == 0) {
|
||||
if (arg + 1 < argc) {
|
||||
const char* filename = argv[++arg];
|
||||
out_file.open(filename, std::ios_base::out);
|
||||
if (out_file.fail()) {
|
||||
fprintf(stderr, "Error opening file '%s' for writing\n",
|
||||
filename);
|
||||
return 1;
|
||||
}
|
||||
pyc_output = &out_file;
|
||||
} else {
|
||||
fputs("Option '-o' requires a filename\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(argv[arg], "-c") == 0) {
|
||||
marshalled = true;
|
||||
} else if (strcmp(argv[arg], "-v") == 0) {
|
||||
if (arg + 1 < argc) {
|
||||
version = argv[++arg];
|
||||
} else {
|
||||
fputs("Option '-v' requires a version\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(argv[arg], "--help") == 0 || strcmp(argv[arg], "-h") == 0) {
|
||||
fprintf(stderr, "Usage: %s [options] input.pyc\n\n", argv[0]);
|
||||
fputs("Options:\n", stderr);
|
||||
fputs(" -o <filename> Write output to <filename> (default: stdout)\n", stderr);
|
||||
fputs(" -c Specify loading a compiled code object. Requires the version to be set\n", stderr);
|
||||
fputs(" -v <x.y> Specify a Python version for loading a compiled code object\n", stderr);
|
||||
fputs(" --help Show this help text and then exit\n", stderr);
|
||||
return 0;
|
||||
} else {
|
||||
infile = argv[arg];
|
||||
}
|
||||
}
|
||||
|
||||
if (!infile) {
|
||||
fputs("No input file specified\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
PycModule mod;
|
||||
if (!marshalled) {
|
||||
try {
|
||||
mod.loadFromFile(infile);
|
||||
} catch (std::exception& ex) {
|
||||
fprintf(stderr, "Error loading file %s: %s\n", infile, ex.what());
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (!version) {
|
||||
fputs("Opening raw code objects requires a version to be specified\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
std::string s(version);
|
||||
auto dot = s.find('.');
|
||||
if (dot == std::string::npos || dot == s.size()-1) {
|
||||
fputs("Unable to parse version string (use the format x.y)\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
int major = std::stoi(s.substr(0, dot));
|
||||
int minor = std::stoi(s.substr(dot+1, s.size()));
|
||||
mod.loadFromMarshalledFile(infile, major, minor);
|
||||
}
|
||||
|
||||
if (!mod.isValid()) {
|
||||
fprintf(stderr, "Could not load file %s\n", infile);
|
||||
return 1;
|
||||
}
|
||||
const char* dispname = strrchr(infile, PATHSEP);
|
||||
dispname = (dispname == NULL) ? infile : dispname + 1;
|
||||
*pyc_output << "# Source Generated with Decompyle++\n";
|
||||
formatted_print(*pyc_output, "# File: %s (Python %d.%d%s)\n\n", dispname,
|
||||
mod.majorVer(), mod.minorVer(),
|
||||
(mod.majorVer() < 3 && mod.isUnicode()) ? " Unicode" : "");
|
||||
try {
|
||||
decompyle(mod.code(), &mod, *pyc_output);
|
||||
} catch (std::exception& ex) {
|
||||
fprintf(stderr, "Error decompyling %s: %s\n", infile, ex.what());
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
4
pycdc/scripts/.gitignore
vendored
Normal file
4
pycdc/scripts/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
tarballs/
|
||||
Python-*/
|
||||
Python-*.conf.log
|
||||
Python-*.build.log
|
||||
42
pycdc/scripts/Dockerfile.pybuild
Normal file
42
pycdc/scripts/Dockerfile.pybuild
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# This will generate a local container with the specified version of Python.
|
||||
#
|
||||
# Note: This assumes the the tarball for the particular version you'd like to build has already been downloaded,
|
||||
# unpacked, and patched appropriately.
|
||||
#
|
||||
# To build:
|
||||
# docker build --build-arg python_version=PYTHON-VERSION \
|
||||
# --build-arg install_target=INSTALL-TARGET \
|
||||
# -f Dockerfile.pybuild \
|
||||
# -t python:PYTHON-VERSION
|
||||
#
|
||||
# PYTHON-VERSION full version of Python to build (ex. 3.0.1)
|
||||
# INSTALL-TARGET the target to make for installing (fullinstall for 3.0.1, install otherwise)
|
||||
#
|
||||
# Example for 3.0.1:
|
||||
# docker build --build-arg python_version=3.0.1 \
|
||||
# --build-arg install_target=fullinstall \
|
||||
# -f Dockerfile.pybuild \
|
||||
# -t python:3.0.1
|
||||
#
|
||||
|
||||
FROM debian:buster
|
||||
|
||||
ARG python_version
|
||||
ARG install_target
|
||||
|
||||
RUN mkdir -p /pybuild/ &&\
|
||||
apt-get update && \
|
||||
apt-get upgrade -y && \
|
||||
apt-get install -y build-essential libncurses-dev libz-dev libbz2-dev libreadline-dev
|
||||
|
||||
COPY Python-$python_version /pybuild/
|
||||
|
||||
RUN cd pybuild &&\
|
||||
./configure && \
|
||||
make && \
|
||||
make $install_target && \
|
||||
cd / && \
|
||||
apt-get remove -y build-essential libncurses-dev libz-dev libbz2-dev libreadline-dev && \
|
||||
apt autoremove -y && \
|
||||
rm -rf /pybuild
|
||||
357
pycdc/scripts/pymultic
Normal file
357
pycdc/scripts/pymultic
Normal file
@@ -0,0 +1,357 @@
|
||||
#!/usr/bin/env python3
|
||||
# PyMultiC - Python Multiple Compiler
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
import re
|
||||
|
||||
PYVERS = {
|
||||
'1.0': '1.0.1',
|
||||
'1.1': '1.1',
|
||||
'1.2': '1.2',
|
||||
'1.3': '1.3',
|
||||
'1.4': '1.4',
|
||||
'1.5': '1.5.2',
|
||||
'1.6': '1.6.1',
|
||||
'2.0': '2.0.1',
|
||||
'2.1': '2.1.3',
|
||||
'2.2': '2.2.3',
|
||||
'2.3': '2.3.7',
|
||||
'2.4': '2.4.6',
|
||||
'2.5': '2.5.6',
|
||||
'2.6': '2.6.9',
|
||||
'2.7': '2.7.18',
|
||||
'3.0': '3.0.1',
|
||||
'3.1': '3.1.5',
|
||||
'3.2': '3.2.6',
|
||||
'3.3': '3.3.7',
|
||||
'3.4': '3.4.10',
|
||||
'3.5': '3.5.10',
|
||||
'3.6': '3.6.15',
|
||||
'3.7': '3.7.17',
|
||||
'3.8': '3.8.18',
|
||||
'3.9': '3.9.18',
|
||||
'3.10': '3.10.13',
|
||||
'3.11': '3.11.6',
|
||||
'3.12': '3.12.0',
|
||||
}
|
||||
|
||||
OLD_PYTHONS = ('1.0', '1.1', '1.2', '1.3', '1.4', '1.5')
|
||||
OLD_PYURL = 'https://legacy.python.org/download/releases/src'
|
||||
PYURL = 'https://www.python.org/ftp/python'
|
||||
|
||||
# Not all versions of Python have an official container.
|
||||
PYVER_CONTAINERS = {
|
||||
'2.7',
|
||||
'3.2',
|
||||
'3.3',
|
||||
'3.4',
|
||||
'3.5',
|
||||
'3.6',
|
||||
'3.7',
|
||||
'3.8',
|
||||
'3.9',
|
||||
'3.10',
|
||||
'3.11',
|
||||
'3.12',
|
||||
}
|
||||
CONTAINER_EXES = ['podman', 'docker']
|
||||
CONTAINER_EXE_EXTRA_ARGS = {
|
||||
'podman': [],
|
||||
'docker': ['-u', '{}:{}'.format(os.getuid(), os.getgid())], # Docker requires extra magic for permissions.
|
||||
}
|
||||
|
||||
|
||||
def get_container_exe():
|
||||
container_exe = None
|
||||
for ce in CONTAINER_EXES:
|
||||
if shutil.which(ce) is not None:
|
||||
container_exe = ce
|
||||
break
|
||||
|
||||
if container_exe is None:
|
||||
print('Cannot find {} in $PATH'.format(' or '.join(CONTAINER_EXES)))
|
||||
return sys.exit(1)
|
||||
|
||||
return container_exe
|
||||
|
||||
|
||||
def fetch_python(snekdir, version):
|
||||
realver = PYVERS[version]
|
||||
if version in ('1.0', '1.1'):
|
||||
tarball = 'python{}.tar.gz'.format(realver)
|
||||
url = '{}/{}'.format(OLD_PYURL, tarball)
|
||||
elif version in ('1.2', '1.3', '1.4', '1.5'):
|
||||
tarball = 'python-{}.tar.gz'.format(realver)
|
||||
url = '{}/{}'.format(OLD_PYURL, tarball)
|
||||
elif version == '1.6':
|
||||
tarball = 'Python-{}.tar.gz'.format(realver)
|
||||
url = None
|
||||
else:
|
||||
tarball = 'Python-{}.tgz'.format(realver)
|
||||
url = '{}/{}/{}'.format(PYURL, realver, tarball)
|
||||
|
||||
pyver_dir = os.path.join(snekdir, 'Python-{}'.format(realver))
|
||||
if os.path.exists(pyver_dir):
|
||||
return
|
||||
|
||||
tb_dir = os.path.join(snekdir, 'tarballs')
|
||||
if not os.path.exists(tb_dir):
|
||||
os.makedirs(tb_dir)
|
||||
tarfile = os.path.join(tb_dir, tarball)
|
||||
if not os.path.exists(tarfile):
|
||||
if version == '1.6':
|
||||
print('Python 1.6.1 cannot be downloaded automatically due to a license agreement')
|
||||
print('which must be manually accepted.')
|
||||
print('Please download it from https://www.python.org/download/releases/1.6.1/download/')
|
||||
print('and place the tarball in {}'.format(tb_dir))
|
||||
sys.exit(1)
|
||||
|
||||
print('Downloading Python {}...'.format(realver))
|
||||
if subprocess.call(['curl', '-LfO#', url], cwd=tb_dir) != 0:
|
||||
sys.exit(1)
|
||||
|
||||
print('Extracting Python {}...'.format(realver))
|
||||
if subprocess.call(['tar', 'xaf', tarfile], cwd=snekdir) != 0:
|
||||
sys.exit(1)
|
||||
|
||||
if os.path.exists(os.path.join(snekdir, 'python-{}'.format(realver))) \
|
||||
and not os.path.exists(pyver_dir):
|
||||
# The dual check prevents useless renames on case-insensitive
|
||||
# file systems
|
||||
os.rename(os.path.join(snekdir, 'python-{}'.format(realver)), pyver_dir)
|
||||
|
||||
patch_file = os.path.join(snekdir, 'python-builds', 'Python-{}.patch'.format(realver))
|
||||
if os.path.exists(patch_file):
|
||||
if subprocess.call(['patch', '-p1', '-i', patch_file], cwd=pyver_dir) != 0:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def build_python(snekdir, version):
|
||||
realver = PYVERS[version]
|
||||
snek = 'Python-{}'.format(realver)
|
||||
builddir = os.path.join(snekdir, snek)
|
||||
|
||||
# NOTE: This has only been tested on a Debian 10 x86_64 system -- it is
|
||||
# probably not as robust as it should be...
|
||||
print('Configuring Python {}...'.format(realver))
|
||||
logfile = os.path.join(snekdir, '{}.conf.log'.format(snek))
|
||||
with open(logfile, 'wb') as log:
|
||||
if subprocess.call(['./configure'], stdout=log, stderr=log, cwd=builddir) != 0:
|
||||
print('... Configuration failed. See {} for details'.format(logfile))
|
||||
sys.exit(1)
|
||||
|
||||
print('Building Python {}...'.format(realver))
|
||||
logfile = os.path.join(snekdir, '{}.build.log'.format(snek))
|
||||
with open(logfile, 'wb') as log:
|
||||
if subprocess.call(['make'], stdout=log, stderr=log, cwd=builddir) != 0:
|
||||
print('... Build failed. See {} for details'.format(logfile))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def acquire_python(snekdir, version):
|
||||
snek = 'Python-{}'.format(PYVERS[version])
|
||||
pyexe = os.path.join(snekdir, snek, 'python')
|
||||
if not os.path.exists(pyexe):
|
||||
fetch_python(snekdir, version)
|
||||
build_python(snekdir, version)
|
||||
return pyexe
|
||||
|
||||
|
||||
def build_python_container(snekdir, version):
|
||||
realver = PYVERS[version]
|
||||
snek = 'Python-{}'.format(realver)
|
||||
builddir = os.path.join(snekdir, snek)
|
||||
container_exe = get_container_exe()
|
||||
py_container_tag = 'python:{}'.format(realver)
|
||||
|
||||
if subprocess.call([container_exe, 'image', 'inspect', py_container_tag],
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL) == 0:
|
||||
return
|
||||
|
||||
fetch_python(snekdir, version)
|
||||
|
||||
print('Building Python {} container...'.format(realver))
|
||||
logfile = os.path.join(snekdir, '{}.build.log'.format(snek))
|
||||
install_target = 'fullinstall' if version == '3.0' else 'install'
|
||||
with open(logfile, 'wb') as log:
|
||||
if subprocess.call([container_exe, 'build',
|
||||
'--build-arg', 'python_version={}'.format(realver),
|
||||
'--build-arg', 'install_target={}'.format(install_target),
|
||||
'-f', os.path.join(snekdir, 'Dockerfile.pybuild'),
|
||||
'-t', py_container_tag, snekdir], stdout=log, stderr=log) != 0:
|
||||
print('...Container build failed. See {} for details'.format(logfile))
|
||||
sys.exit(1)
|
||||
|
||||
shutil.rmtree(builddir)
|
||||
|
||||
|
||||
def local_compile(snekdir, ver, infile):
|
||||
pyexe = acquire_python(snekdir, ver)
|
||||
proc = subprocess.Popen([pyexe, '-c', 'import sys; print(sys.version)'],
|
||||
stdout=subprocess.PIPE)
|
||||
out, _ = proc.communicate()
|
||||
if proc.returncode != 0:
|
||||
print('Could not determine Python version for {}'.format(ver))
|
||||
return None
|
||||
|
||||
bcver = str(out, 'iso-8859-1').split(' ', 1)[0]
|
||||
if not bcver.startswith(ver):
|
||||
print('Python {} reported itself as version {}!'.format(ver, bcver))
|
||||
return None
|
||||
|
||||
if infile.endswith('.py'):
|
||||
outfile = os.path.basename(infile)[:-3]
|
||||
else:
|
||||
outfile = os.path.basename(infile)
|
||||
outfile += '.{}.pyc'.format(ver)
|
||||
if os.path.exists(outfile):
|
||||
os.unlink(outfile)
|
||||
|
||||
print('*** Compiling for Python {}'.format(bcver))
|
||||
if ver in {'1.0', '1.1', '1.2', '1.3', '1.4'}:
|
||||
# The hard way -- hope your code is safe...
|
||||
srcdir = os.path.dirname(os.path.realpath(infile))
|
||||
comptmp = os.path.join(srcdir, 'pymc_temp.py')
|
||||
if os.path.exists(comptmp):
|
||||
os.unlink(comptmp)
|
||||
shutil.copyfile(infile, comptmp)
|
||||
cwdsave = os.getcwd()
|
||||
os.chdir(srcdir)
|
||||
proc = subprocess.Popen([pyexe, '-c', 'import pymc_temp'])
|
||||
proc.communicate()
|
||||
os.chdir(cwdsave)
|
||||
if os.path.exists(comptmp + 'o'):
|
||||
shutil.copyfile(comptmp + 'o', outfile)
|
||||
os.unlink(comptmp + 'o')
|
||||
elif os.path.exists(comptmp + 'c'):
|
||||
shutil.copyfile(comptmp + 'c', outfile)
|
||||
os.unlink(comptmp + 'c')
|
||||
os.unlink(comptmp)
|
||||
else:
|
||||
# The easy way
|
||||
proc = subprocess.Popen([pyexe, '-c',
|
||||
"import py_compile; py_compile.compile('{}', '{}')" \
|
||||
.format(infile, outfile)])
|
||||
proc.communicate()
|
||||
|
||||
return outfile
|
||||
|
||||
|
||||
def container_compile(snekdir, ver, infile):
|
||||
if ver not in PYVER_CONTAINERS:
|
||||
build_python_container(snekdir, ver)
|
||||
|
||||
container_exe = get_container_exe()
|
||||
fullver = PYVERS[ver]
|
||||
indir = os.path.dirname(os.path.abspath(infile))
|
||||
infile_full_path = infile
|
||||
infile = os.path.basename(infile)
|
||||
|
||||
if infile.endswith('.py'):
|
||||
outfile = infile[:-3]
|
||||
else:
|
||||
outfile = infile
|
||||
outfile += '.{}.pyc'.format(ver)
|
||||
if os.path.exists(outfile):
|
||||
os.unlink(outfile)
|
||||
|
||||
print('*** Compiling for Python {}'.format(fullver))
|
||||
if ver in {'1.0', '1.1', '1.2', '1.3', '1.4'}:
|
||||
# The hard way -- hope your code is safe...
|
||||
comptmp = os.path.join(indir, 'pymc_temp.py')
|
||||
if os.path.exists(comptmp):
|
||||
os.unlink(comptmp)
|
||||
shutil.copyfile(infile_full_path, comptmp)
|
||||
proc = subprocess.Popen([container_exe, 'run'] + CONTAINER_EXE_EXTRA_ARGS[container_exe] +
|
||||
['--rm', '--name', outfile,
|
||||
'-v', '{}:/indir:Z'.format(indir),
|
||||
'-v', '{}:/outdir:Z'.format(os.getcwd()), '-w', '/outdir',
|
||||
'-w', '/indir',
|
||||
'python:{}'.format(fullver),
|
||||
'python', '-c',
|
||||
"import pymc_temp"])
|
||||
proc.communicate()
|
||||
if os.path.exists(comptmp + 'o'):
|
||||
shutil.copyfile(comptmp + 'o', outfile)
|
||||
os.unlink(comptmp + 'o')
|
||||
elif os.path.exists(comptmp + 'c'):
|
||||
shutil.copyfile(comptmp + 'c', outfile)
|
||||
os.unlink(comptmp + 'c')
|
||||
os.unlink(comptmp)
|
||||
else:
|
||||
# The easy way
|
||||
proc = subprocess.Popen([container_exe, 'run'] + CONTAINER_EXE_EXTRA_ARGS[container_exe] +
|
||||
['--rm', '--name', outfile,
|
||||
'-v', '{}:/indir:Z'.format(indir),
|
||||
'-v', '{}:/outdir:Z'.format(os.getcwd()), '-w', '/outdir',
|
||||
'python:{}'.format(fullver),
|
||||
'python', '-c',
|
||||
"import py_compile; py_compile.compile('/indir/{}', '{}')".format(infile, outfile)])
|
||||
proc.communicate()
|
||||
|
||||
return outfile
|
||||
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print('Usage: {} [-c] [versions] input.py'.format(sys.argv[0]))
|
||||
print('Compile input.py for one or more python versions')
|
||||
print()
|
||||
print('-c\tuse prebuilt containers for running different versions of Python')
|
||||
print('\t(not available for all versions)')
|
||||
print()
|
||||
print('Output is written to input.<version>.pyc for each version successfully compiled')
|
||||
print()
|
||||
print('Version is X.Y (e.g. 3.4), not including the patch version')
|
||||
sys.exit(1)
|
||||
|
||||
RE_PYVER = re.compile(r'\d\.\d')
|
||||
|
||||
pythons = []
|
||||
infile = None
|
||||
use_containers = False
|
||||
for arg in sys.argv[1:]:
|
||||
if RE_PYVER.match(arg):
|
||||
if arg in PYVERS.keys():
|
||||
pythons.append(arg)
|
||||
else:
|
||||
print('Unknown Python version: {}'.format(arg))
|
||||
sys.exit(1)
|
||||
elif arg == '-c':
|
||||
use_containers = True
|
||||
elif arg.startswith('-'):
|
||||
print("WARNING: Unrecognized argument '{}'".format(arg))
|
||||
else:
|
||||
infile = arg
|
||||
|
||||
if infile is None:
|
||||
print('No input file specified')
|
||||
sys.exit(1)
|
||||
elif not os.path.exists(infile):
|
||||
print('Error: Input file {} does not exist'.format(infile))
|
||||
sys.exit(1)
|
||||
|
||||
if len(pythons) == 0:
|
||||
print('At least one Python version is required')
|
||||
sys.exit(1)
|
||||
|
||||
snekdir = os.path.dirname(os.path.realpath(__file__))
|
||||
result = 0
|
||||
for ver in pythons:
|
||||
compile_with_container = use_containers
|
||||
if use_containers and ver not in PYVER_CONTAINERS:
|
||||
print('Warning: No officially supported container for {} - using locally built one'.format(ver))
|
||||
|
||||
outfile = None
|
||||
if compile_with_container:
|
||||
outfile = container_compile(snekdir, ver, infile)
|
||||
else:
|
||||
outfile = local_compile(snekdir, ver, infile)
|
||||
|
||||
if outfile is None or not os.path.exists(outfile):
|
||||
result = 1
|
||||
|
||||
sys.exit(result)
|
||||
40
pycdc/scripts/python-builds/Python-1.0.1.patch
Normal file
40
pycdc/scripts/python-builds/Python-1.0.1.patch
Normal file
@@ -0,0 +1,40 @@
|
||||
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
|
||||
index e79a671..b1bd74e 100644
|
||||
--- a/Objects/fileobject.c
|
||||
+++ b/Objects/fileobject.c
|
||||
@@ -336,7 +336,7 @@ file_read(f, args)
|
||||
*/
|
||||
|
||||
static object *
|
||||
-getline(f, n)
|
||||
+_py_getline(f, n)
|
||||
fileobject *f;
|
||||
int n;
|
||||
{
|
||||
@@ -458,7 +458,7 @@ filegetline(f, n)
|
||||
}
|
||||
if (((fileobject*)f)->f_fp == NULL)
|
||||
return err_closed();
|
||||
- return getline((fileobject *)f, n);
|
||||
+ return _py_getline((fileobject *)f, n);
|
||||
}
|
||||
|
||||
/* Python method */
|
||||
@@ -483,7 +483,7 @@ file_readline(f, args)
|
||||
}
|
||||
}
|
||||
|
||||
- return getline(f, n);
|
||||
+ return _py_getline(f, n);
|
||||
}
|
||||
|
||||
static object *
|
||||
@@ -501,7 +501,7 @@ file_readlines(f, args)
|
||||
if ((list = newlistobject(0)) == NULL)
|
||||
return NULL;
|
||||
for (;;) {
|
||||
- line = getline(f, 0);
|
||||
+ line = _py_getline(f, 0);
|
||||
if (line != NULL && getstringsize(line) == 0) {
|
||||
DECREF(line);
|
||||
break;
|
||||
8870
pycdc/scripts/python-builds/Python-1.1.patch
Normal file
8870
pycdc/scripts/python-builds/Python-1.1.patch
Normal file
File diff suppressed because it is too large
Load Diff
9008
pycdc/scripts/python-builds/Python-1.2.patch
Normal file
9008
pycdc/scripts/python-builds/Python-1.2.patch
Normal file
File diff suppressed because it is too large
Load Diff
8910
pycdc/scripts/python-builds/Python-1.3.patch
Normal file
8910
pycdc/scripts/python-builds/Python-1.3.patch
Normal file
File diff suppressed because it is too large
Load Diff
9594
pycdc/scripts/python-builds/Python-1.4.patch
Normal file
9594
pycdc/scripts/python-builds/Python-1.4.patch
Normal file
File diff suppressed because it is too large
Load Diff
40
pycdc/scripts/python-builds/Python-1.5.2.patch
Normal file
40
pycdc/scripts/python-builds/Python-1.5.2.patch
Normal file
@@ -0,0 +1,40 @@
|
||||
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
|
||||
index b0eb332..e1aa559 100644
|
||||
--- a/Objects/fileobject.c
|
||||
+++ b/Objects/fileobject.c
|
||||
@@ -587,7 +587,7 @@ file_readinto(f, args)
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
-getline(f, n)
|
||||
+_py_getline(f, n)
|
||||
PyFileObject *f;
|
||||
int n;
|
||||
{
|
||||
@@ -709,7 +709,7 @@ PyFile_GetLine(f, n)
|
||||
}
|
||||
if (((PyFileObject*)f)->f_fp == NULL)
|
||||
return err_closed();
|
||||
- return getline((PyFileObject *)f, n);
|
||||
+ return _py_getline((PyFileObject *)f, n);
|
||||
}
|
||||
|
||||
/* Python method */
|
||||
@@ -729,7 +729,7 @@ file_readline(f, args)
|
||||
return PyString_FromString("");
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
- return getline(f, n);
|
||||
+ return _py_getline(f, n);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
@@ -823,7 +823,7 @@ file_readlines(f, args)
|
||||
goto error;
|
||||
if (sizehint > 0) {
|
||||
/* Need to complete the last line */
|
||||
- PyObject *rest = getline(f, 0);
|
||||
+ PyObject *rest = _py_getline(f, 0);
|
||||
if (rest == NULL) {
|
||||
Py_DECREF(line);
|
||||
goto error;
|
||||
34
pycdc/scripts/python-builds/Python-2.3.7.patch
Normal file
34
pycdc/scripts/python-builds/Python-2.3.7.patch
Normal file
@@ -0,0 +1,34 @@
|
||||
diff -rupN a/Include/objimpl.h b/Include/objimpl.h
|
||||
--- a/Include/objimpl.h 2003-04-17 10:29:22.000000000 -0700
|
||||
+++ b/Include/objimpl.h 2019-09-30 15:42:32.012660303 -0700
|
||||
@@ -245,6 +245,20 @@ PyAPI_FUNC(PyVarObject *) _PyObject_GC_R
|
||||
/* for source compatibility with 2.2 */
|
||||
#define _PyObject_GC_Del PyObject_GC_Del
|
||||
|
||||
+/*
|
||||
+ * Former over-aligned definition of PyGC_Head, used to compute the size of the
|
||||
+ * padding for the new version below.
|
||||
+ */
|
||||
+union _gc_head;
|
||||
+union _gc_head_old {
|
||||
+ struct {
|
||||
+ union _gc_head_old *gc_next;
|
||||
+ union _gc_head_old *gc_prev;
|
||||
+ int gc_refs;
|
||||
+ } gc;
|
||||
+ long double dummy;
|
||||
+};
|
||||
+
|
||||
/* GC information is stored BEFORE the object structure. */
|
||||
typedef union _gc_head {
|
||||
struct {
|
||||
@@ -252,7 +266,8 @@ typedef union _gc_head {
|
||||
union _gc_head *gc_prev;
|
||||
int gc_refs;
|
||||
} gc;
|
||||
- long double dummy; /* force worst-case alignment */
|
||||
+ double dummy; /* Force at least 8-byte alignment. */
|
||||
+ char dummy_padding[sizeof(union _gc_head_old)];
|
||||
} PyGC_Head;
|
||||
|
||||
extern PyGC_Head *_PyGC_generation0;
|
||||
34
pycdc/scripts/python-builds/Python-2.4.6.patch
Normal file
34
pycdc/scripts/python-builds/Python-2.4.6.patch
Normal file
@@ -0,0 +1,34 @@
|
||||
diff -rupN a/Include/objimpl.h b/Include/objimpl.h
|
||||
--- a/Include/objimpl.h 2003-04-17 10:29:22.000000000 -0700
|
||||
+++ b/Include/objimpl.h 2019-09-30 15:42:32.012660303 -0700
|
||||
@@ -245,6 +245,20 @@ PyAPI_FUNC(PyVarObject *) _PyObject_GC_R
|
||||
/* for source compatibility with 2.2 */
|
||||
#define _PyObject_GC_Del PyObject_GC_Del
|
||||
|
||||
+/*
|
||||
+ * Former over-aligned definition of PyGC_Head, used to compute the size of the
|
||||
+ * padding for the new version below.
|
||||
+ */
|
||||
+union _gc_head;
|
||||
+union _gc_head_old {
|
||||
+ struct {
|
||||
+ union _gc_head_old *gc_next;
|
||||
+ union _gc_head_old *gc_prev;
|
||||
+ int gc_refs;
|
||||
+ } gc;
|
||||
+ long double dummy;
|
||||
+};
|
||||
+
|
||||
/* GC information is stored BEFORE the object structure. */
|
||||
typedef union _gc_head {
|
||||
struct {
|
||||
@@ -252,7 +266,8 @@ typedef union _gc_head {
|
||||
union _gc_head *gc_prev;
|
||||
int gc_refs;
|
||||
} gc;
|
||||
- long double dummy; /* force worst-case alignment */
|
||||
+ double dummy; /* Force at least 8-byte alignment. */
|
||||
+ char dummy_padding[sizeof(union _gc_head_old)];
|
||||
} PyGC_Head;
|
||||
|
||||
extern PyGC_Head *_PyGC_generation0;
|
||||
83
pycdc/scripts/python-builds/Python-2.5.6.patch
Normal file
83
pycdc/scripts/python-builds/Python-2.5.6.patch
Normal file
@@ -0,0 +1,83 @@
|
||||
diff -rupN a/Include/objimpl.h b/Include/objimpl.h
|
||||
--- a/Include/objimpl.h 2006-04-14 20:22:46.000000000 -0700
|
||||
+++ b/Include/objimpl.h 2019-09-30 15:52:15.197269278 -0700
|
||||
@@ -241,6 +241,20 @@ PyAPI_FUNC(PyVarObject *) _PyObject_GC_R
|
||||
/* for source compatibility with 2.2 */
|
||||
#define _PyObject_GC_Del PyObject_GC_Del
|
||||
|
||||
+/*
|
||||
+ * Former over-aligned definition of PyGC_Head, used to compute the size of the
|
||||
+ * padding for the new version below.
|
||||
+ */
|
||||
+union _gc_head;
|
||||
+union _gc_head_old {
|
||||
+ struct {
|
||||
+ union _gc_head_old *gc_next;
|
||||
+ union _gc_head_old *gc_prev;
|
||||
+ Py_ssize_t gc_refs;
|
||||
+ } gc;
|
||||
+ long double dummy;
|
||||
+};
|
||||
+
|
||||
/* GC information is stored BEFORE the object structure. */
|
||||
typedef union _gc_head {
|
||||
struct {
|
||||
@@ -248,7 +262,8 @@ typedef union _gc_head {
|
||||
union _gc_head *gc_prev;
|
||||
Py_ssize_t gc_refs;
|
||||
} gc;
|
||||
- long double dummy; /* force worst-case alignment */
|
||||
+ double dummy; /* Force at least 8-byte alignment. */
|
||||
+ char dummy_padding[sizeof(union _gc_head_old)];
|
||||
} PyGC_Head;
|
||||
|
||||
extern PyGC_Head *_PyGC_generation0;
|
||||
diff -rupN a/Makefile.pre.in b/Makefile.pre.in
|
||||
--- a/Makefile.pre.in 2008-09-21 17:22:44.000000000 -0700
|
||||
+++ b/Makefile.pre.in 2019-09-30 15:50:47.804578897 -0700
|
||||
@@ -458,7 +458,7 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \
|
||||
$(SIGNAL_OBJS) \
|
||||
$(MODOBJS) \
|
||||
$(srcdir)/Modules/getbuildinfo.c
|
||||
- $(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c
|
||||
+ $(CC) -c $(PY_CFLAGS) -DSVNVERSION="\"`LC_ALL=C $(SVNVERSION)`\"" -o $@ $(srcdir)/Modules/getbuildinfo.c
|
||||
|
||||
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
|
||||
$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
|
||||
diff -rupN a/setup.py b/setup.py
|
||||
--- a/setup.py 2008-10-16 11:58:19.000000000 -0700
|
||||
+++ b/setup.py 2019-09-30 15:50:47.808578930 -0700
|
||||
@@ -296,7 +296,8 @@ class PyBuildExt(build_ext):
|
||||
# if a file is found in one of those directories, it can
|
||||
# be assumed that no additional -I,-L directives are needed.
|
||||
lib_dirs = self.compiler.library_dirs + [
|
||||
- '/lib64', '/usr/lib64',
|
||||
+ '/usr/lib/x86_64-linux-gnu',
|
||||
+ '/lib/x86_64-linux-gnu',
|
||||
'/lib', '/usr/lib',
|
||||
]
|
||||
inc_dirs = self.compiler.include_dirs + ['/usr/include']
|
||||
@@ -711,9 +712,9 @@ class PyBuildExt(build_ext):
|
||||
|
||||
# check lib directories parallel to the location of the header
|
||||
db_dirs_to_check = [
|
||||
- os.path.join(db_incdir, '..', 'lib64'),
|
||||
+ os.path.join(db_incdir, '..', 'lib/x86_64-linux-gnu'),
|
||||
os.path.join(db_incdir, '..', 'lib'),
|
||||
- os.path.join(db_incdir, '..', '..', 'lib64'),
|
||||
+ os.path.join(db_incdir, '..', '..', 'lib/x86_64-linux-gnu'),
|
||||
os.path.join(db_incdir, '..', '..', 'lib'),
|
||||
]
|
||||
db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check)
|
||||
@@ -800,9 +801,9 @@ class PyBuildExt(build_ext):
|
||||
|
||||
if sqlite_incdir:
|
||||
sqlite_dirs_to_check = [
|
||||
- os.path.join(sqlite_incdir, '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', 'lib/x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', 'lib'),
|
||||
- os.path.join(sqlite_incdir, '..', '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', '..', 'lib/x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', '..', 'lib'),
|
||||
]
|
||||
sqlite_libfile = self.compiler.find_library_file(
|
||||
68
pycdc/scripts/python-builds/Python-2.6.9.patch
Normal file
68
pycdc/scripts/python-builds/Python-2.6.9.patch
Normal file
@@ -0,0 +1,68 @@
|
||||
diff -rupN a/Include/objimpl.h b/Include/objimpl.h
|
||||
--- a/Include/objimpl.h 2013-10-29 08:04:37.000000000 -0700
|
||||
+++ b/Include/objimpl.h 2019-09-30 16:18:58.318197021 -0700
|
||||
@@ -241,6 +241,20 @@ PyAPI_FUNC(PyVarObject *) _PyObject_GC_R
|
||||
/* for source compatibility with 2.2 */
|
||||
#define _PyObject_GC_Del PyObject_GC_Del
|
||||
|
||||
+/*
|
||||
+ * Former over-aligned definition of PyGC_Head, used to compute the size of the
|
||||
+ * padding for the new version below.
|
||||
+ */
|
||||
+union _gc_head;
|
||||
+union _gc_head_old {
|
||||
+ struct {
|
||||
+ union _gc_head_old *gc_next;
|
||||
+ union _gc_head_old *gc_prev;
|
||||
+ Py_ssize_t gc_refs;
|
||||
+ } gc;
|
||||
+ long double dummy;
|
||||
+};
|
||||
+
|
||||
/* GC information is stored BEFORE the object structure. */
|
||||
typedef union _gc_head {
|
||||
struct {
|
||||
@@ -248,7 +262,8 @@ typedef union _gc_head {
|
||||
union _gc_head *gc_prev;
|
||||
Py_ssize_t gc_refs;
|
||||
} gc;
|
||||
- long double dummy; /* force worst-case alignment */
|
||||
+ double dummy; /* Force at least 8-byte alignment. */
|
||||
+ char dummy_padding[sizeof(union _gc_head_old)];
|
||||
} PyGC_Head;
|
||||
|
||||
extern PyGC_Head *_PyGC_generation0;
|
||||
diff -rupN a/setup.py b/setup.py
|
||||
--- a/setup.py 2013-10-29 08:04:39.000000000 -0700
|
||||
+++ b/setup.py 2019-09-30 16:19:09.146284481 -0700
|
||||
@@ -408,7 +408,8 @@ class PyBuildExt(build_ext):
|
||||
# if a file is found in one of those directories, it can
|
||||
# be assumed that no additional -I,-L directives are needed.
|
||||
lib_dirs = self.compiler.library_dirs + [
|
||||
- '/lib64', '/usr/lib64',
|
||||
+ '/usr/lib/x86_64-linux-gnu',
|
||||
+ '/lib/x86_64-linux-gnu',
|
||||
'/lib', '/usr/lib',
|
||||
]
|
||||
inc_dirs = self.compiler.include_dirs + ['/usr/include']
|
||||
@@ -922,7 +923,7 @@ class PyBuildExt(build_ext):
|
||||
|
||||
# check lib directories parallel to the location of the header
|
||||
db_dirs_to_check = [
|
||||
- db_incdir.replace("include", 'lib64'),
|
||||
+ db_incdir.replace("include", 'lib/x86_64-linux-gnu'),
|
||||
db_incdir.replace("include", 'lib'),
|
||||
]
|
||||
|
||||
@@ -1034,9 +1035,9 @@ class PyBuildExt(build_ext):
|
||||
|
||||
if sqlite_incdir:
|
||||
sqlite_dirs_to_check = [
|
||||
- os.path.join(sqlite_incdir, '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', 'lib', 'x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', 'lib'),
|
||||
- os.path.join(sqlite_incdir, '..', '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', '..', 'lib', 'x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', '..', 'lib'),
|
||||
]
|
||||
sqlite_libfile = self.compiler.find_library_file(
|
||||
39
pycdc/scripts/python-builds/Python-3.0.1.patch
Normal file
39
pycdc/scripts/python-builds/Python-3.0.1.patch
Normal file
@@ -0,0 +1,39 @@
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index 4485a81..54a7e8d 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -499,7 +499,7 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \
|
||||
$(SIGNAL_OBJS) \
|
||||
$(MODOBJS) \
|
||||
$(srcdir)/Modules/getbuildinfo.c
|
||||
- $(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c
|
||||
+ $(CC) -c $(PY_CFLAGS) -DSVNVERSION="\"`LC_ALL=C $(SVNVERSION)`\"" -o $@ $(srcdir)/Modules/getbuildinfo.c
|
||||
|
||||
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
|
||||
$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
|
||||
diff --git a/setup.py b/setup.py
|
||||
index e1d5984..9051d09 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -357,7 +357,8 @@ class PyBuildExt(build_ext):
|
||||
# if a file is found in one of those directories, it can
|
||||
# be assumed that no additional -I,-L directives are needed.
|
||||
lib_dirs = self.compiler.library_dirs + [
|
||||
- '/lib64', '/usr/lib64',
|
||||
+ '/lib/x86_64-linux-gnu',
|
||||
+ '/usr/lib/x86_64-linux-gnu',
|
||||
'/lib', '/usr/lib',
|
||||
]
|
||||
inc_dirs = self.compiler.include_dirs + ['/usr/include']
|
||||
@@ -725,9 +726,9 @@ class PyBuildExt(build_ext):
|
||||
|
||||
if sqlite_incdir:
|
||||
sqlite_dirs_to_check = [
|
||||
- os.path.join(sqlite_incdir, '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', 'lib', 'x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', 'lib'),
|
||||
- os.path.join(sqlite_incdir, '..', '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', '..', 'lib', 'x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', '..', 'lib'),
|
||||
]
|
||||
sqlite_libfile = self.compiler.find_library_file(
|
||||
16
pycdc/scripts/python-builds/Python-3.1.5.patch
Normal file
16
pycdc/scripts/python-builds/Python-3.1.5.patch
Normal file
@@ -0,0 +1,16 @@
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index e01cd2745a..dcf465e30e 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -817,6 +817,11 @@ bininstall: altbininstall
|
||||
else true; \
|
||||
fi
|
||||
(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON)3$(EXE))
|
||||
+ -if test -f $(DESTDIR)$(BINDIR)/$(PYTHON)$(EXE) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON)$(EXE); \
|
||||
+ then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON)$(EXE); \
|
||||
+ else true; \
|
||||
+ fi
|
||||
+ (cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON)$(EXE))
|
||||
-rm -f $(DESTDIR)$(BINDIR)/python3-config
|
||||
(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python3-config)
|
||||
-rm -f $(DESTDIR)$(LIBPC)/python3.pc
|
||||
270
pycdc/scripts/token_dump
Normal file
270
pycdc/scripts/token_dump
Normal file
@@ -0,0 +1,270 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Compare two python source files by tokens, ignoring whitespace (other than
|
||||
# indentation) and comments
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
|
||||
class PyToken:
|
||||
INDENT = 1
|
||||
OUTDENT = 2
|
||||
ENDLINE = 3
|
||||
WORD = 100
|
||||
INT = 101
|
||||
FLOAT = 102
|
||||
STRING = 103
|
||||
|
||||
def __init__(self, type, n_line):
|
||||
self.type = type
|
||||
self.n_line = n_line
|
||||
|
||||
def __str__(self):
|
||||
if self.type == PyToken.INDENT:
|
||||
return '<INDENT>'
|
||||
if self.type == PyToken.OUTDENT:
|
||||
return '<OUTDENT>'
|
||||
if self.type == PyToken.ENDLINE:
|
||||
return '<EOL>'
|
||||
return str(self.type)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.type == other.type
|
||||
|
||||
|
||||
class WordToken(PyToken):
|
||||
# We don't need to distinguish between keywords and other words, so
|
||||
# we just lump them together in a single token type...
|
||||
def __init__(self, word, n_line):
|
||||
super().__init__(PyToken.WORD, n_line)
|
||||
self.word = word
|
||||
|
||||
def __str__(self):
|
||||
return self.word
|
||||
|
||||
def __eq__(self, other):
|
||||
if not super().__eq__(other):
|
||||
return False
|
||||
return self.word == other.word
|
||||
|
||||
|
||||
class IntToken(PyToken):
|
||||
def __init__(self, value, n_line):
|
||||
super().__init__(PyToken.INT, n_line)
|
||||
try:
|
||||
self.value = int(value.replace('_', ''), 0)
|
||||
except ValueError:
|
||||
# Support Python 2.x octal literals
|
||||
if value.startswith('0'):
|
||||
self.value = int(value.replace('_', ''), 8)
|
||||
else:
|
||||
raise
|
||||
|
||||
def __str__(self):
|
||||
return str(self.value)
|
||||
|
||||
def __eq__(self, other):
|
||||
if not super().__eq__(other):
|
||||
return False
|
||||
return self.value == other.value
|
||||
|
||||
|
||||
class FloatToken(PyToken):
|
||||
def __init__(self, value, n_line):
|
||||
super().__init__(PyToken.FLOAT, n_line)
|
||||
self.value = float(value.replace('_', ''))
|
||||
|
||||
def __str__(self):
|
||||
return str(self.value)
|
||||
|
||||
def __eq__(self, other):
|
||||
if not super().__eq__(other):
|
||||
return False
|
||||
# TODO: Might need some fuzz
|
||||
return self.value == other.value
|
||||
|
||||
|
||||
class StringToken(PyToken):
|
||||
def __init__(self, prefix, content, n_line):
|
||||
super().__init__(PyToken.STRING, n_line)
|
||||
|
||||
# Normalize prefix for comparison
|
||||
self.prefix = ''.join(sorted(prefix.lower()))
|
||||
|
||||
# Normalize special characters for comparison
|
||||
self.content = content.replace("\\'", "'").replace("'", "\\'") \
|
||||
.replace('\\"', '"').replace('\t', '\\t') \
|
||||
.replace('\n', '\\n').replace('\r', '\\r')
|
||||
|
||||
def __str__(self):
|
||||
return "{}'{}'".format(self.prefix, self.content)
|
||||
|
||||
def __eq__(self, other):
|
||||
if not super().__eq__(other):
|
||||
return False
|
||||
return self.prefix == other.prefix and self.content == other.content
|
||||
|
||||
|
||||
RE_WHITESPACE = re.compile(r'\s+')
|
||||
RE_WORD = re.compile(r'[A-Za-z_][A-Za-z0-9_]*')
|
||||
RE_INT = re.compile(r'[0-9][0-9_]*|0[Xx][0-9A-Fa-f_]+|0[Bb][0-1_]+|0[Oo][0-7_]+')
|
||||
RE_FLOAT = re.compile(r'(([0-9][0-9_]*)?\.[0-9][0-9_]*|[0-9][0-9_]*\.)([eE][+-]?[0-9][0-9_]*)?')
|
||||
RE_START_STRING = re.compile(r'([rR][fFbB]?|[uU]|[fF][rR]?|[bB][rR]?)?(\'\'\'|\'|"""|")')
|
||||
|
||||
# Note, tokens sharing a common prefix should be entered in order from
|
||||
# longest to shortest, so we don't mismatch a long token as a sequence
|
||||
# of shorter tokens
|
||||
SYMBOLIC_TOKENS = (
|
||||
'<<=', '>>=', '**=', '//=', '...', '.',
|
||||
'+=', '-=', '*=', '@=', '/=', '%=', '&=', '|=', '^=',
|
||||
'<>', '<<', '<=', '<', '>>', '>=', '>', '!=', '==', '=',
|
||||
',', ';', ':=', ':', '->', '~', '`',
|
||||
'+', '-', '**', '*', '@', '//', '/', '%', '&', '|', '^',
|
||||
'(', ')', '{', '}', '[', ']',
|
||||
)
|
||||
def symbolic_token(line, n_line):
|
||||
for tok in SYMBOLIC_TOKENS:
|
||||
if line.startswith(tok):
|
||||
return PyToken(tok, n_line)
|
||||
return None
|
||||
|
||||
|
||||
def string_token(line, n_line, pysrc):
|
||||
match = RE_START_STRING.match(line)
|
||||
if not match:
|
||||
return None
|
||||
|
||||
# Look for the end of the string
|
||||
prefix = match.group(1)
|
||||
if prefix is None:
|
||||
prefix = ''
|
||||
quotes = match.group(2)
|
||||
start = len(prefix) + len(quotes)
|
||||
content = ''
|
||||
while True:
|
||||
end = line.find(quotes, start)
|
||||
if end > 0 and line[end - 1] == '\\':
|
||||
content += line[start:end + 1]
|
||||
start = end + 1
|
||||
continue
|
||||
elif end >= 0:
|
||||
content += line[start:end]
|
||||
break
|
||||
|
||||
# Read in a new line
|
||||
content += line[start:]
|
||||
line = pysrc.readline()
|
||||
n_line += 1
|
||||
start = 0
|
||||
if not line:
|
||||
raise RuntimeError('Reached EOF while looking for {}'.format(repr(quotes)))
|
||||
|
||||
token = StringToken(prefix, content, n_line)
|
||||
token.rem_line = line[end + len(quotes):]
|
||||
token.end_line = n_line
|
||||
return token
|
||||
|
||||
|
||||
def read_tokens(pysrc):
|
||||
indent_stack = [0]
|
||||
context_stack = []
|
||||
n_line = 0
|
||||
|
||||
while True:
|
||||
line = pysrc.readline()
|
||||
n_line += 1
|
||||
if not line:
|
||||
break
|
||||
|
||||
if not line.strip() or line.lstrip().startswith('#'):
|
||||
continue
|
||||
|
||||
# Look for indentation changes
|
||||
if len(context_stack) == 0:
|
||||
indent = len(line) - len(line.lstrip())
|
||||
if indent > indent_stack[-1]:
|
||||
indent_stack.append(indent)
|
||||
yield PyToken(PyToken.INDENT, n_line)
|
||||
while indent < indent_stack[-1]:
|
||||
indent_stack.pop()
|
||||
yield PyToken(PyToken.OUTDENT, n_line)
|
||||
if indent != indent_stack[-1]:
|
||||
raise RuntimeError('Incorrect indentation on line {}'.format(n_line))
|
||||
|
||||
while True:
|
||||
line = line.lstrip()
|
||||
if not line:
|
||||
break
|
||||
if line[0] == '#':
|
||||
# The rest of this line is a comment
|
||||
break
|
||||
|
||||
token = symbolic_token(line, n_line)
|
||||
if token:
|
||||
if token.type in {'(', '{', '['}:
|
||||
context_stack.append(token.type)
|
||||
elif token.type == ')':
|
||||
if len(context_stack) == 0 or context_stack[-1] != '(':
|
||||
raise RuntimeError('Mismatched token at {} on line {}'.format(line, n_line))
|
||||
context_stack.pop()
|
||||
elif token.type == '}':
|
||||
if len(context_stack) == 0 or context_stack[-1] != '{':
|
||||
raise RuntimeError('Mismatched token at {} on line {}'.format(line, n_line))
|
||||
context_stack.pop()
|
||||
elif token.type == ']':
|
||||
if len(context_stack) == 0 or context_stack[-1] != '[':
|
||||
raise RuntimeError('Mismatched token at {} on line {}'.format(line, n_line))
|
||||
context_stack.pop()
|
||||
yield token
|
||||
line = line[len(token.type):]
|
||||
continue
|
||||
|
||||
match = RE_FLOAT.match(line)
|
||||
if match:
|
||||
yield FloatToken(match.group(), n_line)
|
||||
line = line[match.end():]
|
||||
continue
|
||||
|
||||
match = RE_INT.match(line)
|
||||
if match:
|
||||
yield IntToken(match.group(), n_line)
|
||||
line = line[match.end():]
|
||||
continue
|
||||
|
||||
token = string_token(line, n_line, pysrc)
|
||||
if token:
|
||||
line = token.rem_line
|
||||
n_line = token.end_line
|
||||
yield token
|
||||
continue
|
||||
|
||||
match = RE_WORD.match(line)
|
||||
if match:
|
||||
yield WordToken(match.group(), n_line)
|
||||
line = line[match.end():]
|
||||
continue
|
||||
|
||||
raise RuntimeError('Error: Unrecognized tokens: "{}" at line {}'.format(line, n_line))
|
||||
|
||||
if len(context_stack) == 0:
|
||||
yield PyToken(PyToken.ENDLINE, n_line)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if '--help' in sys.argv:
|
||||
print('Usage: token_dump <file>.py')
|
||||
sys.exit(0)
|
||||
|
||||
if len(sys.argv) >= 2:
|
||||
pysrc = open(sys.argv[1], 'r')
|
||||
else:
|
||||
pysrc = sys.stdin
|
||||
|
||||
for tok in read_tokens(pysrc):
|
||||
if tok.type in {PyToken.ENDLINE, PyToken.INDENT, PyToken.OUTDENT}:
|
||||
print(tok)
|
||||
else:
|
||||
print(tok, end=' ')
|
||||
|
||||
pysrc.close()
|
||||
BIN
pycdc/tests/compiled/GEN_START.3.10.pyc
Normal file
BIN
pycdc/tests/compiled/GEN_START.3.10.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/async_def.3.5.pyc
Normal file
BIN
pycdc/tests/compiled/async_def.3.5.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/async_for.3.7.pyc
Normal file
BIN
pycdc/tests/compiled/async_for.3.7.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/binary_ops.3.11.pyc
Normal file
BIN
pycdc/tests/compiled/binary_ops.3.11.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/binary_slice.3.12.pyc
Normal file
BIN
pycdc/tests/compiled/binary_slice.3.12.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/build_const_key_map.2.7.pyc
Normal file
BIN
pycdc/tests/compiled/build_const_key_map.2.7.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/build_const_key_map.3.8.pyc
Normal file
BIN
pycdc/tests/compiled/build_const_key_map.3.8.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/chain_assignment.2.7.pyc
Normal file
BIN
pycdc/tests/compiled/chain_assignment.2.7.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/chain_assignment.3.7.pyc
Normal file
BIN
pycdc/tests/compiled/chain_assignment.3.7.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/class_NODE_BINARY.3.9.pyc
Normal file
BIN
pycdc/tests/compiled/class_NODE_BINARY.3.9.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/conditional_expressions.3.1.pyc
Normal file
BIN
pycdc/tests/compiled/conditional_expressions.3.1.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/conditional_expressions.3.9.pyc
Normal file
BIN
pycdc/tests/compiled/conditional_expressions.3.9.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/conditional_expressions_py2.2.7.pyc
Normal file
BIN
pycdc/tests/compiled/conditional_expressions_py2.2.7.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/contains_op.3.9.pyc
Normal file
BIN
pycdc/tests/compiled/contains_op.3.9.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/f-string.3.7.pyc
Normal file
BIN
pycdc/tests/compiled/f-string.3.7.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/if_elif_else.1.5.pyc
Normal file
BIN
pycdc/tests/compiled/if_elif_else.1.5.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/if_elif_else.2.2.pyc
Normal file
BIN
pycdc/tests/compiled/if_elif_else.2.2.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/if_elif_else.2.6.pyc
Normal file
BIN
pycdc/tests/compiled/if_elif_else.2.6.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/if_elif_else.2.7.pyc
Normal file
BIN
pycdc/tests/compiled/if_elif_else.2.7.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/if_elif_else.3.0.pyc
Normal file
BIN
pycdc/tests/compiled/if_elif_else.3.0.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/if_elif_else.3.7.pyc
Normal file
BIN
pycdc/tests/compiled/if_elif_else.3.7.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/is_op.3.9.pyc
Normal file
BIN
pycdc/tests/compiled/is_op.3.9.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/iter_unpack.2.7.pyc
Normal file
BIN
pycdc/tests/compiled/iter_unpack.2.7.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/lambdas_assignment.2.7.pyc
Normal file
BIN
pycdc/tests/compiled/lambdas_assignment.2.7.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/list_extend.3.9.pyc
Normal file
BIN
pycdc/tests/compiled/list_extend.3.9.pyc
Normal file
Binary file not shown.
BIN
pycdc/tests/compiled/load_classderef.3.4.pyc
Normal file
BIN
pycdc/tests/compiled/load_classderef.3.4.pyc
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user