@@ -1974,14 +1974,19 @@ STATIC void emit_native_pop_except(emit_t *emit) {
19741974STATIC void emit_native_unary_op (emit_t * emit , mp_unary_op_t op ) {
19751975 vtype_kind_t vtype ;
19761976 emit_pre_pop_reg (emit , & vtype , REG_ARG_2 );
1977- assert (vtype == VTYPE_PYOBJ );
1978- if (op == MP_UNARY_OP_NOT ) {
1979- // we need to synthesise this operation by converting to bool first
1980- emit_call_with_imm_arg (emit , MP_F_UNARY_OP , MP_UNARY_OP_BOOL , REG_ARG_1 );
1981- ASM_MOV_REG_REG (emit -> as , REG_ARG_2 , REG_RET );
1977+ if (vtype == VTYPE_PYOBJ ) {
1978+ if (op == MP_UNARY_OP_NOT ) {
1979+ // we need to synthesise this operation by converting to bool first
1980+ emit_call_with_imm_arg (emit , MP_F_UNARY_OP , MP_UNARY_OP_BOOL , REG_ARG_1 );
1981+ ASM_MOV_REG_REG (emit -> as , REG_ARG_2 , REG_RET );
1982+ }
1983+ emit_call_with_imm_arg (emit , MP_F_UNARY_OP , op , REG_ARG_1 );
1984+ emit_post_push_reg (emit , VTYPE_PYOBJ , REG_RET );
1985+ } else {
1986+ adjust_stack (emit , 1 );
1987+ EMIT_NATIVE_VIPER_TYPE_ERROR (emit ,
1988+ "unary op %q not implemented" , mp_unary_op_method_name [op ]);
19821989 }
1983- emit_call_with_imm_arg (emit , MP_F_UNARY_OP , op , REG_ARG_1 );
1984- emit_post_push_reg (emit , VTYPE_PYOBJ , REG_RET );
19851990}
19861991
19871992STATIC void emit_native_binary_op (emit_t * emit , mp_binary_op_t op ) {
0 commit comments