Skip to content

Commit d17926d

Browse files
committed
Rename rt_* to mp_*.
Mostly just a global search and replace. Except rt_is_true which becomes mp_obj_is_true. Still would like to tidy up some of the names, but this will do for now.
1 parent 09d2077 commit d17926d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+988
-983
lines changed

py/builtin.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ STATIC mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {
2222
assert(2 <= n_args);
2323

2424
// we differ from CPython: we set the new __locals__ object here
25-
mp_map_t *old_locals = rt_locals_get();
25+
mp_map_t *old_locals = mp_locals_get();
2626
mp_obj_t class_locals = mp_obj_new_dict(0);
27-
rt_locals_set(mp_obj_dict_get_map(class_locals));
27+
mp_locals_set(mp_obj_dict_get_map(class_locals));
2828

2929
// call the class code
30-
mp_obj_t cell = rt_call_function_1(args[0], (mp_obj_t)0xdeadbeef);
30+
mp_obj_t cell = mp_call_function_1(args[0], (mp_obj_t)0xdeadbeef);
3131

3232
// restore old __locals__ object
33-
rt_locals_set(old_locals);
33+
mp_locals_set(old_locals);
3434

3535
// get the class type (meta object) from the base objects
3636
mp_obj_t meta;
@@ -49,7 +49,7 @@ STATIC mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {
4949
meta_args[0] = args[1]; // class name
5050
meta_args[1] = mp_obj_new_tuple(n_args - 2, args + 2); // tuple of bases
5151
meta_args[2] = class_locals; // dict of members
52-
mp_obj_t new_class = rt_call_function_n_kw(meta, 3, 0, meta_args);
52+
mp_obj_t new_class = mp_call_function_n_kw(meta, 3, 0, meta_args);
5353

5454
// store into cell if neede
5555
if (cell != mp_const_none) {
@@ -101,10 +101,10 @@ mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
101101
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs);
102102

103103
STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
104-
mp_obj_t iterable = rt_getiter(o_in);
104+
mp_obj_t iterable = mp_getiter(o_in);
105105
mp_obj_t item;
106-
while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
107-
if (!rt_is_true(item)) {
106+
while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
107+
if (!mp_obj_is_true(item)) {
108108
return mp_const_false;
109109
}
110110
}
@@ -114,10 +114,10 @@ STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
114114
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all);
115115

116116
STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
117-
mp_obj_t iterable = rt_getiter(o_in);
117+
mp_obj_t iterable = mp_getiter(o_in);
118118
mp_obj_t item;
119-
while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
120-
if (rt_is_true(item)) {
119+
while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
120+
if (mp_obj_is_true(item)) {
121121
return mp_const_true;
122122
}
123123
}
@@ -154,7 +154,7 @@ STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
154154
mp_map_t *map = NULL;
155155
if (n_args == 0) {
156156
// make a list of names in the local name space
157-
map = rt_locals_get();
157+
map = mp_locals_get();
158158
} else { // n_args == 1
159159
// make a list of names in the given object
160160
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) {
193193
mp_obj_t args[2];
194194
args[0] = MP_OBJ_NEW_SMALL_INT(i1 / i2);
195195
args[1] = MP_OBJ_NEW_SMALL_INT(i1 % i2);
196-
return rt_build_tuple(2, args);
196+
return mp_build_tuple(2, args);
197197
} else {
198198
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)));
199199
}
@@ -209,7 +209,7 @@ STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
209209
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash);
210210

211211
STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
212-
return rt_getiter(o_in);
212+
return mp_getiter(o_in);
213213
}
214214

