Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
py/showbc.c@10:33521d742af1, 2016-04-27 (annotated)
- Committer:
- Colin Hogben
- Date:
- Wed Apr 27 22:11:29 2016 +0100
- Revision:
- 10:33521d742af1
- Parent:
- 0:5868e8752d44
Update README and version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pythontech | 0:5868e8752d44 | 1 | /* |
pythontech | 0:5868e8752d44 | 2 | * This file is part of the Micro Python project, http://micropython.org/ |
pythontech | 0:5868e8752d44 | 3 | * |
pythontech | 0:5868e8752d44 | 4 | * The MIT License (MIT) |
pythontech | 0:5868e8752d44 | 5 | * |
pythontech | 0:5868e8752d44 | 6 | * Copyright (c) 2013, 2014 Damien P. George |
pythontech | 0:5868e8752d44 | 7 | * |
pythontech | 0:5868e8752d44 | 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
pythontech | 0:5868e8752d44 | 9 | * of this software and associated documentation files (the "Software"), to deal |
pythontech | 0:5868e8752d44 | 10 | * in the Software without restriction, including without limitation the rights |
pythontech | 0:5868e8752d44 | 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
pythontech | 0:5868e8752d44 | 12 | * copies of the Software, and to permit persons to whom the Software is |
pythontech | 0:5868e8752d44 | 13 | * furnished to do so, subject to the following conditions: |
pythontech | 0:5868e8752d44 | 14 | * |
pythontech | 0:5868e8752d44 | 15 | * The above copyright notice and this permission notice shall be included in |
pythontech | 0:5868e8752d44 | 16 | * all copies or substantial portions of the Software. |
pythontech | 0:5868e8752d44 | 17 | * |
pythontech | 0:5868e8752d44 | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
pythontech | 0:5868e8752d44 | 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
pythontech | 0:5868e8752d44 | 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
pythontech | 0:5868e8752d44 | 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
pythontech | 0:5868e8752d44 | 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
pythontech | 0:5868e8752d44 | 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
pythontech | 0:5868e8752d44 | 24 | * THE SOFTWARE. |
pythontech | 0:5868e8752d44 | 25 | */ |
pythontech | 0:5868e8752d44 | 26 | |
pythontech | 0:5868e8752d44 | 27 | #include <stdio.h> |
pythontech | 0:5868e8752d44 | 28 | #include <assert.h> |
pythontech | 0:5868e8752d44 | 29 | |
pythontech | 0:5868e8752d44 | 30 | #include "py/bc0.h" |
pythontech | 0:5868e8752d44 | 31 | #include "py/bc.h" |
pythontech | 0:5868e8752d44 | 32 | |
pythontech | 0:5868e8752d44 | 33 | #if MICROPY_DEBUG_PRINTERS |
pythontech | 0:5868e8752d44 | 34 | |
pythontech | 0:5868e8752d44 | 35 | #define DECODE_UINT { \ |
pythontech | 0:5868e8752d44 | 36 | unum = 0; \ |
pythontech | 0:5868e8752d44 | 37 | do { \ |
pythontech | 0:5868e8752d44 | 38 | unum = (unum << 7) + (*ip & 0x7f); \ |
pythontech | 0:5868e8752d44 | 39 | } while ((*ip++ & 0x80) != 0); \ |
pythontech | 0:5868e8752d44 | 40 | } |
pythontech | 0:5868e8752d44 | 41 | #define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0) |
pythontech | 0:5868e8752d44 | 42 | #define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0) |
pythontech | 0:5868e8752d44 | 43 | |
pythontech | 0:5868e8752d44 | 44 | #if MICROPY_PERSISTENT_CODE |
pythontech | 0:5868e8752d44 | 45 | |
pythontech | 0:5868e8752d44 | 46 | #define DECODE_QSTR \ |
pythontech | 0:5868e8752d44 | 47 | qst = ip[0] | ip[1] << 8; \ |
pythontech | 0:5868e8752d44 | 48 | ip += 2; |
pythontech | 0:5868e8752d44 | 49 | #define DECODE_PTR \ |
pythontech | 0:5868e8752d44 | 50 | DECODE_UINT; \ |
pythontech | 0:5868e8752d44 | 51 | unum = mp_showbc_const_table[unum] |
pythontech | 0:5868e8752d44 | 52 | #define DECODE_OBJ \ |
pythontech | 0:5868e8752d44 | 53 | DECODE_UINT; \ |
pythontech | 0:5868e8752d44 | 54 | unum = mp_showbc_const_table[unum] |
pythontech | 0:5868e8752d44 | 55 | |
pythontech | 0:5868e8752d44 | 56 | #else |
pythontech | 0:5868e8752d44 | 57 | |
pythontech | 0:5868e8752d44 | 58 | #define DECODE_QSTR { \ |
pythontech | 0:5868e8752d44 | 59 | qst = 0; \ |
pythontech | 0:5868e8752d44 | 60 | do { \ |
pythontech | 0:5868e8752d44 | 61 | qst = (qst << 7) + (*ip & 0x7f); \ |
pythontech | 0:5868e8752d44 | 62 | } while ((*ip++ & 0x80) != 0); \ |
pythontech | 0:5868e8752d44 | 63 | } |
pythontech | 0:5868e8752d44 | 64 | #define DECODE_PTR do { \ |
pythontech | 0:5868e8752d44 | 65 | ip = (byte*)MP_ALIGN(ip, sizeof(void*)); \ |
pythontech | 0:5868e8752d44 | 66 | unum = (uintptr_t)*(void**)ip; \ |
pythontech | 0:5868e8752d44 | 67 | ip += sizeof(void*); \ |
pythontech | 0:5868e8752d44 | 68 | } while (0) |
pythontech | 0:5868e8752d44 | 69 | #define DECODE_OBJ do { \ |
pythontech | 0:5868e8752d44 | 70 | ip = (byte*)MP_ALIGN(ip, sizeof(mp_obj_t)); \ |
pythontech | 0:5868e8752d44 | 71 | unum = (mp_uint_t)*(mp_obj_t*)ip; \ |
pythontech | 0:5868e8752d44 | 72 | ip += sizeof(mp_obj_t); \ |
pythontech | 0:5868e8752d44 | 73 | } while (0) |
pythontech | 0:5868e8752d44 | 74 | |
pythontech | 0:5868e8752d44 | 75 | #endif |
pythontech | 0:5868e8752d44 | 76 | |
pythontech | 0:5868e8752d44 | 77 | const byte *mp_showbc_code_start; |
pythontech | 0:5868e8752d44 | 78 | const mp_uint_t *mp_showbc_const_table; |
pythontech | 0:5868e8752d44 | 79 | |
pythontech | 0:5868e8752d44 | 80 | void mp_bytecode_print(const void *descr, const byte *ip, mp_uint_t len, const mp_uint_t *const_table) { |
pythontech | 0:5868e8752d44 | 81 | mp_showbc_code_start = ip; |
pythontech | 0:5868e8752d44 | 82 | mp_showbc_const_table = const_table; |
pythontech | 0:5868e8752d44 | 83 | |
pythontech | 0:5868e8752d44 | 84 | // get bytecode parameters |
pythontech | 0:5868e8752d44 | 85 | mp_uint_t n_state = mp_decode_uint(&ip); |
pythontech | 0:5868e8752d44 | 86 | mp_uint_t n_exc_stack = mp_decode_uint(&ip); |
pythontech | 0:5868e8752d44 | 87 | /*mp_uint_t scope_flags =*/ ip++; |
pythontech | 0:5868e8752d44 | 88 | mp_uint_t n_pos_args = *ip++; |
pythontech | 0:5868e8752d44 | 89 | mp_uint_t n_kwonly_args = *ip++; |
pythontech | 0:5868e8752d44 | 90 | /*mp_uint_t n_def_pos_args =*/ ip++; |
pythontech | 0:5868e8752d44 | 91 | |
pythontech | 0:5868e8752d44 | 92 | const byte *code_info = ip; |
pythontech | 0:5868e8752d44 | 93 | mp_uint_t code_info_size = mp_decode_uint(&code_info); |
pythontech | 0:5868e8752d44 | 94 | ip += code_info_size; |
pythontech | 0:5868e8752d44 | 95 | |
pythontech | 0:5868e8752d44 | 96 | #if MICROPY_PERSISTENT_CODE |
pythontech | 0:5868e8752d44 | 97 | qstr block_name = code_info[0] | (code_info[1] << 8); |
pythontech | 0:5868e8752d44 | 98 | qstr source_file = code_info[2] | (code_info[3] << 8); |
pythontech | 0:5868e8752d44 | 99 | #else |
pythontech | 0:5868e8752d44 | 100 | qstr block_name = mp_decode_uint(&code_info); |
pythontech | 0:5868e8752d44 | 101 | qstr source_file = mp_decode_uint(&code_info); |
pythontech | 0:5868e8752d44 | 102 | #endif |
pythontech | 0:5868e8752d44 | 103 | printf("File %s, code block '%s' (descriptor: %p, bytecode @%p " UINT_FMT " bytes)\n", |
pythontech | 0:5868e8752d44 | 104 | qstr_str(source_file), qstr_str(block_name), descr, mp_showbc_code_start, len); |
pythontech | 0:5868e8752d44 | 105 | |
pythontech | 0:5868e8752d44 | 106 | // raw bytecode dump |
pythontech | 0:5868e8752d44 | 107 | printf("Raw bytecode (code_info_size=" UINT_FMT ", bytecode_size=" UINT_FMT "):\n", code_info_size, len - code_info_size); |
pythontech | 0:5868e8752d44 | 108 | for (mp_uint_t i = 0; i < len; i++) { |
pythontech | 0:5868e8752d44 | 109 | if (i > 0 && i % 16 == 0) { |
pythontech | 0:5868e8752d44 | 110 | printf("\n"); |
pythontech | 0:5868e8752d44 | 111 | } |
pythontech | 0:5868e8752d44 | 112 | printf(" %02x", mp_showbc_code_start[i]); |
pythontech | 0:5868e8752d44 | 113 | } |
pythontech | 0:5868e8752d44 | 114 | printf("\n"); |
pythontech | 0:5868e8752d44 | 115 | |
pythontech | 0:5868e8752d44 | 116 | // bytecode prelude: arg names (as qstr objects) |
pythontech | 0:5868e8752d44 | 117 | printf("arg names:"); |
pythontech | 0:5868e8752d44 | 118 | for (mp_uint_t i = 0; i < n_pos_args + n_kwonly_args; i++) { |
pythontech | 0:5868e8752d44 | 119 | printf(" %s", qstr_str(MP_OBJ_QSTR_VALUE(const_table[i]))); |
pythontech | 0:5868e8752d44 | 120 | } |
pythontech | 0:5868e8752d44 | 121 | printf("\n"); |
pythontech | 0:5868e8752d44 | 122 | |
pythontech | 0:5868e8752d44 | 123 | printf("(N_STATE " UINT_FMT ")\n", n_state); |
pythontech | 0:5868e8752d44 | 124 | printf("(N_EXC_STACK " UINT_FMT ")\n", n_exc_stack); |
pythontech | 0:5868e8752d44 | 125 | |
pythontech | 0:5868e8752d44 | 126 | // for printing line number info |
pythontech | 0:5868e8752d44 | 127 | const byte *bytecode_start = ip; |
pythontech | 0:5868e8752d44 | 128 | |
pythontech | 0:5868e8752d44 | 129 | // bytecode prelude: initialise closed over variables |
pythontech | 0:5868e8752d44 | 130 | { |
pythontech | 0:5868e8752d44 | 131 | uint local_num; |
pythontech | 0:5868e8752d44 | 132 | while ((local_num = *ip++) != 255) { |
pythontech | 0:5868e8752d44 | 133 | printf("(INIT_CELL %u)\n", local_num); |
pythontech | 0:5868e8752d44 | 134 | } |
pythontech | 0:5868e8752d44 | 135 | len -= ip - mp_showbc_code_start; |
pythontech | 0:5868e8752d44 | 136 | } |
pythontech | 0:5868e8752d44 | 137 | |
pythontech | 0:5868e8752d44 | 138 | // print out line number info |
pythontech | 0:5868e8752d44 | 139 | { |
pythontech | 0:5868e8752d44 | 140 | mp_int_t bc = bytecode_start - ip; |
pythontech | 0:5868e8752d44 | 141 | mp_uint_t source_line = 1; |
pythontech | 0:5868e8752d44 | 142 | printf(" bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line); |
pythontech | 0:5868e8752d44 | 143 | for (const byte* ci = code_info; *ci;) { |
pythontech | 0:5868e8752d44 | 144 | if ((ci[0] & 0x80) == 0) { |
pythontech | 0:5868e8752d44 | 145 | // 0b0LLBBBBB encoding |
pythontech | 0:5868e8752d44 | 146 | bc += ci[0] & 0x1f; |
pythontech | 0:5868e8752d44 | 147 | source_line += ci[0] >> 5; |
pythontech | 0:5868e8752d44 | 148 | ci += 1; |
pythontech | 0:5868e8752d44 | 149 | } else { |
pythontech | 0:5868e8752d44 | 150 | // 0b1LLLBBBB 0bLLLLLLLL encoding (l's LSB in second byte) |
pythontech | 0:5868e8752d44 | 151 | bc += ci[0] & 0xf; |
pythontech | 0:5868e8752d44 | 152 | source_line += ((ci[0] << 4) & 0x700) | ci[1]; |
pythontech | 0:5868e8752d44 | 153 | ci += 2; |
pythontech | 0:5868e8752d44 | 154 | } |
pythontech | 0:5868e8752d44 | 155 | printf(" bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line); |
pythontech | 0:5868e8752d44 | 156 | } |
pythontech | 0:5868e8752d44 | 157 | } |
pythontech | 0:5868e8752d44 | 158 | mp_bytecode_print2(ip, len - 0); |
pythontech | 0:5868e8752d44 | 159 | } |
pythontech | 0:5868e8752d44 | 160 | |
pythontech | 0:5868e8752d44 | 161 | const byte *mp_bytecode_print_str(const byte *ip) { |
pythontech | 0:5868e8752d44 | 162 | mp_uint_t unum; |
pythontech | 0:5868e8752d44 | 163 | qstr qst; |
pythontech | 0:5868e8752d44 | 164 | |
pythontech | 0:5868e8752d44 | 165 | switch (*ip++) { |
pythontech | 0:5868e8752d44 | 166 | case MP_BC_LOAD_CONST_FALSE: |
pythontech | 0:5868e8752d44 | 167 | printf("LOAD_CONST_FALSE"); |
pythontech | 0:5868e8752d44 | 168 | break; |
pythontech | 0:5868e8752d44 | 169 | |
pythontech | 0:5868e8752d44 | 170 | case MP_BC_LOAD_CONST_NONE: |
pythontech | 0:5868e8752d44 | 171 | printf("LOAD_CONST_NONE"); |
pythontech | 0:5868e8752d44 | 172 | break; |
pythontech | 0:5868e8752d44 | 173 | |
pythontech | 0:5868e8752d44 | 174 | case MP_BC_LOAD_CONST_TRUE: |
pythontech | 0:5868e8752d44 | 175 | printf("LOAD_CONST_TRUE"); |
pythontech | 0:5868e8752d44 | 176 | break; |
pythontech | 0:5868e8752d44 | 177 | |
pythontech | 0:5868e8752d44 | 178 | case MP_BC_LOAD_CONST_SMALL_INT: { |
pythontech | 0:5868e8752d44 | 179 | mp_int_t num = 0; |
pythontech | 0:5868e8752d44 | 180 | if ((ip[0] & 0x40) != 0) { |
pythontech | 0:5868e8752d44 | 181 | // Number is negative |
pythontech | 0:5868e8752d44 | 182 | num--; |
pythontech | 0:5868e8752d44 | 183 | } |
pythontech | 0:5868e8752d44 | 184 | do { |
pythontech | 0:5868e8752d44 | 185 | num = (num << 7) | (*ip & 0x7f); |
pythontech | 0:5868e8752d44 | 186 | } while ((*ip++ & 0x80) != 0); |
pythontech | 0:5868e8752d44 | 187 | printf("LOAD_CONST_SMALL_INT " INT_FMT, num); |
pythontech | 0:5868e8752d44 | 188 | break; |
pythontech | 0:5868e8752d44 | 189 | } |
pythontech | 0:5868e8752d44 | 190 | |
pythontech | 0:5868e8752d44 | 191 | case MP_BC_LOAD_CONST_STRING: |
pythontech | 0:5868e8752d44 | 192 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 193 | printf("LOAD_CONST_STRING '%s'", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 194 | break; |
pythontech | 0:5868e8752d44 | 195 | |
pythontech | 0:5868e8752d44 | 196 | case MP_BC_LOAD_CONST_OBJ: |
pythontech | 0:5868e8752d44 | 197 | DECODE_OBJ; |
pythontech | 0:5868e8752d44 | 198 | printf("LOAD_CONST_OBJ %p=", MP_OBJ_TO_PTR(unum)); |
pythontech | 0:5868e8752d44 | 199 | mp_obj_print_helper(&mp_plat_print, (mp_obj_t)unum, PRINT_REPR); |
pythontech | 0:5868e8752d44 | 200 | break; |
pythontech | 0:5868e8752d44 | 201 | |
pythontech | 0:5868e8752d44 | 202 | case MP_BC_LOAD_NULL: |
pythontech | 0:5868e8752d44 | 203 | printf("LOAD_NULL"); |
pythontech | 0:5868e8752d44 | 204 | break; |
pythontech | 0:5868e8752d44 | 205 | |
pythontech | 0:5868e8752d44 | 206 | case MP_BC_LOAD_FAST_N: |
pythontech | 0:5868e8752d44 | 207 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 208 | printf("LOAD_FAST_N " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 209 | break; |
pythontech | 0:5868e8752d44 | 210 | |
pythontech | 0:5868e8752d44 | 211 | case MP_BC_LOAD_DEREF: |
pythontech | 0:5868e8752d44 | 212 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 213 | printf("LOAD_DEREF " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 214 | break; |
pythontech | 0:5868e8752d44 | 215 | |
pythontech | 0:5868e8752d44 | 216 | case MP_BC_LOAD_NAME: |
pythontech | 0:5868e8752d44 | 217 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 218 | printf("LOAD_NAME %s", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 219 | if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { |
pythontech | 0:5868e8752d44 | 220 | printf(" (cache=%u)", *ip++); |
pythontech | 0:5868e8752d44 | 221 | } |
pythontech | 0:5868e8752d44 | 222 | break; |
pythontech | 0:5868e8752d44 | 223 | |
pythontech | 0:5868e8752d44 | 224 | case MP_BC_LOAD_GLOBAL: |
pythontech | 0:5868e8752d44 | 225 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 226 | printf("LOAD_GLOBAL %s", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 227 | if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { |
pythontech | 0:5868e8752d44 | 228 | printf(" (cache=%u)", *ip++); |
pythontech | 0:5868e8752d44 | 229 | } |
pythontech | 0:5868e8752d44 | 230 | break; |
pythontech | 0:5868e8752d44 | 231 | |
pythontech | 0:5868e8752d44 | 232 | case MP_BC_LOAD_ATTR: |
pythontech | 0:5868e8752d44 | 233 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 234 | printf("LOAD_ATTR %s", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 235 | if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { |
pythontech | 0:5868e8752d44 | 236 | printf(" (cache=%u)", *ip++); |
pythontech | 0:5868e8752d44 | 237 | } |
pythontech | 0:5868e8752d44 | 238 | break; |
pythontech | 0:5868e8752d44 | 239 | |
pythontech | 0:5868e8752d44 | 240 | case MP_BC_LOAD_METHOD: |
pythontech | 0:5868e8752d44 | 241 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 242 | printf("LOAD_METHOD %s", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 243 | break; |
pythontech | 0:5868e8752d44 | 244 | |
pythontech | 0:5868e8752d44 | 245 | case MP_BC_LOAD_BUILD_CLASS: |
pythontech | 0:5868e8752d44 | 246 | printf("LOAD_BUILD_CLASS"); |
pythontech | 0:5868e8752d44 | 247 | break; |
pythontech | 0:5868e8752d44 | 248 | |
pythontech | 0:5868e8752d44 | 249 | case MP_BC_LOAD_SUBSCR: |
pythontech | 0:5868e8752d44 | 250 | printf("LOAD_SUBSCR"); |
pythontech | 0:5868e8752d44 | 251 | break; |
pythontech | 0:5868e8752d44 | 252 | |
pythontech | 0:5868e8752d44 | 253 | case MP_BC_STORE_FAST_N: |
pythontech | 0:5868e8752d44 | 254 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 255 | printf("STORE_FAST_N " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 256 | break; |
pythontech | 0:5868e8752d44 | 257 | |
pythontech | 0:5868e8752d44 | 258 | case MP_BC_STORE_DEREF: |
pythontech | 0:5868e8752d44 | 259 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 260 | printf("STORE_DEREF " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 261 | break; |
pythontech | 0:5868e8752d44 | 262 | |
pythontech | 0:5868e8752d44 | 263 | case MP_BC_STORE_NAME: |
pythontech | 0:5868e8752d44 | 264 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 265 | printf("STORE_NAME %s", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 266 | break; |
pythontech | 0:5868e8752d44 | 267 | |
pythontech | 0:5868e8752d44 | 268 | case MP_BC_STORE_GLOBAL: |
pythontech | 0:5868e8752d44 | 269 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 270 | printf("STORE_GLOBAL %s", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 271 | break; |
pythontech | 0:5868e8752d44 | 272 | |
pythontech | 0:5868e8752d44 | 273 | case MP_BC_STORE_ATTR: |
pythontech | 0:5868e8752d44 | 274 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 275 | printf("STORE_ATTR %s", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 276 | if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { |
pythontech | 0:5868e8752d44 | 277 | printf(" (cache=%u)", *ip++); |
pythontech | 0:5868e8752d44 | 278 | } |
pythontech | 0:5868e8752d44 | 279 | break; |
pythontech | 0:5868e8752d44 | 280 | |
pythontech | 0:5868e8752d44 | 281 | case MP_BC_STORE_SUBSCR: |
pythontech | 0:5868e8752d44 | 282 | printf("STORE_SUBSCR"); |
pythontech | 0:5868e8752d44 | 283 | break; |
pythontech | 0:5868e8752d44 | 284 | |
pythontech | 0:5868e8752d44 | 285 | case MP_BC_DELETE_FAST: |
pythontech | 0:5868e8752d44 | 286 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 287 | printf("DELETE_FAST " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 288 | break; |
pythontech | 0:5868e8752d44 | 289 | |
pythontech | 0:5868e8752d44 | 290 | case MP_BC_DELETE_DEREF: |
pythontech | 0:5868e8752d44 | 291 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 292 | printf("DELETE_DEREF " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 293 | break; |
pythontech | 0:5868e8752d44 | 294 | |
pythontech | 0:5868e8752d44 | 295 | case MP_BC_DELETE_NAME: |
pythontech | 0:5868e8752d44 | 296 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 297 | printf("DELETE_NAME %s", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 298 | break; |
pythontech | 0:5868e8752d44 | 299 | |
pythontech | 0:5868e8752d44 | 300 | case MP_BC_DELETE_GLOBAL: |
pythontech | 0:5868e8752d44 | 301 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 302 | printf("DELETE_GLOBAL %s", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 303 | break; |
pythontech | 0:5868e8752d44 | 304 | |
pythontech | 0:5868e8752d44 | 305 | case MP_BC_DUP_TOP: |
pythontech | 0:5868e8752d44 | 306 | printf("DUP_TOP"); |
pythontech | 0:5868e8752d44 | 307 | break; |
pythontech | 0:5868e8752d44 | 308 | |
pythontech | 0:5868e8752d44 | 309 | case MP_BC_DUP_TOP_TWO: |
pythontech | 0:5868e8752d44 | 310 | printf("DUP_TOP_TWO"); |
pythontech | 0:5868e8752d44 | 311 | break; |
pythontech | 0:5868e8752d44 | 312 | |
pythontech | 0:5868e8752d44 | 313 | case MP_BC_POP_TOP: |
pythontech | 0:5868e8752d44 | 314 | printf("POP_TOP"); |
pythontech | 0:5868e8752d44 | 315 | break; |
pythontech | 0:5868e8752d44 | 316 | |
pythontech | 0:5868e8752d44 | 317 | case MP_BC_ROT_TWO: |
pythontech | 0:5868e8752d44 | 318 | printf("ROT_TWO"); |
pythontech | 0:5868e8752d44 | 319 | break; |
pythontech | 0:5868e8752d44 | 320 | |
pythontech | 0:5868e8752d44 | 321 | case MP_BC_ROT_THREE: |
pythontech | 0:5868e8752d44 | 322 | printf("ROT_THREE"); |
pythontech | 0:5868e8752d44 | 323 | break; |
pythontech | 0:5868e8752d44 | 324 | |
pythontech | 0:5868e8752d44 | 325 | case MP_BC_JUMP: |
pythontech | 0:5868e8752d44 | 326 | DECODE_SLABEL; |
pythontech | 0:5868e8752d44 | 327 | printf("JUMP " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); |
pythontech | 0:5868e8752d44 | 328 | break; |
pythontech | 0:5868e8752d44 | 329 | |
pythontech | 0:5868e8752d44 | 330 | case MP_BC_POP_JUMP_IF_TRUE: |
pythontech | 0:5868e8752d44 | 331 | DECODE_SLABEL; |
pythontech | 0:5868e8752d44 | 332 | printf("POP_JUMP_IF_TRUE " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); |
pythontech | 0:5868e8752d44 | 333 | break; |
pythontech | 0:5868e8752d44 | 334 | |
pythontech | 0:5868e8752d44 | 335 | case MP_BC_POP_JUMP_IF_FALSE: |
pythontech | 0:5868e8752d44 | 336 | DECODE_SLABEL; |
pythontech | 0:5868e8752d44 | 337 | printf("POP_JUMP_IF_FALSE " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); |
pythontech | 0:5868e8752d44 | 338 | break; |
pythontech | 0:5868e8752d44 | 339 | |
pythontech | 0:5868e8752d44 | 340 | case MP_BC_JUMP_IF_TRUE_OR_POP: |
pythontech | 0:5868e8752d44 | 341 | DECODE_SLABEL; |
pythontech | 0:5868e8752d44 | 342 | printf("JUMP_IF_TRUE_OR_POP " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); |
pythontech | 0:5868e8752d44 | 343 | break; |
pythontech | 0:5868e8752d44 | 344 | |
pythontech | 0:5868e8752d44 | 345 | case MP_BC_JUMP_IF_FALSE_OR_POP: |
pythontech | 0:5868e8752d44 | 346 | DECODE_SLABEL; |
pythontech | 0:5868e8752d44 | 347 | printf("JUMP_IF_FALSE_OR_POP " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); |
pythontech | 0:5868e8752d44 | 348 | break; |
pythontech | 0:5868e8752d44 | 349 | |
pythontech | 0:5868e8752d44 | 350 | case MP_BC_SETUP_WITH: |
pythontech | 0:5868e8752d44 | 351 | DECODE_ULABEL; // loop-like labels are always forward |
pythontech | 0:5868e8752d44 | 352 | printf("SETUP_WITH " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); |
pythontech | 0:5868e8752d44 | 353 | break; |
pythontech | 0:5868e8752d44 | 354 | |
pythontech | 0:5868e8752d44 | 355 | case MP_BC_WITH_CLEANUP: |
pythontech | 0:5868e8752d44 | 356 | printf("WITH_CLEANUP"); |
pythontech | 0:5868e8752d44 | 357 | break; |
pythontech | 0:5868e8752d44 | 358 | |
pythontech | 0:5868e8752d44 | 359 | case MP_BC_UNWIND_JUMP: |
pythontech | 0:5868e8752d44 | 360 | DECODE_SLABEL; |
pythontech | 0:5868e8752d44 | 361 | printf("UNWIND_JUMP " UINT_FMT " %d", (mp_uint_t)(ip + unum - mp_showbc_code_start), *ip); |
pythontech | 0:5868e8752d44 | 362 | ip += 1; |
pythontech | 0:5868e8752d44 | 363 | break; |
pythontech | 0:5868e8752d44 | 364 | |
pythontech | 0:5868e8752d44 | 365 | case MP_BC_SETUP_EXCEPT: |
pythontech | 0:5868e8752d44 | 366 | DECODE_ULABEL; // except labels are always forward |
pythontech | 0:5868e8752d44 | 367 | printf("SETUP_EXCEPT " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); |
pythontech | 0:5868e8752d44 | 368 | break; |
pythontech | 0:5868e8752d44 | 369 | |
pythontech | 0:5868e8752d44 | 370 | case MP_BC_SETUP_FINALLY: |
pythontech | 0:5868e8752d44 | 371 | DECODE_ULABEL; // except labels are always forward |
pythontech | 0:5868e8752d44 | 372 | printf("SETUP_FINALLY " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); |
pythontech | 0:5868e8752d44 | 373 | break; |
pythontech | 0:5868e8752d44 | 374 | |
pythontech | 0:5868e8752d44 | 375 | case MP_BC_END_FINALLY: |
pythontech | 0:5868e8752d44 | 376 | // if TOS is an exception, reraises the exception (3 values on TOS) |
pythontech | 0:5868e8752d44 | 377 | // if TOS is an integer, does something else |
pythontech | 0:5868e8752d44 | 378 | // if TOS is None, just pops it and continues |
pythontech | 0:5868e8752d44 | 379 | // else error |
pythontech | 0:5868e8752d44 | 380 | printf("END_FINALLY"); |
pythontech | 0:5868e8752d44 | 381 | break; |
pythontech | 0:5868e8752d44 | 382 | |
pythontech | 0:5868e8752d44 | 383 | case MP_BC_GET_ITER: |
pythontech | 0:5868e8752d44 | 384 | printf("GET_ITER"); |
pythontech | 0:5868e8752d44 | 385 | break; |
pythontech | 0:5868e8752d44 | 386 | |
pythontech | 0:5868e8752d44 | 387 | case MP_BC_FOR_ITER: |
pythontech | 0:5868e8752d44 | 388 | DECODE_ULABEL; // the jump offset if iteration finishes; for labels are always forward |
pythontech | 0:5868e8752d44 | 389 | printf("FOR_ITER " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start)); |
pythontech | 0:5868e8752d44 | 390 | break; |
pythontech | 0:5868e8752d44 | 391 | |
pythontech | 0:5868e8752d44 | 392 | case MP_BC_POP_BLOCK: |
pythontech | 0:5868e8752d44 | 393 | // pops block and restores the stack |
pythontech | 0:5868e8752d44 | 394 | printf("POP_BLOCK"); |
pythontech | 0:5868e8752d44 | 395 | break; |
pythontech | 0:5868e8752d44 | 396 | |
pythontech | 0:5868e8752d44 | 397 | case MP_BC_POP_EXCEPT: |
pythontech | 0:5868e8752d44 | 398 | // pops block, checks it's an exception block, and restores the stack, saving the 3 exception values to local threadstate |
pythontech | 0:5868e8752d44 | 399 | printf("POP_EXCEPT"); |
pythontech | 0:5868e8752d44 | 400 | break; |
pythontech | 0:5868e8752d44 | 401 | |
pythontech | 0:5868e8752d44 | 402 | case MP_BC_BUILD_TUPLE: |
pythontech | 0:5868e8752d44 | 403 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 404 | printf("BUILD_TUPLE " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 405 | break; |
pythontech | 0:5868e8752d44 | 406 | |
pythontech | 0:5868e8752d44 | 407 | case MP_BC_BUILD_LIST: |
pythontech | 0:5868e8752d44 | 408 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 409 | printf("BUILD_LIST " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 410 | break; |
pythontech | 0:5868e8752d44 | 411 | |
pythontech | 0:5868e8752d44 | 412 | case MP_BC_LIST_APPEND: |
pythontech | 0:5868e8752d44 | 413 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 414 | printf("LIST_APPEND " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 415 | break; |
pythontech | 0:5868e8752d44 | 416 | |
pythontech | 0:5868e8752d44 | 417 | case MP_BC_BUILD_MAP: |
pythontech | 0:5868e8752d44 | 418 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 419 | printf("BUILD_MAP " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 420 | break; |
pythontech | 0:5868e8752d44 | 421 | |
pythontech | 0:5868e8752d44 | 422 | case MP_BC_STORE_MAP: |
pythontech | 0:5868e8752d44 | 423 | printf("STORE_MAP"); |
pythontech | 0:5868e8752d44 | 424 | break; |
pythontech | 0:5868e8752d44 | 425 | |
pythontech | 0:5868e8752d44 | 426 | case MP_BC_MAP_ADD: |
pythontech | 0:5868e8752d44 | 427 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 428 | printf("MAP_ADD " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 429 | break; |
pythontech | 0:5868e8752d44 | 430 | |
pythontech | 0:5868e8752d44 | 431 | case MP_BC_BUILD_SET: |
pythontech | 0:5868e8752d44 | 432 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 433 | printf("BUILD_SET " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 434 | break; |
pythontech | 0:5868e8752d44 | 435 | |
pythontech | 0:5868e8752d44 | 436 | case MP_BC_SET_ADD: |
pythontech | 0:5868e8752d44 | 437 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 438 | printf("SET_ADD " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 439 | break; |
pythontech | 0:5868e8752d44 | 440 | |
pythontech | 0:5868e8752d44 | 441 | #if MICROPY_PY_BUILTINS_SLICE |
pythontech | 0:5868e8752d44 | 442 | case MP_BC_BUILD_SLICE: |
pythontech | 0:5868e8752d44 | 443 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 444 | printf("BUILD_SLICE " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 445 | break; |
pythontech | 0:5868e8752d44 | 446 | #endif |
pythontech | 0:5868e8752d44 | 447 | |
pythontech | 0:5868e8752d44 | 448 | case MP_BC_UNPACK_SEQUENCE: |
pythontech | 0:5868e8752d44 | 449 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 450 | printf("UNPACK_SEQUENCE " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 451 | break; |
pythontech | 0:5868e8752d44 | 452 | |
pythontech | 0:5868e8752d44 | 453 | case MP_BC_UNPACK_EX: |
pythontech | 0:5868e8752d44 | 454 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 455 | printf("UNPACK_EX " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 456 | break; |
pythontech | 0:5868e8752d44 | 457 | |
pythontech | 0:5868e8752d44 | 458 | case MP_BC_MAKE_FUNCTION: |
pythontech | 0:5868e8752d44 | 459 | DECODE_PTR; |
pythontech | 0:5868e8752d44 | 460 | printf("MAKE_FUNCTION %p", (void*)(uintptr_t)unum); |
pythontech | 0:5868e8752d44 | 461 | break; |
pythontech | 0:5868e8752d44 | 462 | |
pythontech | 0:5868e8752d44 | 463 | case MP_BC_MAKE_FUNCTION_DEFARGS: |
pythontech | 0:5868e8752d44 | 464 | DECODE_PTR; |
pythontech | 0:5868e8752d44 | 465 | printf("MAKE_FUNCTION_DEFARGS %p", (void*)(uintptr_t)unum); |
pythontech | 0:5868e8752d44 | 466 | break; |
pythontech | 0:5868e8752d44 | 467 | |
pythontech | 0:5868e8752d44 | 468 | case MP_BC_MAKE_CLOSURE: { |
pythontech | 0:5868e8752d44 | 469 | DECODE_PTR; |
pythontech | 0:5868e8752d44 | 470 | mp_uint_t n_closed_over = *ip++; |
pythontech | 0:5868e8752d44 | 471 | printf("MAKE_CLOSURE %p " UINT_FMT, (void*)(uintptr_t)unum, n_closed_over); |
pythontech | 0:5868e8752d44 | 472 | break; |
pythontech | 0:5868e8752d44 | 473 | } |
pythontech | 0:5868e8752d44 | 474 | |
pythontech | 0:5868e8752d44 | 475 | case MP_BC_MAKE_CLOSURE_DEFARGS: { |
pythontech | 0:5868e8752d44 | 476 | DECODE_PTR; |
pythontech | 0:5868e8752d44 | 477 | mp_uint_t n_closed_over = *ip++; |
pythontech | 0:5868e8752d44 | 478 | printf("MAKE_CLOSURE_DEFARGS %p " UINT_FMT, (void*)(uintptr_t)unum, n_closed_over); |
pythontech | 0:5868e8752d44 | 479 | break; |
pythontech | 0:5868e8752d44 | 480 | } |
pythontech | 0:5868e8752d44 | 481 | |
pythontech | 0:5868e8752d44 | 482 | case MP_BC_CALL_FUNCTION: |
pythontech | 0:5868e8752d44 | 483 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 484 | printf("CALL_FUNCTION n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); |
pythontech | 0:5868e8752d44 | 485 | break; |
pythontech | 0:5868e8752d44 | 486 | |
pythontech | 0:5868e8752d44 | 487 | case MP_BC_CALL_FUNCTION_VAR_KW: |
pythontech | 0:5868e8752d44 | 488 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 489 | printf("CALL_FUNCTION_VAR_KW n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); |
pythontech | 0:5868e8752d44 | 490 | break; |
pythontech | 0:5868e8752d44 | 491 | |
pythontech | 0:5868e8752d44 | 492 | case MP_BC_CALL_METHOD: |
pythontech | 0:5868e8752d44 | 493 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 494 | printf("CALL_METHOD n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); |
pythontech | 0:5868e8752d44 | 495 | break; |
pythontech | 0:5868e8752d44 | 496 | |
pythontech | 0:5868e8752d44 | 497 | case MP_BC_CALL_METHOD_VAR_KW: |
pythontech | 0:5868e8752d44 | 498 | DECODE_UINT; |
pythontech | 0:5868e8752d44 | 499 | printf("CALL_METHOD_VAR_KW n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff); |
pythontech | 0:5868e8752d44 | 500 | break; |
pythontech | 0:5868e8752d44 | 501 | |
pythontech | 0:5868e8752d44 | 502 | case MP_BC_RETURN_VALUE: |
pythontech | 0:5868e8752d44 | 503 | printf("RETURN_VALUE"); |
pythontech | 0:5868e8752d44 | 504 | break; |
pythontech | 0:5868e8752d44 | 505 | |
pythontech | 0:5868e8752d44 | 506 | case MP_BC_RAISE_VARARGS: |
pythontech | 0:5868e8752d44 | 507 | unum = *ip++; |
pythontech | 0:5868e8752d44 | 508 | printf("RAISE_VARARGS " UINT_FMT, unum); |
pythontech | 0:5868e8752d44 | 509 | break; |
pythontech | 0:5868e8752d44 | 510 | |
pythontech | 0:5868e8752d44 | 511 | case MP_BC_YIELD_VALUE: |
pythontech | 0:5868e8752d44 | 512 | printf("YIELD_VALUE"); |
pythontech | 0:5868e8752d44 | 513 | break; |
pythontech | 0:5868e8752d44 | 514 | |
pythontech | 0:5868e8752d44 | 515 | case MP_BC_YIELD_FROM: |
pythontech | 0:5868e8752d44 | 516 | printf("YIELD_FROM"); |
pythontech | 0:5868e8752d44 | 517 | break; |
pythontech | 0:5868e8752d44 | 518 | |
pythontech | 0:5868e8752d44 | 519 | case MP_BC_IMPORT_NAME: |
pythontech | 0:5868e8752d44 | 520 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 521 | printf("IMPORT_NAME '%s'", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 522 | break; |
pythontech | 0:5868e8752d44 | 523 | |
pythontech | 0:5868e8752d44 | 524 | case MP_BC_IMPORT_FROM: |
pythontech | 0:5868e8752d44 | 525 | DECODE_QSTR; |
pythontech | 0:5868e8752d44 | 526 | printf("IMPORT_FROM '%s'", qstr_str(qst)); |
pythontech | 0:5868e8752d44 | 527 | break; |
pythontech | 0:5868e8752d44 | 528 | |
pythontech | 0:5868e8752d44 | 529 | case MP_BC_IMPORT_STAR: |
pythontech | 0:5868e8752d44 | 530 | printf("IMPORT_STAR"); |
pythontech | 0:5868e8752d44 | 531 | break; |
pythontech | 0:5868e8752d44 | 532 | |
pythontech | 0:5868e8752d44 | 533 | default: |
pythontech | 0:5868e8752d44 | 534 | if (ip[-1] < MP_BC_LOAD_CONST_SMALL_INT_MULTI + 64) { |
pythontech | 0:5868e8752d44 | 535 | printf("LOAD_CONST_SMALL_INT " INT_FMT, (mp_int_t)ip[-1] - MP_BC_LOAD_CONST_SMALL_INT_MULTI - 16); |
pythontech | 0:5868e8752d44 | 536 | } else if (ip[-1] < MP_BC_LOAD_FAST_MULTI + 16) { |
pythontech | 0:5868e8752d44 | 537 | printf("LOAD_FAST " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_LOAD_FAST_MULTI); |
pythontech | 0:5868e8752d44 | 538 | } else if (ip[-1] < MP_BC_STORE_FAST_MULTI + 16) { |
pythontech | 0:5868e8752d44 | 539 | printf("STORE_FAST " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_STORE_FAST_MULTI); |
pythontech | 0:5868e8752d44 | 540 | } else if (ip[-1] < MP_BC_UNARY_OP_MULTI + 7) { |
pythontech | 0:5868e8752d44 | 541 | printf("UNARY_OP " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_UNARY_OP_MULTI); |
pythontech | 0:5868e8752d44 | 542 | } else if (ip[-1] < MP_BC_BINARY_OP_MULTI + 36) { |
pythontech | 0:5868e8752d44 | 543 | mp_uint_t op = ip[-1] - MP_BC_BINARY_OP_MULTI; |
pythontech | 0:5868e8752d44 | 544 | printf("BINARY_OP " UINT_FMT " %s", op, qstr_str(mp_binary_op_method_name[op])); |
pythontech | 0:5868e8752d44 | 545 | } else { |
pythontech | 0:5868e8752d44 | 546 | printf("code %p, byte code 0x%02x not implemented\n", ip, ip[-1]); |
pythontech | 0:5868e8752d44 | 547 | assert(0); |
pythontech | 0:5868e8752d44 | 548 | return ip; |
pythontech | 0:5868e8752d44 | 549 | } |
pythontech | 0:5868e8752d44 | 550 | break; |
pythontech | 0:5868e8752d44 | 551 | } |
pythontech | 0:5868e8752d44 | 552 | |
pythontech | 0:5868e8752d44 | 553 | return ip; |
pythontech | 0:5868e8752d44 | 554 | } |
pythontech | 0:5868e8752d44 | 555 | |
pythontech | 0:5868e8752d44 | 556 | void mp_bytecode_print2(const byte *ip, mp_uint_t len) { |
pythontech | 0:5868e8752d44 | 557 | mp_showbc_code_start = ip; |
pythontech | 0:5868e8752d44 | 558 | while (ip < len + mp_showbc_code_start) { |
pythontech | 0:5868e8752d44 | 559 | printf("%02u ", (uint)(ip - mp_showbc_code_start)); |
pythontech | 0:5868e8752d44 | 560 | ip = mp_bytecode_print_str(ip); |
pythontech | 0:5868e8752d44 | 561 | printf("\n"); |
pythontech | 0:5868e8752d44 | 562 | } |
pythontech | 0:5868e8752d44 | 563 | } |
pythontech | 0:5868e8752d44 | 564 | |
pythontech | 0:5868e8752d44 | 565 | #endif // MICROPY_DEBUG_PRINTERS |