Merge pull request #2282 from theacodes/native-if-available
Make the @micropython.native decorator no-op if support isn't enabled
This commit is contained in:
commit
cc008598d0
13
py/compile.c
13
py/compile.c
@ -775,13 +775,22 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_
|
|||||||
qstr attr = MP_PARSE_NODE_LEAF_ARG(name_nodes[1]);
|
qstr attr = MP_PARSE_NODE_LEAF_ARG(name_nodes[1]);
|
||||||
if (attr == MP_QSTR_bytecode) {
|
if (attr == MP_QSTR_bytecode) {
|
||||||
*emit_options = MP_EMIT_OPT_BYTECODE;
|
*emit_options = MP_EMIT_OPT_BYTECODE;
|
||||||
#if MICROPY_EMIT_NATIVE
|
// @micropython.native decorator.
|
||||||
} else if (attr == MP_QSTR_native) {
|
} else if (attr == MP_QSTR_native) {
|
||||||
|
// Different from MicroPython: native doesn't raise SyntaxError if native support isn't
|
||||||
|
// compiled, it just passes through the function unmodified.
|
||||||
|
#if MICROPY_EMIT_NATIVE
|
||||||
*emit_options = MP_EMIT_OPT_NATIVE_PYTHON;
|
*emit_options = MP_EMIT_OPT_NATIVE_PYTHON;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
#if MICROPY_EMIT_NATIVE
|
||||||
|
// @micropython.viper decorator.
|
||||||
} else if (attr == MP_QSTR_viper) {
|
} else if (attr == MP_QSTR_viper) {
|
||||||
*emit_options = MP_EMIT_OPT_VIPER;
|
*emit_options = MP_EMIT_OPT_VIPER;
|
||||||
#endif
|
#endif
|
||||||
#if MICROPY_EMIT_INLINE_ASM
|
#if MICROPY_EMIT_INLINE_ASM
|
||||||
|
// @micropython.asm_thumb decorator.
|
||||||
} else if (attr == ASM_DECORATOR_QSTR) {
|
} else if (attr == ASM_DECORATOR_QSTR) {
|
||||||
*emit_options = MP_EMIT_OPT_ASM;
|
*emit_options = MP_EMIT_OPT_ASM;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user