summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/obj.c9
-rw-r--r--py/obj.h1
-rw-r--r--py/objfun.c24
-rw-r--r--py/objgenerator.c9
-rw-r--r--py/objnone.c3
-rw-r--r--py/objsingleton.c3
-rw-r--r--py/objtype.c1
-rw-r--r--py/profile.c2
-rw-r--r--py/runtime.c3
9 files changed, 16 insertions, 39 deletions
diff --git a/py/obj.c b/py/obj.c
index 3b0fd171c..7e26d4c7f 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -594,12 +594,3 @@ void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flag
mp_raise_TypeError(MP_ERROR_TEXT("object with buffer protocol required"));
}
}
-
-mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
- switch (op) {
- case MP_UNARY_OP_HASH:
- return MP_OBJ_NEW_SMALL_INT((mp_uint_t)o_in);
- default:
- return MP_OBJ_NULL; // op not supported
- }
-}
diff --git a/py/obj.h b/py/obj.h
index d41511b0e..04c153f50 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -1016,7 +1016,6 @@ mp_obj_t mp_obj_id(mp_obj_t o_in);
mp_obj_t mp_obj_len(mp_obj_t o_in);
mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL
mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val);
-mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in);
// cell
diff --git a/py/objfun.c b/py/objfun.c
index 390ddaa2d..94b33cd5b 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -58,8 +58,7 @@ STATIC mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw,
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_fun_builtin_0, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN,
- call, fun_builtin_0_call,
- unary_op, mp_generic_unary_op
+ call, fun_builtin_0_call
);
STATIC mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
@@ -71,8 +70,7 @@ STATIC mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw,
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_fun_builtin_1, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN,
- call, fun_builtin_1_call,
- unary_op, mp_generic_unary_op
+ call, fun_builtin_1_call
);
STATIC mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
@@ -84,8 +82,7 @@ STATIC mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw,
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_fun_builtin_2, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN,
- call, fun_builtin_2_call,
- unary_op, mp_generic_unary_op
+ call, fun_builtin_2_call
);
STATIC mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
@@ -97,8 +94,7 @@ STATIC mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw,
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_fun_builtin_3, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN,
- call, fun_builtin_3_call,
- unary_op, mp_generic_unary_op
+ call, fun_builtin_3_call
);
STATIC mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
@@ -126,8 +122,7 @@ STATIC mp_obj_t fun_builtin_var_call(mp_obj_t self_in, size_t n_args, size_t n_k
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_fun_builtin_var, MP_QSTR_function, MP_TYPE_FLAG_BINDS_SELF | MP_TYPE_FLAG_BUILTIN_FUN,
- call, fun_builtin_var_call,
- unary_op, mp_generic_unary_op
+ call, fun_builtin_var_call
);
/******************************************************************************/
@@ -370,8 +365,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
MP_TYPE_FLAG_BINDS_SELF,
FUN_BC_TYPE_PRINT
FUN_BC_TYPE_ATTR
- call, fun_bc_call,
- unary_op, mp_generic_unary_op
+ call, fun_bc_call
);
mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_module_context_t *context, struct _mp_raw_code_t *const *child_table) {
@@ -432,8 +426,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
MP_TYPE_FLAG_BINDS_SELF,
FUN_BC_TYPE_PRINT
FUN_BC_TYPE_ATTR
- call, fun_native_call,
- unary_op, mp_generic_unary_op
+ call, fun_native_call
);
mp_obj_t mp_obj_new_fun_native(const mp_obj_t *def_args, const void *fun_data, const mp_module_context_t *mc, struct _mp_raw_code_t *const *child_table) {
@@ -540,8 +533,7 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
mp_type_fun_asm,
MP_QSTR_function,
MP_TYPE_FLAG_BINDS_SELF,
- call, fun_asm_call,
- unary_op, mp_generic_unary_op
+ call, fun_asm_call
);
mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig) {
diff --git a/py/objgenerator.c b/py/objgenerator.c
index 8175dbd68..ecd1f583e 100644
--- a/py/objgenerator.c
+++ b/py/objgenerator.c
@@ -81,8 +81,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
MP_QSTR_generator,
MP_TYPE_FLAG_BINDS_SELF,
GEN_WRAP_TYPE_ATTR
- call, gen_wrap_call,
- unary_op, mp_generic_unary_op
+ call, gen_wrap_call
);
/******************************************************************************/
@@ -136,7 +135,7 @@ STATIC mp_obj_t native_gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_k
}
#if MICROPY_PY_FUNCTION_ATTRS
-#define NATIVE_GEN_WRAP_TYPE_ATTR attr, mp_obj_fun_bc_attr,
+#define NATIVE_GEN_WRAP_TYPE_ATTR , attr, mp_obj_fun_bc_attr
#else
#define NATIVE_GEN_WRAP_TYPE_ATTR
#endif
@@ -145,9 +144,8 @@ MP_DEFINE_CONST_OBJ_TYPE(
mp_type_native_gen_wrap,
MP_QSTR_generator,
MP_TYPE_FLAG_BINDS_SELF,
- call, native_gen_wrap_call,
+ call, native_gen_wrap_call
NATIVE_GEN_WRAP_TYPE_ATTR
- unary_op, mp_generic_unary_op
);
#endif // MICROPY_EMIT_NATIVE
@@ -370,7 +368,6 @@ MP_DEFINE_CONST_OBJ_TYPE(
MP_QSTR_generator,
MP_TYPE_FLAG_ITER_IS_ITERNEXT,
print, gen_instance_print,
- unary_op, mp_generic_unary_op,
iter, gen_instance_iternext,
locals_dict, &gen_instance_locals_dict
);
diff --git a/py/objnone.c b/py/objnone.c
index 4f8996e89..4b0696d3a 100644
--- a/py/objnone.c
+++ b/py/objnone.c
@@ -47,8 +47,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
mp_type_NoneType,
MP_QSTR_NoneType,
MP_TYPE_FLAG_NONE,
- print, none_print,
- unary_op, mp_generic_unary_op
+ print, none_print
);
#if !MICROPY_OBJ_IMMEDIATE_OBJS
diff --git a/py/objsingleton.c b/py/objsingleton.c
index dc73d28c2..6537676c5 100644
--- a/py/objsingleton.c
+++ b/py/objsingleton.c
@@ -45,8 +45,7 @@ STATIC void singleton_print(const mp_print_t *print, mp_obj_t self_in, mp_print_
MP_DEFINE_CONST_OBJ_TYPE(
mp_type_singleton, MP_QSTR_, MP_TYPE_FLAG_NONE,
- print, singleton_print,
- unary_op, mp_generic_unary_op
+ print, singleton_print
);
const mp_obj_singleton_t mp_const_ellipsis_obj = {{&mp_type_singleton}, MP_QSTR_Ellipsis};
diff --git a/py/objtype.c b/py/objtype.c
index 7f71968ea..88d1c8ebe 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -1112,7 +1112,6 @@ MP_DEFINE_CONST_OBJ_TYPE(
make_new, type_make_new,
print, type_print,
call, type_call,
- unary_op, mp_generic_unary_op,
attr, type_attr
);
diff --git a/py/profile.c b/py/profile.c
index fd2d61caa..89af8640a 100644
--- a/py/profile.c
+++ b/py/profile.c
@@ -177,7 +177,6 @@ MP_DEFINE_CONST_OBJ_TYPE(
MP_QSTR_code,
MP_TYPE_FLAG_NONE,
print, code_print,
- unary_op, mp_generic_unary_op,
attr, code_attr
);
@@ -247,7 +246,6 @@ MP_DEFINE_CONST_OBJ_TYPE(
MP_QSTR_frame,
MP_TYPE_FLAG_NONE,
print, frame_print,
- unary_op, mp_generic_unary_op,
attr, frame_attr
);
diff --git a/py/runtime.c b/py/runtime.c
index 3c7c0350c..47e094763 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -314,6 +314,9 @@ mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg) {
if (result != MP_OBJ_NULL) {
return result;
}
+ } else if (op == MP_UNARY_OP_HASH) {
+ // Type doesn't have unary_op so use hash of object instance.
+ return MP_OBJ_NEW_SMALL_INT((mp_uint_t)arg);
}
if (op == MP_UNARY_OP_BOOL) {
// Type doesn't have unary_op (or didn't handle MP_UNARY_OP_BOOL),