diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-08 21:11:49 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-08 21:11:49 +0100 |
commit | 1d24ea5207ba4b62b20dbba22ab2800496418463 (patch) | |
tree | 0ac953019f01f030778f2bc6381b69884e7124be /py/emitbc.c | |
parent | 134c10e776a5d75cfdd6bf98697cb50d7da7adf6 (diff) | |
download | micropython-1d24ea5207ba4b62b20dbba22ab2800496418463.tar.gz micropython-1d24ea5207ba4b62b20dbba22ab2800496418463.zip |
py: Finish implementation of all del opcodes.
At this point, all opcodes are now implemented!
Some del opcodes have been combined with store opcodes, with the value
to store being MP_OBJ_NULL.
Diffstat (limited to 'py/emitbc.c')
-rw-r--r-- | py/emitbc.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/py/emitbc.c b/py/emitbc.c index 11519fdd80..2a390a056c 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -36,6 +36,8 @@ struct _emit_t { byte dummy_data[8]; }; +STATIC void emit_bc_rot_two(emit_t *emit); + emit_t *emit_bc_new(uint max_num_labels) { emit_t *emit = m_new0(emit_t, 1); emit->max_num_labels = max_num_labels; @@ -487,14 +489,13 @@ STATIC void emit_bc_store_subscr(emit_t *emit) { } STATIC void emit_bc_delete_fast(emit_t *emit, qstr qstr, int local_num) { - assert(local_num >= 0); - emit_bc_pre(emit, 0); - emit_write_byte_code_byte_uint(emit, MP_BC_DELETE_FAST_N, local_num); + emit_bc_load_null(emit); + emit_bc_store_fast(emit, qstr, local_num); } STATIC void emit_bc_delete_deref(emit_t *emit, qstr qstr, int local_num) { - emit_bc_pre(emit, 0); - emit_write_byte_code_byte_qstr(emit, MP_BC_DELETE_DEREF, local_num); + emit_bc_load_null(emit); + emit_bc_store_deref(emit, qstr, local_num); } STATIC void emit_bc_delete_name(emit_t *emit, qstr qstr) { @@ -508,8 +509,9 @@ STATIC void emit_bc_delete_global(emit_t *emit, qstr qstr) { } STATIC void emit_bc_delete_attr(emit_t *emit, qstr qstr) { - emit_bc_pre(emit, -1); - emit_write_byte_code_byte_qstr(emit, MP_BC_DELETE_ATTR, qstr); + emit_bc_load_null(emit); + emit_bc_rot_two(emit); + emit_bc_store_attr(emit, qstr); } STATIC void emit_bc_delete_subscr(emit_t *emit) { |