diff options
author | Damien George <damien@micropython.org> | 2025-01-19 23:30:59 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-02-11 16:42:14 +1100 |
commit | 62e821ccb82fd8362a8198ad59ccb51b8a5c441e (patch) | |
tree | 36202713393c8bc4842171bc1cca13a4300b928b /py/mpconfig.h | |
parent | 372ecfef02eccc4e52a5d0abef068c7d25fc4315 (diff) | |
download | micropython-62e821ccb82fd8362a8198ad59ccb51b8a5c441e.tar.gz micropython-62e821ccb82fd8362a8198ad59ccb51b8a5c441e.zip |
py/objcode: Factor code object out into its own file.
The `mp_obj_code_t` and `mp_type_code` code object was defined internally
in both `py/builtinevex.c` and `py/profile.c`, with completely different
implementations (the former very minimal, the latter quite complete).
This commit factors these implementations into a new, separate source file,
and allows the code object to have four different modes, selected at
compile-time:
- MICROPY_PY_BUILTINS_CODE_NONE: code object not included in the build.
- MICROPY_PY_BUILTINS_CODE_MINIMUM: very simple code object that just holds
a reference to the function that it represents. This level is used when
MICROPY_PY_BUILTINS_COMPILE is enabled.
- MICROPY_PY_BUILTINS_CODE_BASIC: simple code object that holds a reference
to the proto-function and its constants.
- MICROPY_PY_BUILTINS_CODE_FULL: almost complete implementation of the code
object. This level is used when MICROPY_PY_SYS_SETTRACE is enabled.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/mpconfig.h')
-rw-r--r-- | py/mpconfig.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h index 64138a9ea7..76aff4681d 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1129,6 +1129,15 @@ typedef double mp_float_t; #define MICROPY_PY_BUILTINS_BYTEARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif +// Whether to support code objects, and how many features they have +#define MICROPY_PY_BUILTINS_CODE_NONE (0) +#define MICROPY_PY_BUILTINS_CODE_MINIMUM (1) +#define MICROPY_PY_BUILTINS_CODE_BASIC (2) +#define MICROPY_PY_BUILTINS_CODE_FULL (3) +#ifndef MICROPY_PY_BUILTINS_CODE +#define MICROPY_PY_BUILTINS_CODE (MICROPY_PY_SYS_SETTRACE ? MICROPY_PY_BUILTINS_CODE_FULL : (MICROPY_PY_BUILTINS_COMPILE ? MICROPY_PY_BUILTINS_CODE_MINIMUM : MICROPY_PY_BUILTINS_CODE_NONE)) +#endif + // Whether to support dict.fromkeys() class method #ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS #define MICROPY_PY_BUILTINS_DICT_FROMKEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) |