summaryrefslogtreecommitdiffstatshomepage
path: root/py/emitbc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-12-27 17:07:16 +0000
committerDamien George <damien.p.george@gmail.com>2014-12-27 17:33:30 +0000
commite37dcaafb43c1246ab55d79ebb8889a61f280533 (patch)
tree79b86304793ac4d2396c7bc8a24209459e3eaf1a /py/emitbc.c
parent3b74c91684e6dfc785bf33ba03e520470f59059e (diff)
downloadmicropython-e37dcaafb43c1246ab55d79ebb8889a61f280533.tar.gz
micropython-e37dcaafb43c1246ab55d79ebb8889a61f280533.zip
py: Allow to properly disable builtin "set" object.
This patch makes MICROPY_PY_BUILTINS_SET compile-time option fully disable the builtin set object (when set to 0). This includes removing set constructor/comprehension from the grammar, the compiler and the emitters. Now, enabling set costs 8168 bytes on unix x64, and 3576 bytes on stmhal.
Diffstat (limited to 'py/emitbc.c')
-rw-r--r--py/emitbc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/emitbc.c b/py/emitbc.c
index 795c412830..723d5eda25 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -782,6 +782,7 @@ STATIC void emit_bc_map_add(emit_t *emit, mp_uint_t map_stack_index) {
emit_write_bytecode_byte_uint(emit, MP_BC_MAP_ADD, map_stack_index);
}
+#if MICROPY_PY_BUILTINS_SET
STATIC void emit_bc_build_set(emit_t *emit, mp_uint_t n_args) {
emit_bc_pre(emit, 1 - n_args);
emit_write_bytecode_byte_uint(emit, MP_BC_BUILD_SET, n_args);
@@ -791,6 +792,7 @@ STATIC void emit_bc_set_add(emit_t *emit, mp_uint_t set_stack_index) {
emit_bc_pre(emit, -1);
emit_write_bytecode_byte_uint(emit, MP_BC_SET_ADD, set_stack_index);
}
+#endif
STATIC void emit_bc_build_slice(emit_t *emit, mp_uint_t n_args) {
emit_bc_pre(emit, 1 - n_args);
@@ -960,8 +962,10 @@ const emit_method_table_t emit_bc_method_table = {
emit_bc_build_map,
emit_bc_store_map,
emit_bc_map_add,
+ #if MICROPY_PY_BUILTINS_SET
emit_bc_build_set,
emit_bc_set_add,
+ #endif
emit_bc_build_slice,
emit_bc_unpack_sequence,
emit_bc_unpack_ex,