Skip to content

Commit

Permalink
tools/mpy-tool.py: Fix offset of line number info.
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Milata <martin@martinmilata.cz>
  • Loading branch information
mmilata committed Aug 13, 2020
1 parent 60f5b94 commit 359ca43
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/mpy-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def __init__(self, code_kind, bytecode, prelude_offset, qstrs, objs, raw_codes):
self.ip, self.ip2, self.prelude = extract_prelude(self.bytecode, self.prelude_offset)
self.simple_name = self._unpack_qstr(self.ip2)
self.source_file = self._unpack_qstr(self.ip2 + 2)
self.line_info_offset = self.ip2 + 4

def _unpack_qstr(self, ip):
qst = self.bytecode[ip] | self.bytecode[ip + 1] << 8
Expand Down Expand Up @@ -404,7 +405,10 @@ def freeze_module(self, qstr_links=(), type_sig=0):
print(" .n_def_pos_args = %u," % self.prelude[5])
print(" .qstr_block_name = %s," % self.simple_name.qstr_id)
print(" .qstr_source_file = %s," % self.source_file.qstr_id)
print(" .line_info = fun_data_%s + %u," % (self.escaped_name, 0)) # TODO
print(
" .line_info = fun_data_%s + %u,"
% (self.escaped_name, self.line_info_offset)
)
print(" .opcodes = fun_data_%s + %u," % (self.escaped_name, self.ip))
print(" },")
print(" .line_of_definition = %u," % 0) # TODO
Expand Down

0 comments on commit 359ca43

Please sign in to comment.