Skip to content

Commit 95dc22f

Browse files
author
rocky
committed
MAKE_FUNCTION is nargs_op with VARYING_INT pops
1 parent 34b8475 commit 95dc22f

File tree

7 files changed

+22
-15
lines changed

7 files changed

+22
-15
lines changed

xdis/opcodes/opcode_1x/opcode_1x.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@
128128

129129
def_op(loc, "BREAK_LOOP", 80, 0, 0, fallthrough=False)
130130

131-
def_op(loc, "LOAD_LOCALS", 82, 0, 1)
131+
def_op(loc, "LOAD_LOCALS", 82, 0, 1) # Pushes a reference to the locals of the current scope.
132+
# This is not a name op.
132133
def_op(loc, "RETURN_VALUE", 83, 1, 0, fallthrough=False)
133134

134135
def_op(loc, "EXEC_STMT", 85, 3, 0)

xdis/opcodes/opcode_2x/opcode_2x.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@
136136
def_op(loc, "INPLACE_OR", 79, 2, 1)
137137
def_op(loc, "BREAK_LOOP", 80, 0, 0, fallthrough=False)
138138

139-
def_op(loc, "LOAD_LOCALS", 82, 0, 1)
139+
def_op(loc, "LOAD_LOCALS", 82, 0, 1) # Pushes a reference to the locals of the current scope.
140+
# This is not a name op.
140141
def_op(loc, "RETURN_VALUE", 83, 1, 0, fallthrough=False)
141142
def_op(loc, "IMPORT_STAR", 84, 1, 0)
142143
def_op(loc, "EXEC_STMT", 85, 3, 0)
@@ -208,11 +209,11 @@
208209
# number
209210
local_op(loc, "DELETE_FAST", 126, 0, 0) # Local variable number is in operand
210211

211-
nargs_op(loc, "RAISE_VARARGS", 130, -1, 2, fallthrough=False)
212+
nargs_op(loc, "RAISE_VARARGS", 130, VARYING_STACK_INT, 2, fallthrough=False)
212213
# Number of raise arguments (1, 2, or 3)
213-
call_op(loc, "CALL_FUNCTION", 131, -1, 2) # TOS is #args + (#kwargs << 8)
214+
call_op(loc, "CALL_FUNCTION", 131, VARYING_STACK_INT, 2) # TOS is #args + (#kwargs << 8)
214215

215-
nargs_op(loc, "MAKE_FUNCTION", 132, -1, 2) # TOS is number of args with
216+
nargs_op(loc, "MAKE_FUNCTION", 132, VARYING_STACK_INT, 2) # TOS is number of args with
216217
# default values
217218
varargs_op(loc, "BUILD_SLICE", 133, 2, 1) # TOS is number of items
218219

xdis/opcodes/opcode_3x/opcode_312.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
binary_op(loc , "STORE_SLICE" , 27 , 4, 0)
9595

9696
def_op(loc , "CLEANUP_THROW" , 55 , 2, 1)
97-
def_op(loc , "LOAD_LOCALS" , 87 , 0, 1)
97+
def_op(loc , "LOAD_LOCALS" , 87 , 0, 1) # Pushes a reference to the locals of the current scope.
98+
# This is not a name op.
9899
def_op(loc , "RETURN_CONST" , 121, 0, 0)
99100
local_op(loc , "LOAD_FAST_CHECK" , 127, 0, 1)
100101

xdis/opcodes/opcode_3x/opcode_313.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from typing import Optional, Tuple
2525

