Change padding comment from words to bytes, as the 'words' could have a different width in the same file.
On master, generating a C file for the test file results in the following crash in maybe_pad:
cheby-dev -i reg.cheby --gen-c reg.h
# [...]
File "proto/cheby/tree.py", line 32, in visit
return f(*args, **kwargs)
File "proto/cheby/gen_c.py", line 125, in cprint_block
cprint_children(cp, n, n.c_size)
File "proto/cheby/gen_c.py", line 100, in cprint_children
maybe_pad(size - addr)
File "proto/cheby/gen_c.py", line 69, in maybe_pad
cp.cp_txt('/* padding to: {} words */'.format(el.c_address // sz))
NameError: free variable 'el' referenced before assignment in enclosing scope
The bug is triggered when n.c_sorted_children is empty. In that case, el is not defined before it's used for the last pad.
The padding comments referred to the number of words of the specific size, which could be quite confusing. E.g., the following could happen:
/* padding to: 28 words */
uint8_t __padding_1[2];
/* ... */
/* padding to: 16 words */
uint32_t __padding_0[5];
now this should be more clear:
/* padding to: 28 Bytes */
uint8_t __padding_1[2];
/* ... */
/* padding to: 64 Bytes */
uint32_t __padding_0[5];
Changes:
On master, generating a C file for the test file results in the following crash in
maybe_pad
:The bug is triggered when
n.c_sorted_children
is empty. In that case,el
is not defined before it's used for the last pad.The padding comments referred to the number of words of the specific size, which could be quite confusing. E.g., the following could happen:
now this should be more clear: