py: Move mp_native_type_from_qstr() from emitnative.c to nativeglue.c.
This commit is contained in:
parent
28c2873d99
commit
3b973a5658
|
@ -156,8 +156,6 @@ typedef struct _emit_method_table_t {
|
|||
void (*end_except_handler)(emit_t *emit);
|
||||
} emit_method_table_t;
|
||||
|
||||
int mp_native_type_from_qstr(qstr qst);
|
||||
|
||||
static inline void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst) {
|
||||
scope_find_or_add_id(scope, qst, ID_INFO_KIND_GLOBAL_IMPLICIT);
|
||||
}
|
||||
|
|
|
@ -136,20 +136,6 @@ typedef enum {
|
|||
VTYPE_BUILTIN_CAST = 0x70 | MP_NATIVE_TYPE_OBJ,
|
||||
} vtype_kind_t;
|
||||
|
||||
int mp_native_type_from_qstr(qstr qst) {
|
||||
switch (qst) {
|
||||
case MP_QSTR_object: return MP_NATIVE_TYPE_OBJ;
|
||||
case MP_QSTR_bool: return MP_NATIVE_TYPE_BOOL;
|
||||
case MP_QSTR_int: return MP_NATIVE_TYPE_INT;
|
||||
case MP_QSTR_uint: return MP_NATIVE_TYPE_UINT;
|
||||
case MP_QSTR_ptr: return MP_NATIVE_TYPE_PTR;
|
||||
case MP_QSTR_ptr8: return MP_NATIVE_TYPE_PTR8;
|
||||
case MP_QSTR_ptr16: return MP_NATIVE_TYPE_PTR16;
|
||||
case MP_QSTR_ptr32: return MP_NATIVE_TYPE_PTR32;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
STATIC qstr vtype_to_qstr(vtype_kind_t vtype) {
|
||||
switch (vtype) {
|
||||
case VTYPE_PYOBJ: return MP_QSTR_object;
|
||||
|
|
|
@ -41,6 +41,20 @@
|
|||
|
||||
#if MICROPY_EMIT_NATIVE
|
||||
|
||||
int mp_native_type_from_qstr(qstr qst) {
|
||||
switch (qst) {
|
||||
case MP_QSTR_object: return MP_NATIVE_TYPE_OBJ;
|
||||
case MP_QSTR_bool: return MP_NATIVE_TYPE_BOOL;
|
||||
case MP_QSTR_int: return MP_NATIVE_TYPE_INT;
|
||||
case MP_QSTR_uint: return MP_NATIVE_TYPE_UINT;
|
||||
case MP_QSTR_ptr: return MP_NATIVE_TYPE_PTR;
|
||||
case MP_QSTR_ptr8: return MP_NATIVE_TYPE_PTR8;
|
||||
case MP_QSTR_ptr16: return MP_NATIVE_TYPE_PTR16;
|
||||
case MP_QSTR_ptr32: return MP_NATIVE_TYPE_PTR32;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// convert a MicroPython object to a valid native value based on type
|
||||
mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type) {
|
||||
DEBUG_printf("mp_convert_obj_to_native(%p, " UINT_FMT ")\n", obj, type);
|
||||
|
|
|
@ -169,6 +169,7 @@ NORETURN void mp_raise_recursion_depth(void);
|
|||
#endif
|
||||
|
||||
// helper functions for native/viper code
|
||||
int mp_native_type_from_qstr(qstr qst);
|
||||
mp_uint_t mp_convert_obj_to_native(mp_obj_t obj, mp_uint_t type);
|
||||
mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type);
|
||||
mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals);
|
||||
|
|
Loading…
Reference in New Issue