aboutsummaryrefslogtreecommitdiff
path: root/py/bc.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-10-23 01:23:11 +0100
committerDamien George <damien.p.george@gmail.com>2015-11-13 12:49:18 +0000
commit713ea1800d1f0c82a0c75885ad034705556ab5ef (patch)
treeac865eaf1d258007dbd6718d972967886d9a39e8 /py/bc.h
parent3a3db4dcf0400cffef860f61a84979cb1f7a7541 (diff)
py: Add constant table to bytecode.
Contains just argument names at the moment but makes it easy to add arbitrary constants.
Diffstat (limited to 'py/bc.h')
-rw-r--r--py/bc.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/py/bc.h b/py/bc.h
index 5824688d8..4c8401b9f 100644
--- a/py/bc.h
+++ b/py/bc.h
@@ -38,24 +38,26 @@
// n_kwonly_args : byte number of keyword-only arguments this function takes
// n_def_pos_args : byte number of default positional arguments
//
-// <word alignment padding>
-//
-// argname0 : obj (qstr)
-// ... : obj (qstr)
-// argnameN : obj (qstr) N = num_pos_args + num_kwonly_args
-//
// code_info_size : var uint | code_info_size counts bytes in this chunk
// simple_name : var qstr |
// source_file : var qstr |
// <line number info> |
-// <word alignment padding> |
+// <word alignment padding> | only needed if bytecode contains pointers
//
-// num_cells : byte number of locals that are cells
-// local_num0 : byte
-// ... : byte
-// local_numN : byte N = num_cells
+// local_num0 : byte |
+// ... : byte |
+// local_numN : byte | N = num_cells
+// 255 : byte | end of list sentinel
+// <bytecode> |
//
-// <bytecode>
+//
+// constant table layout:
+//
+// argname0 : obj (qstr)
+// ... : obj (qstr)
+// argnameN : obj (qstr) N = num_pos_args + num_kwonly_args
+// const0 : obj
+// constN : obj
// Exception stack entry
typedef struct _mp_exc_stack {
@@ -70,6 +72,7 @@ typedef struct _mp_exc_stack {
typedef struct _mp_code_state {
const byte *code_info;
const byte *ip;
+ const mp_uint_t *const_table;
mp_obj_t *sp;
// bit 0 is saved currently_in_except_block value
mp_exc_stack_t *exc_sp;
@@ -89,7 +92,7 @@ mp_uint_t mp_decode_uint(const byte **ptr);
mp_vm_return_kind_t mp_execute_bytecode(mp_code_state *code_state, volatile mp_obj_t inject_exc);
mp_code_state *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
void mp_setup_code_state(mp_code_state *code_state, mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
-void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len);
+void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table);
void mp_bytecode_print2(const byte *code, mp_uint_t len);
const byte *mp_bytecode_print_str(const byte *ip);
#define mp_bytecode_print_inst(code) mp_bytecode_print2(code, 1)