Skip to content

Commit

Permalink
Add documentation and initial framework for Python 3.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
zrax committed Nov 27, 2013
1 parent ad03ec3 commit 6ecbcfb
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 188 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ BYTES = \
python_10 python_11 python_13 python_14 python_15 python_16 \
python_20 python_21 python_22 python_23 python_24 \
python_25 python_26 python_27 \
python_30 python_31 python_32 python_33
python_30 python_31 python_32 python_33 python_34

BYTE_OBJS = $(BYTES:%=out/%.o)
BYTE_SRCS = $(BYTES:%=bytes/%.cpp)
Expand Down
375 changes: 191 additions & 184 deletions PythonBytecode.txt

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion bytecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ DECLARE_PYTHON(3, 0)
DECLARE_PYTHON(3, 1)
DECLARE_PYTHON(3, 2)
DECLARE_PYTHON(3, 3)
DECLARE_PYTHON(3, 4)

const char* Pyc::OpcodeName(int opcode)
{
Expand Down Expand Up @@ -65,7 +66,7 @@ const char* Pyc::OpcodeName(int opcode)
"POP_JUMP_IF_FALSE", "POP_JUMP_IF_TRUE", "CONTINUE_LOOP", "MAKE_CLOSURE",
"LOAD_CLOSURE", "LOAD_DEREF", "STORE_DEREF", "DELETE_DEREF",
"EXTENDED_ARG", "SETUP_WITH", "SET_ADD", "MAP_ADD", "UNPACK_EX",
"LIST_APPEND"
"LIST_APPEND", "LOAD_CLASSDEREF",
};

if (opcode < 0)
Expand Down Expand Up @@ -110,6 +111,7 @@ int Pyc::ByteToOpcode(int maj, int min, int opcode)
case 1: return python_31_map(opcode);
case 2: return python_32_map(opcode);
case 3: return python_33_map(opcode);
case 4: return python_34_map(opcode);
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion bytecode.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum Opcode {
POP_JUMP_IF_FALSE_A, POP_JUMP_IF_TRUE_A, CONTINUE_LOOP_A, MAKE_CLOSURE_A,
LOAD_CLOSURE_A, LOAD_DEREF_A, STORE_DEREF_A, DELETE_DEREF_A,
EXTENDED_ARG_A, SETUP_WITH_A, SET_ADD_A, MAP_ADD_A, UNPACK_EX_A,
LIST_APPEND_A,
LIST_APPEND_A, LOAD_CLASSDEREF_A,

PYC_LAST_OPCODE,
PYC_INVALID_OPCODE = -1,
Expand Down
2 changes: 1 addition & 1 deletion bytes/comp_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

maplist = [ 10, 11, 13, 14, 15, 16,
20, 21, 22, 23, 24, 25, 26, 27,
30, 31, 32, 33 ]
30, 31, 32, 33, 34 ]

for mapver in maplist:
infile = open('python_%d.map' % mapver, 'rt')
Expand Down
101 changes: 101 additions & 0 deletions bytes/python_34.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
1 POP_TOP
2 ROT_TWO
3 ROT_THREE
4 DUP_TOP
5 DUP_TOP_TWO
9 NOP
10 UNARY_POSITIVE
11 UNARY_NEGATIVE
12 UNARY_NOT
15 UNARY_INVERT
19 BINARY_POWER
20 BINARY_MULTIPLY
22 BINARY_MODULO
23 BINARY_ADD
24 BINARY_SUBTRACT
25 BINARY_SUBSCR
26 BINARY_FLOOR_DIVIDE
27 BINARY_TRUE_DIVIDE
28 INPLACE_FLOOR_DIVIDE
29 INPLACE_TRUE_DIVIDE
54 STORE_MAP
55 INPLACE_ADD
56 INPLACE_SUBTRACT
57 INPLACE_MULTIPLY
59 INPLACE_MODULO
60 STORE_SUBSCR
61 DELETE_SUBSCR
62 BINARY_LSHIFT
63 BINARY_RSHIFT
64 BINARY_AND
65 BINARY_XOR
66 BINARY_OR
67 INPLACE_POWER
68 GET_ITER
70 PRINT_EXPR
71 LOAD_BUILD_CLASS
72 YIELD_FROM
75 INPLACE_LSHIFT
76 INPLACE_RSHIFT
77 INPLACE_AND
78 INPLACE_XOR
79 INPLACE_OR
80 BREAK_LOOP
81 WITH_CLEANUP
83 RETURN_VALUE
84 IMPORT_STAR
86 YIELD_VALUE
87 POP_BLOCK
88 END_FINALLY
89 POP_EXCEPT
90 STORE_NAME_A
91 DELETE_NAME_A
92 UNPACK_SEQUENCE_A
93 FOR_ITER_A
94 UNPACK_EX_A
95 STORE_ATTR_A
96 DELETE_ATTR_A
97 STORE_GLOBAL_A
98 DELETE_GLOBAL_A
100 LOAD_CONST_A
101 LOAD_NAME_A
102 BUILD_TUPLE_A
103 BUILD_LIST_A
104 BUILD_SET_A
105 BUILD_MAP_A
106 LOAD_ATTR_A
107 COMPARE_OP_A
108 IMPORT_NAME_A
109 IMPORT_FROM_A
110 JUMP_FORWARD_A
111 JUMP_IF_FALSE_OR_POP_A
112 JUMP_IF_TRUE_OR_POP_A
113 JUMP_ABSOLUTE_A
114 POP_JUMP_IF_FALSE_A
115 POP_JUMP_IF_TRUE_A
116 LOAD_GLOBAL_A
119 CONTINUE_LOOP_A
120 SETUP_LOOP_A
121 SETUP_EXCEPT_A
122 SETUP_FINALLY_A
124 LOAD_FAST_A
125 STORE_FAST_A
126 DELETE_FAST_A
130 RAISE_VARARGS_A
131 CALL_FUNCTION_A
132 MAKE_FUNCTION_A
133 BUILD_SLICE_A
134 MAKE_CLOSURE_A
135 LOAD_CLOSURE_A
136 LOAD_DEREF_A
137 STORE_DEREF_A
138 DELETE_DEREF_A
140 CALL_FUNCTION_VAR_A
141 CALL_FUNCTION_KW_A
142 CALL_FUNCTION_VAR_KW_A
143 SETUP_WITH_A
144 EXTENDED_ARG_A
145 LIST_APPEND_A
146 SET_ADD_A
147 MAP_ADD_A
148 LOAD_CLASSDEREF_A
6 changes: 6 additions & 0 deletions pyc_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ void PycModule::setVersion(unsigned int magic)
m_unicode = true;
break;

case MAGIC_3_4:
m_maj = 3;
m_min = 4;
m_unicode = true;
break;

/* Bad Magic detected */
default:
m_maj = -1;
Expand Down
1 change: 1 addition & 0 deletions pyc_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum PycMagic {
MAGIC_3_1 = 0x0A0D0C4E,
MAGIC_3_2 = 0x0A0D0C6C,
MAGIC_3_3 = 0x0A0D0C9E,
MAGIC_3_4 = 0x0A0D0CE4,
};

#define PYC_VERSION(maj, min) MAGIC_##maj##_##min
Expand Down

0 comments on commit 6ecbcfb

Please sign in to comment.