summaryrefslogtreecommitdiffstatshomepage
path: root/py/builtin.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/builtin.c')
-rw-r--r--py/builtin.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/py/builtin.c b/py/builtin.c
index 6d3fc9029f..a8a7009708 100644
--- a/py/builtin.c
+++ b/py/builtin.c
@@ -22,15 +22,15 @@ STATIC mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {
assert(2 <= n_args);
// we differ from CPython: we set the new __locals__ object here
- mp_map_t *old_locals = rt_locals_get();
+ mp_map_t *old_locals = mp_locals_get();
mp_obj_t class_locals = mp_obj_new_dict(0);
- rt_locals_set(mp_obj_dict_get_map(class_locals));
+ mp_locals_set(mp_obj_dict_get_map(class_locals));
// call the class code
- mp_obj_t cell = rt_call_function_1(args[0], (mp_obj_t)0xdeadbeef);
+ mp_obj_t cell = mp_call_function_1(args[0], (mp_obj_t)0xdeadbeef);
// restore old __locals__ object
- rt_locals_set(old_locals);
+ mp_locals_set(old_locals);
// get the class type (meta object) from the base objects
mp_obj_t meta;
@@ -49,7 +49,7 @@ STATIC mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {
meta_args[0] = args[1]; // class name
meta_args[1] = mp_obj_new_tuple(n_args - 2, args + 2); // tuple of bases
meta_args[2] = class_locals; // dict of members
- mp_obj_t new_class = rt_call_function_n_kw(meta, 3, 0, meta_args);
+ mp_obj_t new_class = mp_call_function_n_kw(meta, 3, 0, meta_args);
// store into cell if neede
if (cell != mp_const_none) {
@@ -101,10 +101,10 @@ mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs);
STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
- mp_obj_t iterable = rt_getiter(o_in);
+ mp_obj_t iterable = mp_getiter(o_in);
mp_obj_t item;
- while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
- if (!rt_is_true(item)) {
+ while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
+ if (!mp_obj_is_true(item)) {
return mp_const_false;
}
}
@@ -114,10 +114,10 @@ STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all);
STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
- mp_obj_t iterable = rt_getiter(o_in);
+ mp_obj_t iterable = mp_getiter(o_in);
mp_obj_t item;
- while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
- if (rt_is_true(item)) {
+ while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
+ if (mp_obj_is_true(item)) {
return mp_const_true;
}
}
@@ -154,7 +154,7 @@ STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
mp_map_t *map = NULL;
if (n_args == 0) {
// make a list of names in the local name space
- map = rt_locals_get();
+ map = mp_locals_get();
} else { // n_args == 1
// make a list of names in the given object
if (MP_OBJ_IS_TYPE(args[0], &mp_type_module)) {
@@ -193,7 +193,7 @@ STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
mp_obj_t args[2];
args[0] = MP_OBJ_NEW_SMALL_INT(i1 / i2);
args[1] = MP_OBJ_NEW_SMALL_INT(i1 % i2);
- return rt_build_tuple(2, args);
+ return mp_build_tuple(2, args);
} else {
nlr_jump(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "unsupported operand type(s) for divmod(): '%s' and '%s'", mp_obj_get_type_str(o1_in), mp_obj_get_type_str(o2_in)));
}
@@ -209,7 +209,7 @@ STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash);
STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
- return rt_getiter(o_in);
+ return mp_getiter(o_in);
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter);
@@ -228,10 +228,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_len_obj, mp_builtin_len);
STATIC mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {
if (n_args == 1) {
// given an iterable
- mp_obj_t iterable = rt_getiter(args[0]);
+ mp_obj_t iterable = mp_getiter(args[0]);
mp_obj_t max_obj = NULL;
mp_obj_t item;
- while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
+ while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
if (max_obj == NULL || mp_obj_less(max_obj, item)) {
max_obj = item;
}
@@ -257,10 +257,10 @@ MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_max_obj, 1, mp_builtin_max);
STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
if (n_args == 1) {
// given an iterable
- mp_obj_t iterable = rt_getiter(args[0]);
+ mp_obj_t iterable = mp_getiter(args[0]);
mp_obj_t min_obj = NULL;
mp_obj_t item;
- while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
+ while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
if (min_obj == NULL || mp_obj_less(item, min_obj)) {
min_obj = item;
}
@@ -284,7 +284,7 @@ STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_min_obj, 1, mp_builtin_min);
STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
- mp_obj_t ret = rt_iternext_allow_raise(o);
+ mp_obj_t ret = mp_iternext_allow_raise(o);
if (ret == MP_OBJ_NULL) {
nlr_jump(mp_obj_new_exception(&mp_type_StopIteration));
} else {
@@ -311,8 +311,8 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord);
STATIC mp_obj_t mp_builtin_pow(uint n_args, const mp_obj_t *args) {
assert(2 <= n_args && n_args <= 3);
switch (n_args) {
- case 2: return rt_binary_op(RT_BINARY_OP_POWER, args[0], args[1]);
- default: return rt_binary_op(RT_BINARY_OP_MODULO, rt_binary_op(RT_BINARY_OP_POWER, args[0], args[1]), args[2]); // TODO optimise...
+ case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
+ default: return mp_binary_op(MP_BINARY_OP_MODULO, mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]), args[2]); // TODO optimise...
}
}
@@ -359,10 +359,10 @@ STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {
case 1: value = mp_obj_new_int(0); break;
default: value = args[1]; break;
}
- mp_obj_t iterable = rt_getiter(args[0]);
+ mp_obj_t iterable = mp_getiter(args[0]);
mp_obj_t item;
- while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
- value = rt_binary_op(RT_BINARY_OP_ADD, value, item);
+ while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
+ value = mp_binary_op(MP_BINARY_OP_ADD, value, item);
}
return value;
}
@@ -391,7 +391,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_builtin_id);
STATIC mp_obj_t mp_builtin_getattr(mp_obj_t o_in, mp_obj_t attr) {
assert(MP_OBJ_IS_QSTR(attr));
- return rt_load_attr(o_in, MP_OBJ_QSTR_VALUE(attr));
+ return mp_load_attr(o_in, MP_OBJ_QSTR_VALUE(attr));
}
MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_getattr_obj, mp_builtin_getattr);