py: Removing dangling "else" to improve code format consistency.
This commit is contained in:
parent
4b23e98fb0
commit
a1b18b3ba7
20
py/binary.c
20
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);
|
||||
|
@ -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);
|
||||
|
@ -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, ®_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);
|
||||
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 if (op == MP_BINARY_OP_RSHIFT) {
|
||||
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);
|
||||
|
@ -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) {
|
||||
|
@ -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 = {
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user