summaryrefslogtreecommitdiffstatshomepage
path: root/py/bc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-11-27 17:01:44 +0000
committerDamien George <damien.p.george@gmail.com>2015-11-29 14:25:35 +0000
commit999cedb90ff0827cdb9dfe0e4faa6ebc1739d271 (patch)
tree897eb07b82f1893cfd413b9ef7f625cd996f859d /py/bc.c
parentcbf7674025814797f5c537d6d1c195efe58ccaaf (diff)
downloadmicropython-999cedb90ff0827cdb9dfe0e4faa6ebc1739d271.tar.gz
micropython-999cedb90ff0827cdb9dfe0e4faa6ebc1739d271.zip
py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.
This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
Diffstat (limited to 'py/bc.c')
-rw-r--r--py/bc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/py/bc.c b/py/bc.c
index 909edb603b..84dc3291a8 100644
--- a/py/bc.c
+++ b/py/bc.c
@@ -68,7 +68,7 @@ STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, mp_uint_t expecte
#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
"%q() takes %d positional arguments but %d were given",
- mp_obj_fun_get_name(f), expected, given));
+ mp_obj_fun_get_name(MP_OBJ_FROM_PTR(f)), expected, given));
#endif
}
@@ -95,7 +95,7 @@ void mp_setup_code_state(mp_code_state *code_state, mp_obj_fun_bc_t *self, mp_ui
mp_uint_t n_state = code_state->n_state;
// ip comes in as an offset into bytecode, so turn it into a true pointer
- code_state->ip = self->bytecode + (mp_uint_t)code_state->ip;
+ code_state->ip = self->bytecode + (size_t)code_state->ip;
// store pointer to constant table
code_state->const_table = self->const_table;
@@ -219,7 +219,7 @@ continue2:;
if (code_state->state[n_state - 1 - n_pos_args - i] == MP_OBJ_NULL) {
mp_map_elem_t *elem = NULL;
if ((scope_flags & MP_SCOPE_FLAG_DEFKWARGS) != 0) {
- elem = mp_map_lookup(&((mp_obj_dict_t*)self->extra_args[n_def_pos_args])->map, arg_names[n_pos_args + i], MP_MAP_LOOKUP);
+ elem = mp_map_lookup(&((mp_obj_dict_t*)MP_OBJ_TO_PTR(self->extra_args[n_def_pos_args]))->map, arg_names[n_pos_args + i], MP_MAP_LOOKUP);
}
if (elem != NULL) {
code_state->state[n_state - 1 - n_pos_args - i] = elem->value;