depyo 1.0.2 → 1.0.3

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.
@@ -66,19 +66,19 @@ const opcodes = [
66
66
  [60, new OpCode(OpCodes.CONVERT_VALUE_A, "CONVERT_VALUE", {HasArgument: true})],
67
67
  [61, new OpCode(OpCodes.COPY_A, "COPY", {HasArgument: true})],
68
68
  [62, new OpCode(OpCodes.COPY_FREE_VARS_A, "COPY_FREE_VARS", {HasArgument: true})],
69
- [63, new OpCode(OpCodes.DELETE_ATTR_A, "DELETE_ATTR", {HasArgument: true})],
70
- [64, new OpCode(OpCodes.DELETE_DEREF_A, "DELETE_DEREF", {HasArgument: true})],
71
- [65, new OpCode(OpCodes.DELETE_FAST_A, "DELETE_FAST", {HasArgument: true})],
72
- [66, new OpCode(OpCodes.DELETE_GLOBAL_A, "DELETE_GLOBAL", {HasArgument: true})],
73
- [67, new OpCode(OpCodes.DELETE_NAME_A, "DELETE_NAME", {HasArgument: true})],
69
+ [63, new OpCode(OpCodes.DELETE_ATTR_A, "DELETE_ATTR", {HasArgument: true, HasName: true})],
70
+ [64, new OpCode(OpCodes.DELETE_DEREF_A, "DELETE_DEREF", {HasArgument: true, HasFree: true})],
71
+ [65, new OpCode(OpCodes.DELETE_FAST_A, "DELETE_FAST", {HasArgument: true, HasLocal: true})],
72
+ [66, new OpCode(OpCodes.DELETE_GLOBAL_A, "DELETE_GLOBAL", {HasArgument: true, HasName: true})],
73
+ [67, new OpCode(OpCodes.DELETE_NAME_A, "DELETE_NAME", {HasArgument: true, HasName: true})],
74
74
  [68, new OpCode(OpCodes.DICT_MERGE_A, "DICT_MERGE", {HasArgument: true})],
75
75
  [69, new OpCode(OpCodes.DICT_UPDATE_A, "DICT_UPDATE", {HasArgument: true})],
76
76
  [70, new OpCode(OpCodes.ENTER_EXECUTOR_A, "ENTER_EXECUTOR", {HasArgument: true})],
77
77
  [71, new OpCode(OpCodes.EXTENDED_ARG_A, "EXTENDED_ARG", {HasArgument: true})],
78
78
  [72, new OpCode(OpCodes.FOR_ITER_A, "FOR_ITER", {HasArgument: true})],
79
79
  [73, new OpCode(OpCodes.GET_AWAITABLE_A, "GET_AWAITABLE", {HasArgument: true})],
80
- [74, new OpCode(OpCodes.IMPORT_FROM_A, "IMPORT_FROM", {HasArgument: true})],
81
- [75, new OpCode(OpCodes.IMPORT_NAME_A, "IMPORT_NAME", {HasArgument: true})],
80
+ [74, new OpCode(OpCodes.IMPORT_FROM_A, "IMPORT_FROM", {HasArgument: true, HasName: true})],
81
+ [75, new OpCode(OpCodes.IMPORT_NAME_A, "IMPORT_NAME", {HasArgument: true, HasName: true})],
82
82
  [76, new OpCode(OpCodes.IS_OP_A, "IS_OP", {HasArgument: true})],
83
83
  [77, new OpCode(OpCodes.JUMP_BACKWARD_A, "JUMP_BACKWARD", {HasArgument: true})],
84
84
  [78, new OpCode(OpCodes.JUMP_BACKWARD_NO_INTERRUPT_A, "JUMP_BACKWARD_NO_INTERRUPT", {HasArgument: true})],
@@ -87,17 +87,17 @@ const opcodes = [
87
87
  [81, new OpCode(OpCodes.LIST_EXTEND_A, "LIST_EXTEND", {HasArgument: true})],
88
88
  [82, new OpCode(OpCodes.LOAD_ATTR_A, "LOAD_ATTR", {HasArgument: true, HasName: true})],
89
89
  [83, new OpCode(OpCodes.LOAD_CONST_A, "LOAD_CONST", {HasArgument: true, HasConstant: true})],
90
- [84, new OpCode(OpCodes.LOAD_DEREF_A, "LOAD_DEREF", {HasArgument: true})],
90
+ [84, new OpCode(OpCodes.LOAD_DEREF_A, "LOAD_DEREF", {HasArgument: true, HasFree: true})],
91
91
  [85, new OpCode(OpCodes.LOAD_FAST_A, "LOAD_FAST", {HasArgument: true, HasLocal: true})],
92
92
  [86, new OpCode(OpCodes.LOAD_FAST_AND_CLEAR_A, "LOAD_FAST_AND_CLEAR", {HasArgument: true, HasLocal: true})],
93
93
  [87, new OpCode(OpCodes.LOAD_FAST_CHECK_A, "LOAD_FAST_CHECK", {HasArgument: true, HasLocal: true})],
94
94
  [88, new OpCode(OpCodes.LOAD_FAST_LOAD_FAST_A, "LOAD_FAST_LOAD_FAST", {HasArgument: true, HasLocal: true})],
95
- [89, new OpCode(OpCodes.LOAD_FROM_DICT_OR_DEREF_A, "LOAD_FROM_DICT_OR_DEREF", {HasArgument: true, HasLocal: true, HasName: true})],
95
+ [89, new OpCode(OpCodes.LOAD_FROM_DICT_OR_DEREF_A, "LOAD_FROM_DICT_OR_DEREF", {HasArgument: true, HasFree: true})],
96
96
  [90, new OpCode(OpCodes.LOAD_FROM_DICT_OR_GLOBALS_A, "LOAD_FROM_DICT_OR_GLOBALS", {HasArgument: true, HasName: true})],
97
97
  [91, new OpCode(OpCodes.LOAD_GLOBAL_A, "LOAD_GLOBAL", {HasArgument: true, HasName: true})],
98
98
  [92, new OpCode(OpCodes.LOAD_NAME_A, "LOAD_NAME", {HasArgument: true, HasName: true})],
99
- [93, new OpCode(OpCodes.LOAD_SUPER_ATTR_A, "LOAD_SUPER_ATTR", {HasArgument: true})],
100
- [94, new OpCode(OpCodes.MAKE_CELL_A, "MAKE_CELL", {HasArgument: true})],
99
+ [93, new OpCode(OpCodes.LOAD_SUPER_ATTR_A, "LOAD_SUPER_ATTR", {HasArgument: true, HasName: true})],
100
+ [94, new OpCode(OpCodes.MAKE_CELL_A, "MAKE_CELL", {HasArgument: true, HasFree: true})],
101
101
  [95, new OpCode(OpCodes.MAP_ADD_A, "MAP_ADD", {HasArgument: true})],
102
102
  [96, new OpCode(OpCodes.MATCH_CLASS_A, "MATCH_CLASS", {HasArgument: true})],
103
103
  [97, new OpCode(OpCodes.POP_JUMP_IF_FALSE_A, "POP_JUMP_IF_FALSE", {HasArgument: true})],
@@ -112,7 +112,7 @@ const opcodes = [
112
112
  [106, new OpCode(OpCodes.SET_FUNCTION_ATTRIBUTE_A, "SET_FUNCTION_ATTRIBUTE", {HasArgument: true})],
113
113
  [107, new OpCode(OpCodes.SET_UPDATE_A, "SET_UPDATE", {HasArgument: true})],
114
114
  [108, new OpCode(OpCodes.STORE_ATTR_A, "STORE_ATTR", {HasArgument: true, HasName: true})],
115
- [109, new OpCode(OpCodes.STORE_DEREF_A, "STORE_DEREF", {HasArgument: true})],
115
+ [109, new OpCode(OpCodes.STORE_DEREF_A, "STORE_DEREF", {HasArgument: true, HasFree: true})],
116
116
  [110, new OpCode(OpCodes.STORE_FAST_A, "STORE_FAST", {HasArgument: true, HasLocal: true})],
117
117
  [111, new OpCode(OpCodes.STORE_FAST_LOAD_FAST_A, "STORE_FAST_LOAD_FAST", {HasArgument: true, HasLocal: true})],
118
118
  [112, new OpCode(OpCodes.STORE_FAST_STORE_FAST_A, "STORE_FAST_STORE_FAST", {HasArgument: true, HasLocal: true})],
@@ -144,7 +144,7 @@ const opcodes = [
144
144
  [254, new OpCode(OpCodes.INSTRUMENTED_LINE_A, "INSTRUMENTED_LINE", {HasArgument: true})],
145
145
  [256, new OpCode(OpCodes.JUMP_A, "JUMP", {HasArgument: true})],
146
146
  [257, new OpCode(OpCodes.JUMP_NO_INTERRUPT_A, "JUMP_NO_INTERRUPT", {HasArgument: true})],
147
- [258, new OpCode(OpCodes.LOAD_CLOSURE_A, "LOAD_CLOSURE", {HasArgument: true})],
147
+ [258, new OpCode(OpCodes.LOAD_CLOSURE_A, "LOAD_CLOSURE", {HasArgument: true, HasFree: true})],
148
148
  [259, new OpCode(OpCodes.LOAD_METHOD_A, "LOAD_METHOD", {HasArgument: true})],
149
149
  [260, new OpCode(OpCodes.LOAD_SUPER_METHOD_A, "LOAD_SUPER_METHOD", {HasArgument: true})],
150
150
  [261, new OpCode(OpCodes.LOAD_ZERO_SUPER_ATTR_A, "LOAD_ZERO_SUPER_ATTR", {HasArgument: true})],
@@ -64,19 +64,19 @@ const opcodes = [
64
64
  [58, new OpCode(OpCodes.CONVERT_VALUE_A, "CONVERT_VALUE", {HasArgument: true})],
65
65
  [59, new OpCode(OpCodes.COPY_A, "COPY", {HasArgument: true})],
66
66
  [60, new OpCode(OpCodes.COPY_FREE_VARS_A, "COPY_FREE_VARS", {HasArgument: true})],
67
- [61, new OpCode(OpCodes.DELETE_ATTR_A, "DELETE_ATTR", {HasArgument: true})],
68
- [62, new OpCode(OpCodes.DELETE_DEREF_A, "DELETE_DEREF", {HasArgument: true})],
69
- [63, new OpCode(OpCodes.DELETE_FAST_A, "DELETE_FAST", {HasArgument: true})],
70
- [64, new OpCode(OpCodes.DELETE_GLOBAL_A, "DELETE_GLOBAL", {HasArgument: true})],
71
- [65, new OpCode(OpCodes.DELETE_NAME_A, "DELETE_NAME", {HasArgument: true})],
67
+ [61, new OpCode(OpCodes.DELETE_ATTR_A, "DELETE_ATTR", {HasArgument: true, HasName: true})],
68
+ [62, new OpCode(OpCodes.DELETE_DEREF_A, "DELETE_DEREF", {HasArgument: true, HasFree: true})],
69
+ [63, new OpCode(OpCodes.DELETE_FAST_A, "DELETE_FAST", {HasArgument: true, HasLocal: true})],
70
+ [64, new OpCode(OpCodes.DELETE_GLOBAL_A, "DELETE_GLOBAL", {HasArgument: true, HasName: true})],
71
+ [65, new OpCode(OpCodes.DELETE_NAME_A, "DELETE_NAME", {HasArgument: true, HasName: true})],
72
72
  [66, new OpCode(OpCodes.DICT_MERGE_A, "DICT_MERGE", {HasArgument: true})],
73
73
  [67, new OpCode(OpCodes.DICT_UPDATE_A, "DICT_UPDATE", {HasArgument: true})],
74
74
  [68, new OpCode(OpCodes.END_ASYNC_FOR_A, "END_ASYNC_FOR", {HasArgument: true})],
75
75
  [69, new OpCode(OpCodes.EXTENDED_ARG_A, "EXTENDED_ARG", {HasArgument: true})],
76
76
  [70, new OpCode(OpCodes.FOR_ITER_A, "FOR_ITER", {HasArgument: true})],
77
77
  [71, new OpCode(OpCodes.GET_AWAITABLE_A, "GET_AWAITABLE", {HasArgument: true})],
78
- [72, new OpCode(OpCodes.IMPORT_FROM_A, "IMPORT_FROM", {HasArgument: true})],
79
- [73, new OpCode(OpCodes.IMPORT_NAME_A, "IMPORT_NAME", {HasArgument: true})],
78
+ [72, new OpCode(OpCodes.IMPORT_FROM_A, "IMPORT_FROM", {HasArgument: true, HasName: true})],
79
+ [73, new OpCode(OpCodes.IMPORT_NAME_A, "IMPORT_NAME", {HasArgument: true, HasName: true})],
80
80
  [74, new OpCode(OpCodes.IS_OP_A, "IS_OP", {HasArgument: true})],
81
81
  [75, new OpCode(OpCodes.JUMP_BACKWARD_A, "JUMP_BACKWARD", {HasArgument: true})],
82
82
  [76, new OpCode(OpCodes.JUMP_BACKWARD_NO_INTERRUPT_A, "JUMP_BACKWARD_NO_INTERRUPT", {HasArgument: true})],
@@ -86,21 +86,21 @@ const opcodes = [
86
86
  [80, new OpCode(OpCodes.LOAD_ATTR_A, "LOAD_ATTR", {HasArgument: true, HasName: true})],
87
87
  [81, new OpCode(OpCodes.LOAD_COMMON_CONSTANT_A, "LOAD_COMMON_CONSTANT", {HasArgument: true})],
88
88
  [82, new OpCode(OpCodes.LOAD_CONST_A, "LOAD_CONST", {HasArgument: true, HasConstant: true})],
89
- [83, new OpCode(OpCodes.LOAD_DEREF_A, "LOAD_DEREF", {HasArgument: true})],
89
+ [83, new OpCode(OpCodes.LOAD_DEREF_A, "LOAD_DEREF", {HasArgument: true, HasFree: true})],
90
90
  [84, new OpCode(OpCodes.LOAD_FAST_A, "LOAD_FAST", {HasArgument: true, HasLocal: true})],
91
91
  [85, new OpCode(OpCodes.LOAD_FAST_AND_CLEAR_A, "LOAD_FAST_AND_CLEAR", {HasArgument: true, HasLocal: true})],
92
92
  [86, new OpCode(OpCodes.LOAD_FAST_BORROW_A, "LOAD_FAST_BORROW", {HasArgument: true, HasLocal: true})],
93
93
  [87, new OpCode(OpCodes.LOAD_FAST_BORROW_LOAD_FAST_BORROW_A, "LOAD_FAST_BORROW_LOAD_FAST_BORROW", {HasArgument: true, HasLocal: true})],
94
94
  [88, new OpCode(OpCodes.LOAD_FAST_CHECK_A, "LOAD_FAST_CHECK", {HasArgument: true, HasLocal: true})],
95
95
  [89, new OpCode(OpCodes.LOAD_FAST_LOAD_FAST_A, "LOAD_FAST_LOAD_FAST", {HasArgument: true, HasLocal: true})],
96
- [90, new OpCode(OpCodes.LOAD_FROM_DICT_OR_DEREF_A, "LOAD_FROM_DICT_OR_DEREF", {HasArgument: true, HasLocal: true, HasName: true})],
96
+ [90, new OpCode(OpCodes.LOAD_FROM_DICT_OR_DEREF_A, "LOAD_FROM_DICT_OR_DEREF", {HasArgument: true, HasFree: true})],
97
97
  [91, new OpCode(OpCodes.LOAD_FROM_DICT_OR_GLOBALS_A, "LOAD_FROM_DICT_OR_GLOBALS", {HasArgument: true, HasName: true})],
98
98
  [92, new OpCode(OpCodes.LOAD_GLOBAL_A, "LOAD_GLOBAL", {HasArgument: true, HasName: true})],
99
99
  [93, new OpCode(OpCodes.LOAD_NAME_A, "LOAD_NAME", {HasArgument: true, HasName: true})],
100
100
  [94, new OpCode(OpCodes.LOAD_SMALL_INT_A, "LOAD_SMALL_INT", {HasArgument: true})],
101
101
  [95, new OpCode(OpCodes.LOAD_SPECIAL_A, "LOAD_SPECIAL", {HasArgument: true})],
102
- [96, new OpCode(OpCodes.LOAD_SUPER_ATTR_A, "LOAD_SUPER_ATTR", {HasArgument: true})],
103
- [97, new OpCode(OpCodes.MAKE_CELL_A, "MAKE_CELL", {HasArgument: true})],
102
+ [96, new OpCode(OpCodes.LOAD_SUPER_ATTR_A, "LOAD_SUPER_ATTR", {HasArgument: true, HasName: true})],
103
+ [97, new OpCode(OpCodes.MAKE_CELL_A, "MAKE_CELL", {HasArgument: true, HasFree: true})],
104
104
  [98, new OpCode(OpCodes.MAP_ADD_A, "MAP_ADD", {HasArgument: true})],
105
105
  [99, new OpCode(OpCodes.MATCH_CLASS_A, "MATCH_CLASS", {HasArgument: true})],
106
106
  [100, new OpCode(OpCodes.POP_JUMP_IF_FALSE_A, "POP_JUMP_IF_FALSE", {HasArgument: true})],
@@ -114,7 +114,7 @@ const opcodes = [
114
114
  [108, new OpCode(OpCodes.SET_FUNCTION_ATTRIBUTE_A, "SET_FUNCTION_ATTRIBUTE", {HasArgument: true})],
115
115
  [109, new OpCode(OpCodes.SET_UPDATE_A, "SET_UPDATE", {HasArgument: true})],
116
116
  [110, new OpCode(OpCodes.STORE_ATTR_A, "STORE_ATTR", {HasArgument: true, HasName: true})],
117
- [111, new OpCode(OpCodes.STORE_DEREF_A, "STORE_DEREF", {HasArgument: true})],
117
+ [111, new OpCode(OpCodes.STORE_DEREF_A, "STORE_DEREF", {HasArgument: true, HasFree: true})],
118
118
  [112, new OpCode(OpCodes.STORE_FAST_A, "STORE_FAST", {HasArgument: true, HasLocal: true})],
119
119
  [113, new OpCode(OpCodes.STORE_FAST_LOAD_FAST_A, "STORE_FAST_LOAD_FAST", {HasArgument: true, HasLocal: true})],
120
120
  [114, new OpCode(OpCodes.STORE_FAST_STORE_FAST_A, "STORE_FAST_STORE_FAST", {HasArgument: true, HasLocal: true})],
@@ -152,7 +152,7 @@ const opcodes = [
152
152
  [258, new OpCode(OpCodes.JUMP_IF_FALSE_A, "JUMP_IF_FALSE", {HasArgument: true})],
153
153
  [259, new OpCode(OpCodes.JUMP_IF_TRUE_A, "JUMP_IF_TRUE", {HasArgument: true})],
154
154
  [260, new OpCode(OpCodes.JUMP_NO_INTERRUPT_A, "JUMP_NO_INTERRUPT", {HasArgument: true})],
155
- [261, new OpCode(OpCodes.LOAD_CLOSURE_A, "LOAD_CLOSURE", {HasArgument: true})],
155
+ [261, new OpCode(OpCodes.LOAD_CLOSURE_A, "LOAD_CLOSURE", {HasArgument: true, HasFree: true})],
156
156
  [262, new OpCode(OpCodes.POP_BLOCK_A, "POP_BLOCK", {HasArgument: true})],
157
157
  [263, new OpCode(OpCodes.SETUP_CLEANUP_A, "SETUP_CLEANUP", {HasArgument: true})],
158
158
  [264, new OpCode(OpCodes.SETUP_FINALLY_A, "SETUP_FINALLY", {HasArgument: true})],
@@ -0,0 +1,183 @@
1
+ // Python 3.15 OpCodes
2
+ // Generated from CPython v3.15.0a8 opcode.opmap.
3
+ // Notable changes vs 3.14:
4
+ // - GET_YIELD_FROM_ITER removed
5
+ // - GET_ITER moved 16 -> 70 and now takes an argument
6
+ // - INSTRUMENTED_END_FOR/POP_ITER/END_SEND/etc. shifted down by one
7
+ // - TRACE_RECORD added at 255 (instrumentation only; ignore)
8
+ // - ENTER_EXECUTOR moved 255 -> 254
9
+ const OpCode = require('../OpCode');
10
+ const OpCodes = require('../OpCodes');
11
+
12
+ const opcodes = [
13
+ [0, new OpCode(OpCodes.CACHE, "CACHE")],
14
+ [1, new OpCode(OpCodes.BINARY_SLICE, "BINARY_SLICE")],
15
+ [2, new OpCode(OpCodes.BUILD_TEMPLATE, "BUILD_TEMPLATE")],
16
+ [4, new OpCode(OpCodes.CALL_FUNCTION_EX, "CALL_FUNCTION_EX")],
17
+ [5, new OpCode(OpCodes.CHECK_EG_MATCH, "CHECK_EG_MATCH")],
18
+ [6, new OpCode(OpCodes.CHECK_EXC_MATCH, "CHECK_EXC_MATCH")],
19
+ [7, new OpCode(OpCodes.CLEANUP_THROW, "CLEANUP_THROW")],
20
+ [8, new OpCode(OpCodes.DELETE_SUBSCR, "DELETE_SUBSCR")],
21
+ [9, new OpCode(OpCodes.END_FOR, "END_FOR")],
22
+ [10, new OpCode(OpCodes.END_SEND, "END_SEND")],
23
+ [11, new OpCode(OpCodes.EXIT_INIT_CHECK, "EXIT_INIT_CHECK")],
24
+ [12, new OpCode(OpCodes.FORMAT_SIMPLE, "FORMAT_SIMPLE")],
25
+ [13, new OpCode(OpCodes.FORMAT_WITH_SPEC, "FORMAT_WITH_SPEC")],
26
+ [14, new OpCode(OpCodes.GET_AITER, "GET_AITER")],
27
+ [15, new OpCode(OpCodes.GET_ANEXT, "GET_ANEXT")],
28
+ [16, new OpCode(OpCodes.GET_LEN, "GET_LEN")],
29
+ [17, new OpCode(OpCodes.RESERVED, "RESERVED")],
30
+ [18, new OpCode(OpCodes.INTERPRETER_EXIT, "INTERPRETER_EXIT")],
31
+ [19, new OpCode(OpCodes.LOAD_BUILD_CLASS, "LOAD_BUILD_CLASS")],
32
+ [20, new OpCode(OpCodes.LOAD_LOCALS, "LOAD_LOCALS")],
33
+ [21, new OpCode(OpCodes.MAKE_FUNCTION, "MAKE_FUNCTION")],
34
+ [22, new OpCode(OpCodes.MATCH_KEYS, "MATCH_KEYS")],
35
+ [23, new OpCode(OpCodes.MATCH_MAPPING, "MATCH_MAPPING")],
36
+ [24, new OpCode(OpCodes.MATCH_SEQUENCE, "MATCH_SEQUENCE")],
37
+ [25, new OpCode(OpCodes.NOP, "NOP")],
38
+ [26, new OpCode(OpCodes.NOT_TAKEN, "NOT_TAKEN")],
39
+ [27, new OpCode(OpCodes.POP_EXCEPT, "POP_EXCEPT")],
40
+ [28, new OpCode(OpCodes.POP_ITER, "POP_ITER")],
41
+ [29, new OpCode(OpCodes.POP_TOP, "POP_TOP")],
42
+ [30, new OpCode(OpCodes.PUSH_EXC_INFO, "PUSH_EXC_INFO")],
43
+ [31, new OpCode(OpCodes.PUSH_NULL, "PUSH_NULL")],
44
+ [32, new OpCode(OpCodes.RETURN_GENERATOR, "RETURN_GENERATOR")],
45
+ [33, new OpCode(OpCodes.RETURN_VALUE, "RETURN_VALUE")],
46
+ [34, new OpCode(OpCodes.SETUP_ANNOTATIONS, "SETUP_ANNOTATIONS")],
47
+ [35, new OpCode(OpCodes.STORE_SLICE, "STORE_SLICE")],
48
+ [36, new OpCode(OpCodes.STORE_SUBSCR, "STORE_SUBSCR")],
49
+ [37, new OpCode(OpCodes.TO_BOOL, "TO_BOOL")],
50
+ [38, new OpCode(OpCodes.UNARY_INVERT, "UNARY_INVERT")],
51
+ [39, new OpCode(OpCodes.UNARY_NEGATIVE, "UNARY_NEGATIVE")],
52
+ [40, new OpCode(OpCodes.UNARY_NOT, "UNARY_NOT")],
53
+ [41, new OpCode(OpCodes.WITH_EXCEPT_START_A, "WITH_EXCEPT_START", {HasArgument: true})],
54
+ [42, new OpCode(OpCodes.BINARY_OP_A, "BINARY_OP", {HasArgument: true})],
55
+ [43, new OpCode(OpCodes.BUILD_INTERPOLATION_A, "BUILD_INTERPOLATION", {HasArgument: true})],
56
+ [44, new OpCode(OpCodes.BUILD_LIST_A, "BUILD_LIST", {HasArgument: true})],
57
+ [45, new OpCode(OpCodes.BUILD_MAP_A, "BUILD_MAP", {HasArgument: true})],
58
+ [46, new OpCode(OpCodes.BUILD_SET_A, "BUILD_SET", {HasArgument: true})],
59
+ [47, new OpCode(OpCodes.BUILD_SLICE_A, "BUILD_SLICE", {HasArgument: true})],
60
+ [48, new OpCode(OpCodes.BUILD_STRING_A, "BUILD_STRING", {HasArgument: true})],
61
+ [49, new OpCode(OpCodes.BUILD_TUPLE_A, "BUILD_TUPLE", {HasArgument: true})],
62
+ [50, new OpCode(OpCodes.CALL_A, "CALL", {HasArgument: true})],
63
+ [51, new OpCode(OpCodes.CALL_INTRINSIC_1_A, "CALL_INTRINSIC_1", {HasArgument: true})],
64
+ [52, new OpCode(OpCodes.CALL_INTRINSIC_2_A, "CALL_INTRINSIC_2", {HasArgument: true})],
65
+ [53, new OpCode(OpCodes.CALL_KW_A, "CALL_KW", {HasArgument: true})],
66
+ [54, new OpCode(OpCodes.COMPARE_OP_A, "COMPARE_OP", {HasArgument: true})],
67
+ [55, new OpCode(OpCodes.CONTAINS_OP_A, "CONTAINS_OP", {HasArgument: true})],
68
+ [56, new OpCode(OpCodes.CONVERT_VALUE_A, "CONVERT_VALUE", {HasArgument: true})],
69
+ [57, new OpCode(OpCodes.COPY_A, "COPY", {HasArgument: true})],
70
+ [58, new OpCode(OpCodes.COPY_FREE_VARS_A, "COPY_FREE_VARS", {HasArgument: true})],
71
+ [59, new OpCode(OpCodes.DELETE_ATTR_A, "DELETE_ATTR", {HasArgument: true, HasName: true})],
72
+ [60, new OpCode(OpCodes.DELETE_DEREF_A, "DELETE_DEREF", {HasArgument: true, HasFree: true})],
73
+ [61, new OpCode(OpCodes.DELETE_FAST_A, "DELETE_FAST", {HasArgument: true, HasLocal: true})],
74
+ [62, new OpCode(OpCodes.DELETE_GLOBAL_A, "DELETE_GLOBAL", {HasArgument: true, HasName: true})],
75
+ [63, new OpCode(OpCodes.DELETE_NAME_A, "DELETE_NAME", {HasArgument: true, HasName: true})],
76
+ [64, new OpCode(OpCodes.DICT_MERGE_A, "DICT_MERGE", {HasArgument: true})],
77
+ [65, new OpCode(OpCodes.DICT_UPDATE_A, "DICT_UPDATE", {HasArgument: true})],
78
+ [66, new OpCode(OpCodes.END_ASYNC_FOR_A, "END_ASYNC_FOR", {HasArgument: true})],
79
+ [67, new OpCode(OpCodes.EXTENDED_ARG_A, "EXTENDED_ARG", {HasArgument: true})],
80
+ [68, new OpCode(OpCodes.FOR_ITER_A, "FOR_ITER", {HasArgument: true})],
81
+ [69, new OpCode(OpCodes.GET_AWAITABLE_A, "GET_AWAITABLE", {HasArgument: true})],
82
+ [70, new OpCode(OpCodes.GET_ITER, "GET_ITER", {HasArgument: true})],
83
+ [71, new OpCode(OpCodes.IMPORT_FROM_A, "IMPORT_FROM", {HasArgument: true, HasName: true})],
84
+ [72, new OpCode(OpCodes.IMPORT_NAME_A, "IMPORT_NAME", {HasArgument: true, HasName: true})],
85
+ [73, new OpCode(OpCodes.IS_OP_A, "IS_OP", {HasArgument: true})],
86
+ [74, new OpCode(OpCodes.JUMP_BACKWARD_A, "JUMP_BACKWARD", {HasArgument: true})],
87
+ [75, new OpCode(OpCodes.JUMP_BACKWARD_NO_INTERRUPT_A, "JUMP_BACKWARD_NO_INTERRUPT", {HasArgument: true})],
88
+ [76, new OpCode(OpCodes.JUMP_FORWARD_A, "JUMP_FORWARD", {HasArgument: true})],
89
+ [77, new OpCode(OpCodes.LIST_APPEND_A, "LIST_APPEND", {HasArgument: true})],
90
+ [78, new OpCode(OpCodes.LIST_EXTEND_A, "LIST_EXTEND", {HasArgument: true})],
91
+ [79, new OpCode(OpCodes.LOAD_ATTR_A, "LOAD_ATTR", {HasArgument: true, HasName: true})],
92
+ [80, new OpCode(OpCodes.LOAD_COMMON_CONSTANT_A, "LOAD_COMMON_CONSTANT", {HasArgument: true})],
93
+ [81, new OpCode(OpCodes.LOAD_CONST_A, "LOAD_CONST", {HasArgument: true, HasConstant: true})],
94
+ [82, new OpCode(OpCodes.LOAD_DEREF_A, "LOAD_DEREF", {HasArgument: true, HasFree: true})],
95
+ [83, new OpCode(OpCodes.LOAD_FAST_A, "LOAD_FAST", {HasArgument: true, HasLocal: true})],
96
+ [84, new OpCode(OpCodes.LOAD_FAST_AND_CLEAR_A, "LOAD_FAST_AND_CLEAR", {HasArgument: true, HasLocal: true})],
97
+ [85, new OpCode(OpCodes.LOAD_FAST_BORROW_A, "LOAD_FAST_BORROW", {HasArgument: true, HasLocal: true})],
98
+ [86, new OpCode(OpCodes.LOAD_FAST_BORROW_LOAD_FAST_BORROW_A, "LOAD_FAST_BORROW_LOAD_FAST_BORROW", {HasArgument: true, HasLocal: true})],
99
+ [87, new OpCode(OpCodes.LOAD_FAST_CHECK_A, "LOAD_FAST_CHECK", {HasArgument: true, HasLocal: true})],
100
+ [88, new OpCode(OpCodes.LOAD_FAST_LOAD_FAST_A, "LOAD_FAST_LOAD_FAST", {HasArgument: true, HasLocal: true})],
101
+ [89, new OpCode(OpCodes.LOAD_FROM_DICT_OR_DEREF_A, "LOAD_FROM_DICT_OR_DEREF", {HasArgument: true, HasFree: true})],
102
+ [90, new OpCode(OpCodes.LOAD_FROM_DICT_OR_GLOBALS_A, "LOAD_FROM_DICT_OR_GLOBALS", {HasArgument: true, HasName: true})],
103
+ [91, new OpCode(OpCodes.LOAD_GLOBAL_A, "LOAD_GLOBAL", {HasArgument: true, HasName: true})],
104
+ [92, new OpCode(OpCodes.LOAD_NAME_A, "LOAD_NAME", {HasArgument: true, HasName: true})],
105
+ [93, new OpCode(OpCodes.LOAD_SMALL_INT_A, "LOAD_SMALL_INT", {HasArgument: true})],
106
+ [94, new OpCode(OpCodes.LOAD_SPECIAL_A, "LOAD_SPECIAL", {HasArgument: true})],
107
+ [95, new OpCode(OpCodes.LOAD_SUPER_ATTR_A, "LOAD_SUPER_ATTR", {HasArgument: true, HasName: true})],
108
+ [96, new OpCode(OpCodes.MAKE_CELL_A, "MAKE_CELL", {HasArgument: true, HasFree: true})],
109
+ [97, new OpCode(OpCodes.MAP_ADD_A, "MAP_ADD", {HasArgument: true})],
110
+ [98, new OpCode(OpCodes.MATCH_CLASS_A, "MATCH_CLASS", {HasArgument: true})],
111
+ [99, new OpCode(OpCodes.POP_JUMP_IF_FALSE_A, "POP_JUMP_IF_FALSE", {HasArgument: true})],
112
+ [100, new OpCode(OpCodes.POP_JUMP_IF_NONE_A, "POP_JUMP_IF_NONE", {HasArgument: true})],
113
+ [101, new OpCode(OpCodes.POP_JUMP_IF_NOT_NONE_A, "POP_JUMP_IF_NOT_NONE", {HasArgument: true})],
114
+ [102, new OpCode(OpCodes.POP_JUMP_IF_TRUE_A, "POP_JUMP_IF_TRUE", {HasArgument: true})],
115
+ [103, new OpCode(OpCodes.RAISE_VARARGS_A, "RAISE_VARARGS", {HasArgument: true})],
116
+ [104, new OpCode(OpCodes.RERAISE_A, "RERAISE", {HasArgument: true})],
117
+ [105, new OpCode(OpCodes.SEND_A, "SEND", {HasArgument: true})],
118
+ [106, new OpCode(OpCodes.SET_ADD_A, "SET_ADD", {HasArgument: true})],
119
+ [107, new OpCode(OpCodes.SET_FUNCTION_ATTRIBUTE_A, "SET_FUNCTION_ATTRIBUTE", {HasArgument: true})],
120
+ [108, new OpCode(OpCodes.SET_UPDATE_A, "SET_UPDATE", {HasArgument: true})],
121
+ [109, new OpCode(OpCodes.STORE_ATTR_A, "STORE_ATTR", {HasArgument: true, HasName: true})],
122
+ [110, new OpCode(OpCodes.STORE_DEREF_A, "STORE_DEREF", {HasArgument: true, HasFree: true})],
123
+ [111, new OpCode(OpCodes.STORE_FAST_A, "STORE_FAST", {HasArgument: true, HasLocal: true})],
124
+ [112, new OpCode(OpCodes.STORE_FAST_LOAD_FAST_A, "STORE_FAST_LOAD_FAST", {HasArgument: true, HasLocal: true})],
125
+ [113, new OpCode(OpCodes.STORE_FAST_STORE_FAST_A, "STORE_FAST_STORE_FAST", {HasArgument: true, HasLocal: true})],
126
+ [114, new OpCode(OpCodes.STORE_GLOBAL_A, "STORE_GLOBAL", {HasArgument: true, HasName: true})],
127
+ [115, new OpCode(OpCodes.STORE_NAME_A, "STORE_NAME", {HasArgument: true, HasName: true})],
128
+ [116, new OpCode(OpCodes.SWAP_A, "SWAP", {HasArgument: true})],
129
+ [117, new OpCode(OpCodes.UNPACK_EX_A, "UNPACK_EX", {HasArgument: true})],
130
+ [118, new OpCode(OpCodes.UNPACK_SEQUENCE_A, "UNPACK_SEQUENCE", {HasArgument: true})],
131
+ [119, new OpCode(OpCodes.YIELD_VALUE_A, "YIELD_VALUE", {HasArgument: true})],
132
+ [128, new OpCode(OpCodes.RESUME_A, "RESUME", {HasArgument: true})],
133
+ [233, new OpCode(OpCodes.INSTRUMENTED_END_FOR_A, "INSTRUMENTED_END_FOR", {HasArgument: true})],
134
+ [234, new OpCode(OpCodes.INSTRUMENTED_POP_ITER_A, "INSTRUMENTED_POP_ITER", {HasArgument: true})],
135
+ [235, new OpCode(OpCodes.INSTRUMENTED_END_SEND_A, "INSTRUMENTED_END_SEND", {HasArgument: true})],
136
+ [236, new OpCode(OpCodes.INSTRUMENTED_FOR_ITER_A, "INSTRUMENTED_FOR_ITER", {HasArgument: true})],
137
+ [237, new OpCode(OpCodes.INSTRUMENTED_INSTRUCTION_A, "INSTRUMENTED_INSTRUCTION", {HasArgument: true})],
138
+ [238, new OpCode(OpCodes.INSTRUMENTED_JUMP_FORWARD_A, "INSTRUMENTED_JUMP_FORWARD", {HasArgument: true})],
139
+ [239, new OpCode(OpCodes.INSTRUMENTED_NOT_TAKEN_A, "INSTRUMENTED_NOT_TAKEN", {HasArgument: true})],
140
+ [240, new OpCode(OpCodes.INSTRUMENTED_POP_JUMP_IF_TRUE_A, "INSTRUMENTED_POP_JUMP_IF_TRUE", {HasArgument: true})],
141
+ [241, new OpCode(OpCodes.INSTRUMENTED_POP_JUMP_IF_FALSE_A, "INSTRUMENTED_POP_JUMP_IF_FALSE", {HasArgument: true})],
142
+ [242, new OpCode(OpCodes.INSTRUMENTED_POP_JUMP_IF_NONE_A, "INSTRUMENTED_POP_JUMP_IF_NONE", {HasArgument: true})],
143
+ [243, new OpCode(OpCodes.INSTRUMENTED_POP_JUMP_IF_NOT_NONE_A, "INSTRUMENTED_POP_JUMP_IF_NOT_NONE", {HasArgument: true})],
144
+ [244, new OpCode(OpCodes.INSTRUMENTED_RESUME_A, "INSTRUMENTED_RESUME", {HasArgument: true})],
145
+ [245, new OpCode(OpCodes.INSTRUMENTED_RETURN_VALUE_A, "INSTRUMENTED_RETURN_VALUE", {HasArgument: true})],
146
+ [246, new OpCode(OpCodes.INSTRUMENTED_YIELD_VALUE_A, "INSTRUMENTED_YIELD_VALUE", {HasArgument: true})],
147
+ [247, new OpCode(OpCodes.INSTRUMENTED_END_ASYNC_FOR_A, "INSTRUMENTED_END_ASYNC_FOR", {HasArgument: true})],
148
+ [248, new OpCode(OpCodes.INSTRUMENTED_LOAD_SUPER_ATTR_A, "INSTRUMENTED_LOAD_SUPER_ATTR", {HasArgument: true})],
149
+ [249, new OpCode(OpCodes.INSTRUMENTED_CALL_A, "INSTRUMENTED_CALL", {HasArgument: true})],
150
+ [250, new OpCode(OpCodes.INSTRUMENTED_CALL_KW_A, "INSTRUMENTED_CALL_KW", {HasArgument: true})],
151
+ [251, new OpCode(OpCodes.INSTRUMENTED_CALL_FUNCTION_EX_A, "INSTRUMENTED_CALL_FUNCTION_EX", {HasArgument: true})],
152
+ [252, new OpCode(OpCodes.INSTRUMENTED_JUMP_BACKWARD_A, "INSTRUMENTED_JUMP_BACKWARD", {HasArgument: true})],
153
+ [253, new OpCode(OpCodes.INSTRUMENTED_LINE_A, "INSTRUMENTED_LINE", {HasArgument: true})],
154
+ [254, new OpCode(OpCodes.ENTER_EXECUTOR_A, "ENTER_EXECUTOR", {HasArgument: true})],
155
+ [255, new OpCode(OpCodes.TRACE_RECORD_A, "TRACE_RECORD", {HasArgument: true})],
156
+ [256, new OpCode(OpCodes.ANNOTATIONS_PLACEHOLDER_A, "ANNOTATIONS_PLACEHOLDER", {HasArgument: true})],
157
+ [257, new OpCode(OpCodes.JUMP_A, "JUMP", {HasArgument: true})],
158
+ [258, new OpCode(OpCodes.JUMP_IF_FALSE_A, "JUMP_IF_FALSE", {HasArgument: true})],
159
+ [259, new OpCode(OpCodes.JUMP_IF_TRUE_A, "JUMP_IF_TRUE", {HasArgument: true})],
160
+ [260, new OpCode(OpCodes.JUMP_NO_INTERRUPT_A, "JUMP_NO_INTERRUPT", {HasArgument: true})],
161
+ [261, new OpCode(OpCodes.LOAD_CLOSURE_A, "LOAD_CLOSURE", {HasArgument: true, HasFree: true})],
162
+ [262, new OpCode(OpCodes.POP_BLOCK_A, "POP_BLOCK", {HasArgument: true})],
163
+ [263, new OpCode(OpCodes.SETUP_CLEANUP_A, "SETUP_CLEANUP", {HasArgument: true})],
164
+ [264, new OpCode(OpCodes.SETUP_FINALLY_A, "SETUP_FINALLY", {HasArgument: true})],
165
+ [265, new OpCode(OpCodes.SETUP_WITH_A, "SETUP_WITH", {HasArgument: true})],
166
+ [266, new OpCode(OpCodes.STORE_FAST_MAYBE_NULL_A, "STORE_FAST_MAYBE_NULL", {HasArgument: true})],
167
+ ];
168
+
169
+ class Python3_15_OpCodes extends OpCodes {
170
+ constructor(co) {
171
+ super();
172
+ this.PopulateOpCodes(opcodes);
173
+ this.SetupByteCode(co);
174
+ }
175
+
176
+ PopulateOpCodes(opCodeList) {
177
+ for (let [idx, opcode] of opCodeList) {
178
+ this.OpCodeList[idx] = opcode;
179
+ }
180
+ }
181
+ }
182
+
183
+ module.exports = Python3_15_OpCodes;
@@ -1,146 +1,107 @@
1
- class CodeReader {
2
- constructor(code, endian) {
3
- this.endian = endian || 'B';
4
- this._reader = Buffer.from(code);
5
- this._pc = 0;
6
- }
7
-
8
- get pc() {
9
- return this._pc;
10
- }
11
-
12
- set pc(pos) {
13
- if (pos > this.length || pos < 0) {
14
- pos = this.length;
15
- }
16
- this._pc = pos;
17
- }
18
-
19
- get length() {
20
- return this._reader.length
21
- }
22
-
23
- get EOF() {
24
- return this._pc >= this._reader.length;
25
- }
26
-
27
- readByte() {
28
- try {
29
- let value = this._reader.readUInt8(this.pc, true);
30
- this.pc++;
31
- return value;
32
- } catch {
33
- debugger;
34
- }
35
- }
36
-
37
- readUShort() {
38
- try {
39
- let value = this._reader[`readUInt16${this.endian}E`](this.pc, true);
40
- this.pc += 2;
41
- return value;
42
- } catch {
43
- debugger;
44
- }
45
- }
46
-
47
- readShort() {
48
- try {
49
- let value = this._reader[`readInt16${this.endian}E`](this.pc, true);
50
- this.pc += 2;
51
- return value;
52
- } catch {
53
- debugger;
54
- }
55
- }
56
-
57
- readInt() {
58
- try {
59
- let value = this._reader[`readInt32${this.endian}E`](this.pc, true);
60
- this.pc += 4;
61
- return value;
62
- } catch {
63
- debugger;
64
- }
65
- }
66
-
67
- readUInt() {
68
- try {
69
- let value = this._reader[`readUInt32${this.endian}E`](this.pc, true);
70
- this.pc += 4;
71
- return value;
72
- } catch (ex) {
73
- debugger;
74
- }
75
- }
76
-
77
- readLong() {
78
- try {
79
- let high = this.readInt()
80
- let low = this.readInt()
81
- return {low, high};
82
- } catch {
83
- debugger;
84
- }
85
- }
86
-
87
- readULong() {
88
- try {
89
- let high = this.readUInt()
90
- let low = this.readUInt()
91
- return {low, high};
92
- } catch {
93
- debugger;
94
- }
95
- }
96
-
97
- readFloat() {
98
- try {
99
- let value = this._reader[`readFloat${this.endian}E`](this.pc, true);
100
- this.pc += 4;
101
- return value;
102
- } catch {
103
- debugger;
104
- }
105
- }
106
-
107
- readDouble() {
108
- try {
109
- let value = this._reader[`readDouble${this.endian}E`](this.pc, true);
110
- this.pc += 8;
111
- return value;
112
- } catch {
113
- debugger;
114
- }
115
- }
116
-
117
- readBytes(length) {
118
- try {
119
- let value = this._reader.slice(this.pc, this.pc + length);
120
- this.pc += length;
121
- return value;
122
- } catch {
123
- debugger;
124
- }
125
- }
126
-
127
- readString(length) {
128
- try {
129
- let value = this._reader.slice(this.pc, this.pc + length).toString('utf8');
130
- this.pc += length;
131
- return value;
132
- } catch {
133
- debugger;
134
- }
135
- }
136
-
137
- peekByte() {
138
- try {
139
- return this._reader.readUInt8(this.pc, true);
140
- } catch {
141
- debugger;
142
- }
143
- }
144
- }
145
-
146
- module.exports = CodeReader;
1
+ class CodeReaderError extends Error {
2
+ constructor(message, pc, length) {
3
+ super(`${message} (pc=${pc}, length=${length})`);
4
+ this.name = 'CodeReaderError';
5
+ this.pc = pc;
6
+ this.length = length;
7
+ }
8
+ }
9
+
10
+ class CodeReader {
11
+ constructor(code, endian) {
12
+ this.endian = endian || 'B';
13
+ this._reader = Buffer.from(code);
14
+ this._pc = 0;
15
+ }
16
+
17
+ get pc() {
18
+ return this._pc;
19
+ }
20
+
21
+ set pc(pos) {
22
+ if (pos > this.length || pos < 0) {
23
+ pos = this.length;
24
+ }
25
+ this._pc = pos;
26
+ }
27
+
28
+ get length() {
29
+ return this._reader.length
30
+ }
31
+
32
+ get EOF() {
33
+ return this._pc >= this._reader.length;
34
+ }
35
+
36
+ _read(label, size, fn) {
37
+ if (this._pc + size > this._reader.length) {
38
+ throw new CodeReaderError(`${label}: read past end of buffer`, this._pc, this._reader.length);
39
+ }
40
+ try {
41
+ const value = fn();
42
+ this._pc += size;
43
+ return value;
44
+ } catch (ex) {
45
+ if (ex instanceof CodeReaderError) throw ex;
46
+ throw new CodeReaderError(`${label}: ${ex.message}`, this._pc, this._reader.length);
47
+ }
48
+ }
49
+
50
+ readByte() {
51
+ return this._read('readByte', 1, () => this._reader.readUInt8(this._pc, true));
52
+ }
53
+
54
+ readUShort() {
55
+ return this._read('readUShort', 2, () => this._reader[`readUInt16${this.endian}E`](this._pc, true));
56
+ }
57
+
58
+ readShort() {
59
+ return this._read('readShort', 2, () => this._reader[`readInt16${this.endian}E`](this._pc, true));
60
+ }
61
+
62
+ readInt() {
63
+ return this._read('readInt', 4, () => this._reader[`readInt32${this.endian}E`](this._pc, true));
64
+ }
65
+
66
+ readUInt() {
67
+ return this._read('readUInt', 4, () => this._reader[`readUInt32${this.endian}E`](this._pc, true));
68
+ }
69
+
70
+ readLong() {
71
+ const high = this.readInt();
72
+ const low = this.readInt();
73
+ return {low, high};
74
+ }
75
+
76
+ readULong() {
77
+ const high = this.readUInt();
78
+ const low = this.readUInt();
79
+ return {low, high};
80
+ }
81
+
82
+ readFloat() {
83
+ return this._read('readFloat', 4, () => this._reader[`readFloat${this.endian}E`](this._pc, true));
84
+ }
85
+
86
+ readDouble() {
87
+ return this._read('readDouble', 8, () => this._reader[`readDouble${this.endian}E`](this._pc, true));
88
+ }
89
+
90
+ readBytes(length) {
91
+ return this._read(`readBytes(${length})`, length, () => this._reader.slice(this._pc, this._pc + length));
92
+ }
93
+
94
+ readString(length) {
95
+ return this._read(`readString(${length})`, length, () => this._reader.slice(this._pc, this._pc + length).toString('utf8'));
96
+ }
97
+
98
+ peekByte() {
99
+ if (this._pc >= this._reader.length) {
100
+ throw new CodeReaderError('peekByte: read past end of buffer', this._pc, this._reader.length);
101
+ }
102
+ return this._reader.readUInt8(this._pc, true);
103
+ }
104
+ }
105
+
106
+ module.exports = CodeReader;
107
+ module.exports.CodeReaderError = CodeReaderError;
@@ -41,8 +41,57 @@ function processListAppend() {
41
41
  let value = this.dataStack.pop();
42
42
  let list = this.dataStack.top();
43
43
 
44
- if (this.curBlock.blockType == AST.ASTBlock.BlockType.For && this.curBlock.comprehension) {
44
+ // Pre-3.8 list comprehensions can nest the LIST_APPEND inside if/and/or
45
+ // blocks (e.g. `[o for o in xs if cond]`), so curBlock may be an If/Else
46
+ // when the append fires. Walk up to find the enclosing For+comprehension.
47
+ let forBlock = null;
48
+ let ifBlocks = [];
49
+ for (let i = this.blocks.length - 1; i >= 0; i--) {
50
+ const blk = this.blocks[i];
51
+ if (blk.blockType == AST.ASTBlock.BlockType.For && blk.comprehension) {
52
+ forBlock = blk;
53
+ break;
54
+ }
55
+ if (blk.blockType == AST.ASTBlock.BlockType.If) {
56
+ ifBlocks.push(blk);
57
+ } else {
58
+ break;
59
+ }
60
+ }
61
+
62
+ if (!forBlock) {
63
+ // Async comprehension inner code: no For+comp block exists because
64
+ // GET_ANEXT iteration uses SETUP_EXCEPT instead of FOR_ITER.
65
+ // Save the appended value so the reconstruction in function_calls.js
66
+ // can use it as the comprehension's yield expression.
67
+ this.object._asyncCompYieldExpr = value;
68
+ }
69
+
70
+ if (forBlock) {
45
71
  this.dataStack.pop();
72
+ // Transfer any intervening if-filter conditions to the comprehension's
73
+ // for-block, then close the intermediate if-blocks so the For+comp is
74
+ // curBlock when JUMP_ABSOLUTE reaches the close path.
75
+ for (const ifBlk of ifBlocks) {
76
+ let cond = ifBlk.condition;
77
+ if (!cond) continue;
78
+ if (ifBlk.negative) {
79
+ const notCond = new AST.ASTUnary(cond, AST.ASTUnary.UnaryOp.Not);
80
+ notCond.line = this.code.Current.LineNo;
81
+ cond = notCond;
82
+ }
83
+ if (forBlock.condition) {
84
+ const andCond = new AST.ASTBinary(forBlock.condition, cond, AST.ASTBinary.BinOp.LogicalAnd);
85
+ andCond.line = this.code.Current.LineNo;
86
+ forBlock.condition = andCond;
87
+ } else {
88
+ forBlock.condition = cond;
89
+ }
90
+ }
91
+ while (this.curBlock !== forBlock && this.blocks.length > 1) {
92
+ this.blocks.pop();
93
+ this.curBlock = this.blocks.top();
94
+ }
46
95
  let node = new AST.ASTComprehension (value);
47
96
  node.line = this.code.Current.LineNo;
48
97
  this.dataStack.push(node);