Numworks Epsilon  1.4.1
Graphing Calculator Operating System
modbuiltins.c
Go to the documentation of this file.
1 /*
2  * This file is part of the MicroPython project, http://micropython.org/
3  *
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2013, 2014 Damien P. George
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  */
26 
27 #include <stdio.h>
28 #include <assert.h>
29 
30 #include "py/smallint.h"
31 #include "py/objint.h"
32 #include "py/objstr.h"
33 #include "py/objtype.h"
34 #include "py/runtime.h"
35 #include "py/builtin.h"
36 #include "py/stream.h"
37 
38 #if MICROPY_PY_BUILTINS_FLOAT
39 #include <math.h>
40 #endif
41 
42 #if MICROPY_PY_IO
43 extern struct _mp_dummy_t mp_sys_stdout_obj; // type is irrelevant, just need pointer
44 #endif
45 
46 // args[0] is function from class body
47 // args[1] is class name
48 // args[2:] are base objects
50  assert(2 <= n_args);
51 
52  // set the new classes __locals__ object
53  mp_obj_dict_t *old_locals = mp_locals_get();
54  mp_obj_t class_locals = mp_obj_new_dict(0);
55  mp_locals_set(MP_OBJ_TO_PTR(class_locals));
56 
57  // call the class code
58  mp_obj_t cell = mp_call_function_0(args[0]);
59 
60  // restore old __locals__ object
61  mp_locals_set(old_locals);
62 
63  // get the class type (meta object) from the base objects
64  mp_obj_t meta;
65  if (n_args == 2) {
66  // no explicit bases, so use 'type'
68  } else {
69  // use type of first base object
71  }
72 
73  // TODO do proper metaclass resolution for multiple base objects
74 
75  // create the new class using a call to the meta object
76  mp_obj_t meta_args[3];
77  meta_args[0] = args[1]; // class name
78  meta_args[1] = mp_obj_new_tuple(n_args - 2, args + 2); // tuple of bases
79  meta_args[2] = class_locals; // dict of members
80  mp_obj_t new_class = mp_call_function_n_kw(meta, 3, 0, meta_args);
81 
82  // store into cell if neede
83  if (cell != mp_const_none) {
84  mp_obj_cell_set(cell, new_class);
85  }
86 
87  return new_class;
88 }
89 MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj, 2, mp_builtin___build_class__);
90 
92  return mp_unary_op(MP_UNARY_OP_ABS, o_in);
93 }
94 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs);
95 
97  mp_obj_iter_buf_t iter_buf;
98  mp_obj_t iterable = mp_getiter(o_in, &iter_buf);
99  mp_obj_t item;
100  while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
101  if (!mp_obj_is_true(item)) {
102  return mp_const_false;
103  }
104  }
105  return mp_const_true;
106 }
107 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all);
108 
110  mp_obj_iter_buf_t iter_buf;
111  mp_obj_t iterable = mp_getiter(o_in, &iter_buf);
112  mp_obj_t item;
113  while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
114  if (mp_obj_is_true(item)) {
115  return mp_const_true;
116  }
117  }
118  return mp_const_false;
119 }
120 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_any_obj, mp_builtin_any);
121 
123  mp_obj_t args[] = { MP_OBJ_NEW_QSTR(MP_QSTR__brace_open__colon__hash_b_brace_close_), o_in };
125 }
126 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bin_obj, mp_builtin_bin);
127 
129  if (mp_obj_is_callable(o_in)) {
130  return mp_const_true;
131  } else {
132  return mp_const_false;
133  }
134 }
135 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable);
136 
138  #if MICROPY_PY_BUILTINS_STR_UNICODE
139  mp_uint_t c = mp_obj_get_int(o_in);
140  char str[4];
141  int len = 0;
142  if (c < 0x80) {
143  *str = c; len = 1;
144  } else if (c < 0x800) {
145  str[0] = (c >> 6) | 0xC0;
146  str[1] = (c & 0x3F) | 0x80;
147  len = 2;
148  } else if (c < 0x10000) {
149  str[0] = (c >> 12) | 0xE0;
150  str[1] = ((c >> 6) & 0x3F) | 0x80;
151  str[2] = (c & 0x3F) | 0x80;
152  len = 3;
153  } else if (c < 0x110000) {
154  str[0] = (c >> 18) | 0xF0;
155  str[1] = ((c >> 12) & 0x3F) | 0x80;
156  str[2] = ((c >> 6) & 0x3F) | 0x80;
157  str[3] = (c & 0x3F) | 0x80;
158  len = 4;
159  } else {
160  mp_raise_ValueError("chr() arg not in range(0x110000)");
161  }
162  return mp_obj_new_str(str, len, true);
163  #else
164  mp_int_t ord = mp_obj_get_int(o_in);
165  if (0 <= ord && ord <= 0xff) {
166  char str[1] = {ord};
167  return mp_obj_new_str(str, 1, true);
168  } else {
169  mp_raise_ValueError("chr() arg not in range(256)");
170  }
171  #endif
172 }
173 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_chr_obj, mp_builtin_chr);
174 
175 STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
176  // TODO make this function more general and less of a hack
177 
178  mp_obj_dict_t *dict = NULL;
179  mp_map_t *members = NULL;
180  if (n_args == 0) {
181  // make a list of names in the local name space
182  dict = mp_locals_get();
183  } else { // n_args == 1
184  // make a list of names in the given object
185  if (MP_OBJ_IS_TYPE(args[0], &mp_type_module)) {
186  dict = mp_obj_module_get_globals(args[0]);
187  } else {
188  mp_obj_type_t *type;
189  if (MP_OBJ_IS_TYPE(args[0], &mp_type_type)) {
190  type = MP_OBJ_TO_PTR(args[0]);
191  } else {
192  type = mp_obj_get_type(args[0]);
193  }
194  if (type->locals_dict != NULL && type->locals_dict->base.type == &mp_type_dict) {
195  dict = type->locals_dict;
196  }
197  }
200  members = &inst->members;
201  }
202  }
203 
204  mp_obj_t dir = mp_obj_new_list(0, NULL);
205  if (dict != NULL) {
206  for (size_t i = 0; i < dict->map.alloc; i++) {
207  if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) {
208  mp_obj_list_append(dir, dict->map.table[i].key);
209  }
210  }
211  }
212  if (members != NULL) {
213  for (size_t i = 0; i < members->alloc; i++) {
214  if (MP_MAP_SLOT_IS_FILLED(members, i)) {
215  mp_obj_list_append(dir, members->table[i].key);
216  }
217  }
218  }
219  return dir;
220 }
221 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj, 0, 1, mp_builtin_dir);
222 
224  return mp_binary_op(MP_BINARY_OP_DIVMOD, o1_in, o2_in);
225 }
226 MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj, mp_builtin_divmod);
227 
229  // result is guaranteed to be a (small) int
230  return mp_unary_op(MP_UNARY_OP_HASH, o_in);
231 }
232 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash);
233 
235  return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_x), o_in);
236 }
237 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex);
238 
239 #if MICROPY_PY_BUILTINS_INPUT
240 
241 #include "py/mphal.h"
242 #include "lib/mp-readline/readline.h"
243 
244 // A port can define mp_hal_readline if they want to use a custom function here
245 #ifndef mp_hal_readline
246 #define mp_hal_readline readline
247 #endif
248 
249 STATIC mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
250  if (n_args == 1) {
252  }
253  vstr_t line;
254  vstr_init(&line, 16);
255  int ret = mp_hal_readline(&line, "");
256  if (ret == CHAR_CTRL_C) {
258  }
259  if (line.len == 0 && ret == CHAR_CTRL_D) {
261  }
262  return mp_obj_new_str_from_vstr(&mp_type_str, &line);
263 }
264 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_input_obj, 0, 1, mp_builtin_input);
265 
266 #endif
267 
269  return mp_getiter(o_in, NULL);
270 }
271 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter);
272 
273 #if MICROPY_PY_BUILTINS_MIN_MAX
274 
275 STATIC mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs, mp_uint_t op) {
276  mp_map_elem_t *key_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_key), MP_MAP_LOOKUP);
277  mp_map_elem_t *default_elem;
278  mp_obj_t key_fn = key_elem == NULL ? MP_OBJ_NULL : key_elem->value;
279  if (n_args == 1) {
280  // given an iterable
281  mp_obj_iter_buf_t iter_buf;
282  mp_obj_t iterable = mp_getiter(args[0], &iter_buf);
283  mp_obj_t best_key = MP_OBJ_NULL;
284  mp_obj_t best_obj = MP_OBJ_NULL;
285  mp_obj_t item;
286  while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
287  mp_obj_t key = key_fn == MP_OBJ_NULL ? item : mp_call_function_1(key_fn, item);
288  if (best_obj == MP_OBJ_NULL || (mp_binary_op(op, key, best_key) == mp_const_true)) {
289  best_key = key;
290  best_obj = item;
291  }
292  }
293  if (best_obj == MP_OBJ_NULL) {
294  default_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_default), MP_MAP_LOOKUP);
295  if (default_elem != NULL) {
296  best_obj = default_elem->value;
297  } else {
298  mp_raise_ValueError("arg is an empty sequence");
299  }
300  }
301  return best_obj;
302  } else {
303  // given many args
304  mp_obj_t best_key = MP_OBJ_NULL;
305  mp_obj_t best_obj = MP_OBJ_NULL;
306  for (size_t i = 0; i < n_args; i++) {
307  mp_obj_t key = key_fn == MP_OBJ_NULL ? args[i] : mp_call_function_1(key_fn, args[i]);
308  if (best_obj == MP_OBJ_NULL || (mp_binary_op(op, key, best_key) == mp_const_true)) {
309  best_key = key;
310  best_obj = args[i];
311  }
312  }
313  return best_obj;
314  }
315 }
316 
317 STATIC mp_obj_t mp_builtin_max(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
318  return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_MORE);
319 }
320 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_max_obj, 1, mp_builtin_max);
321 
322 STATIC mp_obj_t mp_builtin_min(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
323  return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_LESS);
324 }
325 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min);
326 
327 #endif
328 
331  if (ret == MP_OBJ_STOP_ITERATION) {
333  } else {
334  return ret;
335  }
336 }
337 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next);
338 
340  return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_o), o_in);
341 }
342 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct);
343 
345  size_t len;
346  const char *str = mp_obj_str_get_data(o_in, &len);
347  #if MICROPY_PY_BUILTINS_STR_UNICODE
348  if (MP_OBJ_IS_STR(o_in)) {
349  len = unichar_charlen(str, len);
350  if (len == 1) {
351  return mp_obj_new_int(utf8_get_char((const byte*)str));
352  }
353  } else
354  #endif
355  {
356  // a bytes object, or a str without unicode support (don't sign extend the char)
357  if (len == 1) {
358  return MP_OBJ_NEW_SMALL_INT(((const byte*)str)[0]);
359  }
360  }
361 
363  mp_raise_TypeError("ord expects a character");
364  } else {
366  "ord() expected a character, but string of length %d found", (int)len));
367  }
368 }
369 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord);
370 
371 STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
372  switch (n_args) {
373  case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
374  default:
375 #if !MICROPY_PY_BUILTINS_POW3
376  mp_raise_msg(&mp_type_NotImplementedError, "3-arg pow() not supported");
377 #elif MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_MPZ
379 #else
380  return mp_obj_int_pow3(args[0], args[1], args[2]);
381 #endif
382  }
383 }
384 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow);
385 
386 STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
387  mp_map_elem_t *sep_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_sep), MP_MAP_LOOKUP);
388  mp_map_elem_t *end_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_end), MP_MAP_LOOKUP);
389  const char *sep_data = " ";
390  size_t sep_len = 1;
391  const char *end_data = "\n";
392  size_t end_len = 1;
393  if (sep_elem != NULL && sep_elem->value != mp_const_none) {
394  sep_data = mp_obj_str_get_data(sep_elem->value, &sep_len);
395  }
396  if (end_elem != NULL && end_elem->value != mp_const_none) {
397  end_data = mp_obj_str_get_data(end_elem->value, &end_len);
398  }
399  #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
400  void *stream_obj = &mp_sys_stdout_obj;
401  mp_map_elem_t *file_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_file), MP_MAP_LOOKUP);
402  if (file_elem != NULL && file_elem->value != mp_const_none) {
403  stream_obj = MP_OBJ_TO_PTR(file_elem->value); // XXX may not be a concrete object
404  }
405 
406  mp_print_t print = {stream_obj, mp_stream_write_adaptor};
407  #endif
408  for (size_t i = 0; i < n_args; i++) {
409  if (i > 0) {
410  #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
411  mp_stream_write_adaptor(stream_obj, sep_data, sep_len);
412  #else
413  mp_print_strn(&mp_plat_print, sep_data, sep_len, 0, 0, 0);
414  #endif
415  }
416  #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
417  mp_obj_print_helper(&print, args[i], PRINT_STR);
418  #else
420  #endif
421  }
422  #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
423  mp_stream_write_adaptor(stream_obj, end_data, end_len);
424  #else
425  mp_print_strn(&mp_plat_print, end_data, end_len, 0, 0, 0);
426  #endif
427  return mp_const_none;
428 }
429 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print);
430 
432  if (o != mp_const_none) {
435  #if MICROPY_CAN_OVERRIDE_BUILTINS
436  // Set "_" special variable
437  mp_obj_t dest[2] = {MP_OBJ_SENTINEL, o};
439  #endif
440  }
441  return mp_const_none;
442 }
443 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin___repl_print___obj, mp_builtin___repl_print__);
444 
446  vstr_t vstr;
447  mp_print_t print;
448  vstr_init_print(&vstr, 16, &print);
449  mp_obj_print_helper(&print, o_in, PRINT_REPR);
450  return mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
451 }
452 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr);
453 
454 STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args) {
455  mp_obj_t o_in = args[0];
456  if (MP_OBJ_IS_INT(o_in)) {
457  return o_in;
458  }
459 #if MICROPY_PY_BUILTINS_FLOAT
460  mp_int_t num_dig = 0;
461  if (n_args > 1) {
462  num_dig = mp_obj_get_int(args[1]);
463  mp_float_t val = mp_obj_get_float(o_in);
464  mp_float_t mult = MICROPY_FLOAT_C_FUN(pow)(10, num_dig);
465  // TODO may lead to overflow
466  mp_float_t rounded = MICROPY_FLOAT_C_FUN(nearbyint)(val * mult) / mult;
467  return mp_obj_new_float(rounded);
468  }
469  mp_float_t val = mp_obj_get_float(o_in);
470  mp_float_t rounded = MICROPY_FLOAT_C_FUN(nearbyint)(val);
471  return mp_obj_new_int_from_float(rounded);
472 #else
473  mp_int_t r = mp_obj_get_int(o_in);
474  return mp_obj_new_int(r);
475 #endif
476 }
477 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_round_obj, 1, 2, mp_builtin_round);
478 
479 STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
480  mp_obj_t value;
481  switch (n_args) {
482  case 1: value = MP_OBJ_NEW_SMALL_INT(0); break;
483  default: value = args[1]; break;
484  }
485  mp_obj_iter_buf_t iter_buf;
486  mp_obj_t iterable = mp_getiter(args[0], &iter_buf);
487  mp_obj_t item;
488  while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
489  value = mp_binary_op(MP_BINARY_OP_ADD, value, item);
490  }
491  return value;
492 }
493 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum);
494 
495 STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
496  if (n_args > 1) {
497  mp_raise_TypeError("must use keyword argument for key function");
498  }
500  mp_obj_list_sort(1, &self, kwargs);
501 
502  return self;
503 }
504 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_sorted_obj, 1, mp_builtin_sorted);
505 
506 // See mp_load_attr() if making any changes
507 static inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t defval) {
508  mp_obj_t dest[2];
509  // use load_method, raising or not raising exception
510  ((defval == MP_OBJ_NULL) ? mp_load_method : mp_load_method_maybe)(base, attr, dest);
511  if (dest[0] == MP_OBJ_NULL) {
512  return defval;
513  } else if (dest[1] == MP_OBJ_NULL) {
514  // load_method returned just a normal attribute
515  return dest[0];
516  } else {
517  // load_method returned a method, so build a bound method object
518  return mp_obj_new_bound_meth(dest[0], dest[1]);
519  }
520 }
521 
523  mp_obj_t defval = MP_OBJ_NULL;
524  if (n_args > 2) {
525  defval = args[2];
526  }
527  return mp_load_attr_default(args[0], mp_obj_str_get_qstr(args[1]), defval);
528 }
529 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_getattr_obj, 2, 3, mp_builtin_getattr);
530 
532  mp_store_attr(base, mp_obj_str_get_qstr(attr), value);
533  return mp_const_none;
534 }
535 MP_DEFINE_CONST_FUN_OBJ_3(mp_builtin_setattr_obj, mp_builtin_setattr);
536 
537 #if MICROPY_CPYTHON_COMPAT
538 STATIC mp_obj_t mp_builtin_delattr(mp_obj_t base, mp_obj_t attr) {
539  return mp_builtin_setattr(base, attr, MP_OBJ_NULL);
540 }
541 MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_delattr_obj, mp_builtin_delattr);
542 #endif
543 
545  qstr attr = mp_obj_str_get_qstr(attr_in);
546 
547  mp_obj_t dest[2];
548  // TODO: https://docs.python.org/3/library/functions.html?highlight=hasattr#hasattr
549  // explicitly says "This is implemented by calling getattr(object, name) and seeing
550  // whether it raises an AttributeError or not.", so we should explicitly wrap this
551  // in nlr_push and handle exception.
552  mp_load_method_maybe(object_in, attr, dest);
553 
554  return mp_obj_new_bool(dest[0] != MP_OBJ_NULL);
555 }
556 MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj, mp_builtin_hasattr);
557 
559  return MP_OBJ_FROM_PTR(mp_globals_get());
560 }
561 MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_globals_obj, mp_builtin_globals);
562 
564  return MP_OBJ_FROM_PTR(mp_locals_get());
565 }
566 MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_locals_obj, mp_builtin_locals);
567 
568 // These are defined in terms of MicroPython API functions right away
569 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_obj_id);
570 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_len_obj, mp_obj_len);
571 
573  { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_builtins) },
574 
575  // built-in core functions
576  { MP_ROM_QSTR(MP_QSTR___build_class__), MP_ROM_PTR(&mp_builtin___build_class___obj) },
577  { MP_ROM_QSTR(MP_QSTR___import__), MP_ROM_PTR(&mp_builtin___import___obj) },
578  { MP_ROM_QSTR(MP_QSTR___repl_print__), MP_ROM_PTR(&mp_builtin___repl_print___obj) },
579 
580  // built-in types
581  { MP_ROM_QSTR(MP_QSTR_bool), MP_ROM_PTR(&mp_type_bool) },
582  { MP_ROM_QSTR(MP_QSTR_bytes), MP_ROM_PTR(&mp_type_bytes) },
583  #if MICROPY_PY_BUILTINS_BYTEARRAY
584  { MP_ROM_QSTR(MP_QSTR_bytearray), MP_ROM_PTR(&mp_type_bytearray) },
585  #endif
586  #if MICROPY_PY_BUILTINS_COMPLEX
587  { MP_ROM_QSTR(MP_QSTR_complex), MP_ROM_PTR(&mp_type_complex) },
588  #endif
589  { MP_ROM_QSTR(MP_QSTR_dict), MP_ROM_PTR(&mp_type_dict) },
590  #if MICROPY_PY_BUILTINS_ENUMERATE
591  { MP_ROM_QSTR(MP_QSTR_enumerate), MP_ROM_PTR(&mp_type_enumerate) },
592  #endif
593  #if MICROPY_PY_BUILTINS_FILTER
594  { MP_ROM_QSTR(MP_QSTR_filter), MP_ROM_PTR(&mp_type_filter) },
595  #endif
596  #if MICROPY_PY_BUILTINS_FLOAT
597  { MP_ROM_QSTR(MP_QSTR_float), MP_ROM_PTR(&mp_type_float) },
598  #endif
599  #if MICROPY_PY_BUILTINS_SET && MICROPY_PY_BUILTINS_FROZENSET
600  { MP_ROM_QSTR(MP_QSTR_frozenset), MP_ROM_PTR(&mp_type_frozenset) },
601  #endif
602  { MP_ROM_QSTR(MP_QSTR_int), MP_ROM_PTR(&mp_type_int) },
603  { MP_ROM_QSTR(MP_QSTR_list), MP_ROM_PTR(&mp_type_list) },
604  { MP_ROM_QSTR(MP_QSTR_map), MP_ROM_PTR(&mp_type_map) },
605  #if MICROPY_PY_BUILTINS_MEMORYVIEW
606  { MP_ROM_QSTR(MP_QSTR_memoryview), MP_ROM_PTR(&mp_type_memoryview) },
607  #endif
608  { MP_ROM_QSTR(MP_QSTR_object), MP_ROM_PTR(&mp_type_object) },
609  #if MICROPY_PY_BUILTINS_PROPERTY
610  { MP_ROM_QSTR(MP_QSTR_property), MP_ROM_PTR(&mp_type_property) },
611  #endif
612  { MP_ROM_QSTR(MP_QSTR_range), MP_ROM_PTR(&mp_type_range) },
613  #if MICROPY_PY_BUILTINS_REVERSED
614  { MP_ROM_QSTR(MP_QSTR_reversed), MP_ROM_PTR(&mp_type_reversed) },
615  #endif
616  #if MICROPY_PY_BUILTINS_SET
617  { MP_ROM_QSTR(MP_QSTR_set), MP_ROM_PTR(&mp_type_set) },
618  #endif
619  #if MICROPY_PY_BUILTINS_SLICE
620  { MP_ROM_QSTR(MP_QSTR_slice), MP_ROM_PTR(&mp_type_slice) },
621  #endif
622  { MP_ROM_QSTR(MP_QSTR_str), MP_ROM_PTR(&mp_type_str) },
623  { MP_ROM_QSTR(MP_QSTR_super), MP_ROM_PTR(&mp_type_super) },
624  { MP_ROM_QSTR(MP_QSTR_tuple), MP_ROM_PTR(&mp_type_tuple) },
625  { MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&mp_type_type) },
626  { MP_ROM_QSTR(MP_QSTR_zip), MP_ROM_PTR(&mp_type_zip) },
627 
628  { MP_ROM_QSTR(MP_QSTR_classmethod), MP_ROM_PTR(&mp_type_classmethod) },
629  { MP_ROM_QSTR(MP_QSTR_staticmethod), MP_ROM_PTR(&mp_type_staticmethod) },
630 
631  // built-in objects
632  { MP_ROM_QSTR(MP_QSTR_Ellipsis), MP_ROM_PTR(&mp_const_ellipsis_obj) },
633  #if MICROPY_PY_BUILTINS_NOTIMPLEMENTED
634  { MP_ROM_QSTR(MP_QSTR_NotImplemented), MP_ROM_PTR(&mp_const_notimplemented_obj) },
635  #endif
636 
637  // built-in user functions
638  { MP_ROM_QSTR(MP_QSTR_abs), MP_ROM_PTR(&mp_builtin_abs_obj) },
639  { MP_ROM_QSTR(MP_QSTR_all), MP_ROM_PTR(&mp_builtin_all_obj) },
640  { MP_ROM_QSTR(MP_QSTR_any), MP_ROM_PTR(&mp_builtin_any_obj) },
641  { MP_ROM_QSTR(MP_QSTR_bin), MP_ROM_PTR(&mp_builtin_bin_obj) },
642  { MP_ROM_QSTR(MP_QSTR_callable), MP_ROM_PTR(&mp_builtin_callable_obj) },
643  #if MICROPY_PY_BUILTINS_COMPILE
644  { MP_ROM_QSTR(MP_QSTR_compile), MP_ROM_PTR(&mp_builtin_compile_obj) },
645  #endif
646  { MP_ROM_QSTR(MP_QSTR_chr), MP_ROM_PTR(&mp_builtin_chr_obj) },
647  #if MICROPY_CPYTHON_COMPAT
648  { MP_ROM_QSTR(MP_QSTR_delattr), MP_ROM_PTR(&mp_builtin_delattr_obj) },
649  #endif
650  { MP_ROM_QSTR(MP_QSTR_dir), MP_ROM_PTR(&mp_builtin_dir_obj) },
651  { MP_ROM_QSTR(MP_QSTR_divmod), MP_ROM_PTR(&mp_builtin_divmod_obj) },
652  #if MICROPY_PY_BUILTINS_EVAL_EXEC
653  { MP_ROM_QSTR(MP_QSTR_eval), MP_ROM_PTR(&mp_builtin_eval_obj) },
654  { MP_ROM_QSTR(MP_QSTR_exec), MP_ROM_PTR(&mp_builtin_exec_obj) },
655  #endif
656  #if MICROPY_PY_BUILTINS_EXECFILE
657  { MP_ROM_QSTR(MP_QSTR_execfile), MP_ROM_PTR(&mp_builtin_execfile_obj) },
658  #endif
659  { MP_ROM_QSTR(MP_QSTR_getattr), MP_ROM_PTR(&mp_builtin_getattr_obj) },
660  { MP_ROM_QSTR(MP_QSTR_setattr), MP_ROM_PTR(&mp_builtin_setattr_obj) },
661  { MP_ROM_QSTR(MP_QSTR_globals), MP_ROM_PTR(&mp_builtin_globals_obj) },
662  { MP_ROM_QSTR(MP_QSTR_hasattr), MP_ROM_PTR(&mp_builtin_hasattr_obj) },
663  { MP_ROM_QSTR(MP_QSTR_hash), MP_ROM_PTR(&mp_builtin_hash_obj) },
664  #if MICROPY_PY_BUILTINS_HELP
665  { MP_ROM_QSTR(MP_QSTR_help), MP_ROM_PTR(&mp_builtin_help_obj) },
666  #endif
667  { MP_ROM_QSTR(MP_QSTR_hex), MP_ROM_PTR(&mp_builtin_hex_obj) },
668  { MP_ROM_QSTR(MP_QSTR_id), MP_ROM_PTR(&mp_builtin_id_obj) },
669  #if MICROPY_PY_BUILTINS_INPUT
670  { MP_ROM_QSTR(MP_QSTR_input), MP_ROM_PTR(&mp_builtin_input_obj) },
671  #endif
672  { MP_ROM_QSTR(MP_QSTR_isinstance), MP_ROM_PTR(&mp_builtin_isinstance_obj) },
673  { MP_ROM_QSTR(MP_QSTR_issubclass), MP_ROM_PTR(&mp_builtin_issubclass_obj) },
674  { MP_ROM_QSTR(MP_QSTR_iter), MP_ROM_PTR(&mp_builtin_iter_obj) },
675  { MP_ROM_QSTR(MP_QSTR_len), MP_ROM_PTR(&mp_builtin_len_obj) },
676  { MP_ROM_QSTR(MP_QSTR_locals), MP_ROM_PTR(&mp_builtin_locals_obj) },
677  #if MICROPY_PY_BUILTINS_MIN_MAX
678  { MP_ROM_QSTR(MP_QSTR_max), MP_ROM_PTR(&mp_builtin_max_obj) },
679  { MP_ROM_QSTR(MP_QSTR_min), MP_ROM_PTR(&mp_builtin_min_obj) },
680  #endif
681  { MP_ROM_QSTR(MP_QSTR_next), MP_ROM_PTR(&mp_builtin_next_obj) },
682  { MP_ROM_QSTR(MP_QSTR_oct), MP_ROM_PTR(&mp_builtin_oct_obj) },
683  { MP_ROM_QSTR(MP_QSTR_ord), MP_ROM_PTR(&mp_builtin_ord_obj) },
684  { MP_ROM_QSTR(MP_QSTR_pow), MP_ROM_PTR(&mp_builtin_pow_obj) },
685  { MP_ROM_QSTR(MP_QSTR_print), MP_ROM_PTR(&mp_builtin_print_obj) },
686  { MP_ROM_QSTR(MP_QSTR_repr), MP_ROM_PTR(&mp_builtin_repr_obj) },
687  { MP_ROM_QSTR(MP_QSTR_round), MP_ROM_PTR(&mp_builtin_round_obj) },
688  { MP_ROM_QSTR(MP_QSTR_sorted), MP_ROM_PTR(&mp_builtin_sorted_obj) },
689  { MP_ROM_QSTR(MP_QSTR_sum), MP_ROM_PTR(&mp_builtin_sum_obj) },
690 
691  // built-in exceptions
692  { MP_ROM_QSTR(MP_QSTR_BaseException), MP_ROM_PTR(&mp_type_BaseException) },
693  { MP_ROM_QSTR(MP_QSTR_ArithmeticError), MP_ROM_PTR(&mp_type_ArithmeticError) },
694  { MP_ROM_QSTR(MP_QSTR_AssertionError), MP_ROM_PTR(&mp_type_AssertionError) },
695  { MP_ROM_QSTR(MP_QSTR_AttributeError), MP_ROM_PTR(&mp_type_AttributeError) },
696  { MP_ROM_QSTR(MP_QSTR_EOFError), MP_ROM_PTR(&mp_type_EOFError) },
697  { MP_ROM_QSTR(MP_QSTR_Exception), MP_ROM_PTR(&mp_type_Exception) },
698  { MP_ROM_QSTR(MP_QSTR_GeneratorExit), MP_ROM_PTR(&mp_type_GeneratorExit) },
699  { MP_ROM_QSTR(MP_QSTR_ImportError), MP_ROM_PTR(&mp_type_ImportError) },
700  { MP_ROM_QSTR(MP_QSTR_IndentationError), MP_ROM_PTR(&mp_type_IndentationError) },
701  { MP_ROM_QSTR(MP_QSTR_IndexError), MP_ROM_PTR(&mp_type_IndexError) },
702  { MP_ROM_QSTR(MP_QSTR_KeyboardInterrupt), MP_ROM_PTR(&mp_type_KeyboardInterrupt) },
703  { MP_ROM_QSTR(MP_QSTR_KeyError), MP_ROM_PTR(&mp_type_KeyError) },
704  { MP_ROM_QSTR(MP_QSTR_LookupError), MP_ROM_PTR(&mp_type_LookupError) },
705  { MP_ROM_QSTR(MP_QSTR_MemoryError), MP_ROM_PTR(&mp_type_MemoryError) },
706  { MP_ROM_QSTR(MP_QSTR_NameError), MP_ROM_PTR(&mp_type_NameError) },
707  { MP_ROM_QSTR(MP_QSTR_NotImplementedError), MP_ROM_PTR(&mp_type_NotImplementedError) },
708  { MP_ROM_QSTR(MP_QSTR_OSError), MP_ROM_PTR(&mp_type_OSError) },
709  { MP_ROM_QSTR(MP_QSTR_OverflowError), MP_ROM_PTR(&mp_type_OverflowError) },
710  { MP_ROM_QSTR(MP_QSTR_RuntimeError), MP_ROM_PTR(&mp_type_RuntimeError) },
711  #if MICROPY_PY_ASYNC_AWAIT
712  { MP_ROM_QSTR(MP_QSTR_StopAsyncIteration), MP_ROM_PTR(&mp_type_StopAsyncIteration) },
713  #endif
714  { MP_ROM_QSTR(MP_QSTR_StopIteration), MP_ROM_PTR(&mp_type_StopIteration) },
715  { MP_ROM_QSTR(MP_QSTR_SyntaxError), MP_ROM_PTR(&mp_type_SyntaxError) },
716  { MP_ROM_QSTR(MP_QSTR_SystemExit), MP_ROM_PTR(&mp_type_SystemExit) },
717  { MP_ROM_QSTR(MP_QSTR_TypeError), MP_ROM_PTR(&mp_type_TypeError) },
718  #if MICROPY_PY_BUILTINS_STR_UNICODE
719  { MP_ROM_QSTR(MP_QSTR_UnicodeError), MP_ROM_PTR(&mp_type_UnicodeError) },
720  #endif
721  { MP_ROM_QSTR(MP_QSTR_ValueError), MP_ROM_PTR(&mp_type_ValueError) },
722  #if MICROPY_EMIT_NATIVE
723  { MP_ROM_QSTR(MP_QSTR_ViperTypeError), MP_ROM_PTR(&mp_type_ViperTypeError) },
724  #endif
725  { MP_ROM_QSTR(MP_QSTR_ZeroDivisionError), MP_ROM_PTR(&mp_type_ZeroDivisionError) },
726  // Somehow CPython managed to have OverflowError not inherit from ValueError ;-/
727  // TODO: For MICROPY_CPYTHON_COMPAT==0 use ValueError to avoid exc proliferation
728 
729  // Extra builtins as defined by a port
731 };
732 
734 
736  .base = { &mp_type_module },
738 };
const mp_print_t mp_plat_print
Definition: mpprint.c:51
STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[]
Definition: modbuiltins.c:572
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj, 0, 1, mp_builtin_dir)
qstr mp_obj_str_get_qstr(mp_obj_t self_in)
Definition: objstr.c:2082
const mp_obj_type_t mp_type_reversed
const mp_obj_dict_t mp_module_builtins_globals
mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg)
Definition: runtime.c:216
intptr_t mp_int_t
Definition: mpconfigport.h:73
uintptr_t mp_uint_t
Definition: mpconfigport.h:74
const mp_obj_type_t mp_type_set
const mp_obj_type_t mp_type_KeyboardInterrupt
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg)
Definition: runtime.c:1448
Definition: misc.h:142
STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o)
Definition: modbuiltins.c:431
const mp_obj_type_t mp_type_EOFError
mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items)
Definition: objtuple.c:235
const mp_obj_type_t mp_type_SystemExit
const mp_obj_type_t mp_type_AssertionError
void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest)
Definition: runtime.c:1040
const mp_obj_type_t mp_type_float
#define assert(e)
Definition: assert.h:9
#define MICROPY_ERROR_REPORTING_TERSE
Definition: mpconfig.h:521
const mp_obj_type_t mp_type_bytearray
#define mp_const_none
Definition: obj.h:614
MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj, mp_builtin_divmod)
const mp_obj_type_t mp_type_ZeroDivisionError
const mp_obj_type_t mp_type_memoryview
mp_make_new_fun_t make_new
Definition: obj.h:484
const mp_obj_type_t mp_type_TypeError
STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in)
Definition: modbuiltins.c:109
#define MP_OBJ_IS_TYPE(o, t)
Definition: obj.h:254
STATIC const uint8_t attr[]
Definition: unicode.c:51
STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in)
Definition: modbuiltins.c:137
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt,...)
Definition: objexcept.c:380
mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type)
Definition: objexcept.c:329
STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args)
Definition: modbuiltins.c:175
STATIC mp_obj_t mp_builtin_print(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs)
Definition: modbuiltins.c:386
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print)
const mp_obj_type_t mp_type_StopIteration
STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in)
Definition: modbuiltins.c:339
void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind)
Definition: obj.c:76
#define MP_OBJ_SENTINEL
Definition: obj.h:75
mp_obj_type_t * mp_obj_get_type(mp_const_obj_t o_in)
Definition: obj.c:40
const mp_obj_type_t mp_type_filter
int mp_print_str(const mp_print_t *print, const char *str)
Definition: mpprint.c:53
void vstr_init(vstr_t *vstr, size_t alloc)
Definition: vstr.c:40
const mp_obj_type_t mp_type_NotImplementedError
#define MP_ROM_QSTR(q)
Definition: obj.h:241
STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in)
Definition: modbuiltins.c:223
#define MP_OBJ_FROM_PTR(p)
Definition: obj.h:233
const mp_obj_type_t mp_type_Exception
#define MP_OBJ_NEW_QSTR(qst)
Definition: obj.h:92
const mp_obj_type_t mp_type_ViperTypeError
const mp_obj_type_t mp_type_super
Definition: objtype.c:1125
STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in)
Definition: modbuiltins.c:544
const mp_obj_type_t mp_type_ImportError
#define MP_ROM_PTR(p)
Definition: obj.h:242
#define mp_const_true
Definition: obj.h:616
const mp_obj_type_t mp_type_bytes
Definition: objstr.c:1964
#define MP_ARRAY_SIZE(a)
Definition: misc.h:106
mp_obj_t mp_obj_new_list(size_t n, mp_obj_t *items)
Definition: objlist.c:470
mp_obj_t key
Definition: obj.h:342
size_t len
Definition: misc.h:144
mp_obj_base_t base
Definition: obj.h:814
const mp_obj_type_t mp_type_LookupError
size_t alloc
Definition: obj.h:361
mp_int_t mp_obj_get_int(mp_const_obj_t arg)
Definition: obj.c:225
mp_obj_base_t base
Definition: obj.h:765
mp_obj_dict_t * mp_obj_module_get_globals(mp_obj_t self_in)
Definition: objmodule.c:125
STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in)
Definition: modbuiltins.c:228
mp_obj_t mp_call_function_0(mp_obj_t fun)
Definition: runtime.c:599
#define STATIC
Definition: mpconfig.h:1178
mp_obj_t mp_obj_new_dict(size_t n_args)
Definition: objdict.c:584
STATIC mp_obj_t mp_builtin_bin(mp_obj_t o_in)
Definition: modbuiltins.c:122
const mp_obj_type_t mp_type_NameError
STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in)
Definition: modbuiltins.c:445
MP_DEFINE_CONST_DICT(mp_module_builtins_globals, mp_module_builtins_globals_table)
const mp_obj_type_t mp_type_SyntaxError
void mp_load_method(mp_obj_t base, qstr attr, mp_obj_t *dest)
Definition: runtime.c:1076
mp_map_elem_t * mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind)
Definition: map.c:138
mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg)
Definition: objlist.c:234
const mp_obj_type_t mp_type_complex
STATIC mp_obj_t mp_builtin_round(size_t n_args, const mp_obj_t *args)
Definition: modbuiltins.c:454
c(generic_all_nodes)
const mp_obj_type_t mp_type_StopAsyncIteration
#define MP_OBJ_NEW_SMALL_INT(small_int)
Definition: obj.h:87
#define MICROPY_ERROR_REPORTING
Definition: mpconfigport.h:32
const mp_obj_type_t mp_type_staticmethod
Definition: objtype.c:1241
mp_obj_t mp_call_function_1(mp_obj_t fun, mp_obj_t arg)
Definition: runtime.c:603
STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs)
Definition: modbuiltins.c:495
mp_obj_t mp_obj_id(mp_obj_t o_in)
Definition: obj.c:414
mp_map_t members
Definition: objtype.h:35
#define MICROPY_PORT_BUILTINS
Definition: mpconfigport.h:83
const char * mp_obj_str_get_data(mp_obj_t self_in, size_t *len)
Definition: objstr.c:2105
#define NULL
Definition: stddef.h:4
#define MP_OBJ_NULL
Definition: obj.h:73
const mp_obj_type_t mp_type_OSError
#define MP_PYTHON_PRINTER
Definition: mpprint.h:45
STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in)
Definition: modbuiltins.c:268
const mp_obj_type_t mp_type_frozenset
STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in)
Definition: modbuiltins.c:344
const mp_obj_type_t mp_type_range
Definition: objrange.c:192
void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind)
Definition: obj.c:59
size_t qstr
Definition: qstr.h:48
#define pow(x, y)
Definition: math.h:190
const mp_obj_type_t mp_type_str
Definition: objstr.c:1950
mp_obj_t mp_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs)
Definition: runtime.c:277
mp_obj_t value
Definition: obj.h:343
STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in)
Definition: modbuiltins.c:91
bool mp_obj_is_callable(mp_obj_t o_in)
Definition: obj.c:141
const mp_obj_type_t mp_type_ValueError
mp_obj_t mp_obj_new_str(const char *data, size_t len, bool make_qstr_if_not_already)
Definition: objstr.c:2025
const mp_obj_type_t mp_type_MemoryError
STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in)
Definition: modbuiltins.c:128
const struct _mp_obj_singleton_t mp_const_notimplemented_obj
const mp_obj_type_t mp_type_GeneratorExit
mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in)
Definition: runtime.c:1162
STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args)
Definition: modbuiltins.c:371
args
Definition: i18n.py:175
#define MP_OBJ_IS_INT(o)
Definition: obj.h:255
const mp_obj_type_t mp_type_object
Definition: objobject.c:74
mp_obj_t mp_obj_new_int(mp_int_t value)
Definition: objint.c:353
STATIC mp_obj_t mp_builtin_setattr(mp_obj_t base, mp_obj_t attr, mp_obj_t value)
Definition: modbuiltins.c:531
const mp_obj_module_t mp_module_builtins
Definition: modbuiltins.c:735
Definition: obj.h:356
unsigned char byte
Definition: misc.h:37
MP_DEFINE_CONST_FUN_OBJ_3(mp_builtin_setattr_obj, mp_builtin_setattr)
mp_obj_t mp_obj_new_str_from_vstr(const mp_obj_type_t *type, vstr_t *vstr)
Definition: objstr.c:1998
STATIC mp_obj_t mp_builtin_getattr(size_t n_args, const mp_obj_t *args)
Definition: modbuiltins.c:522
STATIC mp_obj_t mp_builtin_next(mp_obj_t o)
Definition: modbuiltins.c:329
const mp_obj_type_t mp_type_UnicodeError
void mp_stream_write_adaptor(void *self, const char *buf, size_t len)
Definition: stream.c:262
const mp_obj_type_t mp_type_type
Definition: objtype.c:969
const mp_obj_type_t mp_type_AttributeError
const mp_obj_type_t mp_type_bool
Definition: obj.h:543
MP_DEFINE_CONST_FUN_OBJ_0(mp_builtin_globals_obj, mp_builtin_globals)
const mp_obj_type_t mp_type_ArithmeticError
const mp_obj_type_t mp_type_IndexError
NORETURN void mp_raise_ValueError(const char *msg)
Definition: runtime.c:1456
void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj)
Definition: objcell.c:39
const struct _mp_obj_singleton_t mp_const_ellipsis_obj
Definition: objsingleton.c:52
unichar utf8_get_char(const byte *s)
Definition: unicode.c:71
const mp_obj_type_t mp_type_IndentationError
MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj, 2, mp_builtin___build_class__)
STATIC mp_obj_t mp_builtin_locals(void)
Definition: modbuiltins.c:563
mp_obj_t mp_obj_new_bound_meth(mp_obj_t meth, mp_obj_t self)
Definition: objboundmeth.c:103
mp_attr_fun_t attr
Definition: obj.h:505
const mp_obj_type_t mp_type_map
Definition: objmap.c:67
mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs)
Definition: objlist.c:315
const mp_obj_type_t mp_type_slice
#define MP_OBJ_TO_PTR(o)
Definition: obj.h:228
Definition: obj.h:413
const mp_obj_type_t mp_type_tuple
Definition: objtuple.c:220
const mp_obj_type_t mp_type_dict
Definition: objdict.c:552
const mp_obj_type_t mp_type_module
Definition: objmodule.c:94
mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf)
Definition: runtime.c:1120
#define nlr_raise(val)
Definition: nlr.h:89
void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value)
Definition: runtime.c:1100
STATIC mp_obj_t mp_builtin___build_class__(size_t n_args, const mp_obj_t *args)
Definition: modbuiltins.c:49
int mp_print_strn(const mp_print_t *print, const char *str, size_t len, int flags, char fill, int width)
Definition: mpprint.c:61
const mp_obj_type_t mp_type_classmethod
Definition: objtype.c:1247
#define MP_OBJ_STOP_ITERATION
Definition: obj.h:74
mp_map_t map
Definition: obj.h:766
uint64_t mp_obj_t
Definition: obj.h:39
mp_obj_t mp_iternext(mp_obj_t o_in)
Definition: runtime.c:1186
mp_map_elem_t * table
Definition: obj.h:362
mp_obj_t mp_call_function_n_kw(mp_obj_t fun_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
Definition: runtime.c:615
mp_obj_t mp_obj_len(mp_obj_t o_in)
Definition: obj.c:433
const mp_obj_type_t mp_type_int
Definition: obj.h:544
#define MP_OBJ_IS_STR(o)
Definition: obj.h:256
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs)
#define mp_obj_is_instance_type(type)
Definition: objtype.h:47
STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args)
Definition: modbuiltins.c:479
const mp_obj_type_t mp_type_property
STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in)
Definition: modbuiltins.c:96
NORETURN void mp_raise_TypeError(const char *msg)
Definition: runtime.c:1460
mp_uint_t unichar_charlen(const char *str, mp_uint_t len)
Definition: unicode.c:113
double nearbyint(double x)
Definition: nearbyint.c:7
const mp_obj_type_t mp_type_list
Definition: objlist.c:444
const mp_obj_type_t mp_type_zip
Definition: objzip.c:70
void vstr_init_print(vstr_t *vstr, size_t alloc, struct _mp_print_t *print)
Definition: vstr.c:64
bool mp_obj_is_true(mp_obj_t arg)
Definition: obj.c:108
const mp_obj_type_t mp_type_KeyError
STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in)
Definition: modbuiltins.c:234
const mp_obj_type_t mp_type_BaseException
Definition: objexcept.c:229
mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs)
Definition: objstr.c:1364
const mp_obj_type_t mp_type_OverflowError
mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus)
#define mp_const_false
Definition: obj.h:615
struct _mp_obj_dict_t * locals_dict
Definition: obj.h:536
const mp_obj_type_t mp_type_RuntimeError
STATIC mp_obj_t mp_builtin_globals(void)
Definition: modbuiltins.c:558
const mp_obj_type_t mp_type_enumerate
mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args)
Definition: builtins.c:11