blob: 119cf818cf9a5f2cb82fbb210681796b6439ba04 [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"
Damien Georgedf8127a2014-04-13 11:04:33 +010012#include "obj.h"
13#include "emitglue.h"
Damien429d7192013-10-04 19:53:11 +010014#include "scope.h"
Damiend99b0522013-12-21 18:17:45 +000015#include "runtime0.h"
Damien429d7192013-10-04 19:53:11 +010016#include "emit.h"
17
Damien Georgee67ed5d2014-01-04 13:55:24 +000018// wrapper around everything in this file
Damien3ef4abb2013-10-12 16:53:13 +010019#if MICROPY_EMIT_CPYTHON
Damien429d7192013-10-04 19:53:11 +010020
Damien415eb6f2013-10-05 12:19:06 +010021struct _emit_t {
Damien429d7192013-10-04 19:53:11 +010022 int pass;
Damien429d7192013-10-04 19:53:11 +010023 int byte_code_offset;
24 int stack_size;
25 bool last_emit_was_return_value;
26
27 scope_t *scope;
28
Damienb05d7072013-10-05 13:37:10 +010029 uint max_num_labels;
Damien429d7192013-10-04 19:53:11 +010030 int *label_offsets;
31};
32
Damien6cdd3af2013-10-05 18:08:26 +010033emit_t *emit_cpython_new(uint max_num_labels) {
34 emit_t *emit = m_new(emit_t, 1);
35 emit->max_num_labels = max_num_labels;
36 emit->label_offsets = m_new(int, max_num_labels);
37 return emit;
38}
39
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020040STATIC void emit_cpy_set_native_types(emit_t *emit, bool do_native_types) {
Damien429d7192013-10-04 19:53:11 +010041}
42
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020043STATIC void emit_cpy_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
Damien429d7192013-10-04 19:53:11 +010044 emit->pass = pass;
Damien429d7192013-10-04 19:53:11 +010045 emit->byte_code_offset = 0;
46 emit->stack_size = 0;
47 emit->last_emit_was_return_value = false;
48 emit->scope = scope;
Damienb05d7072013-10-05 13:37:10 +010049 if (pass == PASS_2) {
50 memset(emit->label_offsets, -1, emit->max_num_labels * sizeof(int));
Damien429d7192013-10-04 19:53:11 +010051 }
52}
53
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020054STATIC void emit_cpy_end_pass(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +010055 // check stack is back to zero size
56 if (emit->stack_size != 0) {
57 printf("ERROR: stack size not back to zero; got %d\n", emit->stack_size);
58 }
Damien429d7192013-10-04 19:53:11 +010059}
60
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020061STATIC bool emit_cpy_last_emit_was_return_value(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +010062 return emit->last_emit_was_return_value;
63}
64
Damien Georged66ae182014-04-10 17:28:54 +000065STATIC void emit_cpy_adjust_stack_size(emit_t *emit, int delta) {
66 emit->stack_size += delta;
Damien429d7192013-10-04 19:53:11 +010067}
68
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020069STATIC void emit_cpy_set_source_line(emit_t *emit, int source_line) {
Damien George08335002014-01-18 23:24:36 +000070}
71
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020072STATIC void emit_cpy_load_id(emit_t *emit, qstr qstr) {
Damien6cdd3af2013-10-05 18:08:26 +010073 emit_common_load_id(emit, &emit_cpython_method_table, emit->scope, qstr);
Damien4b03e772013-10-05 14:17:09 +010074}
75
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020076STATIC void emit_cpy_store_id(emit_t *emit, qstr qstr) {
Damien6cdd3af2013-10-05 18:08:26 +010077 emit_common_store_id(emit, &emit_cpython_method_table, emit->scope, qstr);
Damien4b03e772013-10-05 14:17:09 +010078}
79
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020080STATIC void emit_cpy_delete_id(emit_t *emit, qstr qstr) {
Damien6cdd3af2013-10-05 18:08:26 +010081 emit_common_delete_id(emit, &emit_cpython_method_table, emit->scope, qstr);
Damien4b03e772013-10-05 14:17:09 +010082}
83
Paul Sokolovsky520e2f52014-02-12 18:31:30 +020084// TODO: module-polymorphic function (read: name clash if made global)
Damien415eb6f2013-10-05 12:19:06 +010085static void emit_pre(emit_t *emit, int stack_size_delta, int byte_code_size) {
Damien429d7192013-10-04 19:53:11 +010086 emit->stack_size += stack_size_delta;
Damienb05d7072013-10-05 13:37:10 +010087 if (emit->stack_size > emit->scope->stack_size) {
Damien429d7192013-10-04 19:53:11 +010088 emit->scope->stack_size = emit->stack_size;
89 }
90 emit->last_emit_was_return_value = false;
91 if (emit->pass == PASS_3 && byte_code_size > 0) {
92 if (emit->byte_code_offset >= 1000) {
93 printf("%d ", emit->byte_code_offset);
94 } else {
95 printf("% 4d ", emit->byte_code_offset);
96 }
97 }
98 emit->byte_code_offset += byte_code_size;
99}
100
Damien George6f355fd2014-04-10 14:11:31 +0100101STATIC void emit_cpy_label_assign(emit_t *emit, uint l) {
Damien429d7192013-10-04 19:53:11 +0100102 emit_pre(emit, 0, 0);
Damienb05d7072013-10-05 13:37:10 +0100103 assert(l < emit->max_num_labels);
104 if (emit->pass == PASS_2) {
105 // assign label offset
106 assert(emit->label_offsets[l] == -1);
107 emit->label_offsets[l] = emit->byte_code_offset;
108 } else if (emit->pass == PASS_3) {
109 // ensure label offset has not changed from PASS_2 to PASS_3
110 assert(emit->label_offsets[l] == emit->byte_code_offset);
111 //printf("l%d: (at %d)\n", l, emit->byte_code_offset);
Damien429d7192013-10-04 19:53:11 +0100112 }
113}
114
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200115STATIC void emit_cpy_import_name(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100116 emit_pre(emit, -1, 3);
117 if (emit->pass == PASS_3) {
118 printf("IMPORT_NAME %s\n", qstr_str(qstr));
119 }
120}
121
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200122STATIC void emit_cpy_import_from(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100123 emit_pre(emit, 1, 3);
124 if (emit->pass == PASS_3) {
125 printf("IMPORT_FROM %s\n", qstr_str(qstr));
126 }
127}
128
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200129STATIC void emit_cpy_import_star(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100130 emit_pre(emit, -1, 1);
131 if (emit->pass == PASS_3) {
132 printf("IMPORT_STAR\n");
133 }
134}
135
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200136STATIC void emit_cpy_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
Damien429d7192013-10-04 19:53:11 +0100137 emit_pre(emit, 1, 3);
138 if (emit->pass == PASS_3) {
139 printf("LOAD_CONST ");
140 switch (tok) {
Damiend99b0522013-12-21 18:17:45 +0000141 case MP_TOKEN_KW_FALSE: printf("False"); break;
142 case MP_TOKEN_KW_NONE: printf("None"); break;
143 case MP_TOKEN_KW_TRUE: printf("True"); break;
Damien429d7192013-10-04 19:53:11 +0100144 default: printf("?=%d\n", tok); return; assert(0);
145 }
146 printf("\n");
147 }
148}
149
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200150STATIC void emit_cpy_load_const_small_int(emit_t *emit, machine_int_t arg) {
Damien429d7192013-10-04 19:53:11 +0100151 emit_pre(emit, 1, 3);
152 if (emit->pass == PASS_3) {
Damien George08d07552014-01-29 18:58:52 +0000153 printf("LOAD_CONST " INT_FMT "\n", arg);
Damien429d7192013-10-04 19:53:11 +0100154 }
155}
156
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200157STATIC void emit_cpy_load_const_int(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100158 emit_pre(emit, 1, 3);
159 if (emit->pass == PASS_3) {
160 printf("LOAD_CONST %s\n", qstr_str(qstr));
161 }
162}
163
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200164STATIC void emit_cpy_load_const_dec(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100165 emit_pre(emit, 1, 3);
166 if (emit->pass == PASS_3) {
167 printf("LOAD_CONST %s\n", qstr_str(qstr));
168 }
169}
170
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200171STATIC void emit_cpy_load_const_id(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100172 emit_pre(emit, 1, 3);
173 if (emit->pass == PASS_3) {
174 printf("LOAD_CONST '%s'\n", qstr_str(qstr));
175 }
176}
177
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200178STATIC void print_quoted_str(qstr qstr, bool bytes) {
Damiena1b26932013-12-12 15:34:40 +0000179 const char *str = qstr_str(qstr);
180 int len = strlen(str);
181 bool has_single_quote = false;
182 bool has_double_quote = false;
183 for (int i = 0; i < len; i++) {
184 if (str[i] == '\'') {
185 has_single_quote = true;
186 } else if (str[i] == '"') {
187 has_double_quote = true;
188 }
189 }
190 if (bytes) {
191 printf("b");
192 }
Damien Georgeb829b5c2014-01-25 13:51:19 +0000193 int quote_char = '\'';
Damiena1b26932013-12-12 15:34:40 +0000194 if (has_single_quote && !has_double_quote) {
Damien Georgeb829b5c2014-01-25 13:51:19 +0000195 quote_char = '"';
Damiena1b26932013-12-12 15:34:40 +0000196 }
Damien Georgeb829b5c2014-01-25 13:51:19 +0000197 printf("%c", quote_char);
198 for (const char *s = str, *top = str + len; s < top; s++) {
199 if (*s == quote_char) {
200 printf("\\%c", quote_char);
201 } else if (*s == '\\') {
Damiena1b26932013-12-12 15:34:40 +0000202 printf("\\\\");
Damien Georgeb829b5c2014-01-25 13:51:19 +0000203 } else if (32 <= *s && *s <= 126) {
204 printf("%c", *s);
205 } else if (*s == '\n') {
206 printf("\\n");
207 // TODO add more escape codes here
Damiena1b26932013-12-12 15:34:40 +0000208 } else {
Damien Georgeb829b5c2014-01-25 13:51:19 +0000209 printf("\\x%02x", (*s) & 0xff);
Damiena1b26932013-12-12 15:34:40 +0000210 }
211 }
Damien Georgeb829b5c2014-01-25 13:51:19 +0000212 printf("%c", quote_char);
Damiena1b26932013-12-12 15:34:40 +0000213}
214
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200215STATIC void emit_cpy_load_const_str(emit_t *emit, qstr qstr, bool bytes) {
Damien429d7192013-10-04 19:53:11 +0100216 emit_pre(emit, 1, 3);
217 if (emit->pass == PASS_3) {
218 printf("LOAD_CONST ");
Damiena1b26932013-12-12 15:34:40 +0000219 print_quoted_str(qstr, bytes);
Damien429d7192013-10-04 19:53:11 +0100220 printf("\n");
221 }
222}
223
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200224STATIC void emit_cpy_load_const_verbatim_str(emit_t *emit, const char *str) {
Damiena1b26932013-12-12 15:34:40 +0000225 emit_pre(emit, 1, 3);
Damien429d7192013-10-04 19:53:11 +0100226 if (emit->pass == PASS_3) {
Damiena1b26932013-12-12 15:34:40 +0000227 printf("LOAD_CONST %s\n", str);
Damien429d7192013-10-04 19:53:11 +0100228 }
229}
230
Damien Georgee2835c12014-04-09 20:20:34 +0100231STATIC void emit_cpy_load_fast(emit_t *emit, qstr qstr, uint id_flags, int local_num) {
Damien6cdd3af2013-10-05 18:08:26 +0100232 emit_pre(emit, 1, 3);
233 if (emit->pass == PASS_3) {
234 printf("LOAD_FAST %d %s\n", local_num, qstr_str(qstr));
235 }
236}
237
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200238STATIC void emit_cpy_load_deref(emit_t *emit, qstr qstr, int local_num) {
Damien429d7192013-10-04 19:53:11 +0100239 emit_pre(emit, 1, 3);
240 if (emit->pass == PASS_3) {
Damien27fb45e2013-10-20 15:07:49 +0100241 printf("LOAD_DEREF %d %s\n", local_num, qstr_str(qstr));
Damien429d7192013-10-04 19:53:11 +0100242 }
243}
244
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200245STATIC void emit_cpy_load_closure(emit_t *emit, qstr qstr, int local_num) {
Damien429d7192013-10-04 19:53:11 +0100246 emit_pre(emit, 1, 3);
247 if (emit->pass == PASS_3) {
Damien27fb45e2013-10-20 15:07:49 +0100248 printf("LOAD_CLOSURE %d %s\n", local_num, qstr_str(qstr));
Damien429d7192013-10-04 19:53:11 +0100249 }
250}
251
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200252STATIC void emit_cpy_load_name(emit_t *emit, qstr qstr) {
Damien9ecbcff2013-12-11 00:41:43 +0000253 emit_pre(emit, 1, 3);
254 if (emit->pass == PASS_3) {
255 printf("LOAD_NAME %s\n", qstr_str(qstr));
256 }
257}
258
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200259STATIC void emit_cpy_load_global(emit_t *emit, qstr qstr) {
Damien9ecbcff2013-12-11 00:41:43 +0000260 emit_pre(emit, 1, 3);
261 if (emit->pass == PASS_3) {
262 printf("LOAD_GLOBAL %s\n", qstr_str(qstr));
263 }
264}
265
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200266STATIC void emit_cpy_load_attr(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100267 emit_pre(emit, 0, 3);
268 if (emit->pass == PASS_3) {
269 printf("LOAD_ATTR %s\n", qstr_str(qstr));
270 }
271}
272
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200273STATIC void emit_cpy_load_method(emit_t *emit, qstr qstr) {
Damien415eb6f2013-10-05 12:19:06 +0100274 emit_cpy_load_attr(emit, qstr);
Damien429d7192013-10-04 19:53:11 +0100275}
276
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200277STATIC void emit_cpy_load_build_class(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100278 emit_pre(emit, 1, 1);
279 if (emit->pass == PASS_3) {
280 printf("LOAD_BUILD_CLASS\n");
281 }
282}
283
Damien George729f7b42014-04-17 22:10:53 +0100284STATIC void emit_cpy_load_subscr(emit_t *emit) {
285 emit_pre(emit, -1, 1);
286 if (emit->pass == PASS_3) {
287 printf("BINARY_SUBSCR\n");
288 }
289}
290
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200291STATIC void emit_cpy_store_fast(emit_t *emit, qstr qstr, int local_num) {
Damien6cdd3af2013-10-05 18:08:26 +0100292 emit_pre(emit, -1, 3);
293 if (emit->pass == PASS_3) {
294 printf("STORE_FAST %d %s\n", local_num, qstr_str(qstr));
295 }
296}
297
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200298STATIC void emit_cpy_store_deref(emit_t *emit, qstr qstr, int local_num) {
Damien9ecbcff2013-12-11 00:41:43 +0000299 emit_pre(emit, -1, 3);
300 if (emit->pass == PASS_3) {
301 printf("STORE_DEREF %d %s\n", local_num, qstr_str(qstr));
302 }
303}
304
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200305STATIC void emit_cpy_store_name(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100306 emit_pre(emit, -1, 3);
307 if (emit->pass == PASS_3) {
308 printf("STORE_NAME %s\n", qstr_str(qstr));
309 }
310}
311
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200312STATIC void emit_cpy_store_global(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100313 emit_pre(emit, -1, 3);
314 if (emit->pass == PASS_3) {
315 printf("STORE_GLOBAL %s\n", qstr_str(qstr));
316 }
317}
318
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200319STATIC void emit_cpy_store_attr(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100320 emit_pre(emit, -2, 3);
321 if (emit->pass == PASS_3) {
322 printf("STORE_ATTR %s\n", qstr_str(qstr));
323 }
324}
325
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200326STATIC void emit_cpy_store_subscr(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100327 emit_pre(emit, -3, 1);
328 if (emit->pass == PASS_3) {
329 printf("STORE_SUBSCR\n");
330 }
331}
332
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200333STATIC void emit_cpy_delete_fast(emit_t *emit, qstr qstr, int local_num) {
Damien6cdd3af2013-10-05 18:08:26 +0100334 emit_pre(emit, 0, 3);
335 if (emit->pass == PASS_3) {
336 printf("DELETE_FAST %d %s\n", local_num, qstr_str(qstr));
337 }
338}
339
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200340STATIC void emit_cpy_delete_deref(emit_t *emit, qstr qstr, int local_num) {
Damien9ecbcff2013-12-11 00:41:43 +0000341 emit_pre(emit, 0, 3);
342 if (emit->pass == PASS_3) {
343 printf("DELETE_DEREF %d %s\n", local_num, qstr_str(qstr));
344 }
345}
346
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200347STATIC void emit_cpy_delete_name(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100348 emit_pre(emit, 0, 3);
349 if (emit->pass == PASS_3) {
350 printf("DELETE_NAME %s\n", qstr_str(qstr));
351 }
352}
353
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200354STATIC void emit_cpy_delete_global(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100355 emit_pre(emit, 0, 3);
356 if (emit->pass == PASS_3) {
357 printf("DELETE_GLOBAL %s\n", qstr_str(qstr));
358 }
359}
360
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200361STATIC void emit_cpy_delete_attr(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100362 emit_pre(emit, -1, 3);
363 if (emit->pass == PASS_3) {
364 printf("DELETE_ATTR %s\n", qstr_str(qstr));
365 }
366}
367
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200368STATIC void emit_cpy_delete_subscr(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100369 emit_pre(emit, -2, 1);
370 if (emit->pass == PASS_3) {
371 printf("DELETE_SUBSCR\n");
372 }
373}
374
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200375STATIC void emit_cpy_dup_top(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100376 emit_pre(emit, 1, 1);
377 if (emit->pass == PASS_3) {
378 printf("DUP_TOP\n");
379 }
380}
381
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200382STATIC void emit_cpy_dup_top_two(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100383 emit_pre(emit, 2, 1);
384 if (emit->pass == PASS_3) {
385 printf("DUP_TOP_TWO\n");
386 }
387}
388
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200389STATIC void emit_cpy_pop_top(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100390 emit_pre(emit, -1, 1);
391 if (emit->pass == PASS_3) {
392 printf("POP_TOP\n");
393 }
394}
395
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200396STATIC void emit_cpy_rot_two(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100397 emit_pre(emit, 0, 1);
398 if (emit->pass == PASS_3) {
399 printf("ROT_TWO\n");
400 }
401}
402
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200403STATIC void emit_cpy_rot_three(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100404 emit_pre(emit, 0, 1);
405 if (emit->pass == PASS_3) {
406 printf("ROT_THREE\n");
407 }
408}
409
Damien George6f355fd2014-04-10 14:11:31 +0100410STATIC void emit_cpy_jump(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100411 emit_pre(emit, 0, 3);
412 if (emit->pass == PASS_3) {
413 int dest = emit->label_offsets[label];
414 if (dest < emit->byte_code_offset) {
415 printf("JUMP_ABSOLUTE %d\n", emit->label_offsets[label]);
416 } else {
417 printf("JUMP_FORWARD %d\n", emit->label_offsets[label]);
418 }
419 }
420}
421
Damien George6f355fd2014-04-10 14:11:31 +0100422STATIC void emit_cpy_pop_jump_if_true(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100423 emit_pre(emit, -1, 3);
424 if (emit->pass == PASS_3) {
425 printf("POP_JUMP_IF_TRUE %d\n", emit->label_offsets[label]);
426 }
427}
428
Damien George6f355fd2014-04-10 14:11:31 +0100429STATIC void emit_cpy_pop_jump_if_false(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100430 emit_pre(emit, -1, 3);
431 if (emit->pass == PASS_3) {
432 printf("POP_JUMP_IF_FALSE %d\n", emit->label_offsets[label]);
433 }
434}
435
Damien George6f355fd2014-04-10 14:11:31 +0100436STATIC void emit_cpy_jump_if_true_or_pop(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100437 emit_pre(emit, -1, 3);
438 if (emit->pass == PASS_3) {
439 printf("JUMP_IF_TRUE_OR_POP %d\n", emit->label_offsets[label]);
440 }
441}
442
Damien George6f355fd2014-04-10 14:11:31 +0100443STATIC void emit_cpy_jump_if_false_or_pop(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100444 emit_pre(emit, -1, 3);
445 if (emit->pass == PASS_3) {
446 printf("JUMP_IF_FALSE_OR_POP %d\n", emit->label_offsets[label]);
447 }
448}
449
Damien George6f355fd2014-04-10 14:11:31 +0100450STATIC void emit_cpy_setup_loop(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100451 emit_pre(emit, 0, 3);
452 if (emit->pass == PASS_3) {
453 printf("SETUP_LOOP %d\n", emit->label_offsets[label]);
454 }
455}
456
Damien George6f355fd2014-04-10 14:11:31 +0100457STATIC void emit_cpy_break_loop(emit_t *emit, uint label, int except_depth) {
Damien429d7192013-10-04 19:53:11 +0100458 emit_pre(emit, 0, 1);
459 if (emit->pass == PASS_3) {
Damien Georgee24b5632014-02-01 21:56:25 +0000460 printf("BREAK_LOOP\n");
Damien429d7192013-10-04 19:53:11 +0100461 }
462}
463
Damien George6f355fd2014-04-10 14:11:31 +0100464STATIC void emit_cpy_continue_loop(emit_t *emit, uint label, int except_depth) {
Damien Georgee24b5632014-02-01 21:56:25 +0000465 if (except_depth == 0) {
466 emit_cpy_jump(emit, label);
467 } else {
468 emit_pre(emit, 0, 3);
469 if (emit->pass == PASS_3) {
470 printf("CONTINUE_LOOP %d\n", emit->label_offsets[label]);
471 }
Damien429d7192013-10-04 19:53:11 +0100472 }
473}
474
Damien George6f355fd2014-04-10 14:11:31 +0100475STATIC void emit_cpy_setup_with(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100476 emit_pre(emit, 7, 3);
477 if (emit->pass == PASS_3) {
478 printf("SETUP_WITH %d\n", emit->label_offsets[label]);
479 }
480}
481
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200482STATIC void emit_cpy_with_cleanup(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100483 emit_pre(emit, -7, 1);
484 if (emit->pass == PASS_3) {
485 printf("WITH_CLEANUP\n");
486 }
487}
488
Damien George6f355fd2014-04-10 14:11:31 +0100489STATIC void emit_cpy_setup_except(emit_t *emit, uint label) {
Damien George069a35e2014-04-10 17:22:19 +0000490 emit_pre(emit, 0, 3);
Damien429d7192013-10-04 19:53:11 +0100491 if (emit->pass == PASS_3) {
492 printf("SETUP_EXCEPT %d\n", emit->label_offsets[label]);
493 }
494}
495
Damien George6f355fd2014-04-10 14:11:31 +0100496STATIC void emit_cpy_setup_finally(emit_t *emit, uint label) {
Damien George069a35e2014-04-10 17:22:19 +0000497 emit_pre(emit, 0, 3);
Damien429d7192013-10-04 19:53:11 +0100498 if (emit->pass == PASS_3) {
499 printf("SETUP_FINALLY %d\n", emit->label_offsets[label]);
500 }
501}
502
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200503STATIC void emit_cpy_end_finally(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100504 emit_pre(emit, -1, 1);
505 if (emit->pass == PASS_3) {
506 printf("END_FINALLY\n");
507 }
508}
509
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200510STATIC void emit_cpy_get_iter(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100511 emit_pre(emit, 0, 1);
512 if (emit->pass == PASS_3) {
513 printf("GET_ITER\n");
514 }
515}
516
Damien George6f355fd2014-04-10 14:11:31 +0100517STATIC void emit_cpy_for_iter(emit_t *emit, uint label) {
Damien429d7192013-10-04 19:53:11 +0100518 emit_pre(emit, 1, 3);
519 if (emit->pass == PASS_3) {
520 printf("FOR_ITER %d\n", emit->label_offsets[label]);
521 }
522}
523
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200524STATIC void emit_cpy_for_iter_end(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100525 emit_pre(emit, -1, 0);
526}
527
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200528STATIC void emit_cpy_pop_block(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100529 emit_pre(emit, 0, 1);
530 if (emit->pass == PASS_3) {
531 printf("POP_BLOCK\n");
532 }
533}
534
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200535STATIC void emit_cpy_pop_except(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100536 emit_pre(emit, 0, 1);
537 if (emit->pass == PASS_3) {
538 printf("POP_EXCEPT\n");
539 }
540}
541
Damien Georged17926d2014-03-30 13:35:08 +0100542STATIC void emit_cpy_unary_op(emit_t *emit, mp_unary_op_t op) {
Damien429d7192013-10-04 19:53:11 +0100543 emit_pre(emit, 0, 1);
544 if (emit->pass == PASS_3) {
545 switch (op) {
Damien Georged17926d2014-03-30 13:35:08 +0100546 case MP_UNARY_OP_POSITIVE: printf("UNARY_POSITIVE\n"); break;
547 case MP_UNARY_OP_NEGATIVE: printf("UNARY_NEGATIVE\n"); break;
548 case MP_UNARY_OP_INVERT: printf("UNARY_INVERT\n"); break;
549 case MP_UNARY_OP_NOT: printf("UNARY_NOT\n"); break;
Damien429d7192013-10-04 19:53:11 +0100550 default: assert(0);
551 }
552 }
553}
554
Damien Georged17926d2014-03-30 13:35:08 +0100555STATIC void emit_cpy_binary_op(emit_t *emit, mp_binary_op_t op) {
556 if (op <= MP_BINARY_OP_INPLACE_POWER) {
Damien Georgebc1d3692014-01-11 09:47:06 +0000557 // CPython uses a byte code for each binary op
558 emit_pre(emit, -1, 1);
559 } else {
560 // CPython uses a byte code plus an argument for compare ops
561 emit_pre(emit, -1, 3);
562 }
Damien429d7192013-10-04 19:53:11 +0100563 if (emit->pass == PASS_3) {
564 switch (op) {
Damien Georged17926d2014-03-30 13:35:08 +0100565 case MP_BINARY_OP_OR: printf("BINARY_OR\n"); break;
566 case MP_BINARY_OP_XOR: printf("BINARY_XOR\n"); break;
567 case MP_BINARY_OP_AND: printf("BINARY_AND\n"); break;
568 case MP_BINARY_OP_LSHIFT: printf("BINARY_LSHIFT\n"); break;
569 case MP_BINARY_OP_RSHIFT: printf("BINARY_RSHIFT\n"); break;
570 case MP_BINARY_OP_ADD: printf("BINARY_ADD\n"); break;
571 case MP_BINARY_OP_SUBTRACT: printf("BINARY_SUBTRACT\n"); break;
572 case MP_BINARY_OP_MULTIPLY: printf("BINARY_MULTIPLY\n"); break;
573 case MP_BINARY_OP_FLOOR_DIVIDE: printf("BINARY_FLOOR_DIVIDE\n"); break;
574 case MP_BINARY_OP_TRUE_DIVIDE: printf("BINARY_TRUE_DIVIDE\n"); break;
575 case MP_BINARY_OP_MODULO: printf("BINARY_MODULO\n"); break;
576 case MP_BINARY_OP_POWER: printf("BINARY_POWER\n"); break;
577 case MP_BINARY_OP_INPLACE_OR: printf("INPLACE_OR\n"); break;
578 case MP_BINARY_OP_INPLACE_XOR: printf("INPLACE_XOR\n"); break;
579 case MP_BINARY_OP_INPLACE_AND: printf("INPLACE_AND\n"); break;
580 case MP_BINARY_OP_INPLACE_LSHIFT: printf("INPLACE_LSHIFT\n"); break;
581 case MP_BINARY_OP_INPLACE_RSHIFT: printf("INPLACE_RSHIFT\n"); break;
582 case MP_BINARY_OP_INPLACE_ADD: printf("INPLACE_ADD\n"); break;
583 case MP_BINARY_OP_INPLACE_SUBTRACT: printf("INPLACE_SUBTRACT\n"); break;
584 case MP_BINARY_OP_INPLACE_MULTIPLY: printf("INPLACE_MULTIPLY\n"); break;
585 case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: printf("INPLACE_FLOOR_DIVIDE\n"); break;
586 case MP_BINARY_OP_INPLACE_TRUE_DIVIDE: printf("INPLACE_TRUE_DIVIDE\n"); break;
587 case MP_BINARY_OP_INPLACE_MODULO: printf("INPLACE_MODULO\n"); break;
588 case MP_BINARY_OP_INPLACE_POWER: printf("INPLACE_POWER\n"); break;
589 case MP_BINARY_OP_LESS: printf("COMPARE_OP <\n"); break;
590 case MP_BINARY_OP_MORE: printf("COMPARE_OP >\n"); break;
591 case MP_BINARY_OP_EQUAL: printf("COMPARE_OP ==\n"); break;
592 case MP_BINARY_OP_LESS_EQUAL: printf("COMPARE_OP <=\n"); break;
593 case MP_BINARY_OP_MORE_EQUAL: printf("COMPARE_OP >=\n"); break;
594 case MP_BINARY_OP_NOT_EQUAL: printf("COMPARE_OP !=\n"); break;
595 case MP_BINARY_OP_IN: printf("COMPARE_OP in\n"); break;
596 case MP_BINARY_OP_IS: printf("COMPARE_OP is\n"); break;
597 case MP_BINARY_OP_EXCEPTION_MATCH: printf("COMPARE_OP exception match\n"); break;
598 case MP_BINARY_OP_NOT_IN: printf("COMPARE_OP not in\n"); break;
599 case MP_BINARY_OP_IS_NOT: printf("COMPARE_OP is not\n"); break;
Damien429d7192013-10-04 19:53:11 +0100600 default: assert(0);
601 }
602 }
603}
604
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200605STATIC void emit_cpy_build_tuple(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100606 emit_pre(emit, 1 - n_args, 3);
607 if (emit->pass == PASS_3) {
608 printf("BUILD_TUPLE %d\n", n_args);
609 }
610}
611
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200612STATIC void emit_cpy_build_list(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100613 emit_pre(emit, 1 - n_args, 3);
614 if (emit->pass == PASS_3) {
615 printf("BUILD_LIST %d\n", n_args);
616 }
617}
618
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200619STATIC void emit_cpy_list_append(emit_t *emit, int list_index) {
Damien429d7192013-10-04 19:53:11 +0100620 emit_pre(emit, -1, 3);
621 if (emit->pass == PASS_3) {
622 printf("LIST_APPEND %d\n", list_index);
623 }
624}
625
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200626STATIC void emit_cpy_build_map(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100627 emit_pre(emit, 1, 3);
628 if (emit->pass == PASS_3) {
629 printf("BUILD_MAP %d\n", n_args);
630 }
631}
632
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200633STATIC void emit_cpy_store_map(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100634 emit_pre(emit, -2, 1);
635 if (emit->pass == PASS_3) {
636 printf("STORE_MAP\n");
637 }
638}
639
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200640STATIC void emit_cpy_map_add(emit_t *emit, int map_index) {
Damien429d7192013-10-04 19:53:11 +0100641 emit_pre(emit, -2, 3);
642 if (emit->pass == PASS_3) {
643 printf("MAP_ADD %d\n", map_index);
644 }
645}
646
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200647STATIC void emit_cpy_build_set(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100648 emit_pre(emit, 1 - n_args, 3);
649 if (emit->pass == PASS_3) {
650 printf("BUILD_SET %d\n", n_args);
651 }
652}
653
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200654STATIC void emit_cpy_set_add(emit_t *emit, int set_index) {
Damien429d7192013-10-04 19:53:11 +0100655 emit_pre(emit, -1, 3);
656 if (emit->pass == PASS_3) {
657 printf("SET_ADD %d\n", set_index);
658 }
659}
660
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200661STATIC void emit_cpy_build_slice(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100662 emit_pre(emit, 1 - n_args, 3);
663 if (emit->pass == PASS_3) {
664 printf("BUILD_SLICE %d\n", n_args);
665 }
666}
667
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200668STATIC void emit_cpy_unpack_sequence(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100669 emit_pre(emit, -1 + n_args, 3);
670 if (emit->pass == PASS_3) {
671 printf("UNPACK_SEQUENCE %d\n", n_args);
672 }
673}
674
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200675STATIC void emit_cpy_unpack_ex(emit_t *emit, int n_left, int n_right) {
Damien429d7192013-10-04 19:53:11 +0100676 emit_pre(emit, -1 + n_left + n_right + 1, 3);
677 if (emit->pass == PASS_3) {
678 printf("UNPACK_EX %d\n", n_left | (n_right << 8));
679 }
680}
681
Damien George922ddd62014-04-09 12:43:17 +0100682STATIC void emit_cpy_call_function(emit_t *emit, int n_positional, int n_keyword, uint star_flags) {
Damien429d7192013-10-04 19:53:11 +0100683 int s = 0;
Damien George922ddd62014-04-09 12:43:17 +0100684 if (star_flags & MP_EMIT_STAR_FLAG_SINGLE) {
Damien429d7192013-10-04 19:53:11 +0100685 s += 1;
686 }
Damien George922ddd62014-04-09 12:43:17 +0100687 if (star_flags & MP_EMIT_STAR_FLAG_DOUBLE) {
Damien429d7192013-10-04 19:53:11 +0100688 s += 1;
689 }
690 emit_pre(emit, -n_positional - 2 * n_keyword - s, 3);
691 if (emit->pass == PASS_3) {
Damien George922ddd62014-04-09 12:43:17 +0100692 if (star_flags & MP_EMIT_STAR_FLAG_SINGLE) {
693 if (star_flags & MP_EMIT_STAR_FLAG_DOUBLE) {
Damien429d7192013-10-04 19:53:11 +0100694 printf("CALL_FUNCTION_VAR_KW");
695 } else {
696 printf("CALL_FUNCTION_VAR");
697 }
698 } else {
Damien George922ddd62014-04-09 12:43:17 +0100699 if (star_flags & MP_EMIT_STAR_FLAG_DOUBLE) {
Damien429d7192013-10-04 19:53:11 +0100700 printf("CALL_FUNCTION_KW");
701 } else {
702 printf("CALL_FUNCTION");
703 }
704 }
705 printf(" %d, %d\n", n_positional, n_keyword);
706 }
707}
708
Damien George922ddd62014-04-09 12:43:17 +0100709STATIC void emit_cpy_call_method(emit_t *emit, int n_positional, int n_keyword, uint star_flags) {
710 emit_cpy_call_function(emit, n_positional, n_keyword, star_flags);
Damien429d7192013-10-04 19:53:11 +0100711}
712
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200713STATIC void emit_cpy_return_value(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100714 emit_pre(emit, -1, 1);
715 emit->last_emit_was_return_value = true;
716 if (emit->pass == PASS_3) {
717 printf("RETURN_VALUE\n");
718 }
719}
720
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200721STATIC void emit_cpy_raise_varargs(emit_t *emit, int n_args) {
Damien429d7192013-10-04 19:53:11 +0100722 emit_pre(emit, -n_args, 3);
723 if (emit->pass == PASS_3) {
724 printf("RAISE_VARARGS %d\n", n_args);
725 }
726}
727
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200728STATIC void load_cpy_const_code_and_name(emit_t *emit, qstr qstr) {
Damien429d7192013-10-04 19:53:11 +0100729 emit_pre(emit, 1, 3);
730 if (emit->pass == PASS_3) {
731 printf("LOAD_CONST code %s\n", qstr_str(qstr));
732 }
733 // load qualified name
734 emit_pre(emit, 1, 3);
735 if (emit->pass == PASS_3) {
736 printf("LOAD_CONST '");
737 // code just to work out the qualname (or whatever it is)
738 {
739 int depth = 0;
740 for (scope_t *s = emit->scope; s->parent != NULL; s = s->parent) {
741 depth += 1;
742 }
743 for (int wanted_depth = depth; wanted_depth >= 0; wanted_depth--) {
744 scope_t *s = emit->scope;
745 for (int i = 0; i < wanted_depth; i++) {
746 s = s->parent;
747 }
748 if (s->kind == SCOPE_FUNCTION) {
749 printf("%s.<locals>.", qstr_str(s->simple_name));
750 } else if (s->kind == SCOPE_CLASS) {
751 printf("%s.", qstr_str(s->simple_name));
752 }
753 }
754 }
755 printf("%s'\n", qstr_str(qstr));
756 }
757}
758
Damien George30565092014-03-31 11:30:17 +0100759STATIC 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 +0100760 load_cpy_const_code_and_name(emit, scope->simple_name);
Damien George30565092014-03-31 11:30:17 +0100761 emit_pre(emit, -1 - n_pos_defaults - 2 * n_kw_defaults, 3);
Damien429d7192013-10-04 19:53:11 +0100762 if (emit->pass == PASS_3) {
Damien George30565092014-03-31 11:30:17 +0100763 printf("MAKE_FUNCTION %d\n", (n_kw_defaults << 8) | n_pos_defaults);
Damien429d7192013-10-04 19:53:11 +0100764 }
765}
766
Damien George30565092014-03-31 11:30:17 +0100767STATIC 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 +0100768 load_cpy_const_code_and_name(emit, scope->simple_name);
Damien George30565092014-03-31 11:30:17 +0100769 emit_pre(emit, -2 - n_pos_defaults - 2 * n_kw_defaults, 3);
Damien429d7192013-10-04 19:53:11 +0100770 if (emit->pass == PASS_3) {
Damien George30565092014-03-31 11:30:17 +0100771 printf("MAKE_CLOSURE %d\n", (n_kw_defaults << 8) | n_pos_defaults);
Damien429d7192013-10-04 19:53:11 +0100772 }
773}
774
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200775STATIC void emit_cpy_yield_value(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100776 emit_pre(emit, 0, 1);
777 if (emit->pass == PASS_2) {
Paul Sokolovsky5fd7bc32014-02-16 03:02:47 +0200778 emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR;
Damien429d7192013-10-04 19:53:11 +0100779 }
780 if (emit->pass == PASS_3) {
781 printf("YIELD_VALUE\n");
782 }
783}
784
Paul Sokolovsky520e2f52014-02-12 18:31:30 +0200785STATIC void emit_cpy_yield_from(emit_t *emit) {
Damien429d7192013-10-04 19:53:11 +0100786 emit_pre(emit, -1, 1);
787 if (emit->pass == PASS_2) {
Paul Sokolovsky5fd7bc32014-02-16 03:02:47 +0200788 emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR;
Damien429d7192013-10-04 19:53:11 +0100789 }
790 if (emit->pass == PASS_3) {
791 printf("YIELD_FROM\n");
792 }
793}
794
Damien6cdd3af2013-10-05 18:08:26 +0100795const emit_method_table_t emit_cpython_method_table = {
Damien415eb6f2013-10-05 12:19:06 +0100796 emit_cpy_set_native_types,
797 emit_cpy_start_pass,
798 emit_cpy_end_pass,
799 emit_cpy_last_emit_was_return_value,
Damien Georged66ae182014-04-10 17:28:54 +0000800 emit_cpy_adjust_stack_size,
Damien George08335002014-01-18 23:24:36 +0000801 emit_cpy_set_source_line,
Damien415eb6f2013-10-05 12:19:06 +0100802
Damien4b03e772013-10-05 14:17:09 +0100803 emit_cpy_load_id,
804 emit_cpy_store_id,
805 emit_cpy_delete_id,
806
Damien415eb6f2013-10-05 12:19:06 +0100807 emit_cpy_label_assign,
808 emit_cpy_import_name,
809 emit_cpy_import_from,
810 emit_cpy_import_star,
811 emit_cpy_load_const_tok,
812 emit_cpy_load_const_small_int,
813 emit_cpy_load_const_int,
814 emit_cpy_load_const_dec,
815 emit_cpy_load_const_id,
816 emit_cpy_load_const_str,
Damien415eb6f2013-10-05 12:19:06 +0100817 emit_cpy_load_const_verbatim_str,
Damien415eb6f2013-10-05 12:19:06 +0100818 emit_cpy_load_fast,
Damien415eb6f2013-10-05 12:19:06 +0100819 emit_cpy_load_deref,
820 emit_cpy_load_closure,
Damien9ecbcff2013-12-11 00:41:43 +0000821 emit_cpy_load_name,
822 emit_cpy_load_global,
Damien415eb6f2013-10-05 12:19:06 +0100823 emit_cpy_load_attr,
824 emit_cpy_load_method,
825 emit_cpy_load_build_class,
Damien George729f7b42014-04-17 22:10:53 +0100826 emit_cpy_load_subscr,
Damien415eb6f2013-10-05 12:19:06 +0100827 emit_cpy_store_fast,
Damien9ecbcff2013-12-11 00:41:43 +0000828 emit_cpy_store_deref,
Damien415eb6f2013-10-05 12:19:06 +0100829 emit_cpy_store_name,
830 emit_cpy_store_global,
Damien415eb6f2013-10-05 12:19:06 +0100831 emit_cpy_store_attr,
Damien415eb6f2013-10-05 12:19:06 +0100832 emit_cpy_store_subscr,
833 emit_cpy_delete_fast,
Damien9ecbcff2013-12-11 00:41:43 +0000834 emit_cpy_delete_deref,
Damien415eb6f2013-10-05 12:19:06 +0100835 emit_cpy_delete_name,
836 emit_cpy_delete_global,
Damien415eb6f2013-10-05 12:19:06 +0100837 emit_cpy_delete_attr,
838 emit_cpy_delete_subscr,
839 emit_cpy_dup_top,
840 emit_cpy_dup_top_two,
841 emit_cpy_pop_top,
842 emit_cpy_rot_two,
843 emit_cpy_rot_three,
844 emit_cpy_jump,
845 emit_cpy_pop_jump_if_true,
846 emit_cpy_pop_jump_if_false,
847 emit_cpy_jump_if_true_or_pop,
848 emit_cpy_jump_if_false_or_pop,
849 emit_cpy_setup_loop,
850 emit_cpy_break_loop,
851 emit_cpy_continue_loop,
852 emit_cpy_setup_with,
853 emit_cpy_with_cleanup,
854 emit_cpy_setup_except,
855 emit_cpy_setup_finally,
856 emit_cpy_end_finally,
857 emit_cpy_get_iter,
858 emit_cpy_for_iter,
859 emit_cpy_for_iter_end,
860 emit_cpy_pop_block,
861 emit_cpy_pop_except,
862 emit_cpy_unary_op,
863 emit_cpy_binary_op,
Damien415eb6f2013-10-05 12:19:06 +0100864 emit_cpy_build_tuple,
865 emit_cpy_build_list,
866 emit_cpy_list_append,
867 emit_cpy_build_map,
868 emit_cpy_store_map,
869 emit_cpy_map_add,
870 emit_cpy_build_set,
871 emit_cpy_set_add,
872 emit_cpy_build_slice,
873 emit_cpy_unpack_sequence,
874 emit_cpy_unpack_ex,
875 emit_cpy_make_function,
876 emit_cpy_make_closure,
877 emit_cpy_call_function,
878 emit_cpy_call_method,
879 emit_cpy_return_value,
880 emit_cpy_raise_varargs,
881 emit_cpy_yield_value,
882 emit_cpy_yield_from,
883};
884
Damien3ef4abb2013-10-12 16:53:13 +0100885#endif // MICROPY_EMIT_CPYTHON