blob: ed475cf3c7a4caa945d5ae3170c12e9e5cdd9387 [file] [log] [blame]
xbeefe34222014-03-16 00:14:26 -07001#include <stdbool.h>
Damien429d7192013-10-04 19:53:11 +01002#include <stdint.h>
3#include <stdio.h>
4#include <string.h>
5#include <assert.h>
6
7#include "misc.h"
Damiend99b0522013-12-21 18:17:45 +00008#include "mpconfig.h"
Damien George55baff42014-01-21 21:40:13 +00009#include "qstr.h"
Damien429d7192013-10-04 19:53:11 +010010#include "lexer.h"
Damien429d7192013-10-04 19:53:11 +010011#include "parse.h"
Damien429d7192013-10-04 19:53:11 +010012#include "scope.h"
Damiend99b0522013-12-21 18:17:45 +000013#include "runtime0.h"
Damien429d7192013-10-04 19:53:11 +010014#include "emit.h"
15
Damien Georgee67ed5d2014-01-04 13:55:24 +000016// wrapper around everything in this file
Damien3ef4abb2013-10-12 16:53:13 +010017#if MICROPY_EMIT_CPYTHON
Damien429d7192013-10-04 19:53:11 +010018
Damien415eb6f2013-10-05 12:19:06 +010019struct _emit_t {
Damien429d7192013-10-04 19:53:11 +010020 int pass;
Damien429d7192013-10-04 19:53:11 +010021 int byte_code_offset;
22 int stack_size;
23 bool last_emit_was_return_value;
24
25 scope_t *scope;
26
Damienb05d7072013-10-05 13:37:10 +010027 uint max_num_labels;
Damien429d7192013-10-04 19:53:11 +010028 int *label_offsets;
29};
30
Damien6cdd3af2013-10-05 18:08:26 +010031emit_t *emit_cpython_new(uint max_num_labels) {
32 emit_t *emit = m_new(emit_t, 1);
33 emit->max_num_labels = max_num_labels;
34 emit->label_offsets = m_new(int, max_num_labels);
35 return emit;
36}
37
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020038STATIC void emit_cpy_set_native_types(emit_t *emit, bool do_native_types) {
Damien429d7192013-10-04 19:53:11 +010039}
40
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020041STATIC void emit_cpy_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
Damien429d7192013-10-04 19:53:11 +010042 emit->pass = pass;
Damien429d7192013-10-04 19:53:11 +010043 emit->byte_code_offset = 0;
44 emit->stack_size = 0;
45 emit->last_emit_was_return_value = false;
46 emit->scope = scope;
Damienb05d7072013-10-05 13:37:10 +010047 if (pass == PASS_2) {
48 memset(emit->label_offsets, -1, emit->max_num_labels * sizeof(int));
Damien429d7192013-10-04 19:53:11 +010049 }
50}
51
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020052STATIC void emit_cpy_end_pass(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +010053 // check stack is back to zero size
54 if (emit->stack_size != 0) {
55 printf("ERROR: stack size not back to zero; got %d\n", emit->stack_size);
56 }
Damien429d7192013-10-04 19:53:11 +010057}
58
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020059STATIC bool emit_cpy_last_emit_was_return_value(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +010060 return emit->last_emit_was_return_value;
61}
62
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020063STATIC int emit_cpy_get_stack_size(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +010064 return emit->stack_size;
65}
66
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020067STATIC void emit_cpy_set_stack_size(emit_t *emit, int size) {
Damien429d7192013-10-04 19:53:11 +010068 emit->stack_size = size;
69}
70
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020071STATIC void emit_cpy_set_source_line(emit_t *emit, int source_line) {
Damien George08335002014-01-18 23:24:36 +000072}
73
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020074STATIC void emit_cpy_load_id(emit_t *emit, qstr qstr) {
Damien6cdd3af2013-10-05 18:08:26 +010075 emit_common_load_id(emit, &emit_cpython_method_table, emit->scope, qstr);
Damien4b03e772013-10-05 14:17:09 +010076}
77
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020078STATIC void emit_cpy_store_id(emit_t *emit, qstr qstr) {
Damien6cdd3af2013-10-05 18:08:26 +010079 emit_common_store_id(emit, &emit_cpython_method_table, emit->scope, qstr);
Damien4b03e772013-10-05 14:17:09 +010080}
81
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020082STATIC void emit_cpy_delete_id(emit_t *emit, qstr qstr) {
Damien6cdd3af2013-10-05 18:08:26 +010083 emit_common_delete_id(emit, &emit_cpython_method_table, emit->scope, qstr);
Damien4b03e772013-10-05 14:17:09 +010084}
85
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020086// TODO: module-polymorphic function (read: name clash if made global)
Damien415eb6f2013-10-05 12:19:06 +010087static void emit_pre(emit_t *emit, int stack_size_delta, int byte_code_size) {
Damien429d7192013-10-04 19:53:11 +010088 emit->stack_size += stack_size_delta;
Damienb05d7072013-10-05 13:37:10 +010089 if (emit->stack_size > emit->scope->stack_size) {
Damien429d7192013-10-04 19:53:11 +010090 emit->scope->stack_size = emit->stack_size;
91 }
92 emit->last_emit_was_return_value = false;
93 if (emit->pass == PASS_3 && byte_code_size > 0) {
94 if (emit->byte_code_offset >= 1000) {
95 printf("%d ", emit->byte_code_offset);
96 } else {
97 printf("% 4d ", emit->byte_code_offset);
98 }
99 }
100 emit->byte_code_offset += byte_code_size;
101}
102
Damien George6f355fd2014-04-10 14:11:31 +0100103STATIC void emit_cpy_label_assign(emit_t *emit, uint l) {
Damien429d7192013-10-04 19:53:11 +0100104 emit_pre(emit, 0, 0);
Damienb05d7072013-10-05 13:37:10 +0100105 assert(l < emit->max_num_labels);
106 if (emit->pass == PASS_2) {
107 // assign label offset
108 assert(emit->label_offsets[l] == -1);
109 emit->label_offsets[l] = emit->byte_code_offset;
110 } else if (emit->pass == PASS_3) {
111 // ensure label offset has not changed from PASS_2 to PASS_3
112 assert(emit->label_offsets[l] == emit->byte_code_offset);
113 //printf("l%d: (at %d)\n", l, emit->byte_code_offset);
Damien429d7192013-10-04 19:53:11 +0100114 }
115}
116
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200117STATIC void emit_cpy_import_name(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100118 emit_pre(emit, -1, 3);
119 if (emit->pass == PASS_3) {
120 printf("IMPORT_NAME %s\n", qstr_str(qstr));
121 }
122}
123
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200124STATIC void emit_cpy_import_from(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100125 emit_pre(emit, 1, 3);
126 if (emit->pass == PASS_3) {
127 printf("IMPORT_FROM %s\n", qstr_str(qstr));
128 }
129}
130
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200131STATIC void emit_cpy_import_star(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100132 emit_pre(emit, -1, 1);
133 if (emit->pass == PASS_3) {
134 printf("IMPORT_STAR\n");
135 }
136}
137
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200138STATIC void emit_cpy_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
Damien429d7192013-10-04 19:53:11 +0100139 emit_pre(emit, 1, 3);
140 if (emit->pass == PASS_3) {
141 printf("LOAD_CONST ");
142 switch (tok) {
Damiend99b0522013-12-21 18:17:45 +0000143 case MP_TOKEN_KW_FALSE: printf("False"); break;
144 case MP_TOKEN_KW_NONE: printf("None"); break;
145 case MP_TOKEN_KW_TRUE: printf("True"); break;
Damien429d7192013-10-04 19:53:11 +0100146 default: printf("?=%d\n", tok); return; assert(0);
147 }
148 printf("\n");
149 }
150}
151
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200152STATIC void emit_cpy_load_const_small_int(emit_t *emit, machine_int_t arg) {
Damien429d7192013-10-04 19:53:11 +0100153 emit_pre(emit, 1, 3);
154 if (emit->pass == PASS_3) {
Damien George08d07552014-01-29 18:58:52 +0000155 printf("LOAD_CONST " INT_FMT "\n", arg);
Damien429d7192013-10-04 19:53:11 +0100156 }
157}
158
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200159STATIC void emit_cpy_load_const_int(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100160 emit_pre(emit, 1, 3);
161 if (emit->pass == PASS_3) {
162 printf("LOAD_CONST %s\n", qstr_str(qstr));
163 }
164}
165
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200166STATIC void emit_cpy_load_const_dec(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100167 emit_pre(emit, 1, 3);
168 if (emit->pass == PASS_3) {
169 printf("LOAD_CONST %s\n", qstr_str(qstr));
170 }
171}
172
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200173STATIC void emit_cpy_load_const_id(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100174 emit_pre(emit, 1, 3);
175 if (emit->pass == PASS_3) {
176 printf("LOAD_CONST '%s'\n", qstr_str(qstr));
177 }
178}
179
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200180STATIC void print_quoted_str(qstr qstr, bool bytes) {
Damiena1b26932013-12-12 15:34:40 +0000181 const char *str = qstr_str(qstr);
182 int len = strlen(str);
183 bool has_single_quote = false;
184 bool has_double_quote = false;
185 for (int i = 0; i < len; i++) {
186 if (str[i] == '\'') {
187 has_single_quote = true;
188 } else if (str[i] == '"') {
189 has_double_quote = true;
190 }
191 }
192 if (bytes) {
193 printf("b");
194 }
Damien Georgeb829b5c2014-01-25 13:51:19 +0000195 int quote_char = '\'';
Damiena1b26932013-12-12 15:34:40 +0000196 if (has_single_quote && !has_double_quote) {
Damien Georgeb829b5c2014-01-25 13:51:19 +0000197 quote_char = '"';
Damiena1b26932013-12-12 15:34:40 +0000198 }
Damien Georgeb829b5c2014-01-25 13:51:19 +0000199 printf("%c", quote_char);
200 for (const char *s = str, *top = str + len; s < top; s++) {
201 if (*s == quote_char) {
202 printf("\\%c", quote_char);
203 } else if (*s == '\\') {
Damiena1b26932013-12-12 15:34:40 +0000204 printf("\\\\");
Damien Georgeb829b5c2014-01-25 13:51:19 +0000205 } else if (32 <= *s && *s <= 126) {
206 printf("%c", *s);
207 } else if (*s == '\n') {
208 printf("\\n");
209 // TODO add more escape codes here
Damiena1b26932013-12-12 15:34:40 +0000210 } else {
Damien Georgeb829b5c2014-01-25 13:51:19 +0000211 printf("\\x%02x", (*s) & 0xff);
Damiena1b26932013-12-12 15:34:40 +0000212 }
213 }
Damien Georgeb829b5c2014-01-25 13:51:19 +0000214 printf("%c", quote_char);
Damiena1b26932013-12-12 15:34:40 +0000215}
216
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200217STATIC void emit_cpy_load_const_str(emit_t *emit, qstr qstr, bool bytes) {
Damien429d7192013-10-04 19:53:11 +0100218 emit_pre(emit, 1, 3);
219 if (emit->pass == PASS_3) {
220 printf("LOAD_CONST ");
Damiena1b26932013-12-12 15:34:40 +0000221 print_quoted_str(qstr, bytes);
Damien429d7192013-10-04 19:53:11 +0100222 printf("\n");
223 }
224}
225
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200226STATIC void emit_cpy_load_const_verbatim_str(emit_t *emit, const char *str) {
Damiena1b26932013-12-12 15:34:40 +0000227 emit_pre(emit, 1, 3);
Damien429d7192013-10-04 19:53:11 +0100228 if (emit->pass == PASS_3) {
Damiena1b26932013-12-12 15:34:40 +0000229 printf("LOAD_CONST %s\n", str);
Damien429d7192013-10-04 19:53:11 +0100230 }
231}
232
Damien Georgee2835c12014-04-09 20:20:34 +0100233STATIC void emit_cpy_load_fast(emit_t *emit, qstr qstr, uint id_flags, int local_num) {
Damien6cdd3af2013-10-05 18:08:26 +0100234 emit_pre(emit, 1, 3);
235 if (emit->pass == PASS_3) {
236 printf("LOAD_FAST %d %s\n", local_num, qstr_str(qstr));
237 }
238}
239
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200240STATIC void emit_cpy_load_deref(emit_t *emit, qstr qstr, int local_num) {
Damien429d7192013-10-04 19:53:11 +0100241 emit_pre(emit, 1, 3);
242 if (emit->pass == PASS_3) {
Damien27fb45e2013-10-20 15:07:49 +0100243 printf("LOAD_DEREF %d %s\n", local_num, qstr_str(qstr));
Damien429d7192013-10-04 19:53:11 +0100244 }
245}
246
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200247STATIC void emit_cpy_load_closure(emit_t *emit, qstr qstr, int local_num) {
Damien429d7192013-10-04 19:53:11 +0100248 emit_pre(emit, 1, 3);
249 if (emit->pass == PASS_3) {
Damien27fb45e2013-10-20 15:07:49 +0100250 printf("LOAD_CLOSURE %d %s\n", local_num, qstr_str(qstr));
Damien429d7192013-10-04 19:53:11 +0100251 }
252}
253
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200254STATIC void emit_cpy_load_name(emit_t *emit, qstr qstr) {
Damien9ecbcff2013-12-11 00:41:43 +0000255 emit_pre(emit, 1, 3);
256 if (emit->pass == PASS_3) {
257 printf("LOAD_NAME %s\n", qstr_str(qstr));
258 }
259}
260
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200261STATIC void emit_cpy_load_global(emit_t *emit, qstr qstr) {
Damien9ecbcff2013-12-11 00:41:43 +0000262 emit_pre(emit, 1, 3);
263 if (emit->pass == PASS_3) {
264 printf("LOAD_GLOBAL %s\n", qstr_str(qstr));
265 }
266}
267
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200268STATIC void emit_cpy_load_attr(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100269 emit_pre(emit, 0, 3);
270 if (emit->pass == PASS_3) {
271 printf("LOAD_ATTR %s\n", qstr_str(qstr));
272 }
273}
274
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200275STATIC void emit_cpy_load_method(emit_t *emit, qstr qstr) {
Damien415eb6f2013-10-05 12:19:06 +0100276 emit_cpy_load_attr(emit, qstr);
Damien429d7192013-10-04 19:53:11 +0100277}
278
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200279STATIC void emit_cpy_load_build_class(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100280 emit_pre(emit, 1, 1);
281 if (emit->pass == PASS_3) {
282 printf("LOAD_BUILD_CLASS\n");
283 }
284}
285
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200286STATIC void emit_cpy_store_fast(emit_t *emit, qstr qstr, int local_num) {
Damien6cdd3af2013-10-05 18:08:26 +0100287 emit_pre(emit, -1, 3);
288 if (emit->pass == PASS_3) {
289 printf("STORE_FAST %d %s\n", local_num, qstr_str(qstr));
290 }
291}
292
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200293STATIC void emit_cpy_store_deref(emit_t *emit, qstr qstr, int local_num) {
Damien9ecbcff2013-12-11 00:41:43 +0000294 emit_pre(emit, -1, 3);
295 if (emit->pass == PASS_3) {
296 printf("STORE_DEREF %d %s\n", local_num, qstr_str(qstr));
297 }
298}
299
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200300STATIC void emit_cpy_store_name(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100301 emit_pre(emit, -1, 3);
302 if (emit->pass == PASS_3) {
303 printf("STORE_NAME %s\n", qstr_str(qstr));
304 }
305}
306
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200307STATIC void emit_cpy_store_global(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100308 emit_pre(emit, -1, 3);
309 if (emit->pass == PASS_3) {
310 printf("STORE_GLOBAL %s\n", qstr_str(qstr));
311 }
312}
313
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200314STATIC void emit_cpy_store_attr(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100315 emit_pre(emit, -2, 3);
316 if (emit->pass == PASS_3) {
317 printf("STORE_ATTR %s\n", qstr_str(qstr));
318 }
319}
320
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200321STATIC void emit_cpy_store_subscr(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100322 emit_pre(emit, -3, 1);
323 if (emit->pass == PASS_3) {
324 printf("STORE_SUBSCR\n");
325 }
326}
327
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200328STATIC void emit_cpy_delete_fast(emit_t *emit, qstr qstr, int local_num) {
Damien6cdd3af2013-10-05 18:08:26 +0100329 emit_pre(emit, 0, 3);
330 if (emit->pass == PASS_3) {
331 printf("DELETE_FAST %d %s\n", local_num, qstr_str(qstr));
332 }
333}
334
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200335STATIC void emit_cpy_delete_deref(emit_t *emit, qstr qstr, int local_num) {
Damien9ecbcff2013-12-11 00:41:43 +0000336 emit_pre(emit, 0, 3);
337 if (emit->pass == PASS_3) {
338 printf("DELETE_DEREF %d %s\n", local_num, qstr_str(qstr));
339 }
340}
341
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200342STATIC void emit_cpy_delete_name(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100343 emit_pre(emit, 0, 3);
344 if (emit->pass == PASS_3) {
345 printf("DELETE_NAME %s\n", qstr_str(qstr));
346 }
347}
348
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200349STATIC void emit_cpy_delete_global(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100350 emit_pre(emit, 0, 3);
351 if (emit->pass == PASS_3) {
352 printf("DELETE_GLOBAL %s\n", qstr_str(qstr));
353 }
354}
355
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200356STATIC void emit_cpy_delete_attr(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100357 emit_pre(emit, -1, 3);
358 if (emit->pass == PASS_3) {
359 printf("DELETE_ATTR %s\n", qstr_str(qstr));
360 }
361}
362
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200363STATIC void emit_cpy_delete_subscr(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100364 emit_pre(emit, -2, 1);
365 if (emit->pass == PASS_3) {
366 printf("DELETE_SUBSCR\n");
367 }
368}
369
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200370STATIC void emit_cpy_dup_top(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100371 emit_pre(emit, 1, 1);
372 if (emit->pass == PASS_3) {
373 printf("DUP_TOP\n");
374 }
375}
376
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200377STATIC void emit_cpy_dup_top_two(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100378 emit_pre(emit, 2, 1);
379 if (emit->pass == PASS_3) {
380 printf("DUP_TOP_TWO\n");
381 }
382}
383
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200384STATIC void emit_cpy_pop_top(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100385 emit_pre(emit, -1, 1);
386 if (emit->pass == PASS_3) {
387 printf("POP_TOP\n");
388 }
389}
390
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200391STATIC void emit_cpy_rot_two(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100392 emit_pre(emit, 0, 1);
393 if (emit->pass == PASS_3) {
394 printf("ROT_TWO\n");
395 }
396}
397
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200398STATIC void emit_cpy_rot_three(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100399 emit_pre(emit, 0, 1);
400 if (emit->pass == PASS_3) {
401 printf("ROT_THREE\n");
402 }
403}
404
Damien George6f355fd2014-04-10 14:11:31 +0100405STATIC void emit_cpy_jump(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100406 emit_pre(emit, 0, 3);
407 if (emit->pass == PASS_3) {
408 int dest = emit->label_offsets[label];
409 if (dest < emit->byte_code_offset) {
410 printf("JUMP_ABSOLUTE %d\n", emit->label_offsets[label]);
411 } else {
412 printf("JUMP_FORWARD %d\n", emit->label_offsets[label]);
413 }
414 }
415}
416
Damien George6f355fd2014-04-10 14:11:31 +0100417STATIC void emit_cpy_pop_jump_if_true(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100418 emit_pre(emit, -1, 3);
419 if (emit->pass == PASS_3) {
420 printf("POP_JUMP_IF_TRUE %d\n", emit->label_offsets[label]);
421 }
422}
423
Damien George6f355fd2014-04-10 14:11:31 +0100424STATIC void emit_cpy_pop_jump_if_false(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100425 emit_pre(emit, -1, 3);
426 if (emit->pass == PASS_3) {
427 printf("POP_JUMP_IF_FALSE %d\n", emit->label_offsets[label]);
428 }
429}
430
Damien George6f355fd2014-04-10 14:11:31 +0100431STATIC void emit_cpy_jump_if_true_or_pop(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100432 emit_pre(emit, -1, 3);
433 if (emit->pass == PASS_3) {
434 printf("JUMP_IF_TRUE_OR_POP %d\n", emit->label_offsets[label]);
435 }
436}
437
Damien George6f355fd2014-04-10 14:11:31 +0100438STATIC void emit_cpy_jump_if_false_or_pop(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100439 emit_pre(emit, -1, 3);
440 if (emit->pass == PASS_3) {
441 printf("JUMP_IF_FALSE_OR_POP %d\n", emit->label_offsets[label]);
442 }
443}
444
Damien George6f355fd2014-04-10 14:11:31 +0100445STATIC void emit_cpy_setup_loop(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100446 emit_pre(emit, 0, 3);
447 if (emit->pass == PASS_3) {
448 printf("SETUP_LOOP %d\n", emit->label_offsets[label]);
449 }
450}
451
Damien George6f355fd2014-04-10 14:11:31 +0100452STATIC void emit_cpy_break_loop(emit_t *emit, uint label, int except_depth) {
Damien429d7192013-10-04 19:53:11 +0100453 emit_pre(emit, 0, 1);
454 if (emit->pass == PASS_3) {
Damien Georgee24b5632014-02-01 21:56:25 +0000455 printf("BREAK_LOOP\n");
Damien429d7192013-10-04 19:53:11 +0100456 }
457}
458
Damien George6f355fd2014-04-10 14:11:31 +0100459STATIC void emit_cpy_continue_loop(emit_t *emit, uint label, int except_depth) {
Damien Georgee24b5632014-02-01 21:56:25 +0000460 if (except_depth == 0) {
461 emit_cpy_jump(emit, label);
462 } else {
463 emit_pre(emit, 0, 3);
464 if (emit->pass == PASS_3) {
465 printf("CONTINUE_LOOP %d\n", emit->label_offsets[label]);
466 }
Damien429d7192013-10-04 19:53:11 +0100467 }
468}
469
Damien George6f355fd2014-04-10 14:11:31 +0100470STATIC void emit_cpy_setup_with(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100471 emit_pre(emit, 7, 3);
472 if (emit->pass == PASS_3) {
473 printf("SETUP_WITH %d\n", emit->label_offsets[label]);
474 }
475}
476
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200477STATIC void emit_cpy_with_cleanup(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100478 emit_pre(emit, -7, 1);
479 if (emit->pass == PASS_3) {
480 printf("WITH_CLEANUP\n");
481 }
482}
483
Damien George6f355fd2014-04-10 14:11:31 +0100484STATIC void emit_cpy_setup_except(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100485 emit_pre(emit, 6, 3);
486 if (emit->pass == PASS_3) {
487 printf("SETUP_EXCEPT %d\n", emit->label_offsets[label]);
488 }
489}
490
Damien George6f355fd2014-04-10 14:11:31 +0100491STATIC void emit_cpy_setup_finally(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100492 emit_pre(emit, 6, 3);
493 if (emit->pass == PASS_3) {
494 printf("SETUP_FINALLY %d\n", emit->label_offsets[label]);
495 }
496}
497
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200498STATIC void emit_cpy_end_finally(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100499 emit_pre(emit, -1, 1);
500 if (emit->pass == PASS_3) {
501 printf("END_FINALLY\n");
502 }
503}
504
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200505STATIC void emit_cpy_get_iter(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100506 emit_pre(emit, 0, 1);
507 if (emit->pass == PASS_3) {
508 printf("GET_ITER\n");
509 }
510}
511
Damien George6f355fd2014-04-10 14:11:31 +0100512STATIC void emit_cpy_for_iter(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100513 emit_pre(emit, 1, 3);
514 if (emit->pass == PASS_3) {
515 printf("FOR_ITER %d\n", emit->label_offsets[label]);
516 }
517}
518
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200519STATIC void emit_cpy_for_iter_end(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100520 emit_pre(emit, -1, 0);
521}
522
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200523STATIC void emit_cpy_pop_block(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100524 emit_pre(emit, 0, 1);
525 if (emit->pass == PASS_3) {
526 printf("POP_BLOCK\n");
527 }
528}
529
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200530STATIC void emit_cpy_pop_except(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100531 emit_pre(emit, 0, 1);
532 if (emit->pass == PASS_3) {
533 printf("POP_EXCEPT\n");
534 }
535}
536
Damien Georged17926d2014-03-30 13:35:08 +0100537STATIC void emit_cpy_unary_op(emit_t *emit, mp_unary_op_t op) {
Damien429d7192013-10-04 19:53:11 +0100538 emit_pre(emit, 0, 1);
539 if (emit->pass == PASS_3) {
540 switch (op) {
Damien Georged17926d2014-03-30 13:35:08 +0100541 case MP_UNARY_OP_POSITIVE: printf("UNARY_POSITIVE\n"); break;
542 case MP_UNARY_OP_NEGATIVE: printf("UNARY_NEGATIVE\n"); break;
543 case MP_UNARY_OP_INVERT: printf("UNARY_INVERT\n"); break;
544 case MP_UNARY_OP_NOT: printf("UNARY_NOT\n"); break;
Damien429d7192013-10-04 19:53:11 +0100545 default: assert(0);
546 }
547 }
548}
549
Damien Georged17926d2014-03-30 13:35:08 +0100550STATIC void emit_cpy_binary_op(emit_t *emit, mp_binary_op_t op) {
551 if (op <= MP_BINARY_OP_INPLACE_POWER) {
Damien Georgebc1d3692014-01-11 09:47:06 +0000552 // CPython uses a byte code for each binary op
553 emit_pre(emit, -1, 1);
554 } else {
555 // CPython uses a byte code plus an argument for compare ops
556 emit_pre(emit, -1, 3);
557 }
Damien429d7192013-10-04 19:53:11 +0100558 if (emit->pass == PASS_3) {
559 switch (op) {
Damien Georged17926d2014-03-30 13:35:08 +0100560 case MP_BINARY_OP_SUBSCR: printf("BINARY_SUBSCR\n"); break;
561 case MP_BINARY_OP_OR: printf("BINARY_OR\n"); break;
562 case MP_BINARY_OP_XOR: printf("BINARY_XOR\n"); break;
563 case MP_BINARY_OP_AND: printf("BINARY_AND\n"); break;
564 case MP_BINARY_OP_LSHIFT: printf("BINARY_LSHIFT\n"); break;
565 case MP_BINARY_OP_RSHIFT: printf("BINARY_RSHIFT\n"); break;
566 case MP_BINARY_OP_ADD: printf("BINARY_ADD\n"); break;
567 case MP_BINARY_OP_SUBTRACT: printf("BINARY_SUBTRACT\n"); break;
568 case MP_BINARY_OP_MULTIPLY: printf("BINARY_MULTIPLY\n"); break;
569 case MP_BINARY_OP_FLOOR_DIVIDE: printf("BINARY_FLOOR_DIVIDE\n"); break;
570 case MP_BINARY_OP_TRUE_DIVIDE: printf("BINARY_TRUE_DIVIDE\n"); break;
571 case MP_BINARY_OP_MODULO: printf("BINARY_MODULO\n"); break;
572 case MP_BINARY_OP_POWER: printf("BINARY_POWER\n"); break;
573 case MP_BINARY_OP_INPLACE_OR: printf("INPLACE_OR\n"); break;
574 case MP_BINARY_OP_INPLACE_XOR: printf("INPLACE_XOR\n"); break;
575 case MP_BINARY_OP_INPLACE_AND: printf("INPLACE_AND\n"); break;
576 case MP_BINARY_OP_INPLACE_LSHIFT: printf("INPLACE_LSHIFT\n"); break;
577 case MP_BINARY_OP_INPLACE_RSHIFT: printf("INPLACE_RSHIFT\n"); break;
578 case MP_BINARY_OP_INPLACE_ADD: printf("INPLACE_ADD\n"); break;
579 case MP_BINARY_OP_INPLACE_SUBTRACT: printf("INPLACE_SUBTRACT\n"); break;
580 case MP_BINARY_OP_INPLACE_MULTIPLY: printf("INPLACE_MULTIPLY\n"); break;
581 case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: printf("INPLACE_FLOOR_DIVIDE\n"); break;
582 case MP_BINARY_OP_INPLACE_TRUE_DIVIDE: printf("INPLACE_TRUE_DIVIDE\n"); break;
583 case MP_BINARY_OP_INPLACE_MODULO: printf("INPLACE_MODULO\n"); break;
584 case MP_BINARY_OP_INPLACE_POWER: printf("INPLACE_POWER\n"); break;
585 case MP_BINARY_OP_LESS: printf("COMPARE_OP <\n"); break;
586 case MP_BINARY_OP_MORE: printf("COMPARE_OP >\n"); break;
587 case MP_BINARY_OP_EQUAL: printf("COMPARE_OP ==\n"); break;
588 case MP_BINARY_OP_LESS_EQUAL: printf("COMPARE_OP <=\n"); break;
589 case MP_BINARY_OP_MORE_EQUAL: printf("COMPARE_OP >=\n"); break;
590 case MP_BINARY_OP_NOT_EQUAL: printf("COMPARE_OP !=\n"); break;
591 case MP_BINARY_OP_IN: printf("COMPARE_OP in\n"); break;
592 case MP_BINARY_OP_IS: printf("COMPARE_OP is\n"); break;
593 case MP_BINARY_OP_EXCEPTION_MATCH: printf("COMPARE_OP exception match\n"); break;
594 case MP_BINARY_OP_NOT_IN: printf("COMPARE_OP not in\n"); break;
595 case MP_BINARY_OP_IS_NOT: printf("COMPARE_OP is not\n"); break;
Damien429d7192013-10-04 19:53:11 +0100596 default: assert(0);
597 }
598 }
599}
600
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200601STATIC void emit_cpy_build_tuple(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100602 emit_pre(emit, 1 - n_args, 3);
603 if (emit->pass == PASS_3) {
604 printf("BUILD_TUPLE %d\n", n_args);
605 }
606}
607
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200608STATIC void emit_cpy_build_list(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100609 emit_pre(emit, 1 - n_args, 3);
610 if (emit->pass == PASS_3) {
611 printf("BUILD_LIST %d\n", n_args);
612 }
613}
614
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200615STATIC void emit_cpy_list_append(emit_t *emit, int list_index) {
Damien429d7192013-10-04 19:53:11 +0100616 emit_pre(emit, -1, 3);
617 if (emit->pass == PASS_3) {
618 printf("LIST_APPEND %d\n", list_index);
619 }
620}
621
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200622STATIC void emit_cpy_build_map(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100623 emit_pre(emit, 1, 3);
624 if (emit->pass == PASS_3) {
625 printf("BUILD_MAP %d\n", n_args);
626 }
627}
628
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200629STATIC void emit_cpy_store_map(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100630 emit_pre(emit, -2, 1);
631 if (emit->pass == PASS_3) {
632 printf("STORE_MAP\n");
633 }
634}
635
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200636STATIC void emit_cpy_map_add(emit_t *emit, int map_index) {
Damien429d7192013-10-04 19:53:11 +0100637 emit_pre(emit, -2, 3);
638 if (emit->pass == PASS_3) {
639 printf("MAP_ADD %d\n", map_index);
640 }
641}
642
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200643STATIC void emit_cpy_build_set(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100644 emit_pre(emit, 1 - n_args, 3);
645 if (emit->pass == PASS_3) {
646 printf("BUILD_SET %d\n", n_args);
647 }
648}
649
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200650STATIC void emit_cpy_set_add(emit_t *emit, int set_index) {
Damien429d7192013-10-04 19:53:11 +0100651 emit_pre(emit, -1, 3);
652 if (emit->pass == PASS_3) {
653 printf("SET_ADD %d\n", set_index);
654 }
655}
656
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200657STATIC void emit_cpy_build_slice(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100658 emit_pre(emit, 1 - n_args, 3);
659 if (emit->pass == PASS_3) {
660 printf("BUILD_SLICE %d\n", n_args);
661 }
662}
663
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200664STATIC void emit_cpy_unpack_sequence(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100665 emit_pre(emit, -1 + n_args, 3);
666 if (emit->pass == PASS_3) {
667 printf("UNPACK_SEQUENCE %d\n", n_args);
668 }
669}
670
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200671STATIC void emit_cpy_unpack_ex(emit_t *emit, int n_left, int n_right) {
Damien429d7192013-10-04 19:53:11 +0100672 emit_pre(emit, -1 + n_left + n_right + 1, 3);
673 if (emit->pass == PASS_3) {
674 printf("UNPACK_EX %d\n", n_left | (n_right << 8));
675 }
676}
677
Damien George922ddd62014-04-09 12:43:17 +0100678STATIC void emit_cpy_call_function(emit_t *emit, int n_positional, int n_keyword, uint star_flags) {
Damien429d7192013-10-04 19:53:11 +0100679 int s = 0;
Damien George922ddd62014-04-09 12:43:17 +0100680 if (star_flags & MP_EMIT_STAR_FLAG_SINGLE) {
Damien429d7192013-10-04 19:53:11 +0100681 s += 1;
682 }
Damien George922ddd62014-04-09 12:43:17 +0100683 if (star_flags & MP_EMIT_STAR_FLAG_DOUBLE) {
Damien429d7192013-10-04 19:53:11 +0100684 s += 1;
685 }
686 emit_pre(emit, -n_positional - 2 * n_keyword - s, 3);
687 if (emit->pass == PASS_3) {
Damien George922ddd62014-04-09 12:43:17 +0100688 if (star_flags & MP_EMIT_STAR_FLAG_SINGLE) {
689 if (star_flags & MP_EMIT_STAR_FLAG_DOUBLE) {
Damien429d7192013-10-04 19:53:11 +0100690 printf("CALL_FUNCTION_VAR_KW");
691 } else {
692 printf("CALL_FUNCTION_VAR");
693 }
694 } else {
Damien George922ddd62014-04-09 12:43:17 +0100695 if (star_flags & MP_EMIT_STAR_FLAG_DOUBLE) {
Damien429d7192013-10-04 19:53:11 +0100696 printf("CALL_FUNCTION_KW");
697 } else {
698 printf("CALL_FUNCTION");
699 }
700 }
701 printf(" %d, %d\n", n_positional, n_keyword);
702 }
703}
704
Damien George922ddd62014-04-09 12:43:17 +0100705STATIC void emit_cpy_call_method(emit_t *emit, int n_positional, int n_keyword, uint star_flags) {
706 emit_cpy_call_function(emit, n_positional, n_keyword, star_flags);
Damien429d7192013-10-04 19:53:11 +0100707}
708
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200709STATIC void emit_cpy_return_value(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100710 emit_pre(emit, -1, 1);
711 emit->last_emit_was_return_value = true;
712 if (emit->pass == PASS_3) {
713 printf("RETURN_VALUE\n");
714 }
715}
716
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200717STATIC void emit_cpy_raise_varargs(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100718 emit_pre(emit, -n_args, 3);
719 if (emit->pass == PASS_3) {
720 printf("RAISE_VARARGS %d\n", n_args);
721 }
722}
723
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200724STATIC void load_cpy_const_code_and_name(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100725 emit_pre(emit, 1, 3);
726 if (emit->pass == PASS_3) {
727 printf("LOAD_CONST code %s\n", qstr_str(qstr));
728 }
729 // load qualified name
730 emit_pre(emit, 1, 3);
731 if (emit->pass == PASS_3) {
732 printf("LOAD_CONST '");
733 // code just to work out the qualname (or whatever it is)
734 {
735 int depth = 0;
736 for (scope_t *s = emit->scope; s->parent != NULL; s = s->parent) {
737 depth += 1;
738 }
739 for (int wanted_depth = depth; wanted_depth >= 0; wanted_depth--) {
740 scope_t *s = emit->scope;
741 for (int i = 0; i < wanted_depth; i++) {
742 s = s->parent;
743 }
744 if (s->kind == SCOPE_FUNCTION) {
745 printf("%s.<locals>.", qstr_str(s->simple_name));
746 } else if (s->kind == SCOPE_CLASS) {
747 printf("%s.", qstr_str(s->simple_name));
748 }
749 }
750 }
751 printf("%s'\n", qstr_str(qstr));
752 }
753}
754
Damien George30565092014-03-31 11:30:17 +0100755STATIC void emit_cpy_make_function(emit_t *emit, scope_t *scope, uint n_pos_defaults, uint n_kw_defaults) {
Damien415eb6f2013-10-05 12:19:06 +0100756 load_cpy_const_code_and_name(emit, scope->simple_name);
Damien George30565092014-03-31 11:30:17 +0100757 emit_pre(emit, -1 - n_pos_defaults - 2 * n_kw_defaults, 3);
Damien429d7192013-10-04 19:53:11 +0100758 if (emit->pass == PASS_3) {
Damien George30565092014-03-31 11:30:17 +0100759 printf("MAKE_FUNCTION %d\n", (n_kw_defaults << 8) | n_pos_defaults);
Damien429d7192013-10-04 19:53:11 +0100760 }
761}
762
Damien George30565092014-03-31 11:30:17 +0100763STATIC void emit_cpy_make_closure(emit_t *emit, scope_t *scope, uint n_pos_defaults, uint n_kw_defaults) {
Damien415eb6f2013-10-05 12:19:06 +0100764 load_cpy_const_code_and_name(emit, scope->simple_name);
Damien George30565092014-03-31 11:30:17 +0100765 emit_pre(emit, -2 - n_pos_defaults - 2 * n_kw_defaults, 3);
Damien429d7192013-10-04 19:53:11 +0100766 if (emit->pass == PASS_3) {
Damien George30565092014-03-31 11:30:17 +0100767 printf("MAKE_CLOSURE %d\n", (n_kw_defaults << 8) | n_pos_defaults);
Damien429d7192013-10-04 19:53:11 +0100768 }
769}
770
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200771STATIC void emit_cpy_yield_value(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100772 emit_pre(emit, 0, 1);
773 if (emit->pass == PASS_2) {
Paul Sokolovsky5fd7bc32014-02-16 03:02:47 +0200774 emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR;
Damien429d7192013-10-04 19:53:11 +0100775 }
776 if (emit->pass == PASS_3) {
777 printf("YIELD_VALUE\n");
778 }
779}
780
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200781STATIC void emit_cpy_yield_from(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100782 emit_pre(emit, -1, 1);
783 if (emit->pass == PASS_2) {
Paul Sokolovsky5fd7bc32014-02-16 03:02:47 +0200784 emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR;
Damien429d7192013-10-04 19:53:11 +0100785 }
786 if (emit->pass == PASS_3) {
787 printf("YIELD_FROM\n");
788 }
789}
790
Damien6cdd3af2013-10-05 18:08:26 +0100791const emit_method_table_t emit_cpython_method_table = {
Damien415eb6f2013-10-05 12:19:06 +0100792 emit_cpy_set_native_types,
793 emit_cpy_start_pass,
794 emit_cpy_end_pass,
795 emit_cpy_last_emit_was_return_value,
796 emit_cpy_get_stack_size,
797 emit_cpy_set_stack_size,
Damien George08335002014-01-18 23:24:36 +0000798 emit_cpy_set_source_line,
Damien415eb6f2013-10-05 12:19:06 +0100799
Damien4b03e772013-10-05 14:17:09 +0100800 emit_cpy_load_id,
801 emit_cpy_store_id,
802 emit_cpy_delete_id,
803
Damien415eb6f2013-10-05 12:19:06 +0100804 emit_cpy_label_assign,
805 emit_cpy_import_name,
806 emit_cpy_import_from,
807 emit_cpy_import_star,
808 emit_cpy_load_const_tok,
809 emit_cpy_load_const_small_int,
810 emit_cpy_load_const_int,
811 emit_cpy_load_const_dec,
812 emit_cpy_load_const_id,
813 emit_cpy_load_const_str,
Damien415eb6f2013-10-05 12:19:06 +0100814 emit_cpy_load_const_verbatim_str,
Damien415eb6f2013-10-05 12:19:06 +0100815 emit_cpy_load_fast,
Damien415eb6f2013-10-05 12:19:06 +0100816 emit_cpy_load_deref,
817 emit_cpy_load_closure,
Damien9ecbcff2013-12-11 00:41:43 +0000818 emit_cpy_load_name,
819 emit_cpy_load_global,
Damien415eb6f2013-10-05 12:19:06 +0100820 emit_cpy_load_attr,
821 emit_cpy_load_method,
822 emit_cpy_load_build_class,
823 emit_cpy_store_fast,
Damien9ecbcff2013-12-11 00:41:43 +0000824 emit_cpy_store_deref,
Damien415eb6f2013-10-05 12:19:06 +0100825 emit_cpy_store_name,
826 emit_cpy_store_global,
Damien415eb6f2013-10-05 12:19:06 +0100827 emit_cpy_store_attr,
Damien415eb6f2013-10-05 12:19:06 +0100828 emit_cpy_store_subscr,
829 emit_cpy_delete_fast,
Damien9ecbcff2013-12-11 00:41:43 +0000830 emit_cpy_delete_deref,
Damien415eb6f2013-10-05 12:19:06 +0100831 emit_cpy_delete_name,
832 emit_cpy_delete_global,
Damien415eb6f2013-10-05 12:19:06 +0100833 emit_cpy_delete_attr,
834 emit_cpy_delete_subscr,
835 emit_cpy_dup_top,
836 emit_cpy_dup_top_two,
837 emit_cpy_pop_top,
838 emit_cpy_rot_two,
839 emit_cpy_rot_three,
840 emit_cpy_jump,
841 emit_cpy_pop_jump_if_true,
842 emit_cpy_pop_jump_if_false,
843 emit_cpy_jump_if_true_or_pop,
844 emit_cpy_jump_if_false_or_pop,
845 emit_cpy_setup_loop,
846 emit_cpy_break_loop,
847 emit_cpy_continue_loop,
848 emit_cpy_setup_with,
849 emit_cpy_with_cleanup,
850 emit_cpy_setup_except,
851 emit_cpy_setup_finally,
852 emit_cpy_end_finally,
853 emit_cpy_get_iter,
854 emit_cpy_for_iter,
855 emit_cpy_for_iter_end,
856 emit_cpy_pop_block,
857 emit_cpy_pop_except,
858 emit_cpy_unary_op,
859 emit_cpy_binary_op,
Damien415eb6f2013-10-05 12:19:06 +0100860 emit_cpy_build_tuple,
861 emit_cpy_build_list,
862 emit_cpy_list_append,
863 emit_cpy_build_map,
864 emit_cpy_store_map,
865 emit_cpy_map_add,
866 emit_cpy_build_set,
867 emit_cpy_set_add,
868 emit_cpy_build_slice,
869 emit_cpy_unpack_sequence,
870 emit_cpy_unpack_ex,
871 emit_cpy_make_function,
872 emit_cpy_make_closure,
873 emit_cpy_call_function,
874 emit_cpy_call_method,
875 emit_cpy_return_value,
876 emit_cpy_raise_varargs,
877 emit_cpy_yield_value,
878 emit_cpy_yield_from,
879};
880
Damien3ef4abb2013-10-12 16:53:13 +0100881#endif // MICROPY_EMIT_CPYTHON