8000 tools/mpy-tool.py: Fix merge of multiple mpy files to POP_TOP correctly. · tve/micropython@4f2fe34 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f2fe34

Browse files
committed
tools/mpy-tool.py: Fix merge of multiple mpy files to POP_TOP correctly.
MP_BC_CALL_FUNCTION will leave the result on the Python stack, so that result must be discarded by MP_BC_POP_TOP. Signed-off-by: Damien George <damien@micropython.org>
1 parent 5f50568 commit 4f2fe34

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/mpy-tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ def merge_mpy(raw_codes, output_file):
938938
merged_mpy.extend(header)
939939

940940
bytecode = bytearray()
941-
bytecode_len = 6 + len(raw_codes) * 4 + 2
941+
bytecode_len = 6 + len(raw_codes) * 5 + 2
942942
bytecode.append(bytecode_len << 2) # kind and length
943943
bytecode.append(0b00000000) # signature prelude
944944
bytecode.append(0b00001000) # size prelude
@@ -947,7 +947,7 @@ def merge_mpy(raw_codes, output_file):
947947
for idx in range(len(raw_codes)):
948948
bytecode.append(0x32) # MP_BC_MAKE_FUNCTION
949949
bytecode.append(idx) # index raw code
950-
bytecode.extend(b"\x34\x00") # MP_BC_CALL_FUNCTION, 0 args
950+
bytecode.extend(b"\x34\x00\x59") # MP_BC_CALL_FUNCTION, 0 args, MP_BC_POP_TOP
951951
bytecode.extend(b"\x51\x63") # MP_BC_LOAD_NONE, MP_BC_RETURN_VALUE
952952

953953
bytecode.append(0) # n_obj

0 commit comments

Comments
 (0)
0