215215
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);
228228
STATIC mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {
229229
if (n_args == 1) {
230230
// given an iterable
231-
mp_obj_t iterable = rt_getiter(args[0]);
231+
mp_obj_t iterable = mp_getiter(args[0]);
232232
mp_obj_t max_obj = NULL;
233233
mp_obj_t item;
234-
while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
234+
while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
235235
if (max_obj == NULL || mp_obj_less(max_obj, item)) {
236236
max_obj = item;
237237
}
@@ -257,10 +257,10 @@ MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_max_obj, 1, mp_builtin_max);
257257
STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
258258
if (n_args == 1) {
259259
// given an iterable
260-
mp_obj_t iterable = rt_getiter(args[0]);
260+
mp_obj_t iterable = mp_getiter(args[0]);
261261
mp_obj_t min_obj = NULL;
262262
mp_obj_t item;
263-
while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
263+
while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
264264
if (min_obj == NULL || mp_obj_less(item, min_obj)) {
265265
min_obj = item;
266266
}
@@ -284,7 +284,7 @@ STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
284284
MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_min_obj, 1, mp_builtin_min);
285285

286286
STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
287-
mp_obj_t ret = rt_iternext_allow_raise(o);
287+
mp_obj_t ret = mp_iternext_allow_raise(o);
288288
if (ret == MP_OBJ_NULL) {
289289
nlr_jump(mp_obj_new_exception(&mp_type_StopIteration));
290290
} else {
@@ -311,8 +311,8 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord);
311311
STATIC mp_obj_t mp_builtin_pow(uint n_args, const mp_obj_t *args) {
312312
assert(2 <= n_args && n_args <= 3);
313313
switch (n_args) {
314-
case 2: return rt_binary_op(RT_BINARY_OP_POWER, args[0], args[1]);
315-
default: return rt_binary_op(RT_BINARY_OP_MODULO, rt_binary_op(RT_BINARY_OP_POWER, args[0], args[1]), args[2]); // TODO optimise...
314+
case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
315+
default: return mp_binary_op(MP_BINARY_OP_MODULO, mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]), args[2]); // TODO optimise...
316316
}
317317
}
318318

@@ -359,10 +359,10 @@ STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {
359359
case 1: value = mp_obj_new_int(0); break;
360360
default: value = args[1]; break;
361361
}
362-
mp_obj_t iterable = rt_getiter(args[0]);
362+
mp_obj_t iterable = mp_getiter(args[0]);
363363
mp_obj_t item;
364-
while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
365-
value = rt_binary_op(RT_BINARY_OP_ADD, value, item);
364+
while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
365+
value = mp_binary_op(MP_BINARY_OP_ADD, value, item);
366366
}
367367
return value;
368368
}
@@ -391,7 +391,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_builtin_id);
391391

392392
STATIC mp_obj_t mp_builtin_getattr(mp_obj_t o_in, mp_obj_t attr) {
393393
assert(MP_OBJ_IS_QSTR(attr));
394-
return rt_load_attr(o_in, MP_OBJ_QSTR_VALUE(attr));
394+
return mp_load_attr(o_in, MP_OBJ_QSTR_VALUE(attr));
395395
}
396396

397397
MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_getattr_obj, mp_builtin_getattr);

py/builtinevex.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ STATIC mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse
4343
}
4444

4545
// complied successfully, execute it
46-
return rt_call_function_0(module_fun);
46+
return mp_call_function_0(module_fun);
4747
}
4848

4949
STATIC mp_obj_t mp_builtin_eval(mp_obj_t o_in) {
@@ -55,8 +55,8 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_eval_obj, mp_builtin_eval);
5555
STATIC mp_obj_t mp_builtin_exec(uint n_args, const mp_obj_t *args) {
5656
// Unconditional getting/setting assumes that these operations
5757
// are cheap, which is the case when this comment was written.
58-
mp_map_t *old_globals = rt_globals_get();
59-
mp_map_t *old_locals = rt_locals_get();
58+
mp_map_t *old_globals = mp_globals_get();
59+
mp_map_t *old_locals = mp_locals_get();
6060
if (n_args > 1) {
6161
mp_obj_t globals = args[1];
6262
mp_obj_t locals;
@@ -65,13 +65,13 @@ STATIC mp_obj_t mp_builtin_exec(uint n_args, const mp_obj_t *args) {
6565
} else {
6666
locals = globals;
6767
}
68-
rt_globals_set(mp_obj_dict_get_map(globals));
69-
rt_locals_set(mp_obj_dict_get_map(locals));
68+
mp_globals_set(mp_obj_dict_get_map(globals));
69+
mp_locals_set(mp_obj_dict_get_map(locals));
7070
}
7171
mp_obj_t res = parse_compile_execute(args[0], MP_PARSE_FILE_INPUT);
7272
// TODO if the above call throws an exception, then we never get to reset the globals/locals
73-
rt_globals_set(old_globals);
74-
rt_locals_set(old_locals);
73+
mp_globals_set(old_globals);
74+
mp_locals_set(old_locals);
7575
return res;
7676
}
7777

