Damien George | 2326d52 | 2014-03-27 23:26:35 +0000 | [diff] [blame] | 1 | // These variables and functions glue the code emitters to the runtime. |
| 2 | |
Damien George | df8127a | 2014-04-13 11:04:33 +0100 | [diff] [blame] | 3 | typedef enum { |
| 4 | MP_CODE_UNUSED, |
| 5 | MP_CODE_RESERVED, |
| 6 | MP_CODE_BYTE, |
| 7 | MP_CODE_NATIVE, |
| 8 | MP_CODE_INLINE_ASM, |
| 9 | } mp_raw_code_kind_t; |
| 10 | |
| 11 | typedef struct _mp_code_t { |
| 12 | mp_raw_code_kind_t kind : 8; |
| 13 | uint scope_flags : 8; |
| 14 | uint n_args : 16; |
| 15 | union { |
| 16 | struct { |
| 17 | byte *code; |
| 18 | uint len; |
| 19 | } u_byte; |
| 20 | struct { |
| 21 | mp_fun_t fun; |
| 22 | } u_native; |
| 23 | struct { |
| 24 | void *fun; |
| 25 | } u_inline_asm; |
| 26 | }; |
| 27 | qstr *arg_names; |
| 28 | } mp_raw_code_t; |
| 29 | |
Damien George | 2326d52 | 2014-03-27 23:26:35 +0000 | [diff] [blame] | 30 | void mp_emit_glue_init(void); |
| 31 | void mp_emit_glue_deinit(void); |
Damien George | df8127a | 2014-04-13 11:04:33 +0100 | [diff] [blame] | 32 | |
| 33 | mp_raw_code_t *mp_emit_glue_new_raw_code(void); |
| 34 | |
| 35 | void mp_emit_glue_assign_byte_code(mp_raw_code_t *rc, byte *code, uint len, int n_args, int n_locals, uint scope_flags, qstr *arg_names); |
| 36 | void mp_emit_glue_assign_native_code(mp_raw_code_t *rc, void *f, uint len, int n_args); |
| 37 | void mp_emit_glue_assign_inline_asm_code(mp_raw_code_t *rc, void *f, uint len, int n_args); |
| 38 | |
| 39 | mp_obj_t mp_make_function_from_raw_code(mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args); |
Damien George | 3558f62 | 2014-04-20 17:50:40 +0100 | [diff] [blame^] | 40 | mp_obj_t mp_make_closure_from_raw_code(mp_raw_code_t *rc, uint n_closed_over, const mp_obj_t *args); |