summaryrefslogtreecommitdiff
path: root/py/showbc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2013-12-30 22:32:17 +0000
committerDamien George <damien.p.george@gmail.com>2013-12-30 22:32:17 +0000
commit6baf76e28b17055fc6e5a6c9560e756d32eaad5d (patch)
treef4245858b6755d6731a7ec6c9f0a6fc49901eb5b /py/showbc.c
parent8cc96a35e532ef999e5a3739deeb44f51a80744b (diff)
py: make closures work.
Diffstat (limited to 'py/showbc.c')
-rw-r--r--py/showbc.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/py/showbc.c b/py/showbc.c
index b063c846a..d5ea70431 100644
--- a/py/showbc.c
+++ b/py/showbc.c
@@ -15,6 +15,19 @@
void mp_show_byte_code(const byte *ip, int len) {
const byte *ip_start = ip;
+
+ // decode prelude
+ {
+ uint n_local = *ip++;
+ printf("(NUM_LOCAL %u)\n", n_local);
+ for (; n_local > 0; n_local--) {
+ uint local_num = *ip++;
+ printf("(INIT_CELL %u)\n", local_num);
+ }
+ len -= ip - ip_start;
+ ip_start = ip;
+ }
+
machine_uint_t unum;
qstr qstr;
while (ip - ip_start < len) {
@@ -73,6 +86,11 @@ void mp_show_byte_code(const byte *ip, int len) {
printf("LOAD_FAST_N " UINT_FMT, unum);
break;
+ case MP_BC_LOAD_DEREF:
+ DECODE_UINT;
+ printf("LOAD_DEREF " UINT_FMT, unum);
+ break;
+
case MP_BC_LOAD_NAME:
DECODE_QSTR;
printf("LOAD_NAME %s", qstr_str(qstr));
@@ -114,6 +132,11 @@ void mp_show_byte_code(const byte *ip, int len) {
printf("STORE_FAST_N " UINT_FMT, unum);
break;
+ case MP_BC_STORE_DEREF:
+ DECODE_UINT;
+ printf("STORE_DEREF " UINT_FMT, unum);
+ break;
+
case MP_BC_STORE_NAME:
DECODE_QSTR;
printf("STORE_NAME %s", qstr_str(qstr));
@@ -301,6 +324,11 @@ void mp_show_byte_code(const byte *ip, int len) {
printf("MAKE_FUNCTION " UINT_FMT, unum);
break;
+ case MP_BC_MAKE_CLOSURE:
+ DECODE_UINT;
+ printf("MAKE_CLOSURE " UINT_FMT, unum);
+ break;
+
case MP_BC_CALL_FUNCTION:
DECODE_UINT;
printf("CALL_FUNCTION n=" UINT_FMT " nkw=" UINT_FMT, unum & 0xff, (unum >> 8) & 0xff);