diff options
| author | Damien George <damien.p.george@gmail.com> | 2014-04-09 12:27:39 +0100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2014-04-09 12:27:39 +0100 |
| commit | 78035b995ff7bd518cc1291aa70c966b53510fd9 (patch) | |
| tree | b401d96d1a29db9cc7c87beedc9c829cc46e56f8 /py/scope.h | |
| parent | fc18c8e834a1ed72b9f61d82cd00099a4de1eab4 (diff) | |
py, compiler: Clean up and compress scope/compile structures.
Convert int types to uint where sensible, and then to uint8_t or
uint16_t where possible to reduce RAM usage.
Diffstat (limited to 'py/scope.h')
| -rw-r--r-- | py/scope.h | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/py/scope.h b/py/scope.h index 7ecd1e19f..daba296dc 100644 --- a/py/scope.h +++ b/py/scope.h @@ -7,14 +7,12 @@ enum { }; typedef struct _id_info_t { - // TODO compress this info to make structure smaller in memory - bool param; - int kind; - qstr qstr; - + uint8_t param; + uint8_t kind; // when it's an ID_INFO_KIND_LOCAL this is the unique number of the local // whet it's an ID_INFO_KIND_CELL/FREE this is the unique number of the closed over variable - int local_num; + uint16_t local_num; + qstr qstr; } id_info_t; // scope is a "block" in Python parlance @@ -26,20 +24,16 @@ typedef struct _scope_t { mp_parse_node_t pn; qstr source_file; qstr simple_name; - int id_info_alloc; - int id_info_len; - id_info_t *id_info; - uint scope_flags; // see runtime0.h - int num_params; - /* not needed - int num_default_params; - int num_dict_params; - */ - int num_locals; - int stack_size; // maximum size of the locals stack - int exc_stack_size; // maximum size of the exception stack uint unique_code_id; - uint emit_options; + uint8_t scope_flags; // see runtime0.h + uint8_t emit_options; // see compile.h + uint16_t num_params; + uint16_t num_locals; + uint16_t stack_size; // maximum size of the locals stack + uint16_t exc_stack_size; // maximum size of the exception stack + uint16_t id_info_alloc; + uint16_t id_info_len; + id_info_t *id_info; } scope_t; scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, uint unique_code_id, uint emit_options); |
