aboutsummaryrefslogtreecommitdiff
path: root/py/vmentrytable.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-12-08 12:28:11 +0000
committerDamien George <damien.p.george@gmail.com>2015-12-10 22:19:48 +0000
commitbdbe8c9ae21559f6dc0b8e1ad84b7bbec2a04726 (patch)
tree3c603ca42bd10e7d5bbd037d85d6b57735d39393 /py/vmentrytable.h
parente242b1785f9e25b36f5d225652c679cd7cec6ec0 (diff)
py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics.
Fixes #1684 and makes "not" match Python semantics. The code is also simplified (the separate MP_BC_NOT opcode is removed) and the patch saves 68 bytes for bare-arm/ and 52 bytes for minimal/. Previously "not x" was implemented as !mp_unary_op(x, MP_UNARY_OP_BOOL), so any given object only needs to implement MP_UNARY_OP_BOOL (and the VM had a special opcode to do the ! bit). With this patch "not x" is implemented as mp_unary_op(x, MP_UNARY_OP_NOT), but this operation is caught at the start of mp_unary_op and dispatched as !mp_obj_is_true(x). mp_obj_is_true has special logic to test for truthness, and is the correct way to handle the not operation.
Diffstat (limited to 'py/vmentrytable.h')
-rw-r--r--py/vmentrytable.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/py/vmentrytable.h b/py/vmentrytable.h
index d71a8d4f6..f3143b5d1 100644
--- a/py/vmentrytable.h
+++ b/py/vmentrytable.h
@@ -76,7 +76,6 @@ static void* entry_table[256] = {
[MP_BC_FOR_ITER] = &&entry_MP_BC_FOR_ITER,
[MP_BC_POP_BLOCK] = &&entry_MP_BC_POP_BLOCK,
[MP_BC_POP_EXCEPT] = &&entry_MP_BC_POP_EXCEPT,
- [MP_BC_NOT] = &&entry_MP_BC_NOT,
[MP_BC_BUILD_TUPLE] = &&entry_MP_BC_BUILD_TUPLE,
[MP_BC_BUILD_LIST] = &&entry_MP_BC_BUILD_LIST,
[MP_BC_LIST_APPEND] = &&entry_MP_BC_LIST_APPEND,
@@ -110,7 +109,7 @@ static void* entry_table[256] = {
[MP_BC_LOAD_CONST_SMALL_INT_MULTI ... MP_BC_LOAD_CONST_SMALL_INT_MULTI + 63] = &&entry_MP_BC_LOAD_CONST_SMALL_INT_MULTI,
[MP_BC_LOAD_FAST_MULTI ... MP_BC_LOAD_FAST_MULTI + 15] = &&entry_MP_BC_LOAD_FAST_MULTI,
[MP_BC_STORE_FAST_MULTI ... MP_BC_STORE_FAST_MULTI + 15] = &&entry_MP_BC_STORE_FAST_MULTI,
- [MP_BC_UNARY_OP_MULTI ... MP_BC_UNARY_OP_MULTI + 5] = &&entry_MP_BC_UNARY_OP_MULTI,
+ [MP_BC_UNARY_OP_MULTI ... MP_BC_UNARY_OP_MULTI + 6] = &&entry_MP_BC_UNARY_OP_MULTI,
[MP_BC_BINARY_OP_MULTI ... MP_BC_BINARY_OP_MULTI + 35] = &&entry_MP_BC_BINARY_OP_MULTI,
};