py/builtinimport.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#define PATH_SEP_CHAR '/'
2424

25-
mp_obj_t sys_path;
25+
mp_obj_t mp_sys_path;
2626

2727
mp_import_stat_t stat_dir_or_file(vstr_t *path) {
2828
//printf("stat %s\n", vstr_str(path));
@@ -42,12 +42,12 @@ mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) {
4242
// extract the list of paths
4343
uint path_num = 0;
4444
mp_obj_t *path_items;
45-
if (sys_path != MP_OBJ_NULL) {
46-
mp_obj_list_get(sys_path, &path_num, &path_items);
45+
if (mp_sys_path != MP_OBJ_NULL) {
46+
mp_obj_list_get(mp_sys_path, &path_num, &path_items);
4747
}
4848

4949
if (path_num == 0) {
50-
// sys_path is empty, so just use the given file name
50+
// mp_sys_path is empty, so just use the given file name
5151
vstr_add_strn(dest, file_str, file_len);
5252
return stat_dir_or_file(dest);
5353
} else {
@@ -84,12 +84,12 @@ void do_load(mp_obj_t module_obj, vstr_t *file) {
8484
qstr source_name = mp_lexer_source_name(lex);
8585

8686
// save the old context
87-
mp_map_t *old_locals = rt_locals_get();
88-
mp_map_t *old_globals = rt_globals_get();
87+
mp_map_t *old_locals = mp_locals_get();
88+
mp_map_t *old_globals = mp_globals_get();
8989

9090
// set the new context
91-
rt_locals_set(mp_obj_module_get_globals(module_obj));
92-
rt_globals_set(mp_obj_module_get_globals(module_obj));
91+
mp_locals_set(mp_obj_module_get_globals(module_obj));
92+
mp_globals_set(mp_obj_module_get_globals(module_obj));
9393

9494
// parse the imported script
9595
mp_parse_error_kind_t parse_error_kind;
@@ -98,8 +98,8 @@ void do_load(mp_obj_t module_obj, vstr_t *file) {
9898

9999
if (pn == MP_PARSE_NODE_NULL) {
100100
// parse error; clean up and raise exception
101-
rt_locals_set(old_locals);
102-
rt_globals_set(old_globals);
101+
mp_locals_set(old_locals);
102+
mp_globals_set(old_globals);
103103
nlr_jump(mp_parse_make_exception(parse_error_kind));
104104
}
105105

@@ -109,24 +109,24 @@ void do_load(mp_obj_t module_obj, vstr_t *file) {
109109

110110
if (module_fun == mp_const_none) {
111111
// TODO handle compile error correctly
112-
rt_locals_set(old_locals);
113-
rt_globals_set(old_globals);
112+
mp_locals_set(old_locals);
113+
mp_globals_set(old_globals);
114114
return;
115115
}
116116

117117
// complied successfully, execute it
118118
nlr_buf_t nlr;
119119
if (nlr_push(&nlr) == 0) {
120-
rt_call_function_0(module_fun);
120+
mp_call_function_0(module_fun);
121121
nlr_pop();
122122
} else {
123123
// exception; restore context and re-raise same exception
124-
rt_locals_set(old_locals);
125-
rt_globals_set(old_globals);
124+
mp_locals_set(old_locals);
125+
mp_globals_set(old_globals);
126126
nlr_jump(nlr.ret_val);
127127
}
128-
rt_locals_set(old_locals);
129-
rt_globals_set(old_globals);
128+
mp_locals_set(old_locals);
129+
mp_globals_set(old_globals);
130130
}
131131

132132
mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
@@ -228,7 +228,7 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
228228
}
229229
if (outer_module_obj != MP_OBJ_NULL) {
230230
qstr s = qstr_from_strn(mod_str + last, i - last);
231-
rt_store_attr(outer_module_obj, s, module_obj);
231+
mp_store_attr(outer_module_obj, s, module_obj);
232232
}
233233
outer_module_obj = module_obj;
234234
if (top_module_obj == MP_OBJ_NULL) {

0 commit comments

Comments
 (0)