Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
py/emit.h@0:5868e8752d44, 2016-04-16 (annotated)
- Committer:
- pythontech
- Date:
- Sat Apr 16 17:11:56 2016 +0000
- Revision:
- 0:5868e8752d44
Split off library from repl
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| pythontech | 0:5868e8752d44 | 1 | /* |
| pythontech | 0:5868e8752d44 | 2 | * This file is part of the Micro Python project, http://micropython.org/ |
| pythontech | 0:5868e8752d44 | 3 | * |
| pythontech | 0:5868e8752d44 | 4 | * The MIT License (MIT) |
| pythontech | 0:5868e8752d44 | 5 | * |
| pythontech | 0:5868e8752d44 | 6 | * Copyright (c) 2013, 2014 Damien P. George |
| pythontech | 0:5868e8752d44 | 7 | * |
| pythontech | 0:5868e8752d44 | 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| pythontech | 0:5868e8752d44 | 9 | * of this software and associated documentation files (the "Software"), to deal |
| pythontech | 0:5868e8752d44 | 10 | * in the Software without restriction, including without limitation the rights |
| pythontech | 0:5868e8752d44 | 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| pythontech | 0:5868e8752d44 | 12 | * copies of the Software, and to permit persons to whom the Software is |
| pythontech | 0:5868e8752d44 | 13 | * furnished to do so, subject to the following conditions: |
| pythontech | 0:5868e8752d44 | 14 | * |
| pythontech | 0:5868e8752d44 | 15 | * The above copyright notice and this permission notice shall be included in |
| pythontech | 0:5868e8752d44 | 16 | * all copies or substantial portions of the Software. |
| pythontech | 0:5868e8752d44 | 17 | * |
| pythontech | 0:5868e8752d44 | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| pythontech | 0:5868e8752d44 | 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| pythontech | 0:5868e8752d44 | 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| pythontech | 0:5868e8752d44 | 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| pythontech | 0:5868e8752d44 | 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| pythontech | 0:5868e8752d44 | 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| pythontech | 0:5868e8752d44 | 24 | * THE SOFTWARE. |
| pythontech | 0:5868e8752d44 | 25 | */ |
| pythontech | 0:5868e8752d44 | 26 | |
| pythontech | 0:5868e8752d44 | 27 | #ifndef __MICROPY_INCLUDED_PY_EMIT_H__ |
| pythontech | 0:5868e8752d44 | 28 | #define __MICROPY_INCLUDED_PY_EMIT_H__ |
| pythontech | 0:5868e8752d44 | 29 | |
| pythontech | 0:5868e8752d44 | 30 | #include "py/lexer.h" |
| pythontech | 0:5868e8752d44 | 31 | #include "py/scope.h" |
| pythontech | 0:5868e8752d44 | 32 | #include "py/runtime0.h" |
| pythontech | 0:5868e8752d44 | 33 | |
| pythontech | 0:5868e8752d44 | 34 | /* Notes on passes: |
| pythontech | 0:5868e8752d44 | 35 | * We don't know exactly the opcodes in pass 1 because they depend on the |
| pythontech | 0:5868e8752d44 | 36 | * closing over of variables (LOAD_CLOSURE, BUILD_TUPLE, MAKE_CLOSURE), which |
| pythontech | 0:5868e8752d44 | 37 | * depends on determining the scope of variables in each function, and this |
| pythontech | 0:5868e8752d44 | 38 | * is not known until the end of pass 1. |
| pythontech | 0:5868e8752d44 | 39 | * As a consequence, we don't know the maximum stack size until the end of pass 2. |
| pythontech | 0:5868e8752d44 | 40 | * This is problematic for some emitters (x64) since they need to know the maximum |
| pythontech | 0:5868e8752d44 | 41 | * stack size to compile the entry to the function, and this affects code size. |
| pythontech | 0:5868e8752d44 | 42 | */ |
| pythontech | 0:5868e8752d44 | 43 | |
| pythontech | 0:5868e8752d44 | 44 | typedef enum { |
| pythontech | 0:5868e8752d44 | 45 | MP_PASS_SCOPE = 1, // work out id's and their kind, and number of labels |
| pythontech | 0:5868e8752d44 | 46 | MP_PASS_STACK_SIZE = 2, // work out maximum stack size |
| pythontech | 0:5868e8752d44 | 47 | MP_PASS_CODE_SIZE = 3, // work out code size and label offsets |
| pythontech | 0:5868e8752d44 | 48 | MP_PASS_EMIT = 4, // emit code |
| pythontech | 0:5868e8752d44 | 49 | } pass_kind_t; |
| pythontech | 0:5868e8752d44 | 50 | |
| pythontech | 0:5868e8752d44 | 51 | #define MP_EMIT_STAR_FLAG_SINGLE (0x01) |
| pythontech | 0:5868e8752d44 | 52 | #define MP_EMIT_STAR_FLAG_DOUBLE (0x02) |
| pythontech | 0:5868e8752d44 | 53 | |
| pythontech | 0:5868e8752d44 | 54 | #define MP_EMIT_BREAK_FROM_FOR (0x8000) |
| pythontech | 0:5868e8752d44 | 55 | |
| pythontech | 0:5868e8752d44 | 56 | #define MP_EMIT_NATIVE_TYPE_ENABLE (0) |
| pythontech | 0:5868e8752d44 | 57 | #define MP_EMIT_NATIVE_TYPE_RETURN (1) |
| pythontech | 0:5868e8752d44 | 58 | #define MP_EMIT_NATIVE_TYPE_ARG (2) |
| pythontech | 0:5868e8752d44 | 59 | |
| pythontech | 0:5868e8752d44 | 60 | typedef struct _emit_t emit_t; |
| pythontech | 0:5868e8752d44 | 61 | |
| pythontech | 0:5868e8752d44 | 62 | typedef struct _mp_emit_method_table_id_ops_t { |
| pythontech | 0:5868e8752d44 | 63 | void (*fast)(emit_t *emit, qstr qst, mp_uint_t local_num); |
| pythontech | 0:5868e8752d44 | 64 | void (*deref)(emit_t *emit, qstr qst, mp_uint_t local_num); |
| pythontech | 0:5868e8752d44 | 65 | void (*name)(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 66 | void (*global)(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 67 | } mp_emit_method_table_id_ops_t; |
| pythontech | 0:5868e8752d44 | 68 | |
| pythontech | 0:5868e8752d44 | 69 | typedef struct _emit_method_table_t { |
| pythontech | 0:5868e8752d44 | 70 | void (*set_native_type)(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2); |
| pythontech | 0:5868e8752d44 | 71 | void (*start_pass)(emit_t *emit, pass_kind_t pass, scope_t *scope); |
| pythontech | 0:5868e8752d44 | 72 | void (*end_pass)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 73 | bool (*last_emit_was_return_value)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 74 | void (*adjust_stack_size)(emit_t *emit, mp_int_t delta); |
| pythontech | 0:5868e8752d44 | 75 | void (*set_source_line)(emit_t *emit, mp_uint_t line); |
| pythontech | 0:5868e8752d44 | 76 | |
| pythontech | 0:5868e8752d44 | 77 | mp_emit_method_table_id_ops_t load_id; |
| pythontech | 0:5868e8752d44 | 78 | mp_emit_method_table_id_ops_t store_id; |
| pythontech | 0:5868e8752d44 | 79 | mp_emit_method_table_id_ops_t delete_id; |
| pythontech | 0:5868e8752d44 | 80 | |
| pythontech | 0:5868e8752d44 | 81 | void (*label_assign)(emit_t *emit, mp_uint_t l); |
| pythontech | 0:5868e8752d44 | 82 | void (*import_name)(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 83 | void (*import_from)(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 84 | void (*import_star)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 85 | void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok); |
| pythontech | 0:5868e8752d44 | 86 | void (*load_const_small_int)(emit_t *emit, mp_int_t arg); |
| pythontech | 0:5868e8752d44 | 87 | void (*load_const_str)(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 88 | void (*load_const_obj)(emit_t *emit, mp_obj_t obj); |
| pythontech | 0:5868e8752d44 | 89 | void (*load_null)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 90 | void (*load_attr)(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 91 | void (*load_method)(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 92 | void (*load_build_class)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 93 | void (*load_subscr)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 94 | void (*store_attr)(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 95 | void (*store_subscr)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 96 | void (*delete_attr)(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 97 | void (*delete_subscr)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 98 | void (*dup_top)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 99 | void (*dup_top_two)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 100 | void (*pop_top)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 101 | void (*rot_two)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 102 | void (*rot_three)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 103 | void (*jump)(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 104 | void (*pop_jump_if)(emit_t *emit, bool cond, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 105 | void (*jump_if_or_pop)(emit_t *emit, bool cond, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 106 | void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); |
| pythontech | 0:5868e8752d44 | 107 | void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); |
| pythontech | 0:5868e8752d44 | 108 | void (*setup_with)(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 109 | void (*with_cleanup)(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 110 | void (*setup_except)(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 111 | void (*setup_finally)(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 112 | void (*end_finally)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 113 | void (*get_iter)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 114 | void (*for_iter)(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 115 | void (*for_iter_end)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 116 | void (*pop_block)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 117 | void (*pop_except)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 118 | void (*unary_op)(emit_t *emit, mp_unary_op_t op); |
| pythontech | 0:5868e8752d44 | 119 | void (*binary_op)(emit_t *emit, mp_binary_op_t op); |
| pythontech | 0:5868e8752d44 | 120 | void (*build_tuple)(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 121 | void (*build_list)(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 122 | void (*list_append)(emit_t *emit, mp_uint_t list_stack_index); |
| pythontech | 0:5868e8752d44 | 123 | void (*build_map)(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 124 | void (*store_map)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 125 | void (*map_add)(emit_t *emit, mp_uint_t map_stack_index); |
| pythontech | 0:5868e8752d44 | 126 | #if MICROPY_PY_BUILTINS_SET |
| pythontech | 0:5868e8752d44 | 127 | void (*build_set)(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 128 | void (*set_add)(emit_t *emit, mp_uint_t set_stack_index); |
| pythontech | 0:5868e8752d44 | 129 | #endif |
| pythontech | 0:5868e8752d44 | 130 | #if MICROPY_PY_BUILTINS_SLICE |
| pythontech | 0:5868e8752d44 | 131 | void (*build_slice)(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 132 | #endif |
| pythontech | 0:5868e8752d44 | 133 | void (*unpack_sequence)(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 134 | void (*unpack_ex)(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); |
| pythontech | 0:5868e8752d44 | 135 | void (*make_function)(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); |
| pythontech | 0:5868e8752d44 | 136 | void (*make_closure)(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); |
| pythontech | 0:5868e8752d44 | 137 | void (*call_function)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); |
| pythontech | 0:5868e8752d44 | 138 | void (*call_method)(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); |
| pythontech | 0:5868e8752d44 | 139 | void (*return_value)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 140 | void (*raise_varargs)(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 141 | void (*yield_value)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 142 | void (*yield_from)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 143 | |
| pythontech | 0:5868e8752d44 | 144 | // these methods are used to control entry to/exit from an exception handler |
| pythontech | 0:5868e8752d44 | 145 | // they may or may not emit code |
| pythontech | 0:5868e8752d44 | 146 | void (*start_except_handler)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 147 | void (*end_except_handler)(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 148 | } emit_method_table_t; |
| pythontech | 0:5868e8752d44 | 149 | |
| pythontech | 0:5868e8752d44 | 150 | void mp_emit_common_get_id_for_load(scope_t *scope, qstr qst); |
| pythontech | 0:5868e8752d44 | 151 | void mp_emit_common_get_id_for_modification(scope_t *scope, qstr qst); |
| pythontech | 0:5868e8752d44 | 152 | void mp_emit_common_id_op(emit_t *emit, const mp_emit_method_table_id_ops_t *emit_method_table, scope_t *scope, qstr qst); |
| pythontech | 0:5868e8752d44 | 153 | |
| pythontech | 0:5868e8752d44 | 154 | extern const emit_method_table_t emit_cpython_method_table; |
| pythontech | 0:5868e8752d44 | 155 | extern const emit_method_table_t emit_bc_method_table; |
| pythontech | 0:5868e8752d44 | 156 | extern const emit_method_table_t emit_native_x64_method_table; |
| pythontech | 0:5868e8752d44 | 157 | extern const emit_method_table_t emit_native_x86_method_table; |
| pythontech | 0:5868e8752d44 | 158 | extern const emit_method_table_t emit_native_thumb_method_table; |
| pythontech | 0:5868e8752d44 | 159 | extern const emit_method_table_t emit_native_arm_method_table; |
| pythontech | 0:5868e8752d44 | 160 | |
| pythontech | 0:5868e8752d44 | 161 | extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_load_id_ops; |
| pythontech | 0:5868e8752d44 | 162 | extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_store_id_ops; |
| pythontech | 0:5868e8752d44 | 163 | extern const mp_emit_method_table_id_ops_t mp_emit_bc_method_table_delete_id_ops; |
| pythontech | 0:5868e8752d44 | 164 | |
| pythontech | 0:5868e8752d44 | 165 | emit_t *emit_cpython_new(void); |
| pythontech | 0:5868e8752d44 | 166 | emit_t *emit_bc_new(void); |
| pythontech | 0:5868e8752d44 | 167 | emit_t *emit_native_x64_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); |
| pythontech | 0:5868e8752d44 | 168 | emit_t *emit_native_x86_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); |
| pythontech | 0:5868e8752d44 | 169 | emit_t *emit_native_thumb_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); |
| pythontech | 0:5868e8752d44 | 170 | emit_t *emit_native_arm_new(mp_obj_t *error_slot, mp_uint_t max_num_labels); |
| pythontech | 0:5868e8752d44 | 171 | |
| pythontech | 0:5868e8752d44 | 172 | void emit_cpython_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); |
| pythontech | 0:5868e8752d44 | 173 | void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels); |
| pythontech | 0:5868e8752d44 | 174 | |
| pythontech | 0:5868e8752d44 | 175 | void emit_cpython_free(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 176 | void emit_bc_free(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 177 | void emit_native_x64_free(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 178 | void emit_native_x86_free(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 179 | void emit_native_thumb_free(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 180 | void emit_native_arm_free(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 181 | |
| pythontech | 0:5868e8752d44 | 182 | void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope); |
| pythontech | 0:5868e8752d44 | 183 | void mp_emit_bc_end_pass(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 184 | bool mp_emit_bc_last_emit_was_return_value(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 185 | void mp_emit_bc_adjust_stack_size(emit_t *emit, mp_int_t delta); |
| pythontech | 0:5868e8752d44 | 186 | void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t line); |
| pythontech | 0:5868e8752d44 | 187 | |
| pythontech | 0:5868e8752d44 | 188 | void mp_emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num); |
| pythontech | 0:5868e8752d44 | 189 | void mp_emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num); |
| pythontech | 0:5868e8752d44 | 190 | void mp_emit_bc_load_name(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 191 | void mp_emit_bc_load_global(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 192 | void mp_emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num); |
| pythontech | 0:5868e8752d44 | 193 | void mp_emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num); |
| pythontech | 0:5868e8752d44 | 194 | void mp_emit_bc_store_name(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 195 | void mp_emit_bc_store_global(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 196 | void mp_emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num); |
| pythontech | 0:5868e8752d44 | 197 | void mp_emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num); |
| pythontech | 0:5868e8752d44 | 198 | void mp_emit_bc_delete_name(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 199 | void mp_emit_bc_delete_global(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 200 | |
| pythontech | 0:5868e8752d44 | 201 | void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l); |
| pythontech | 0:5868e8752d44 | 202 | void mp_emit_bc_import_name(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 203 | void mp_emit_bc_import_from(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 204 | void mp_emit_bc_import_star(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 205 | void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok); |
| pythontech | 0:5868e8752d44 | 206 | void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg); |
| pythontech | 0:5868e8752d44 | 207 | void mp_emit_bc_load_const_str(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 208 | void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj); |
| pythontech | 0:5868e8752d44 | 209 | void mp_emit_bc_load_null(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 210 | void mp_emit_bc_load_attr(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 211 | void mp_emit_bc_load_method(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 212 | void mp_emit_bc_load_build_class(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 213 | void mp_emit_bc_load_subscr(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 214 | void mp_emit_bc_store_attr(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 215 | void mp_emit_bc_store_subscr(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 216 | void mp_emit_bc_delete_attr(emit_t *emit, qstr qst); |
| pythontech | 0:5868e8752d44 | 217 | void mp_emit_bc_delete_subscr(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 218 | void mp_emit_bc_dup_top(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 219 | void mp_emit_bc_dup_top_two(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 220 | void mp_emit_bc_pop_top(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 221 | void mp_emit_bc_rot_two(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 222 | void mp_emit_bc_rot_three(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 223 | void mp_emit_bc_jump(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 224 | void mp_emit_bc_pop_jump_if(emit_t *emit, bool cond, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 225 | void mp_emit_bc_jump_if_or_pop(emit_t *emit, bool cond, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 226 | void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_depth); |
| pythontech | 0:5868e8752d44 | 227 | #define mp_emit_bc_break_loop mp_emit_bc_unwind_jump |
| pythontech | 0:5868e8752d44 | 228 | #define mp_emit_bc_continue_loop mp_emit_bc_unwind_jump |
| pythontech | 0:5868e8752d44 | 229 | void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 230 | void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 231 | void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 232 | void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 233 | void mp_emit_bc_end_finally(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 234 | void mp_emit_bc_get_iter(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 235 | void mp_emit_bc_for_iter(emit_t *emit, mp_uint_t label); |
| pythontech | 0:5868e8752d44 | 236 | void mp_emit_bc_for_iter_end(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 237 | void mp_emit_bc_pop_block(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 238 | void mp_emit_bc_pop_except(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 239 | void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op); |
| pythontech | 0:5868e8752d44 | 240 | void mp_emit_bc_binary_op(emit_t *emit, mp_binary_op_t op); |
| pythontech | 0:5868e8752d44 | 241 | void mp_emit_bc_build_tuple(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 242 | void mp_emit_bc_build_list(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 243 | void mp_emit_bc_list_append(emit_t *emit, mp_uint_t list_stack_index); |
| pythontech | 0:5868e8752d44 | 244 | void mp_emit_bc_build_map(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 245 | void mp_emit_bc_store_map(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 246 | void mp_emit_bc_map_add(emit_t *emit, mp_uint_t map_stack_index); |
| pythontech | 0:5868e8752d44 | 247 | #if MICROPY_PY_BUILTINS_SET |
| pythontech | 0:5868e8752d44 | 248 | void mp_emit_bc_build_set(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 249 | void mp_emit_bc_set_add(emit_t *emit, mp_uint_t set_stack_index); |
| pythontech | 0:5868e8752d44 | 250 | #endif |
| pythontech | 0:5868e8752d44 | 251 | #if MICROPY_PY_BUILTINS_SLICE |
| pythontech | 0:5868e8752d44 | 252 | void mp_emit_bc_build_slice(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 253 | #endif |
| pythontech | 0:5868e8752d44 | 254 | void mp_emit_bc_unpack_sequence(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 255 | void mp_emit_bc_unpack_ex(emit_t *emit, mp_uint_t n_left, mp_uint_t n_right); |
| pythontech | 0:5868e8752d44 | 256 | void mp_emit_bc_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); |
| pythontech | 0:5868e8752d44 | 257 | void mp_emit_bc_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults); |
| pythontech | 0:5868e8752d44 | 258 | void mp_emit_bc_call_function(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); |
| pythontech | 0:5868e8752d44 | 259 | void mp_emit_bc_call_method(emit_t *emit, mp_uint_t n_positional, mp_uint_t n_keyword, mp_uint_t star_flags); |
| pythontech | 0:5868e8752d44 | 260 | void mp_emit_bc_return_value(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 261 | void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args); |
| pythontech | 0:5868e8752d44 | 262 | void mp_emit_bc_yield_value(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 263 | void mp_emit_bc_yield_from(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 264 | void mp_emit_bc_start_except_handler(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 265 | void mp_emit_bc_end_except_handler(emit_t *emit); |
| pythontech | 0:5868e8752d44 | 266 | |
| pythontech | 0:5868e8752d44 | 267 | typedef struct _emit_inline_asm_t emit_inline_asm_t; |
| pythontech | 0:5868e8752d44 | 268 | |
| pythontech | 0:5868e8752d44 | 269 | typedef struct _emit_inline_asm_method_table_t { |
| pythontech | 0:5868e8752d44 | 270 | void (*start_pass)(emit_inline_asm_t *emit, pass_kind_t pass, scope_t *scope, mp_obj_t *error_slot); |
| pythontech | 0:5868e8752d44 | 271 | void (*end_pass)(emit_inline_asm_t *emit, mp_uint_t type_sig); |
| pythontech | 0:5868e8752d44 | 272 | mp_uint_t (*count_params)(emit_inline_asm_t *emit, mp_uint_t n_params, mp_parse_node_t *pn_params); |
| pythontech | 0:5868e8752d44 | 273 | bool (*label)(emit_inline_asm_t *emit, mp_uint_t label_num, qstr label_id); |
| pythontech | 0:5868e8752d44 | 274 | void (*align)(emit_inline_asm_t *emit, mp_uint_t align); |
| pythontech | 0:5868e8752d44 | 275 | void (*data)(emit_inline_asm_t *emit, mp_uint_t bytesize, mp_uint_t val); |
| pythontech | 0:5868e8752d44 | 276 | void (*op)(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args); |
| pythontech | 0:5868e8752d44 | 277 | } emit_inline_asm_method_table_t; |
| pythontech | 0:5868e8752d44 | 278 | |
| pythontech | 0:5868e8752d44 | 279 | extern const emit_inline_asm_method_table_t emit_inline_thumb_method_table; |
| pythontech | 0:5868e8752d44 | 280 | |
| pythontech | 0:5868e8752d44 | 281 | emit_inline_asm_t *emit_inline_thumb_new(mp_uint_t max_num_labels); |
| pythontech | 0:5868e8752d44 | 282 | void emit_inline_thumb_free(emit_inline_asm_t *emit); |
| pythontech | 0:5868e8752d44 | 283 | |
| pythontech | 0:5868e8752d44 | 284 | #if MICROPY_WARNINGS |
| pythontech | 0:5868e8752d44 | 285 | void mp_emitter_warning(pass_kind_t pass, const char *msg); |
| pythontech | 0:5868e8752d44 | 286 | #else |
| pythontech | 0:5868e8752d44 | 287 | #define mp_emitter_warning(pass, msg) |
| pythontech | 0:5868e8752d44 | 288 | #endif |
| pythontech | 0:5868e8752d44 | 289 | |
| pythontech | 0:5868e8752d44 | 290 | #endif // __MICROPY_INCLUDED_PY_EMIT_H__ |