blob: 9aea2e4d45e0495e8a1b2667481dee4cdb539fcd [file] [log] [blame]
Damien George2326d522014-03-27 23:26:35 +00001// These variables and functions glue the code emitters to the runtime.
2
Damien Georgedf8127a2014-04-13 11:04:33 +01003typedef 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
11typedef 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 George2326d522014-03-27 23:26:35 +000030void mp_emit_glue_init(void);
31void mp_emit_glue_deinit(void);
Damien Georgedf8127a2014-04-13 11:04:33 +010032
33mp_raw_code_t *mp_emit_glue_new_raw_code(void);
34
35void 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);
36void mp_emit_glue_assign_native_code(mp_raw_code_t *rc, void *f, uint len, int n_args);
37void mp_emit_glue_assign_inline_asm_code(mp_raw_code_t *rc, void *f, uint len, int n_args);
38
39mp_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 George3558f622014-04-20 17:50:40 +010040mp_obj_t mp_make_closure_from_raw_code(mp_raw_code_t *rc, uint n_closed_over, const mp_obj_t *args);