diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-18 21:21:22 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-19 15:52:57 +0200 |
commit | 0f96ec826811e3cec3703141684445bea639e2bc (patch) | |
tree | c171e47ca4bee59cc396bd1326aebe98cb7ac604 /py/vm.c | |
parent | 46239413d033a25662700ba39a97b07737b820fc (diff) | |
download | micropython-0f96ec826811e3cec3703141684445bea639e2bc.tar.gz micropython-0f96ec826811e3cec3703141684445bea639e2bc.zip |
Bytecode uint varlen encoding: support arbitrary values.
Diffstat (limited to 'py/vm.c')
-rw-r--r-- | py/vm.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -38,10 +38,20 @@ typedef enum { UNWIND_JUMP, } mp_unwind_reason_t; -#define DECODE_UINT do { unum = *ip++; if (unum > 127) { unum = ((unum & 0x3f) << 8) | (*ip++); } } while (0) +#define DECODE_UINT { \ + unum = 0; \ + do { \ + unum = (unum << 7) + (*ip & 0x7f); \ + } while ((*ip++ & 0x80) != 0); \ +} #define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0) #define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0) -#define DECODE_QSTR do { qst = *ip++; if (qst > 127) { qst = ((qst & 0x3f) << 8) | (*ip++); } } while (0) +#define DECODE_QSTR { \ + qst = 0; \ + do { \ + qst = (qst << 7) + (*ip & 0x7f); \ + } while ((*ip++ & 0x80) != 0); \ +} #define PUSH(val) *++sp = (val) #define POP() (*sp--) #define TOP() (*sp) |