Skip to content

Commit

Permalink
tools/mpy-tool.py: Fix offset of line number info. (#2)
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Milata <martin@martinmilata.cz>

(cherry picked from commit 359ca43)
  • Loading branch information
mmilata committed Aug 18, 2020
1 parent f1b8c24 commit d971222
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/mpy-tool.py
Expand Up @@ -229,6 +229,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 @@ -361,7 +362,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 d971222

Please sign in to comment.