depyo 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +97 -0
- package/depyo.js +213 -0
- package/lib/BinaryReader.js +153 -0
- package/lib/OpCode.js +90 -0
- package/lib/OpCodes.js +940 -0
- package/lib/PycDecompiler.js +2031 -0
- package/lib/PycDisassembler.js +55 -0
- package/lib/PycReader.js +905 -0
- package/lib/PycResult.js +82 -0
- package/lib/PythonObject.js +242 -0
- package/lib/Unpickle.js +173 -0
- package/lib/ast/ast_node.js +3442 -0
- package/lib/bytecode/python_1_0.js +116 -0
- package/lib/bytecode/python_1_1.js +116 -0
- package/lib/bytecode/python_1_3.js +119 -0
- package/lib/bytecode/python_1_4.js +121 -0
- package/lib/bytecode/python_1_5.js +120 -0
- package/lib/bytecode/python_1_6.js +124 -0
- package/lib/bytecode/python_2_0.js +137 -0
- package/lib/bytecode/python_2_1.js +142 -0
- package/lib/bytecode/python_2_2.js +147 -0
- package/lib/bytecode/python_2_3.js +145 -0
- package/lib/bytecode/python_2_4.js +147 -0
- package/lib/bytecode/python_2_5.js +147 -0
- package/lib/bytecode/python_2_6.js +147 -0
- package/lib/bytecode/python_2_7.js +151 -0
- package/lib/bytecode/python_3_0.js +132 -0
- package/lib/bytecode/python_3_1.js +135 -0
- package/lib/bytecode/python_3_10.js +312 -0
- package/lib/bytecode/python_3_11.js +284 -0
- package/lib/bytecode/python_3_12.js +327 -0
- package/lib/bytecode/python_3_13.js +173 -0
- package/lib/bytecode/python_3_14.js +177 -0
- package/lib/bytecode/python_3_2.js +136 -0
- package/lib/bytecode/python_3_3.js +136 -0
- package/lib/bytecode/python_3_4.js +137 -0
- package/lib/bytecode/python_3_5.js +149 -0
- package/lib/bytecode/python_3_6.js +153 -0
- package/lib/bytecode/python_3_7.js +292 -0
- package/lib/bytecode/python_3_8.js +294 -0
- package/lib/bytecode/python_3_9.js +296 -0
- package/lib/code_reader.js +146 -0
- package/lib/handlers/binary_ops.js +174 -0
- package/lib/handlers/collections_update.js +239 -0
- package/lib/handlers/comparisons.js +95 -0
- package/lib/handlers/context_managers.js +250 -0
- package/lib/handlers/control_flow_jumps.js +954 -0
- package/lib/handlers/exceptions_blocks.js +952 -0
- package/lib/handlers/formatting.js +31 -0
- package/lib/handlers/function_calls.js +496 -0
- package/lib/handlers/function_class_build.js +330 -0
- package/lib/handlers/generators_async.js +172 -0
- package/lib/handlers/imports.js +53 -0
- package/lib/handlers/load_store_names.js +711 -0
- package/lib/handlers/loop_iterator.js +318 -0
- package/lib/handlers/misc_other.js +1201 -0
- package/lib/handlers/pattern_matching.js +226 -0
- package/lib/handlers/stack_ops.js +280 -0
- package/lib/handlers/subscript_slice.js +394 -0
- package/lib/handlers/unary_ops.js +91 -0
- package/lib/handlers/unpack.js +141 -0
- package/lib/stack_history.js +63 -0
- package/lib/zip_reader.js +217 -0
- package/package.json +35 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const OpCode = require('../OpCode');
|
|
2
|
+
const OpCodes = require('../OpCodes');
|
|
3
|
+
|
|
4
|
+
const opcodes = [
|
|
5
|
+
[0, new OpCode(OpCodes.STOP_CODE, "STOP_CODE")],
|
|
6
|
+
[1, new OpCode(OpCodes.POP_TOP, "POP_TOP")],
|
|
7
|
+
[2, new OpCode(OpCodes.ROT_TWO, "ROT_TWO")],
|
|
8
|
+
[3, new OpCode(OpCodes.ROT_THREE, "ROT_THREE")],
|
|
9
|
+
[4, new OpCode(OpCodes.DUP_TOP, "DUP_TOP"),],
|
|
10
|
+
|
|
11
|
+
[10, new OpCode(OpCodes.UNARY_POSITIVE, "UNARY_POSITIVE")],
|
|
12
|
+
[11, new OpCode(OpCodes.UNARY_NEGATIVE, "UNARY_NEGATIVE")],
|
|
13
|
+
[12, new OpCode(OpCodes.UNARY_NOT, "UNARY_NOT")],
|
|
14
|
+
[13, new OpCode(OpCodes.UNARY_CONVERT, "UNARY_CONVERT")],
|
|
15
|
+
[14, new OpCode(OpCodes.UNARY_CALL, "UNARY_CALL")],
|
|
16
|
+
[15, new OpCode(OpCodes.UNARY_INVERT, "UNARY_INVERT")],
|
|
17
|
+
|
|
18
|
+
[20, new OpCode(OpCodes.BINARY_MULTIPLY, "BINARY_MULTIPLY")],
|
|
19
|
+
[21, new OpCode(OpCodes.BINARY_DIVIDE, "BINARY_DIVIDE")],
|
|
20
|
+
[22, new OpCode(OpCodes.BINARY_MODULO, "BINARY_MODULO")],
|
|
21
|
+
[23, new OpCode(OpCodes.BINARY_ADD, "BINARY_ADD")],
|
|
22
|
+
[24, new OpCode(OpCodes.BINARY_SUBTRACT, "BINARY_SUBTRACT")],
|
|
23
|
+
[25, new OpCode(OpCodes.BINARY_SUBSCR, "BINARY_SUBSCR")],
|
|
24
|
+
[26, new OpCode(OpCodes.BINARY_CALL, "BINARY_CALL")],
|
|
25
|
+
|
|
26
|
+
[30, new OpCode(OpCodes.SLICE_0, "SLICE_0")],
|
|
27
|
+
[31, new OpCode(OpCodes.SLICE_1, "SLICE_1")],
|
|
28
|
+
[32, new OpCode(OpCodes.SLICE_2, "SLICE_2")],
|
|
29
|
+
[33, new OpCode(OpCodes.SLICE_3, "SLICE_3")],
|
|
30
|
+
|
|
31
|
+
[40, new OpCode(OpCodes.STORE_SLICE_0, "STORE_SLICE_0")],
|
|
32
|
+
[41, new OpCode(OpCodes.STORE_SLICE_1, "STORE_SLICE_1")],
|
|
33
|
+
[42, new OpCode(OpCodes.STORE_SLICE_2, "STORE_SLICE_2")],
|
|
34
|
+
[43, new OpCode(OpCodes.STORE_SLICE_3, "STORE_SLICE_3")],
|
|
35
|
+
|
|
36
|
+
[50, new OpCode(OpCodes.DELETE_SLICE_0, "DELETE_SLICE_0")],
|
|
37
|
+
[51, new OpCode(OpCodes.DELETE_SLICE_1, "DELETE_SLICE_1")],
|
|
38
|
+
[52, new OpCode(OpCodes.DELETE_SLICE_2, "DELETE_SLICE_2")],
|
|
39
|
+
[53, new OpCode(OpCodes.DELETE_SLICE_3, "DELETE_SLICE_3")],
|
|
40
|
+
|
|
41
|
+
[60, new OpCode(OpCodes.STORE_SUBSCR, "STORE_SUBSCR")],
|
|
42
|
+
[61, new OpCode(OpCodes.DELETE_SUBSCR, "DELETE_SUBSCR")],
|
|
43
|
+
[62, new OpCode(OpCodes.BINARY_LSHIFT, "BINARY_LSHIFT")],
|
|
44
|
+
[63, new OpCode(OpCodes.BINARY_RSHIFT, "BINARY_RSHIFT")],
|
|
45
|
+
[64, new OpCode(OpCodes.BINARY_AND, "BINARY_AND")],
|
|
46
|
+
[65, new OpCode(OpCodes.BINARY_XOR, "BINARY_XOR")],
|
|
47
|
+
[66, new OpCode(OpCodes.BINARY_OR, "BINARY_OR")],
|
|
48
|
+
|
|
49
|
+
[70, new OpCode(OpCodes.PRINT_EXPR, "PRINT_EXPR")],
|
|
50
|
+
[71, new OpCode(OpCodes.PRINT_ITEM, "PRINT_ITEM")],
|
|
51
|
+
[72, new OpCode(OpCodes.PRINT_NEWLINE, "PRINT_NEWLINE")],
|
|
52
|
+
|
|
53
|
+
[80, new OpCode(OpCodes.BREAK_LOOP, "BREAK_LOOP")],
|
|
54
|
+
[81, new OpCode(OpCodes.RAISE_EXCEPTION, "RAISE_EXCEPTION")],
|
|
55
|
+
[82, new OpCode(OpCodes.LOAD_LOCALS, "LOAD_LOCALS")],
|
|
56
|
+
[83, new OpCode(OpCodes.RETURN_VALUE, "RETURN_VALUE")],
|
|
57
|
+
[84, new OpCode(OpCodes.LOAD_GLOBALS, "LOAD_GLOBALS")],
|
|
58
|
+
[85, new OpCode(OpCodes.EXEC_STMT, "EXEC_STMT")],
|
|
59
|
+
[86, new OpCode(OpCodes.BUILD_FUNCTION, "BUILD_FUNCTION")],
|
|
60
|
+
[87, new OpCode(OpCodes.POP_BLOCK, "POP_BLOCK")],
|
|
61
|
+
[88, new OpCode(OpCodes.END_FINALLY, "END_FINALLY")],
|
|
62
|
+
[89, new OpCode(OpCodes.BUILD_CLASS, "BUILD_CLASS")],
|
|
63
|
+
[90, new OpCode(OpCodes.STORE_NAME_A, "STORE_NAME", {HasArgument: true, HasName: true})],
|
|
64
|
+
[91, new OpCode(OpCodes.DELETE_NAME_A, "DELETE_NAME", {HasArgument: true, HasName: true})],
|
|
65
|
+
[92, new OpCode(OpCodes.UNPACK_TUPLE_A, "UNPACK_TUPLE", {HasArgument: true})],
|
|
66
|
+
[93, new OpCode(OpCodes.UNPACK_LIST_A, "UNPACK_LIST", {HasArgument: true})],
|
|
67
|
+
[94, new OpCode(OpCodes.UNPACK_ARG_A, "UNPACK_ARG", {HasArgument: true})],
|
|
68
|
+
[95, new OpCode(OpCodes.STORE_ATTR_A, "STORE_ATTR", {HasArgument: true, HasName: true})],
|
|
69
|
+
[96, new OpCode(OpCodes.DELETE_ATTR_A, "DELETE_ATTR", {HasArgument: true, HasName: true})],
|
|
70
|
+
[97, new OpCode(OpCodes.STORE_GLOBAL_A, "STORE_GLOBAL", {HasArgument: true, HasName: true})],
|
|
71
|
+
[98, new OpCode(OpCodes.DELETE_GLOBAL_A, "DELETE_GLOBAL", {HasArgument: true, HasName: true})],
|
|
72
|
+
[99, new OpCode(OpCodes.UNPACK_VARARG_A, "UNPACK_VARARG", {HasArgument: true})],
|
|
73
|
+
[100, new OpCode(OpCodes.LOAD_CONST_A, "LOAD_CONST", {HasArgument: true, HasConstant: true})],
|
|
74
|
+
[101, new OpCode(OpCodes.LOAD_NAME_A, "LOAD_NAME", {HasArgument: true, HasName: true})],
|
|
75
|
+
[102, new OpCode(OpCodes.BUILD_TUPLE_A, "BUILD_TUPLE", {HasArgument: true})],
|
|
76
|
+
[103, new OpCode(OpCodes.BUILD_LIST_A, "BUILD_LIST", {HasArgument: true})],
|
|
77
|
+
[104, new OpCode(OpCodes.BUILD_MAP_A, "BUILD_MAP", {HasArgument: true})],
|
|
78
|
+
[105, new OpCode(OpCodes.LOAD_ATTR_A, "LOAD_ATTR", {HasArgument: true, HasName: true})],
|
|
79
|
+
[106, new OpCode(OpCodes.COMPARE_OP_A, "COMPARE_OP", {HasArgument: true, HasCompare: true})],
|
|
80
|
+
[107, new OpCode(OpCodes.IMPORT_NAME_A, "IMPORT_NAME", {HasArgument: true, HasName: true})],
|
|
81
|
+
[108, new OpCode(OpCodes.IMPORT_FROM_A, "IMPORT_FROM", {HasArgument: true, HasName: true})],
|
|
82
|
+
[109, new OpCode(OpCodes.ACCESS_MODE_A, "ACCESS_MODE", {HasArgument: true, HasName: true})],
|
|
83
|
+
[110, new OpCode(OpCodes.JUMP_FORWARD_A, "JUMP_FORWARD", {HasArgument: true, HasJumpRelative: true})],
|
|
84
|
+
[111, new OpCode(OpCodes.JUMP_IF_FALSE_A, "JUMP_IF_FALSE", {HasArgument: true, HasJumpRelative: true})],
|
|
85
|
+
[112, new OpCode(OpCodes.JUMP_IF_TRUE_A, "JUMP_IF_TRUE", {HasArgument: true, HasJumpRelative: true})],
|
|
86
|
+
[113, new OpCode(OpCodes.JUMP_ABSOLUTE_A, "JUMP_ABSOLUTE", {HasArgument: true, HasJumpAbsolute: true})],
|
|
87
|
+
[114, new OpCode(OpCodes.FOR_LOOP_A, "FOR_LOOP", {HasArgument: true, HasJumpRelative: true})],
|
|
88
|
+
[115, new OpCode(OpCodes.LOAD_LOCAL_A, "LOAD_LOCAL", {HasArgument: true, HasName: true})],
|
|
89
|
+
[116, new OpCode(OpCodes.LOAD_GLOBAL_A, "LOAD_GLOBAL", {HasArgument: true, HasName: true})],
|
|
90
|
+
|
|
91
|
+
[120, new OpCode(OpCodes.SETUP_LOOP_A, "SETUP_LOOP", {HasArgument: true, HasJumpRelative: true})],
|
|
92
|
+
[121, new OpCode(OpCodes.SETUP_EXCEPT_A, "SETUP_EXCEPT", {HasArgument: true, HasJumpRelative: true})],
|
|
93
|
+
[122, new OpCode(OpCodes.SETUP_FINALLY_A, "SETUP_FINALLY", {HasArgument: true, HasJumpRelative: true})],
|
|
94
|
+
[123, new OpCode(OpCodes.RESERVE_FAST_A, "RESERVE_FAST", {HasArgument: true, HasConstant: true})],
|
|
95
|
+
[124, new OpCode(OpCodes.LOAD_FAST_A, "LOAD_FAST", {HasArgument: true, HasLocal: true})],
|
|
96
|
+
[125, new OpCode(OpCodes.STORE_FAST_A, "STORE_FAST", {HasArgument: true, HasLocal: true})],
|
|
97
|
+
[126, new OpCode(OpCodes.DELETE_FAST_A, "DELETE_FAST", {HasArgument: true, HasLocal: true})],
|
|
98
|
+
[127, new OpCode(OpCodes.SET_LINENO_A, "SET_LINENO", {HasArgument: true})]
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
class Python1_0_OpCodes extends OpCodes {
|
|
102
|
+
|
|
103
|
+
constructor(co) {
|
|
104
|
+
super();
|
|
105
|
+
this.PopulateOpCodes(opcodes);
|
|
106
|
+
this.SetupByteCode(co);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
PopulateOpCodes(opCodeList) {
|
|
110
|
+
for (let [idx, opcode] of opCodeList) {
|
|
111
|
+
this.OpCodeList[idx] = opcode;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
module.exports = Python1_0_OpCodes;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const OpCode = require('../OpCode');
|
|
2
|
+
const OpCodes = require('../OpCodes');
|
|
3
|
+
|
|
4
|
+
const opcodes = [
|
|
5
|
+
[0, new OpCode(OpCodes.STOP_CODE, "STOP_CODE")],
|
|
6
|
+
[1, new OpCode(OpCodes.POP_TOP, "POP_TOP")],
|
|
7
|
+
[2, new OpCode(OpCodes.ROT_TWO, "ROT_TWO")],
|
|
8
|
+
[3, new OpCode(OpCodes.ROT_THREE, "ROT_THREE")],
|
|
9
|
+
[4, new OpCode(OpCodes.DUP_TOP, "DUP_TOP"),],
|
|
10
|
+
|
|
11
|
+
[10, new OpCode(OpCodes.UNARY_POSITIVE, "UNARY_POSITIVE")],
|
|
12
|
+
[11, new OpCode(OpCodes.UNARY_NEGATIVE, "UNARY_NEGATIVE")],
|
|
13
|
+
[12, new OpCode(OpCodes.UNARY_NOT, "UNARY_NOT")],
|
|
14
|
+
[13, new OpCode(OpCodes.UNARY_CONVERT, "UNARY_CONVERT")],
|
|
15
|
+
[14, new OpCode(OpCodes.UNARY_CALL, "UNARY_CALL")],
|
|
16
|
+
[15, new OpCode(OpCodes.UNARY_INVERT, "UNARY_INVERT")],
|
|
17
|
+
|
|
18
|
+
[20, new OpCode(OpCodes.BINARY_MULTIPLY, "BINARY_MULTIPLY")],
|
|
19
|
+
[21, new OpCode(OpCodes.BINARY_DIVIDE, "BINARY_DIVIDE")],
|
|
20
|
+
[22, new OpCode(OpCodes.BINARY_MODULO, "BINARY_MODULO")],
|
|
21
|
+
[23, new OpCode(OpCodes.BINARY_ADD, "BINARY_ADD")],
|
|
22
|
+
[24, new OpCode(OpCodes.BINARY_SUBTRACT, "BINARY_SUBTRACT")],
|
|
23
|
+
[25, new OpCode(OpCodes.BINARY_SUBSCR, "BINARY_SUBSCR")],
|
|
24
|
+
[26, new OpCode(OpCodes.BINARY_CALL, "BINARY_CALL")],
|
|
25
|
+
|
|
26
|
+
[30, new OpCode(OpCodes.SLICE_0, "SLICE_0")],
|
|
27
|
+
[31, new OpCode(OpCodes.SLICE_1, "SLICE_1")],
|
|
28
|
+
[32, new OpCode(OpCodes.SLICE_2, "SLICE_2")],
|
|
29
|
+
[33, new OpCode(OpCodes.SLICE_3, "SLICE_3")],
|
|
30
|
+
|
|
31
|
+
[40, new OpCode(OpCodes.STORE_SLICE_0, "STORE_SLICE_0")],
|
|
32
|
+
[41, new OpCode(OpCodes.STORE_SLICE_1, "STORE_SLICE_1")],
|
|
33
|
+
[42, new OpCode(OpCodes.STORE_SLICE_2, "STORE_SLICE_2")],
|
|
34
|
+
[43, new OpCode(OpCodes.STORE_SLICE_3, "STORE_SLICE_3")],
|
|
35
|
+
|
|
36
|
+
[50, new OpCode(OpCodes.DELETE_SLICE_0, "DELETE_SLICE_0")],
|
|
37
|
+
[51, new OpCode(OpCodes.DELETE_SLICE_1, "DELETE_SLICE_1")],
|
|
38
|
+
[52, new OpCode(OpCodes.DELETE_SLICE_2, "DELETE_SLICE_2")],
|
|
39
|
+
[53, new OpCode(OpCodes.DELETE_SLICE_3, "DELETE_SLICE_3")],
|
|
40
|
+
|
|
41
|
+
[60, new OpCode(OpCodes.STORE_SUBSCR, "STORE_SUBSCR")],
|
|
42
|
+
[61, new OpCode(OpCodes.DELETE_SUBSCR, "DELETE_SUBSCR")],
|
|
43
|
+
[62, new OpCode(OpCodes.BINARY_LSHIFT, "BINARY_LSHIFT")],
|
|
44
|
+
[63, new OpCode(OpCodes.BINARY_RSHIFT, "BINARY_RSHIFT")],
|
|
45
|
+
[64, new OpCode(OpCodes.BINARY_AND, "BINARY_AND")],
|
|
46
|
+
[65, new OpCode(OpCodes.BINARY_XOR, "BINARY_XOR")],
|
|
47
|
+
[66, new OpCode(OpCodes.BINARY_OR, "BINARY_OR")],
|
|
48
|
+
|
|
49
|
+
[70, new OpCode(OpCodes.PRINT_EXPR, "PRINT_EXPR")],
|
|
50
|
+
[71, new OpCode(OpCodes.PRINT_ITEM, "PRINT_ITEM")],
|
|
51
|
+
[72, new OpCode(OpCodes.PRINT_NEWLINE, "PRINT_NEWLINE")],
|
|
52
|
+
|
|
53
|
+
[80, new OpCode(OpCodes.BREAK_LOOP, "BREAK_LOOP")],
|
|
54
|
+
[81, new OpCode(OpCodes.RAISE_EXCEPTION, "RAISE_EXCEPTION")],
|
|
55
|
+
[82, new OpCode(OpCodes.LOAD_LOCALS, "LOAD_LOCALS")],
|
|
56
|
+
[83, new OpCode(OpCodes.RETURN_VALUE, "RETURN_VALUE")],
|
|
57
|
+
[84, new OpCode(OpCodes.LOAD_GLOBALS, "LOAD_GLOBALS")],
|
|
58
|
+
[85, new OpCode(OpCodes.EXEC_STMT, "EXEC_STMT")],
|
|
59
|
+
[86, new OpCode(OpCodes.BUILD_FUNCTION, "BUILD_FUNCTION")],
|
|
60
|
+
[87, new OpCode(OpCodes.POP_BLOCK, "POP_BLOCK")],
|
|
61
|
+
[88, new OpCode(OpCodes.END_FINALLY, "END_FINALLY")],
|
|
62
|
+
[89, new OpCode(OpCodes.BUILD_CLASS, "BUILD_CLASS")],
|
|
63
|
+
[90, new OpCode(OpCodes.STORE_NAME_A, "STORE_NAME", {HasArgument: true, HasName: true})],
|
|
64
|
+
[91, new OpCode(OpCodes.DELETE_NAME_A, "DELETE_NAME", {HasArgument: true, HasName: true})],
|
|
65
|
+
[92, new OpCode(OpCodes.UNPACK_TUPLE_A, "UNPACK_TUPLE", {HasArgument: true})],
|
|
66
|
+
[93, new OpCode(OpCodes.UNPACK_LIST_A, "UNPACK_LIST", {HasArgument: true})],
|
|
67
|
+
[94, new OpCode(OpCodes.UNPACK_ARG_A, "UNPACK_ARG", {HasArgument: true})],
|
|
68
|
+
[95, new OpCode(OpCodes.STORE_ATTR_A, "STORE_ATTR", {HasArgument: true, HasName: true})],
|
|
69
|
+
[96, new OpCode(OpCodes.DELETE_ATTR_A, "DELETE_ATTR", {HasArgument: true, HasName: true})],
|
|
70
|
+
[97, new OpCode(OpCodes.STORE_GLOBAL_A, "STORE_GLOBAL", {HasArgument: true, HasName: true})],
|
|
71
|
+
[98, new OpCode(OpCodes.DELETE_GLOBAL_A, "DELETE_GLOBAL", {HasArgument: true, HasName: true})],
|
|
72
|
+
[99, new OpCode(OpCodes.UNPACK_VARARG_A, "UNPACK_VARARG", {HasArgument: true})],
|
|
73
|
+
[100, new OpCode(OpCodes.LOAD_CONST_A, "LOAD_CONST", {HasArgument: true, HasConstant: true})],
|
|
74
|
+
[101, new OpCode(OpCodes.LOAD_NAME_A, "LOAD_NAME", {HasArgument: true, HasName: true})],
|
|
75
|
+
[102, new OpCode(OpCodes.BUILD_TUPLE_A, "BUILD_TUPLE", {HasArgument: true})],
|
|
76
|
+
[103, new OpCode(OpCodes.BUILD_LIST_A, "BUILD_LIST", {HasArgument: true})],
|
|
77
|
+
[104, new OpCode(OpCodes.BUILD_MAP_A, "BUILD_MAP", {HasArgument: true})],
|
|
78
|
+
[105, new OpCode(OpCodes.LOAD_ATTR_A, "LOAD_ATTR", {HasArgument: true, HasName: true})],
|
|
79
|
+
[106, new OpCode(OpCodes.COMPARE_OP_A, "COMPARE_OP", {HasArgument: true, HasCompare: true})],
|
|
80
|
+
[107, new OpCode(OpCodes.IMPORT_NAME_A, "IMPORT_NAME", {HasArgument: true, HasName: true})],
|
|
81
|
+
[108, new OpCode(OpCodes.IMPORT_FROM_A, "IMPORT_FROM", {HasArgument: true, HasName: true})],
|
|
82
|
+
[109, new OpCode(OpCodes.ACCESS_MODE_A, "ACCESS_MODE", {HasArgument: true, HasName: true})],
|
|
83
|
+
[110, new OpCode(OpCodes.JUMP_FORWARD_A, "JUMP_FORWARD", {HasArgument: true, HasJumpRelative: true})],
|
|
84
|
+
[111, new OpCode(OpCodes.JUMP_IF_FALSE_A, "JUMP_IF_FALSE", {HasArgument: true, HasJumpRelative: true})],
|
|
85
|
+
[112, new OpCode(OpCodes.JUMP_IF_TRUE_A, "JUMP_IF_TRUE", {HasArgument: true, HasJumpRelative: true})],
|
|
86
|
+
[113, new OpCode(OpCodes.JUMP_ABSOLUTE_A, "JUMP_ABSOLUTE", {HasArgument: true, HasJumpAbsolute: true})],
|
|
87
|
+
[114, new OpCode(OpCodes.FOR_LOOP_A, "FOR_LOOP", {HasArgument: true, HasJumpRelative: true})],
|
|
88
|
+
[115, new OpCode(OpCodes.LOAD_LOCAL_A, "LOAD_LOCAL", {HasArgument: true, HasName: true})],
|
|
89
|
+
[116, new OpCode(OpCodes.LOAD_GLOBAL_A, "LOAD_GLOBAL", {HasArgument: true, HasName: true})],
|
|
90
|
+
[117, new OpCode(OpCodes.SET_FUNC_ARGS_A, "SET_FUNC_ARGS", {HasArgument: true})],
|
|
91
|
+
|
|
92
|
+
[120, new OpCode(OpCodes.SETUP_LOOP_A, "SETUP_LOOP", {HasArgument: true, HasJumpRelative: true})],
|
|
93
|
+
[121, new OpCode(OpCodes.SETUP_EXCEPT_A, "SETUP_EXCEPT", {HasArgument: true, HasJumpRelative: true})],
|
|
94
|
+
[122, new OpCode(OpCodes.SETUP_FINALLY_A, "SETUP_FINALLY", {HasArgument: true, HasJumpRelative: true})],
|
|
95
|
+
[123, new OpCode(OpCodes.RESERVE_FAST_A, "RESERVE_FAST", {HasArgument: true, HasConstant: true})],
|
|
96
|
+
[124, new OpCode(OpCodes.LOAD_FAST_A, "LOAD_FAST", {HasArgument: true, HasLocal: true})],
|
|
97
|
+
[125, new OpCode(OpCodes.STORE_FAST_A, "STORE_FAST", {HasArgument: true, HasLocal: true})],
|
|
98
|
+
[126, new OpCode(OpCodes.DELETE_FAST_A, "DELETE_FAST", {HasArgument: true, HasLocal: true})],
|
|
99
|
+
[127, new OpCode(OpCodes.SET_LINENO_A, "SET_LINENO", {HasArgument: true})]
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
class Python1_1_OpCodes extends OpCodes {
|
|
103
|
+
constructor(co) {
|
|
104
|
+
super();
|
|
105
|
+
this.PopulateOpCodes(opcodes);
|
|
106
|
+
this.SetupByteCode(co);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
PopulateOpCodes(opCodeList) {
|
|
110
|
+
for (let [idx, opcode] of opCodeList) {
|
|
111
|
+
this.OpCodeList[idx] = opcode;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
module.exports = Python1_1_OpCodes;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const OpCode = require('../OpCode');
|
|
2
|
+
const OpCodes = require('../OpCodes');
|
|
3
|
+
|
|
4
|
+
const opcodes = [
|
|
5
|
+
[0, new OpCode(OpCodes.STOP_CODE, "STOP_CODE")],
|
|
6
|
+
[1, new OpCode(OpCodes.POP_TOP, "POP_TOP")],
|
|
7
|
+
[2, new OpCode(OpCodes.ROT_TWO, "ROT_TWO")],
|
|
8
|
+
[3, new OpCode(OpCodes.ROT_THREE, "ROT_THREE")],
|
|
9
|
+
[4, new OpCode(OpCodes.DUP_TOP, "DUP_TOP")],
|
|
10
|
+
|
|
11
|
+
[10, new OpCode(OpCodes.UNARY_POSITIVE, "UNARY_POSITIVE")],
|
|
12
|
+
[11, new OpCode(OpCodes.UNARY_NEGATIVE, "UNARY_NEGATIVE")],
|
|
13
|
+
[12, new OpCode(OpCodes.UNARY_NOT, "UNARY_NOT")],
|
|
14
|
+
[13, new OpCode(OpCodes.UNARY_CONVERT, "UNARY_CONVERT")],
|
|
15
|
+
|
|
16
|
+
[15, new OpCode(OpCodes.UNARY_INVERT, "UNARY_INVERT")],
|
|
17
|
+
|
|
18
|
+
[20, new OpCode(OpCodes.BINARY_MULTIPLY, "BINARY_MULTIPLY")],
|
|
19
|
+
[21, new OpCode(OpCodes.BINARY_DIVIDE, "BINARY_DIVIDE")],
|
|
20
|
+
[22, new OpCode(OpCodes.BINARY_MODULO, "BINARY_MODULO")],
|
|
21
|
+
[23, new OpCode(OpCodes.BINARY_ADD, "BINARY_ADD")],
|
|
22
|
+
[24, new OpCode(OpCodes.BINARY_SUBTRACT, "BINARY_SUBTRACT")],
|
|
23
|
+
[25, new OpCode(OpCodes.BINARY_SUBSCR, "BINARY_SUBSCR")],
|
|
24
|
+
|
|
25
|
+
[30, new OpCode(OpCodes.SLICE_0, "SLICE_0")],
|
|
26
|
+
[31, new OpCode(OpCodes.SLICE_1, "SLICE_1")],
|
|
27
|
+
[32, new OpCode(OpCodes.SLICE_2, "SLICE_2")],
|
|
28
|
+
[33, new OpCode(OpCodes.SLICE_3, "SLICE_3")],
|
|
29
|
+
|
|
30
|
+
[40, new OpCode(OpCodes.STORE_SLICE_0, "STORE_SLICE_0")],
|
|
31
|
+
[41, new OpCode(OpCodes.STORE_SLICE_1, "STORE_SLICE_1")],
|
|
32
|
+
[42, new OpCode(OpCodes.STORE_SLICE_2, "STORE_SLICE_2")],
|
|
33
|
+
[43, new OpCode(OpCodes.STORE_SLICE_3, "STORE_SLICE_3")],
|
|
34
|
+
|
|
35
|
+
[50, new OpCode(OpCodes.DELETE_SLICE_0, "DELETE_SLICE_0")],
|
|
36
|
+
[51, new OpCode(OpCodes.DELETE_SLICE_1, "DELETE_SLICE_1")],
|
|
37
|
+
[52, new OpCode(OpCodes.DELETE_SLICE_2, "DELETE_SLICE_2")],
|
|
38
|
+
[53, new OpCode(OpCodes.DELETE_SLICE_3, "DELETE_SLICE_3")],
|
|
39
|
+
|
|
40
|
+
[60, new OpCode(OpCodes.STORE_SUBSCR, "STORE_SUBSCR")],
|
|
41
|
+
[61, new OpCode(OpCodes.DELETE_SUBSCR, "DELETE_SUBSCR")],
|
|
42
|
+
[62, new OpCode(OpCodes.BINARY_LSHIFT, "BINARY_LSHIFT")],
|
|
43
|
+
[63, new OpCode(OpCodes.BINARY_RSHIFT, "BINARY_RSHIFT")],
|
|
44
|
+
[64, new OpCode(OpCodes.BINARY_AND, "BINARY_AND")],
|
|
45
|
+
[65, new OpCode(OpCodes.BINARY_XOR, "BINARY_XOR")],
|
|
46
|
+
[66, new OpCode(OpCodes.BINARY_OR, "BINARY_OR")],
|
|
47
|
+
|
|
48
|
+
[70, new OpCode(OpCodes.PRINT_EXPR, "PRINT_EXPR")],
|
|
49
|
+
[71, new OpCode(OpCodes.PRINT_ITEM, "PRINT_ITEM")],
|
|
50
|
+
[72, new OpCode(OpCodes.PRINT_NEWLINE, "PRINT_NEWLINE")],
|
|
51
|
+
|
|
52
|
+
[80, new OpCode(OpCodes.BREAK_LOOP, "BREAK_LOOP")],
|
|
53
|
+
|
|
54
|
+
[82, new OpCode(OpCodes.LOAD_LOCALS, "LOAD_LOCALS")],
|
|
55
|
+
[83, new OpCode(OpCodes.RETURN_VALUE, "RETURN_VALUE")],
|
|
56
|
+
|
|
57
|
+
[85, new OpCode(OpCodes.EXEC_STMT, "EXEC_STMT")],
|
|
58
|
+
|
|
59
|
+
[87, new OpCode(OpCodes.POP_BLOCK, "POP_BLOCK")],
|
|
60
|
+
[88, new OpCode(OpCodes.END_FINALLY, "END_FINALLY")],
|
|
61
|
+
[89, new OpCode(OpCodes.BUILD_CLASS, "BUILD_CLASS")],
|
|
62
|
+
[90, new OpCode(OpCodes.STORE_NAME_A, "STORE_NAME", {HasArgument: true, HasName: true})],
|
|
63
|
+
[91, new OpCode(OpCodes.DELETE_NAME_A, "DELETE_NAME", {HasArgument: true, HasName: true})],
|
|
64
|
+
[92, new OpCode(OpCodes.UNPACK_TUPLE_A, "UNPACK_TUPLE", {HasArgument: true})],
|
|
65
|
+
[93, new OpCode(OpCodes.UNPACK_LIST_A, "UNPACK_LIST", {HasArgument: true})],
|
|
66
|
+
[94, new OpCode(OpCodes.UNPACK_ARG_A, "UNPACK_ARG", {HasArgument: true})],
|
|
67
|
+
[95, new OpCode(OpCodes.STORE_ATTR_A, "STORE_ATTR", {HasArgument: true, HasName: true})],
|
|
68
|
+
[96, new OpCode(OpCodes.DELETE_ATTR_A, "DELETE_ATTR", {HasArgument: true, HasName: true})],
|
|
69
|
+
[97, new OpCode(OpCodes.STORE_GLOBAL_A, "STORE_GLOBAL", {HasArgument: true, HasName: true})],
|
|
70
|
+
[98, new OpCode(OpCodes.DELETE_GLOBAL_A, "DELETE_GLOBAL", {HasArgument: true, HasName: true})],
|
|
71
|
+
[99, new OpCode(OpCodes.UNPACK_VARARG_A, "UNPACK_VARARG", {HasArgument: true})],
|
|
72
|
+
[100, new OpCode(OpCodes.LOAD_CONST_A, "LOAD_CONST", {HasArgument: true, HasConstant: true})],
|
|
73
|
+
[101, new OpCode(OpCodes.LOAD_NAME_A, "LOAD_NAME", {HasArgument: true, HasName: true})],
|
|
74
|
+
[102, new OpCode(OpCodes.BUILD_TUPLE_A, "BUILD_TUPLE", {HasArgument: true})],
|
|
75
|
+
[103, new OpCode(OpCodes.BUILD_LIST_A, "BUILD_LIST", {HasArgument: true})],
|
|
76
|
+
[104, new OpCode(OpCodes.BUILD_MAP_A, "BUILD_MAP", {HasArgument: true})],
|
|
77
|
+
[105, new OpCode(OpCodes.LOAD_ATTR_A, "LOAD_ATTR", {HasArgument: true, HasName: true})],
|
|
78
|
+
[106, new OpCode(OpCodes.COMPARE_OP_A, "COMPARE_OP", {HasArgument: true, HasCompare: true})],
|
|
79
|
+
[107, new OpCode(OpCodes.IMPORT_NAME_A, "IMPORT_NAME", {HasArgument: true, HasName: true})],
|
|
80
|
+
[108, new OpCode(OpCodes.IMPORT_FROM_A, "IMPORT_FROM", {HasArgument: true, HasName: true})],
|
|
81
|
+
[109, new OpCode(OpCodes.ACCESS_MODE_A, "ACCESS_MODE", {HasArgument: true, HasName: true})],
|
|
82
|
+
[110, new OpCode(OpCodes.JUMP_FORWARD_A, "JUMP_FORWARD", {HasArgument: true, HasJumpRelative: true})],
|
|
83
|
+
[111, new OpCode(OpCodes.JUMP_IF_FALSE_A, "JUMP_IF_FALSE", {HasArgument: true, HasJumpRelative: true})],
|
|
84
|
+
[112, new OpCode(OpCodes.JUMP_IF_TRUE_A, "JUMP_IF_TRUE", {HasArgument: true, HasJumpRelative: true})],
|
|
85
|
+
[113, new OpCode(OpCodes.JUMP_ABSOLUTE_A, "JUMP_ABSOLUTE", {HasArgument: true, HasJumpAbsolute: true})],
|
|
86
|
+
[114, new OpCode(OpCodes.FOR_LOOP_A, "FOR_LOOP", {HasArgument: true, HasJumpRelative: true})],
|
|
87
|
+
[115, new OpCode(OpCodes.LOAD_LOCAL_A, "LOAD_LOCAL", {HasArgument: true, HasName: true})],
|
|
88
|
+
[116, new OpCode(OpCodes.LOAD_GLOBAL_A, "LOAD_GLOBAL", {HasArgument: true, HasName: true})],
|
|
89
|
+
[117, new OpCode(OpCodes.SET_FUNC_ARGS_A, "SET_FUNC_ARGS", {HasArgument: true})],
|
|
90
|
+
|
|
91
|
+
[120, new OpCode(OpCodes.SETUP_LOOP_A, "SETUP_LOOP", {HasArgument: true, HasJumpRelative: true})],
|
|
92
|
+
[121, new OpCode(OpCodes.SETUP_EXCEPT_A, "SETUP_EXCEPT", {HasArgument: true, HasJumpRelative: true})],
|
|
93
|
+
[122, new OpCode(OpCodes.SETUP_FINALLY_A, "SETUP_FINALLY", {HasArgument: true, HasJumpRelative: true})],
|
|
94
|
+
|
|
95
|
+
[124, new OpCode(OpCodes.LOAD_FAST_A, "LOAD_FAST", {HasArgument: true, HasLocal: true})],
|
|
96
|
+
[125, new OpCode(OpCodes.STORE_FAST_A, "STORE_FAST", {HasArgument: true, HasLocal: true})],
|
|
97
|
+
[126, new OpCode(OpCodes.DELETE_FAST_A, "DELETE_FAST", {HasArgument: true, HasLocal: true})],
|
|
98
|
+
[127, new OpCode(OpCodes.SET_LINENO_A, "SET_LINENO", {HasArgument: true})],
|
|
99
|
+
|
|
100
|
+
[130, new OpCode(OpCodes.RAISE_VARARGS_A, "RAISE_VARARGS", {HasArgument: true})],
|
|
101
|
+
[131, new OpCode(OpCodes.CALL_FUNCTION_A, "CALL_FUNCTION", {HasArgument: true})],
|
|
102
|
+
[132, new OpCode(OpCodes.MAKE_FUNCTION_A, "MAKE_FUNCTION", {HasArgument: true})]
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
class Python1_3_OpCodes extends OpCodes {
|
|
106
|
+
constructor(co) {
|
|
107
|
+
super();
|
|
108
|
+
this.PopulateOpCodes(opcodes);
|
|
109
|
+
this.SetupByteCode(co);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
PopulateOpCodes(opCodeList) {
|
|
113
|
+
for (let [idx, opcode] of opCodeList) {
|
|
114
|
+
this.OpCodeList[idx] = opcode;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = Python1_3_OpCodes;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const OpCode = require('../OpCode');
|
|
2
|
+
const OpCodes = require('../OpCodes');
|
|
3
|
+
|
|
4
|
+
const opcodes = [
|
|
5
|
+
[0, new OpCode(OpCodes.STOP_CODE, "STOP_CODE")],
|
|
6
|
+
[1, new OpCode(OpCodes.POP_TOP, "POP_TOP")],
|
|
7
|
+
[2, new OpCode(OpCodes.ROT_TWO, "ROT_TWO")],
|
|
8
|
+
[3, new OpCode(OpCodes.ROT_THREE, "ROT_THREE")],
|
|
9
|
+
[4, new OpCode(OpCodes.DUP_TOP, "DUP_TOP")],
|
|
10
|
+
|
|
11
|
+
[10, new OpCode(OpCodes.UNARY_POSITIVE, "UNARY_POSITIVE")],
|
|
12
|
+
[11, new OpCode(OpCodes.UNARY_NEGATIVE, "UNARY_NEGATIVE")],
|
|
13
|
+
[12, new OpCode(OpCodes.UNARY_NOT, "UNARY_NOT")],
|
|
14
|
+
[13, new OpCode(OpCodes.UNARY_CONVERT, "UNARY_CONVERT")],
|
|
15
|
+
|
|
16
|
+
[15, new OpCode(OpCodes.UNARY_INVERT, "UNARY_INVERT")],
|
|
17
|
+
|
|
18
|
+
[19, new OpCode(OpCodes.BINARY_POWER, "BINARY_POWER")],
|
|
19
|
+
[20, new OpCode(OpCodes.BINARY_MULTIPLY, "BINARY_MULTIPLY")],
|
|
20
|
+
[21, new OpCode(OpCodes.BINARY_DIVIDE, "BINARY_DIVIDE")],
|
|
21
|
+
[22, new OpCode(OpCodes.BINARY_MODULO, "BINARY_MODULO")],
|
|
22
|
+
[23, new OpCode(OpCodes.BINARY_ADD, "BINARY_ADD")],
|
|
23
|
+
[24, new OpCode(OpCodes.BINARY_SUBTRACT, "BINARY_SUBTRACT")],
|
|
24
|
+
[25, new OpCode(OpCodes.BINARY_SUBSCR, "BINARY_SUBSCR")],
|
|
25
|
+
|
|
26
|
+
[30, new OpCode(OpCodes.SLICE_0, "SLICE_0")],
|
|
27
|
+
[31, new OpCode(OpCodes.SLICE_1, "SLICE_1")],
|
|
28
|
+
[32, new OpCode(OpCodes.SLICE_2, "SLICE_2")],
|
|
29
|
+
[33, new OpCode(OpCodes.SLICE_3, "SLICE_3")],
|
|
30
|
+
|
|
31
|
+
[40, new OpCode(OpCodes.STORE_SLICE_0, "STORE_SLICE_0")],
|
|
32
|
+
[41, new OpCode(OpCodes.STORE_SLICE_1, "STORE_SLICE_1")],
|
|
33
|
+
[42, new OpCode(OpCodes.STORE_SLICE_2, "STORE_SLICE_2")],
|
|
34
|
+
[43, new OpCode(OpCodes.STORE_SLICE_3, "STORE_SLICE_3")],
|
|
35
|
+
|
|
36
|
+
[50, new OpCode(OpCodes.DELETE_SLICE_0, "DELETE_SLICE_0")],
|
|
37
|
+
[51, new OpCode(OpCodes.DELETE_SLICE_1, "DELETE_SLICE_1")],
|
|
38
|
+
[52, new OpCode(OpCodes.DELETE_SLICE_2, "DELETE_SLICE_2")],
|
|
39
|
+
[53, new OpCode(OpCodes.DELETE_SLICE_3, "DELETE_SLICE_3")],
|
|
40
|
+
|
|
41
|
+
[60, new OpCode(OpCodes.STORE_SUBSCR, "STORE_SUBSCR")],
|
|
42
|
+
[61, new OpCode(OpCodes.DELETE_SUBSCR, "DELETE_SUBSCR")],
|
|
43
|
+
[62, new OpCode(OpCodes.BINARY_LSHIFT, "BINARY_LSHIFT")],
|
|
44
|
+
[63, new OpCode(OpCodes.BINARY_RSHIFT, "BINARY_RSHIFT")],
|
|
45
|
+
[64, new OpCode(OpCodes.BINARY_AND, "BINARY_AND")],
|
|
46
|
+
[65, new OpCode(OpCodes.BINARY_XOR, "BINARY_XOR")],
|
|
47
|
+
[66, new OpCode(OpCodes.BINARY_OR, "BINARY_OR")],
|
|
48
|
+
|
|
49
|
+
[70, new OpCode(OpCodes.PRINT_EXPR, "PRINT_EXPR")],
|
|
50
|
+
[71, new OpCode(OpCodes.PRINT_ITEM, "PRINT_ITEM")],
|
|
51
|
+
[72, new OpCode(OpCodes.PRINT_NEWLINE, "PRINT_NEWLINE")],
|
|
52
|
+
|
|
53
|
+
[80, new OpCode(OpCodes.BREAK_LOOP, "BREAK_LOOP")],
|
|
54
|
+
|
|
55
|
+
[82, new OpCode(OpCodes.LOAD_LOCALS, "LOAD_LOCALS")],
|
|
56
|
+
[83, new OpCode(OpCodes.RETURN_VALUE, "RETURN_VALUE")],
|
|
57
|
+
|
|
58
|
+
[85, new OpCode(OpCodes.EXEC_STMT, "EXEC_STMT")],
|
|
59
|
+
|
|
60
|
+
[87, new OpCode(OpCodes.POP_BLOCK, "POP_BLOCK")],
|
|
61
|
+
[88, new OpCode(OpCodes.END_FINALLY, "END_FINALLY")],
|
|
62
|
+
[89, new OpCode(OpCodes.BUILD_CLASS, "BUILD_CLASS")],
|
|
63
|
+
[90, new OpCode(OpCodes.STORE_NAME_A, "STORE_NAME", {HasArgument: true, HasName: true})],
|
|
64
|
+
[91, new OpCode(OpCodes.DELETE_NAME_A, "DELETE_NAME", {HasArgument: true, HasName: true})],
|
|
65
|
+
[92, new OpCode(OpCodes.UNPACK_TUPLE_A, "UNPACK_TUPLE", {HasArgument: true})],
|
|
66
|
+
[93, new OpCode(OpCodes.UNPACK_LIST_A, "UNPACK_LIST", {HasArgument: true})],
|
|
67
|
+
[94, new OpCode(OpCodes.UNPACK_ARG_A, "UNPACK_ARG", {HasArgument: true})],
|
|
68
|
+
[95, new OpCode(OpCodes.STORE_ATTR_A, "STORE_ATTR", {HasArgument: true, HasName: true})],
|
|
69
|
+
[96, new OpCode(OpCodes.DELETE_ATTR_A, "DELETE_ATTR", {HasArgument: true, HasName: true})],
|
|
70
|
+
[97, new OpCode(OpCodes.STORE_GLOBAL_A, "STORE_GLOBAL", {HasArgument: true, HasName: true})],
|
|
71
|
+
[98, new OpCode(OpCodes.DELETE_GLOBAL_A, "DELETE_GLOBAL", {HasArgument: true, HasName: true})],
|
|
72
|
+
[99, new OpCode(OpCodes.UNPACK_VARARG_A, "UNPACK_VARARG", {HasArgument: true})],
|
|
73
|
+
[100, new OpCode(OpCodes.LOAD_CONST_A, "LOAD_CONST", {HasArgument: true, HasConstant: true})],
|
|
74
|
+
[101, new OpCode(OpCodes.LOAD_NAME_A, "LOAD_NAME", {HasArgument: true, HasName: true})],
|
|
75
|
+
[102, new OpCode(OpCodes.BUILD_TUPLE_A, "BUILD_TUPLE", {HasArgument: true})],
|
|
76
|
+
[103, new OpCode(OpCodes.BUILD_LIST_A, "BUILD_LIST", {HasArgument: true})],
|
|
77
|
+
[104, new OpCode(OpCodes.BUILD_MAP_A, "BUILD_MAP", {HasArgument: true})],
|
|
78
|
+
[105, new OpCode(OpCodes.LOAD_ATTR_A, "LOAD_ATTR", {HasArgument: true, HasName: true})],
|
|
79
|
+
[106, new OpCode(OpCodes.COMPARE_OP_A, "COMPARE_OP", {HasArgument: true, HasCompare: true})],
|
|
80
|
+
[107, new OpCode(OpCodes.IMPORT_NAME_A, "IMPORT_NAME", {HasArgument: true, HasName: true})],
|
|
81
|
+
[108, new OpCode(OpCodes.IMPORT_FROM_A, "IMPORT_FROM", {HasArgument: true, HasName: true})],
|
|
82
|
+
[109, new OpCode(OpCodes.ACCESS_MODE_A, "ACCESS_MODE", {HasArgument: true, HasName: true})],
|
|
83
|
+
[110, new OpCode(OpCodes.JUMP_FORWARD_A, "JUMP_FORWARD", {HasArgument: true, HasJumpRelative: true})],
|
|
84
|
+
[111, new OpCode(OpCodes.JUMP_IF_FALSE_A, "JUMP_IF_FALSE", {HasArgument: true, HasJumpRelative: true})],
|
|
85
|
+
[112, new OpCode(OpCodes.JUMP_IF_TRUE_A, "JUMP_IF_TRUE", {HasArgument: true, HasJumpRelative: true})],
|
|
86
|
+
[113, new OpCode(OpCodes.JUMP_ABSOLUTE_A, "JUMP_ABSOLUTE", {HasArgument: true, HasJumpAbsolute: true})],
|
|
87
|
+
[114, new OpCode(OpCodes.FOR_LOOP_A, "FOR_LOOP", {HasArgument: true, HasJumpRelative: true})],
|
|
88
|
+
[115, new OpCode(OpCodes.LOAD_LOCAL_A, "LOAD_LOCAL", {HasArgument: true, HasName: true})],
|
|
89
|
+
[116, new OpCode(OpCodes.LOAD_GLOBAL_A, "LOAD_GLOBAL", {HasArgument: true, HasName: true})],
|
|
90
|
+
[117, new OpCode(OpCodes.SET_FUNC_ARGS_A, "SET_FUNC_ARGS", {HasArgument: true})],
|
|
91
|
+
|
|
92
|
+
[120, new OpCode(OpCodes.SETUP_LOOP_A, "SETUP_LOOP", {HasArgument: true, HasJumpRelative: true})],
|
|
93
|
+
[121, new OpCode(OpCodes.SETUP_EXCEPT_A, "SETUP_EXCEPT", {HasArgument: true, HasJumpRelative: true})],
|
|
94
|
+
[122, new OpCode(OpCodes.SETUP_FINALLY_A, "SETUP_FINALLY", {HasArgument: true, HasJumpRelative: true})],
|
|
95
|
+
|
|
96
|
+
[124, new OpCode(OpCodes.LOAD_FAST_A, "LOAD_FAST", {HasArgument: true, HasLocal: true})],
|
|
97
|
+
[125, new OpCode(OpCodes.STORE_FAST_A, "STORE_FAST", {HasArgument: true, HasLocal: true})],
|
|
98
|
+
[126, new OpCode(OpCodes.DELETE_FAST_A, "DELETE_FAST", {HasArgument: true, HasLocal: true})],
|
|
99
|
+
[127, new OpCode(OpCodes.SET_LINENO_A, "SET_LINENO", {HasArgument: true})],
|
|
100
|
+
|
|
101
|
+
[130, new OpCode(OpCodes.RAISE_VARARGS_A, "RAISE_VARARGS", {HasArgument: true})],
|
|
102
|
+
[131, new OpCode(OpCodes.CALL_FUNCTION_A, "CALL_FUNCTION", {HasArgument: true})],
|
|
103
|
+
[132, new OpCode(OpCodes.MAKE_FUNCTION_A, "MAKE_FUNCTION", {HasArgument: true})],
|
|
104
|
+
[133, new OpCode(OpCodes.BUILD_SLICE_A, "BUILD_SLICE", {HasArgument: true})]
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
class Python1_4_OpCodes extends OpCodes {
|
|
108
|
+
constructor(co) {
|
|
109
|
+
super();
|
|
110
|
+
this.PopulateOpCodes(opcodes);
|
|
111
|
+
this.SetupByteCode(co);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
PopulateOpCodes(opCodeList) {
|
|
115
|
+
for (let [idx, opcode] of opCodeList) {
|
|
116
|
+
this.OpCodeList[idx] = opcode;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = Python1_4_OpCodes;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const OpCode = require('../OpCode');
|
|
2
|
+
const OpCodes = require('../OpCodes');
|
|
3
|
+
|
|
4
|
+
const opcodes = [
|
|
5
|
+
[0, new OpCode(OpCodes.STOP_CODE, "STOP_CODE")],
|
|
6
|
+
[1, new OpCode(OpCodes.POP_TOP, "POP_TOP")],
|
|
7
|
+
[2, new OpCode(OpCodes.ROT_TWO, "ROT_TWO")],
|
|
8
|
+
[3, new OpCode(OpCodes.ROT_THREE, "ROT_THREE")],
|
|
9
|
+
[4, new OpCode(OpCodes.DUP_TOP, "DUP_TOP")],
|
|
10
|
+
|
|
11
|
+
[10, new OpCode(OpCodes.UNARY_POSITIVE, "UNARY_POSITIVE")],
|
|
12
|
+
[11, new OpCode(OpCodes.UNARY_NEGATIVE, "UNARY_NEGATIVE")],
|
|
13
|
+
[12, new OpCode(OpCodes.UNARY_NOT, "UNARY_NOT")],
|
|
14
|
+
[13, new OpCode(OpCodes.UNARY_CONVERT, "UNARY_CONVERT")],
|
|
15
|
+
|
|
16
|
+
[15, new OpCode(OpCodes.UNARY_INVERT, "UNARY_INVERT")],
|
|
17
|
+
|
|
18
|
+
[19, new OpCode(OpCodes.BINARY_POWER, "BINARY_POWER")],
|
|
19
|
+
[20, new OpCode(OpCodes.BINARY_MULTIPLY, "BINARY_MULTIPLY")],
|
|
20
|
+
[21, new OpCode(OpCodes.BINARY_DIVIDE, "BINARY_DIVIDE")],
|
|
21
|
+
[22, new OpCode(OpCodes.BINARY_MODULO, "BINARY_MODULO")],
|
|
22
|
+
[23, new OpCode(OpCodes.BINARY_ADD, "BINARY_ADD")],
|
|
23
|
+
[24, new OpCode(OpCodes.BINARY_SUBTRACT, "BINARY_SUBTRACT")],
|
|
24
|
+
[25, new OpCode(OpCodes.BINARY_SUBSCR, "BINARY_SUBSCR")],
|
|
25
|
+
|
|
26
|
+
[30, new OpCode(OpCodes.SLICE_0, "SLICE_0")],
|
|
27
|
+
[31, new OpCode(OpCodes.SLICE_1, "SLICE_1")],
|
|
28
|
+
[32, new OpCode(OpCodes.SLICE_2, "SLICE_2")],
|
|
29
|
+
[33, new OpCode(OpCodes.SLICE_3, "SLICE_3")],
|
|
30
|
+
|
|
31
|
+
[40, new OpCode(OpCodes.STORE_SLICE_0, "STORE_SLICE_0")],
|
|
32
|
+
[41, new OpCode(OpCodes.STORE_SLICE_1, "STORE_SLICE_1")],
|
|
33
|
+
[42, new OpCode(OpCodes.STORE_SLICE_2, "STORE_SLICE_2")],
|
|
34
|
+
[43, new OpCode(OpCodes.STORE_SLICE_3, "STORE_SLICE_3")],
|
|
35
|
+
|
|
36
|
+
[50, new OpCode(OpCodes.DELETE_SLICE_0, "DELETE_SLICE_0")],
|
|
37
|
+
[51, new OpCode(OpCodes.DELETE_SLICE_1, "DELETE_SLICE_1")],
|
|
38
|
+
[52, new OpCode(OpCodes.DELETE_SLICE_2, "DELETE_SLICE_2")],
|
|
39
|
+
[53, new OpCode(OpCodes.DELETE_SLICE_3, "DELETE_SLICE_3")],
|
|
40
|
+
|
|
41
|
+
[60, new OpCode(OpCodes.STORE_SUBSCR, "STORE_SUBSCR")],
|
|
42
|
+
[61, new OpCode(OpCodes.DELETE_SUBSCR, "DELETE_SUBSCR")],
|
|
43
|
+
[62, new OpCode(OpCodes.BINARY_LSHIFT, "BINARY_LSHIFT")],
|
|
44
|
+
[63, new OpCode(OpCodes.BINARY_RSHIFT, "BINARY_RSHIFT")],
|
|
45
|
+
[64, new OpCode(OpCodes.BINARY_AND, "BINARY_AND")],
|
|
46
|
+
[65, new OpCode(OpCodes.BINARY_XOR, "BINARY_XOR")],
|
|
47
|
+
[66, new OpCode(OpCodes.BINARY_OR, "BINARY_OR")],
|
|
48
|
+
|
|
49
|
+
[70, new OpCode(OpCodes.PRINT_EXPR, "PRINT_EXPR")],
|
|
50
|
+
[71, new OpCode(OpCodes.PRINT_ITEM, "PRINT_ITEM")],
|
|
51
|
+
[72, new OpCode(OpCodes.PRINT_NEWLINE, "PRINT_NEWLINE")],
|
|
52
|
+
|
|
53
|
+
[80, new OpCode(OpCodes.BREAK_LOOP, "BREAK_LOOP")],
|
|
54
|
+
|
|
55
|
+
[82, new OpCode(OpCodes.LOAD_LOCALS, "LOAD_LOCALS")],
|
|
56
|
+
[83, new OpCode(OpCodes.RETURN_VALUE, "RETURN_VALUE")],
|
|
57
|
+
|
|
58
|
+
[85, new OpCode(OpCodes.EXEC_STMT, "EXEC_STMT")],
|
|
59
|
+
|
|
60
|
+
[87, new OpCode(OpCodes.POP_BLOCK, "POP_BLOCK")],
|
|
61
|
+
[88, new OpCode(OpCodes.END_FINALLY, "END_FINALLY")],
|
|
62
|
+
[89, new OpCode(OpCodes.BUILD_CLASS, "BUILD_CLASS")],
|
|
63
|
+
[90, new OpCode(OpCodes.STORE_NAME_A, "STORE_NAME", {HasArgument: true, HasName: true})],
|
|
64
|
+
[91, new OpCode(OpCodes.DELETE_NAME_A, "DELETE_NAME", {HasArgument: true, HasName: true})],
|
|
65
|
+
[92, new OpCode(OpCodes.UNPACK_TUPLE_A, "UNPACK_TUPLE", {HasArgument: true})],
|
|
66
|
+
[93, new OpCode(OpCodes.UNPACK_LIST_A, "UNPACK_LIST", {HasArgument: true})],
|
|
67
|
+
|
|
68
|
+
[95, new OpCode(OpCodes.STORE_ATTR_A, "STORE_ATTR", {HasArgument: true, HasName: true})],
|
|
69
|
+
[96, new OpCode(OpCodes.DELETE_ATTR_A, "DELETE_ATTR", {HasArgument: true, HasName: true})],
|
|
70
|
+
[97, new OpCode(OpCodes.STORE_GLOBAL_A, "STORE_GLOBAL", {HasArgument: true, HasName: true})],
|
|
71
|
+
[98, new OpCode(OpCodes.DELETE_GLOBAL_A, "DELETE_GLOBAL", {HasArgument: true, HasName: true})],
|
|
72
|
+
|
|
73
|
+
[100, new OpCode(OpCodes.LOAD_CONST_A, "LOAD_CONST", {HasArgument: true, HasConstant: true})],
|
|
74
|
+
[101, new OpCode(OpCodes.LOAD_NAME_A, "LOAD_NAME", {HasArgument: true, HasName: true})],
|
|
75
|
+
[102, new OpCode(OpCodes.BUILD_TUPLE_A, "BUILD_TUPLE", {HasArgument: true})],
|
|
76
|
+
[103, new OpCode(OpCodes.BUILD_LIST_A, "BUILD_LIST", {HasArgument: true})],
|
|
77
|
+
[104, new OpCode(OpCodes.BUILD_MAP_A, "BUILD_MAP", {HasArgument: true})],
|
|
78
|
+
[105, new OpCode(OpCodes.LOAD_ATTR_A, "LOAD_ATTR", {HasArgument: true, HasName: true})],
|
|
79
|
+
[106, new OpCode(OpCodes.COMPARE_OP_A, "COMPARE_OP", {HasArgument: true, HasCompare: true})],
|
|
80
|
+
[107, new OpCode(OpCodes.IMPORT_NAME_A, "IMPORT_NAME", {HasArgument: true, HasName: true})],
|
|
81
|
+
[108, new OpCode(OpCodes.IMPORT_FROM_A, "IMPORT_FROM", {HasArgument: true, HasName: true})],
|
|
82
|
+
|
|
83
|
+
[110, new OpCode(OpCodes.JUMP_FORWARD_A, "JUMP_FORWARD", {HasArgument: true, HasJumpRelative: true})],
|
|
84
|
+
[111, new OpCode(OpCodes.JUMP_IF_FALSE_A, "JUMP_IF_FALSE", {HasArgument: true, HasJumpRelative: true})],
|
|
85
|
+
[112, new OpCode(OpCodes.JUMP_IF_TRUE_A, "JUMP_IF_TRUE", {HasArgument: true, HasJumpRelative: true})],
|
|
86
|
+
[113, new OpCode(OpCodes.JUMP_ABSOLUTE_A, "JUMP_ABSOLUTE", {HasArgument: true, HasJumpAbsolute: true})],
|
|
87
|
+
[114, new OpCode(OpCodes.FOR_LOOP_A, "FOR_LOOP", {HasArgument: true, HasJumpRelative: true})],
|
|
88
|
+
|
|
89
|
+
[116, new OpCode(OpCodes.LOAD_GLOBAL_A, "LOAD_GLOBAL", {HasArgument: true, HasName: true})],
|
|
90
|
+
|
|
91
|
+
[120, new OpCode(OpCodes.SETUP_LOOP_A, "SETUP_LOOP", {HasArgument: true, HasJumpRelative: true})],
|
|
92
|
+
[121, new OpCode(OpCodes.SETUP_EXCEPT_A, "SETUP_EXCEPT", {HasArgument: true, HasJumpRelative: true})],
|
|
93
|
+
[122, new OpCode(OpCodes.SETUP_FINALLY_A, "SETUP_FINALLY", {HasArgument: true, HasJumpRelative: true})],
|
|
94
|
+
|
|
95
|
+
[124, new OpCode(OpCodes.LOAD_FAST_A, "LOAD_FAST", {HasArgument: true, HasLocal: true})],
|
|
96
|
+
[125, new OpCode(OpCodes.STORE_FAST_A, "STORE_FAST", {HasArgument: true, HasLocal: true})],
|
|
97
|
+
[126, new OpCode(OpCodes.DELETE_FAST_A, "DELETE_FAST", {HasArgument: true, HasLocal: true})],
|
|
98
|
+
[127, new OpCode(OpCodes.SET_LINENO_A, "SET_LINENO", {HasArgument: true})],
|
|
99
|
+
|
|
100
|
+
[130, new OpCode(OpCodes.RAISE_VARARGS_A, "RAISE_VARARGS", {HasArgument: true})],
|
|
101
|
+
[131, new OpCode(OpCodes.CALL_FUNCTION_A, "CALL_FUNCTION", {HasArgument: true})],
|
|
102
|
+
[132, new OpCode(OpCodes.MAKE_FUNCTION_A, "MAKE_FUNCTION", {HasArgument: true})],
|
|
103
|
+
[133, new OpCode(OpCodes.BUILD_SLICE_A, "BUILD_SLICE", {HasArgument: true})]
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
class Python1_5_OpCodes extends OpCodes {
|
|
107
|
+
constructor(co) {
|
|
108
|
+
super();
|
|
109
|
+
this.PopulateOpCodes(opcodes);
|
|
110
|
+
this.SetupByteCode(co);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
PopulateOpCodes(opCodeList) {
|
|
114
|
+
for (let [idx, opcode] of opCodeList) {
|
|
115
|
+
this.OpCodeList[idx] = opcode;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
module.exports = Python1_5_OpCodes;
|