diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-11 09:47:06 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-11 09:47:06 +0000 |
commit | bc1d36924d616ca58f47142e1eb20146d9f253e7 (patch) | |
tree | a7b100da7eb049d6774c6bad427f4f1056cdd564 /py/emitcpy.c | |
parent | 8d4ccc49ed8bca34579982a5a96b2b50da86d985 (diff) | |
download | micropython-bc1d36924d616ca58f47142e1eb20146d9f253e7.tar.gz micropython-bc1d36924d616ca58f47142e1eb20146d9f253e7.zip |
py: Fix emitcpy and emitnative's binary_op.
Diffstat (limited to 'py/emitcpy.c')
-rw-r--r-- | py/emitcpy.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/py/emitcpy.c b/py/emitcpy.c index dfc851d2ed..ee96e589a3 100644 --- a/py/emitcpy.c +++ b/py/emitcpy.c @@ -551,7 +551,13 @@ static void emit_cpy_unary_op(emit_t *emit, rt_unary_op_t op) { } static void emit_cpy_binary_op(emit_t *emit, rt_binary_op_t op) { - emit_pre(emit, -1, 1); + if (op <= RT_BINARY_OP_INPLACE_POWER) { + // CPython uses a byte code for each binary op + emit_pre(emit, -1, 1); + } else { + // CPython uses a byte code plus an argument for compare ops + emit_pre(emit, -1, 3); + } if (emit->pass == PASS_3) { switch (op) { case RT_BINARY_OP_SUBSCR: printf("BINARY_SUBSCR\n"); break; |