summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/binary.c20
-rw-r--r--py/emitinlinethumb.c4
-rw-r--r--py/emitnative.c16
-rw-r--r--py/objdict.c3
-rw-r--r--py/objfloat.c8
-rw-r--r--py/objfun.c6
-rw-r--r--py/objint_mpz.c6
-rw-r--r--py/runtime.c8
8 files changed, 39 insertions, 32 deletions
diff --git a/py/binary.c b/py/binary.c
index 83f28db91a..a8907bfbfd 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -297,19 +297,19 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p
if (mp_obj_is_type(val_in, &mp_type_int)) {
mp_obj_int_to_bytes_impl(val_in, struct_type == '>', size, p);
return;
- } else
+ }
#endif
- {
- val = mp_obj_get_int(val_in);
- // zero/sign extend if needed
- if (BYTES_PER_WORD < 8 && size > sizeof(val)) {
- int c = (is_signed(val_type) && (mp_int_t)val < 0) ? 0xff : 0x00;
- memset(p, c, size);
- if (struct_type == '>') {
- p += size - sizeof(val);
- }
+
+ val = mp_obj_get_int(val_in);
+ // zero/sign extend if needed
+ if (BYTES_PER_WORD < 8 && size > sizeof(val)) {
+ int c = (is_signed(val_type) && (mp_int_t)val < 0) ? 0xff : 0x00;
+ memset(p, c, size);
+ if (struct_type == '>') {
+ p += size - sizeof(val);
}
}
+ break;
}
mp_binary_set_int(MIN((size_t)size, sizeof(val)), struct_type == '>', p, val);
diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c
index 020dfc8153..0f58976359 100644
--- a/py/emitinlinethumb.c
+++ b/py/emitinlinethumb.c
@@ -521,8 +521,10 @@ STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_a
} else {
goto unknown_op;
}
- } else
+ return;
+ }
#endif
+
if (n_args == 0) {
if (op == MP_QSTR_nop) {
asm_thumb_op16(&emit->as, ASM_THUMB_OP_NOP);
diff --git a/py/emitnative.c b/py/emitnative.c
index d0252560fe..da60c119d5 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -2318,15 +2318,19 @@ STATIC void emit_native_binary_op(emit_t *emit, mp_binary_op_t op) {
int reg_rhs = REG_ARG_3;
emit_pre_pop_reg_flexible(emit, &vtype_rhs, &reg_rhs, REG_RET, REG_ARG_2);
emit_pre_pop_reg(emit, &vtype_lhs, REG_ARG_2);
+
#if !(N_X64 || N_X86)
- if (op == MP_BINARY_OP_LSHIFT) {
- ASM_LSL_REG_REG(emit->as, REG_ARG_2, reg_rhs);
- emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2);
- } else if (op == MP_BINARY_OP_RSHIFT) {
- ASM_ASR_REG_REG(emit->as, REG_ARG_2, reg_rhs);
+ if (op == MP_BINARY_OP_LSHIFT || op == MP_BINARY_OP_RSHIFT) {
+ if (op == MP_BINARY_OP_LSHIFT) {
+ ASM_LSL_REG_REG(emit->as, REG_ARG_2, reg_rhs);
+ } else {
+ ASM_ASR_REG_REG(emit->as, REG_ARG_2, reg_rhs);
+ }
emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2);
- } else
+ return;
+ }
#endif
+
if (op == MP_BINARY_OP_OR) {
ASM_OR_REG_REG(emit->as, REG_ARG_2, reg_rhs);
emit_post_push_reg(emit, VTYPE_INT, REG_ARG_2);
diff --git a/py/objdict.c b/py/objdict.c
index 7a43a85485..f831a04881 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -141,8 +141,9 @@ STATIC mp_obj_t dict_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_
}
}
return e1 == NULL && e2 == NULL ? mp_const_true : mp_const_false;
- } else
+ }
#endif
+
if (mp_obj_is_type(rhs_in, &mp_type_dict)) {
mp_obj_dict_t *rhs = MP_OBJ_TO_PTR(rhs_in);
if (o->map.used != rhs->map.used) {
diff --git a/py/objfloat.c b/py/objfloat.c
index c19cc3960a..055430712a 100644
--- a/py/objfloat.c
+++ b/py/objfloat.c
@@ -159,14 +159,12 @@ STATIC mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
STATIC mp_obj_t float_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_float_t lhs_val = mp_obj_float_get(lhs_in);
-#if MICROPY_PY_BUILTINS_COMPLEX
+ #if MICROPY_PY_BUILTINS_COMPLEX
if (mp_obj_is_type(rhs_in, &mp_type_complex)) {
return mp_obj_complex_binary_op(op, lhs_val, 0, rhs_in);
- } else
-#endif
- {
- return mp_obj_float_binary_op(op, lhs_val, rhs_in);
}
+ #endif
+ return mp_obj_float_binary_op(op, lhs_val, rhs_in);
}
const mp_obj_type_t mp_type_float = {
diff --git a/py/objfun.c b/py/objfun.c
index 984d2000a8..dbff2faa0c 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -456,12 +456,12 @@ STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
return (mp_uint_t)mp_obj_str_get_data(obj, &l);
} else {
const mp_obj_type_t *type = mp_obj_get_type(obj);
-#if MICROPY_PY_BUILTINS_FLOAT
+ #if MICROPY_PY_BUILTINS_FLOAT
if (type == &mp_type_float) {
// convert float to int (could also pass in float registers)
return (mp_int_t)mp_obj_float_get(obj);
- } else
-#endif
+ }
+ #endif
if (type == &mp_type_tuple || type == &mp_type_list) {
// pointer to start of tuple (could pass length, but then could use len(x) for that)
size_t len;
diff --git a/py/objint_mpz.c b/py/objint_mpz.c
index 2c09d9bd2b..834e9a9bda 100644
--- a/py/objint_mpz.c
+++ b/py/objint_mpz.c
@@ -194,7 +194,7 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in);
}
-#if MICROPY_PY_BUILTINS_FLOAT
+ #if MICROPY_PY_BUILTINS_FLOAT
if (op == MP_BINARY_OP_TRUE_DIVIDE || op == MP_BINARY_OP_INPLACE_TRUE_DIVIDE) {
if (mpz_is_zero(zrhs)) {
goto zero_division_error;
@@ -202,8 +202,8 @@ mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
mp_float_t flhs = mpz_as_float(zlhs);
mp_float_t frhs = mpz_as_float(zrhs);
return mp_obj_new_float(flhs / frhs);
- } else
-#endif
+ }
+ #endif
if (op >= MP_BINARY_OP_INPLACE_OR && op < MP_BINARY_OP_CONTAINS) {
mp_obj_int_t *res = mp_obj_int_new_mpz();
diff --git a/py/runtime.c b/py/runtime.c
index 3926f89ce4..9b5527d728 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -1056,12 +1056,14 @@ void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) {
const mp_obj_type_t *type = mp_obj_get_type(obj);
// look for built-in names
-#if MICROPY_CPYTHON_COMPAT
+ #if MICROPY_CPYTHON_COMPAT
if (attr == MP_QSTR___class__) {
// a.__class__ is equivalent to type(a)
dest[0] = MP_OBJ_FROM_PTR(type);
- } else
-#endif
+ return;
+ }
+ #endif
+
if (attr == MP_QSTR___next__ && type->iternext != NULL) {
dest[0] = MP_OBJ_FROM_PTR(&mp_builtin_next_obj);
dest[1] = obj;