Commit 9fc7933f authored by Damien's avatar Damien
Browse files

Add py_get_qstr.

parent e9f1e50b
......@@ -514,7 +514,7 @@ py_obj_t py_builtin___build_class__(py_obj_t o_class_fun, py_obj_t o_class_name)
}
py_obj_t py_builtin_range(py_obj_t o_arg) {
return py_obj_new_range(0, rt_get_int(o_arg), 1);
return py_obj_new_range(0, py_get_int(o_arg), 1);
}
#ifdef WRITE_NATIVE
......@@ -845,7 +845,7 @@ int rt_is_true(py_obj_t arg) {
}
}
int rt_get_int(py_obj_t arg) {
int py_get_int(py_obj_t arg) {
if (arg == py_const_false) {
return 0;
} else if (arg == py_const_true) {
......@@ -858,6 +858,15 @@ int rt_get_int(py_obj_t arg) {
}
}
qstr py_get_qstr(py_obj_t arg) {
if (IS_O(arg, O_STR)) {
return ((py_obj_base_t*)arg)->u_str;
} else {
assert(0);
return 0;
}
}
py_obj_t rt_load_const_str(qstr qstr) {
DEBUG_OP_printf("load '%s'\n", qstr_str(qstr));
return py_obj_new_str(qstr);
......
......@@ -97,7 +97,8 @@ void rt_assign_native_code(int unique_code_id, py_fun_t f, uint len, int n_args)
void rt_assign_inline_asm_code(int unique_code_id, py_fun_t f, uint len, int n_args);
void py_obj_print(py_obj_t o);
int rt_is_true(py_obj_t arg);
int rt_get_int(py_obj_t arg);
int py_get_int(py_obj_t arg);
qstr py_get_qstr(py_obj_t arg);
py_obj_t rt_load_const_str(qstr qstr);
py_obj_t rt_load_name(qstr qstr);
py_obj_t rt_load_global(qstr qstr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment