tools/mpy-tool.py: Don't generate const_table if it's empty.
This commit is contained in:
parent
bfc2092dc5
commit
b6a3289564
|
@ -331,9 +331,11 @@ class RawCode:
|
|||
# TODO
|
||||
raise FreezeError(self, 'freezing of object %r is not implemented' % (obj,))
|
||||
|
||||
# generate constant table
|
||||
# generate constant table, if it has any entries
|
||||
const_table_len = len(self.qstrs) + len(self.objs) + len(self.raw_codes)
|
||||
if const_table_len:
|
||||
print('STATIC const mp_rom_obj_t const_table_data_%s[%u] = {'
|
||||
% (self.escaped_name, len(self.qstrs) + len(self.objs) + len(self.raw_codes)))
|
||||
% (self.escaped_name, const_table_len))
|
||||
for qst in self.qstrs:
|
||||
print(' MP_ROM_QSTR(%s),' % global_qstrs[qst].qstr_id)
|
||||
for i in range(len(self.objs)):
|
||||
|
@ -362,7 +364,10 @@ class RawCode:
|
|||
print(' .n_pos_args = %u,' % self.prelude[3])
|
||||
print(' .data.u_byte = {')
|
||||
print(' .bytecode = bytecode_data_%s,' % self.escaped_name)
|
||||
if const_table_len:
|
||||
print(' .const_table = (mp_uint_t*)const_table_data_%s,' % self.escaped_name)
|
||||
else:
|
||||
print(' .const_table = NULL,')
|
||||
print(' #if MICROPY_PERSISTENT_CODE_SAVE')
|
||||
print(' .bc_len = %u,' % len(self.bytecode))
|
||||
print(' .n_obj = %u,' % len(self.objs))
|
||||
|
|
Loading…
Reference in New Issue