aboutsummaryrefslogtreecommitdiff
path: root/py/emitglue.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-11-02 21:55:42 +0000
committerDamien George <damien.p.george@gmail.com>2015-11-13 12:49:18 +0000
commitd8c834c95d506db979ec871417de90b7951edc30 (patch)
tree929cb08dde61d960d18f47bd80f56114ff10bb4f /py/emitglue.h
parentc8e9c0d89afa90694790fd48e1bf527487a5beb7 (diff)
py: Add MICROPY_PERSISTENT_CODE_LOAD/SAVE to load/save bytecode.
MICROPY_PERSISTENT_CODE must be enabled, and then enabling MICROPY_PERSISTENT_CODE_LOAD/SAVE (either or both) will allow loading and/or saving of code (at the moment just bytecode) from/to a .mpy file.
Diffstat (limited to 'py/emitglue.h')
-rw-r--r--py/emitglue.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/py/emitglue.h b/py/emitglue.h
index 9bb2ba2d7..6da0f6cb4 100644
--- a/py/emitglue.h
+++ b/py/emitglue.h
@@ -43,10 +43,31 @@ typedef struct _mp_raw_code_t mp_raw_code_t;
mp_raw_code_t *mp_emit_glue_new_raw_code(void);
-void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len, const mp_uint_t *const_table, mp_uint_t scope_flags);
+void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len,
+ const mp_uint_t *const_table,
+ #if MICROPY_PERSISTENT_CODE_SAVE
+ uint16_t n_obj, uint16_t n_raw_code,
+ #endif
+ mp_uint_t scope_flags);
void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, const mp_uint_t *const_table, mp_uint_t n_pos_args, mp_uint_t scope_flags, mp_uint_t type_sig);
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);
mp_obj_t mp_make_closure_from_raw_code(mp_raw_code_t *rc, mp_uint_t n_closed_over, const mp_obj_t *args);
+#if MICROPY_PERSISTENT_CODE_LOAD
+typedef struct _mp_reader_t {
+ void *data;
+ mp_uint_t (*read_byte)(void *data);
+ void (*close)(void *data);
+} mp_reader_t;
+
+mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader);
+mp_raw_code_t *mp_raw_code_load_file(const char *filename);
+#endif
+
+#if MICROPY_PERSISTENT_CODE_SAVE
+void mp_raw_code_save(mp_raw_code_t *rc, mp_print_t *print);
+void mp_raw_code_save_file(mp_raw_code_t *rc, const char *filename);
+#endif
+
#endif // __MICROPY_INCLUDED_PY_EMITGLUE_H__