py: Add constant table to bytecode.
Contains just argument names at the moment but makes it easy to add
arbitrary constants.
diff --git a/py/showbc.c b/py/showbc.c
index 538eddc..62c6168 100644
--- a/py/showbc.c
+++ b/py/showbc.c
@@ -54,7 +54,7 @@
const byte *mp_showbc_code_start;
-void mp_bytecode_print(const void *descr, const byte *ip, mp_uint_t len) {
+void mp_bytecode_print(const void *descr, const byte *ip, mp_uint_t len, const mp_uint_t *const_table) {
mp_showbc_code_start = ip;
// get bytecode parameters
@@ -65,12 +65,6 @@
mp_uint_t n_kwonly_args = *ip++;
/*mp_uint_t n_def_pos_args =*/ ip++;
- ip = MP_ALIGN(ip, sizeof(mp_uint_t));
-
- // get and skip arg names
- const mp_obj_t *arg_names = (const mp_obj_t*)ip;
- ip += (n_pos_args + n_kwonly_args) * sizeof(mp_uint_t);
-
const byte *code_info = ip;
mp_uint_t code_info_size = mp_decode_uint(&code_info);
ip += code_info_size;
@@ -93,7 +87,7 @@
// bytecode prelude: arg names (as qstr objects)
printf("arg names:");
for (mp_uint_t i = 0; i < n_pos_args + n_kwonly_args; i++) {
- printf(" %s", qstr_str(MP_OBJ_QSTR_VALUE(arg_names[i])));
+ printf(" %s", qstr_str(MP_OBJ_QSTR_VALUE(const_table[i])));
}
printf("\n");