py: Add option to disable set() object (enabled by default).
This commit is contained in:
parent
fb510b3bf9
commit
3ebd4d0cae
@ -64,7 +64,9 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = {
|
|||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_property), (mp_obj_t)&mp_type_property },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_property), (mp_obj_t)&mp_type_property },
|
||||||
#endif
|
#endif
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_range), (mp_obj_t)&mp_type_range },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_range), (mp_obj_t)&mp_type_range },
|
||||||
|
#if MICROPY_PY_BUILTINS_SET
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_set), (mp_obj_t)&mp_type_set },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_set), (mp_obj_t)&mp_type_set },
|
||||||
|
#endif
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_str), (mp_obj_t)&mp_type_str },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_str), (mp_obj_t)&mp_type_str },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_super), (mp_obj_t)&mp_type_super },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_super), (mp_obj_t)&mp_type_super },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_tuple), (mp_obj_t)&mp_type_tuple },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_tuple), (mp_obj_t)&mp_type_tuple },
|
||||||
|
@ -239,6 +239,11 @@ typedef double mp_float_t;
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Fine control over Python builtins, classes, modules, etc */
|
/* Fine control over Python builtins, classes, modules, etc */
|
||||||
|
|
||||||
|
// Whether to support set object
|
||||||
|
#ifndef MICROPY_PY_BUILTINS_SET
|
||||||
|
#define MICROPY_PY_BUILTINS_SET (1)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Whether to support slice subscript operators and slice object
|
// Whether to support slice subscript operators and slice object
|
||||||
#ifndef MICROPY_PY_BUILTINS_SLICE
|
#ifndef MICROPY_PY_BUILTINS_SLICE
|
||||||
#define MICROPY_PY_BUILTINS_SLICE (1)
|
#define MICROPY_PY_BUILTINS_SLICE (1)
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
#include "runtime0.h"
|
#include "runtime0.h"
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
|
|
||||||
|
#if MICROPY_PY_BUILTINS_SET
|
||||||
|
|
||||||
typedef struct _mp_obj_set_t {
|
typedef struct _mp_obj_set_t {
|
||||||
mp_obj_base_t base;
|
mp_obj_base_t base;
|
||||||
mp_set_t set;
|
mp_set_t set;
|
||||||
@ -584,3 +586,5 @@ void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item) {
|
|||||||
mp_obj_set_t *self = self_in;
|
mp_obj_set_t *self = self_in;
|
||||||
mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
|
mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // MICROPY_PY_BUILTINS_SET
|
||||||
|
@ -1173,8 +1173,10 @@ void *const mp_fun_table[MP_F_NUMBER_OF] = {
|
|||||||
mp_obj_list_append,
|
mp_obj_list_append,
|
||||||
mp_obj_new_dict,
|
mp_obj_new_dict,
|
||||||
mp_obj_dict_store,
|
mp_obj_dict_store,
|
||||||
|
#if MICROPY_PY_BUILTINS_SET
|
||||||
mp_obj_new_set,
|
mp_obj_new_set,
|
||||||
mp_obj_set_store,
|
mp_obj_set_store,
|
||||||
|
#endif
|
||||||
mp_make_function_from_raw_code,
|
mp_make_function_from_raw_code,
|
||||||
mp_call_function_n_kw_for_native,
|
mp_call_function_n_kw_for_native,
|
||||||
mp_call_method_n_kw,
|
mp_call_method_n_kw,
|
||||||
|
@ -115,8 +115,10 @@ typedef enum {
|
|||||||
MP_F_LIST_APPEND,
|
MP_F_LIST_APPEND,
|
||||||
MP_F_BUILD_MAP,
|
MP_F_BUILD_MAP,
|
||||||
MP_F_STORE_MAP,
|
MP_F_STORE_MAP,
|
||||||
|
#if MICROPY_PY_BUILTINS_SET
|
||||||
MP_F_BUILD_SET,
|
MP_F_BUILD_SET,
|
||||||
MP_F_STORE_SET,
|
MP_F_STORE_SET,
|
||||||
|
#endif
|
||||||
MP_F_MAKE_FUNCTION_FROM_RAW_CODE,
|
MP_F_MAKE_FUNCTION_FROM_RAW_CODE,
|
||||||
MP_F_CALL_FUNCTION_N_KW_FOR_NATIVE,
|
MP_F_CALL_FUNCTION_N_KW_FOR_NATIVE,
|
||||||
MP_F_CALL_METHOD_N_KW,
|
MP_F_CALL_METHOD_N_KW,
|
||||||
|
2
py/vm.c
2
py/vm.c
@ -772,6 +772,7 @@ unwind_jump:
|
|||||||
sp -= 2;
|
sp -= 2;
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
|
|
||||||
|
#if MICROPY_PY_BUILTINS_SET
|
||||||
ENTRY(MP_BC_BUILD_SET):
|
ENTRY(MP_BC_BUILD_SET):
|
||||||
DECODE_UINT;
|
DECODE_UINT;
|
||||||
sp -= unum - 1;
|
sp -= unum - 1;
|
||||||
@ -784,6 +785,7 @@ unwind_jump:
|
|||||||
mp_obj_set_store(sp[-unum], sp[0]);
|
mp_obj_set_store(sp[-unum], sp[0]);
|
||||||
sp--;
|
sp--;
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MICROPY_PY_BUILTINS_SLICE
|
#if MICROPY_PY_BUILTINS_SLICE
|
||||||
ENTRY(MP_BC_BUILD_SLICE):
|
ENTRY(MP_BC_BUILD_SLICE):
|
||||||
|
Loading…
Reference in New Issue
Block a user