2626
import xdis.opcodes.opcode_3x.opcode_312 as opcode_312
27-
from xdis.opcodes.base import ( # noqa
27+
from xdis.opcodes.base import (
2828
VARYING_STACK_INT,
2929
call_op,
3030
cpython_implementation,
@@ -33,6 +33,7 @@
3333
free_op,
3434
init_opdata,
3535
local_op,
36+
nargs_op,
3637
rm_op,
3738
update_pj3,
3839
)
@@ -217,8 +218,9 @@
217218
def_op(loc, "INTERPRETER_EXIT" , 22 , 1 , 0)
218219
def_op(loc, "LOAD_ASSERTION_ERROR" , 23 , 0 , 1)
219220
def_op(loc, "LOAD_BUILD_CLASS" , 24 , 0 , 1)
220-
def_op(loc, "LOAD_LOCALS" , 25 , 0 , 1)
221-
def_op(loc, "MAKE_FUNCTION" , 26 , -2, 1)
221+
def_op(loc, "LOAD_LOCALS" , 25 , 0 , 1) # Pushes a reference to the locals of the current scope.
222+
# This is not a name op.
223+
nargs_op(loc, "MAKE_FUNCTION" , 26 , VARYING_STACK_INT, 1)
222224
def_op(loc, "MATCH_KEYS" , 27 , 0 , 1)
223225
def_op(loc, "MATCH_MAPPING" , 28 , 0 , 1)
224226
def_op(loc, "MATCH_SEQUENCE" , 29 , 0 , 1)

xdis/opcodes/opcode_3x/opcode_314.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
of stack usage.
2222
"""
2323

24+
import xdis.opcodes.opcode_3x.opcode_313 as opcode_313
2425
from xdis.opcodes.base import (
2526
VARYING_STACK_INT,
2627
binary_op,
@@ -35,11 +36,13 @@
3536
jrel_op,
3637
local_op,
3738
name_op,
39+
nargs_op,
3840
store_op,
3941
unary_op,
4042
update_pj3,
4143
varargs_op,
4244
)
45+
from xdis.opcodes.format.extended import extended_format_binary_op
4346

4447
version_tuple = (3, 14)
4548
python_implementation = cpython_implementation
@@ -78,8 +81,9 @@
7881
def_op(loc, "GET_YIELD_FROM_ITER", 19, 1, 1)
7982
def_op(loc, "INTERPRETER_EXIT", 20, 1, 0)
8083
def_op(loc, "LOAD_BUILD_CLASS", 21, 0, 1)
81-
def_op(loc, "LOAD_LOCALS", 22, 0, 1)
82-
def_op(loc, "MAKE_FUNCTION", 23, 1, 1)
84+
def_op(loc, "LOAD_LOCALS", 22, 0, 1) # Pushes a reference to the locals of the current scope.
85+
# This is not a name op.
86+
nargs_op(loc, "MAKE_FUNCTION", 23, VARYING_STACK_INT, 1)
8387
def_op(loc, "MATCH_KEYS", 24, 2, 3)
8488
def_op(loc, "MATCH_MAPPING", 25, 1, 2)
8589
def_op(loc, "MATCH_SEQUENCE", 26, 1, 2)
@@ -312,8 +316,6 @@
312316
# fmt: on
313317

314318
### update formatting
315-
import xdis.opcodes.opcode_3x.opcode_313 as opcode_313
316-
from xdis.opcodes.format.extended import extended_format_binary_op
317319

318320
_nb_ops = [
319321
("NB_ADD", "+"),

xdis/opcodes/opcode_rust/opcode_312rust.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def pseudo_op(name: str, op: int, real_ops: list):
243243
jrel_op(loc, "POP_JUMP_IF_NONE", 129)
244244
def_op(loc, "RAISE_VARARGS", 130) # Number of raise arguments (1, 2, or 3)
245245
def_op(loc, "GET_AWAITABLE", 131)
246-
nargs_op(loc, "MAKE_FUNCTION", 132) # Flags
246+
nargs_op(loc, "MAKE_FUNCTION", 132, VARYING_STACK_INT, 1) # Flags
247247
def_op(loc, "BUILD_SLICE", 133) # Number of items
248248
jrel_op(loc, "JUMP_BACKWARD_NO_INTERRUPT", 134) # Number of words to skip (backwards)
249249
free_op(loc, "MAKE_CELL", 135, 0, 0)

xdis/opcodes/opcode_rust/opcode_313rust.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def pseudo_op(name: str, op: int, real_ops: list):
203203
jrel_op(loc, "JUMP_IF_TRUE_OR_POP", 48) # Number of words to skip
204204
jrel_op(loc, "JUMP_IF_FALSE_OR_POP", 49) # "
205205

206-
nargs_op(loc, "MAKE_FUNCTION", 50) # Flags
206+
nargs_op(loc, "MAKE_FUNCTION", 50, VARYING_STACK_INT) # Flags
207207
def_op(loc, "SET_FUNCTION_ATTR", 51)
208208

209209
call_op(loc, "CALL_FUNCTION", 52)

0 commit comments

Comments
 (0)