From ce8f07adcd47c9e5c6edbb42f855f06eb08b88e6 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 27 Mar 2014 23:30:26 +0000 Subject: [PATCH] py: Rename emit_pre so they have globally unique names. --- py/emitbc.c | 159 ++++++++++++++++++++++++------------------------ py/emitnative.c | 49 ++++++++------- 2 files changed, 103 insertions(+), 105 deletions(-) diff --git a/py/emitbc.c b/py/emitbc.c index ac3fc80095..43b2d36d44 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -317,8 +317,7 @@ STATIC void emit_bc_delete_id(emit_t *emit, qstr qstr) { emit_common_delete_id(emit, &emit_bc_method_table, emit->scope, qstr); } -// TODO: module-polymorphic function (read: name clash if made global) -static void emit_pre(emit_t *emit, int stack_size_delta) { +STATIC void emit_bc_pre(emit_t *emit, int stack_size_delta) { emit->stack_size += stack_size_delta; if (emit->stack_size > emit->scope->stack_size) { emit->scope->stack_size = emit->stack_size; @@ -327,7 +326,7 @@ static void emit_pre(emit_t *emit, int stack_size_delta) { } STATIC void emit_bc_label_assign(emit_t *emit, int l) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); assert(l < emit->max_num_labels); if (emit->pass == PASS_2) { // assign label offset @@ -341,22 +340,22 @@ STATIC void emit_bc_label_assign(emit_t *emit, int l) { } STATIC void emit_bc_import_name(emit_t *emit, qstr qstr) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_qstr(emit, MP_BC_IMPORT_NAME, qstr); } STATIC void emit_bc_import_from(emit_t *emit, qstr qstr) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_qstr(emit, MP_BC_IMPORT_FROM, qstr); } STATIC void emit_bc_import_star(emit_t *emit) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte(emit, MP_BC_IMPORT_STAR); } STATIC void emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); switch (tok) { case MP_TOKEN_KW_FALSE: emit_write_byte_code_byte(emit, MP_BC_LOAD_CONST_FALSE); break; case MP_TOKEN_KW_NONE: emit_write_byte_code_byte(emit, MP_BC_LOAD_CONST_NONE); break; @@ -367,27 +366,27 @@ STATIC void emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) { } STATIC void emit_bc_load_const_small_int(emit_t *emit, machine_int_t arg) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_int(emit, MP_BC_LOAD_CONST_SMALL_INT, arg); } STATIC void emit_bc_load_const_int(emit_t *emit, qstr qstr) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_CONST_INT, qstr); } STATIC void emit_bc_load_const_dec(emit_t *emit, qstr qstr) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_CONST_DEC, qstr); } STATIC void emit_bc_load_const_id(emit_t *emit, qstr qstr) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_CONST_ID, qstr); } STATIC void emit_bc_load_const_str(emit_t *emit, qstr qstr, bool bytes) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); if (bytes) { emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_CONST_BYTES, qstr); } else { @@ -402,7 +401,7 @@ STATIC void emit_bc_load_const_verbatim_str(emit_t *emit, const char *str) { STATIC void emit_bc_load_fast(emit_t *emit, qstr qstr, int local_num) { assert(local_num >= 0); - emit_pre(emit, 1); + emit_bc_pre(emit, 1); switch (local_num) { case 0: emit_write_byte_code_byte(emit, MP_BC_LOAD_FAST_0); break; case 1: emit_write_byte_code_byte(emit, MP_BC_LOAD_FAST_1); break; @@ -412,7 +411,7 @@ STATIC void emit_bc_load_fast(emit_t *emit, qstr qstr, int local_num) { } STATIC void emit_bc_load_deref(emit_t *emit, qstr qstr, int local_num) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_uint(emit, MP_BC_LOAD_DEREF, local_num); } @@ -422,33 +421,33 @@ STATIC void emit_bc_load_closure(emit_t *emit, qstr qstr, int local_num) { } STATIC void emit_bc_load_name(emit_t *emit, qstr qstr) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_NAME, qstr); } STATIC void emit_bc_load_global(emit_t *emit, qstr qstr) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_GLOBAL, qstr); } STATIC void emit_bc_load_attr(emit_t *emit, qstr qstr) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_ATTR, qstr); } STATIC void emit_bc_load_method(emit_t *emit, qstr qstr) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_METHOD, qstr); } STATIC void emit_bc_load_build_class(emit_t *emit) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte(emit, MP_BC_LOAD_BUILD_CLASS); } STATIC void emit_bc_store_fast(emit_t *emit, qstr qstr, int local_num) { assert(local_num >= 0); - emit_pre(emit, -1); + emit_bc_pre(emit, -1); switch (local_num) { case 0: emit_write_byte_code_byte(emit, MP_BC_STORE_FAST_0); break; case 1: emit_write_byte_code_byte(emit, MP_BC_STORE_FAST_1); break; @@ -458,119 +457,119 @@ STATIC void emit_bc_store_fast(emit_t *emit, qstr qstr, int local_num) { } STATIC void emit_bc_store_deref(emit_t *emit, qstr qstr, int local_num) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_uint(emit, MP_BC_STORE_DEREF, local_num); } STATIC void emit_bc_store_name(emit_t *emit, qstr qstr) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_qstr(emit, MP_BC_STORE_NAME, qstr); } STATIC void emit_bc_store_global(emit_t *emit, qstr qstr) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_qstr(emit, MP_BC_STORE_GLOBAL, qstr); } STATIC void emit_bc_store_attr(emit_t *emit, qstr qstr) { - emit_pre(emit, -2); + emit_bc_pre(emit, -2); emit_write_byte_code_byte_qstr(emit, MP_BC_STORE_ATTR, qstr); } STATIC void emit_bc_store_subscr(emit_t *emit) { - emit_pre(emit, -3); + emit_bc_pre(emit, -3); emit_write_byte_code_byte(emit, MP_BC_STORE_SUBSCR); } STATIC void emit_bc_store_locals(emit_t *emit) { // not needed - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte(emit, MP_BC_POP_TOP); } STATIC void emit_bc_delete_fast(emit_t *emit, qstr qstr, int local_num) { assert(local_num >= 0); - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_uint(emit, MP_BC_DELETE_FAST_N, local_num); } STATIC void emit_bc_delete_deref(emit_t *emit, qstr qstr, int local_num) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_qstr(emit, MP_BC_DELETE_DEREF, local_num); } STATIC void emit_bc_delete_name(emit_t *emit, qstr qstr) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_qstr(emit, MP_BC_DELETE_NAME, qstr); } STATIC void emit_bc_delete_global(emit_t *emit, qstr qstr) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_qstr(emit, MP_BC_DELETE_GLOBAL, qstr); } STATIC void emit_bc_delete_attr(emit_t *emit, qstr qstr) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_qstr(emit, MP_BC_DELETE_ATTR, qstr); } STATIC void emit_bc_delete_subscr(emit_t *emit) { - emit_pre(emit, -2); + emit_bc_pre(emit, -2); emit_write_byte_code_byte(emit, MP_BC_DELETE_SUBSCR); } STATIC void emit_bc_dup_top(emit_t *emit) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte(emit, MP_BC_DUP_TOP); } STATIC void emit_bc_dup_top_two(emit_t *emit) { - emit_pre(emit, 2); + emit_bc_pre(emit, 2); emit_write_byte_code_byte(emit, MP_BC_DUP_TOP_TWO); } STATIC void emit_bc_pop_top(emit_t *emit) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte(emit, MP_BC_POP_TOP); } STATIC void emit_bc_rot_two(emit_t *emit) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte(emit, MP_BC_ROT_TWO); } STATIC void emit_bc_rot_three(emit_t *emit) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte(emit, MP_BC_ROT_THREE); } STATIC void emit_bc_jump(emit_t *emit, int label) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_signed_label(emit, MP_BC_JUMP, label); } STATIC void emit_bc_pop_jump_if_true(emit_t *emit, int label) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_signed_label(emit, MP_BC_POP_JUMP_IF_TRUE, label); } STATIC void emit_bc_pop_jump_if_false(emit_t *emit, int label) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_signed_label(emit, MP_BC_POP_JUMP_IF_FALSE, label); } STATIC void emit_bc_jump_if_true_or_pop(emit_t *emit, int label) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_signed_label(emit, MP_BC_JUMP_IF_TRUE_OR_POP, label); } STATIC void emit_bc_jump_if_false_or_pop(emit_t *emit, int label) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_signed_label(emit, MP_BC_JUMP_IF_FALSE_OR_POP, label); } STATIC void emit_bc_setup_loop(emit_t *emit, int label) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_unsigned_label(emit, MP_BC_SETUP_LOOP, label); } @@ -578,69 +577,69 @@ STATIC void emit_bc_unwind_jump(emit_t *emit, int label, int except_depth) { if (except_depth == 0) { emit_bc_jump(emit, label); } else { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_signed_label(emit, MP_BC_UNWIND_JUMP, label); emit_write_byte_code_byte(emit, except_depth); } } STATIC void emit_bc_setup_with(emit_t *emit, int label) { - emit_pre(emit, 7); + emit_bc_pre(emit, 7); emit_write_byte_code_byte_unsigned_label(emit, MP_BC_SETUP_WITH, label); } STATIC void emit_bc_with_cleanup(emit_t *emit) { - emit_pre(emit, -7); + emit_bc_pre(emit, -7); emit_write_byte_code_byte(emit, MP_BC_WITH_CLEANUP); } STATIC void emit_bc_setup_except(emit_t *emit, int label) { - emit_pre(emit, 6); + emit_bc_pre(emit, 6); emit_write_byte_code_byte_unsigned_label(emit, MP_BC_SETUP_EXCEPT, label); } STATIC void emit_bc_setup_finally(emit_t *emit, int label) { - emit_pre(emit, 6); + emit_bc_pre(emit, 6); emit_write_byte_code_byte_unsigned_label(emit, MP_BC_SETUP_FINALLY, label); } STATIC void emit_bc_end_finally(emit_t *emit) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte(emit, MP_BC_END_FINALLY); } STATIC void emit_bc_get_iter(emit_t *emit) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte(emit, MP_BC_GET_ITER); } STATIC void emit_bc_for_iter(emit_t *emit, int label) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_unsigned_label(emit, MP_BC_FOR_ITER, label); } STATIC void emit_bc_for_iter_end(emit_t *emit) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); } STATIC void emit_bc_pop_block(emit_t *emit) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte(emit, MP_BC_POP_BLOCK); } STATIC void emit_bc_pop_except(emit_t *emit) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte(emit, MP_BC_POP_EXCEPT); } STATIC void emit_bc_unary_op(emit_t *emit, rt_unary_op_t op) { if (op == RT_UNARY_OP_NOT) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_byte(emit, MP_BC_UNARY_OP, RT_UNARY_OP_BOOL); - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte(emit, MP_BC_NOT); } else { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_byte(emit, MP_BC_UNARY_OP, op); } } @@ -654,86 +653,86 @@ STATIC void emit_bc_binary_op(emit_t *emit, rt_binary_op_t op) { invert = true; op = RT_BINARY_OP_IS; } - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_byte(emit, MP_BC_BINARY_OP, op); if (invert) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte(emit, MP_BC_NOT); } } STATIC void emit_bc_build_tuple(emit_t *emit, int n_args) { assert(n_args >= 0); - emit_pre(emit, 1 - n_args); + emit_bc_pre(emit, 1 - n_args); emit_write_byte_code_byte_uint(emit, MP_BC_BUILD_TUPLE, n_args); } STATIC void emit_bc_build_list(emit_t *emit, int n_args) { assert(n_args >= 0); - emit_pre(emit, 1 - n_args); + emit_bc_pre(emit, 1 - n_args); emit_write_byte_code_byte_uint(emit, MP_BC_BUILD_LIST, n_args); } STATIC void emit_bc_list_append(emit_t *emit, int list_stack_index) { assert(list_stack_index >= 0); - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_uint(emit, MP_BC_LIST_APPEND, list_stack_index); } STATIC void emit_bc_build_map(emit_t *emit, int n_args) { assert(n_args >= 0); - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_uint(emit, MP_BC_BUILD_MAP, n_args); } STATIC void emit_bc_store_map(emit_t *emit) { - emit_pre(emit, -2); + emit_bc_pre(emit, -2); emit_write_byte_code_byte(emit, MP_BC_STORE_MAP); } STATIC void emit_bc_map_add(emit_t *emit, int map_stack_index) { assert(map_stack_index >= 0); - emit_pre(emit, -2); + emit_bc_pre(emit, -2); emit_write_byte_code_byte_uint(emit, MP_BC_MAP_ADD, map_stack_index); } STATIC void emit_bc_build_set(emit_t *emit, int n_args) { assert(n_args >= 0); - emit_pre(emit, 1 - n_args); + emit_bc_pre(emit, 1 - n_args); emit_write_byte_code_byte_uint(emit, MP_BC_BUILD_SET, n_args); } STATIC void emit_bc_set_add(emit_t *emit, int set_stack_index) { assert(set_stack_index >= 0); - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_uint(emit, MP_BC_SET_ADD, set_stack_index); } STATIC void emit_bc_build_slice(emit_t *emit, int n_args) { assert(n_args >= 0); - emit_pre(emit, 1 - n_args); + emit_bc_pre(emit, 1 - n_args); emit_write_byte_code_byte_uint(emit, MP_BC_BUILD_SLICE, n_args); } STATIC void emit_bc_unpack_sequence(emit_t *emit, int n_args) { assert(n_args >= 0); - emit_pre(emit, -1 + n_args); + emit_bc_pre(emit, -1 + n_args); emit_write_byte_code_byte_uint(emit, MP_BC_UNPACK_SEQUENCE, n_args); } STATIC void emit_bc_unpack_ex(emit_t *emit, int n_left, int n_right) { assert(n_left >=0 && n_right >= 0); - emit_pre(emit, -1 + n_left + n_right + 1); + emit_bc_pre(emit, -1 + n_left + n_right + 1); emit_write_byte_code_byte_uint(emit, MP_BC_UNPACK_EX, n_left | (n_right << 8)); } STATIC void emit_bc_make_function(emit_t *emit, scope_t *scope, int n_dict_params, int n_default_params) { assert(n_dict_params == 0); if (n_default_params == 0) { - emit_pre(emit, 1); + emit_bc_pre(emit, 1); emit_write_byte_code_byte_uint(emit, MP_BC_MAKE_FUNCTION, scope->unique_code_id); } else { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_uint(emit, MP_BC_MAKE_FUNCTION_DEFARGS, scope->unique_code_id); } } @@ -741,10 +740,10 @@ STATIC void emit_bc_make_function(emit_t *emit, scope_t *scope, int n_dict_param STATIC void emit_bc_make_closure(emit_t *emit, scope_t *scope, int n_dict_params, int n_default_params) { assert(n_dict_params == 0); if (n_default_params == 0) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); emit_write_byte_code_byte_uint(emit, MP_BC_MAKE_CLOSURE, scope->unique_code_id); } else { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit_write_byte_code_byte_uint(emit, MP_BC_MAKE_CLOSURE_DEFARGS, scope->unique_code_id); } } @@ -757,7 +756,7 @@ STATIC void emit_bc_call_function(emit_t *emit, int n_positional, int n_keyword, if (have_dbl_star_arg) { s += 1; } - emit_pre(emit, -n_positional - 2 * n_keyword - s); + emit_bc_pre(emit, -n_positional - 2 * n_keyword - s); int op; if (have_star_arg) { if (have_dbl_star_arg) { @@ -783,7 +782,7 @@ STATIC void emit_bc_call_method(emit_t *emit, int n_positional, int n_keyword, b if (have_dbl_star_arg) { s += 1; } - emit_pre(emit, -1 - n_positional - 2 * n_keyword - s); + emit_bc_pre(emit, -1 - n_positional - 2 * n_keyword - s); int op; if (have_star_arg) { if (have_dbl_star_arg) { @@ -802,19 +801,19 @@ STATIC void emit_bc_call_method(emit_t *emit, int n_positional, int n_keyword, b } STATIC void emit_bc_return_value(emit_t *emit) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); emit->last_emit_was_return_value = true; emit_write_byte_code_byte(emit, MP_BC_RETURN_VALUE); } STATIC void emit_bc_raise_varargs(emit_t *emit, int n_args) { assert(0 <= n_args && n_args <= 2); - emit_pre(emit, -n_args); + emit_bc_pre(emit, -n_args); emit_write_byte_code_byte_byte(emit, MP_BC_RAISE_VARARGS, n_args); } STATIC void emit_bc_yield_value(emit_t *emit) { - emit_pre(emit, 0); + emit_bc_pre(emit, 0); if (emit->pass == PASS_2) { emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; } @@ -822,7 +821,7 @@ STATIC void emit_bc_yield_value(emit_t *emit) { } STATIC void emit_bc_yield_from(emit_t *emit) { - emit_pre(emit, -1); + emit_bc_pre(emit, -1); if (emit->pass == PASS_2) { emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; } diff --git a/py/emitnative.c b/py/emitnative.c index 743c321119..da58115537 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -315,8 +315,7 @@ STATIC void emit_pre_raw(emit_t *emit, int stack_size_delta) { */ // this must be called at start of emit functions -// TODO: module-polymorphic function (read: name clash if made global) -static void emit_pre(emit_t *emit) { +STATIC void emit_native_pre(emit_t *emit) { emit->last_emit_was_return_value = false; // settle the stack /* @@ -547,7 +546,7 @@ STATIC void emit_native_load_id(emit_t *emit, qstr qstr) { // check for built-ins if (strcmp(qstr_str(qstr), "v_int") == 0) { assert(0); - emit_pre(emit); + emit_native_pre(emit); //emit_post_push_blank(emit, VTYPE_BUILTIN_V_INT); // not a built-in, so do usual thing @@ -567,7 +566,7 @@ STATIC void emit_native_delete_id(emit_t *emit, qstr qstr) { } STATIC void emit_native_label_assign(emit_t *emit, int l) { - emit_pre(emit); + emit_native_pre(emit); // need to commit stack because we can jump here from elsewhere need_stack_settled(emit); #if N_X64 @@ -594,7 +593,7 @@ STATIC void emit_native_import_star(emit_t *emit) { } STATIC void emit_native_load_const_tok(emit_t *emit, mp_token_kind_t tok) { - emit_pre(emit); + emit_native_pre(emit); int vtype; machine_uint_t val; if (emit->do_viper_types) { @@ -617,7 +616,7 @@ STATIC void emit_native_load_const_tok(emit_t *emit, mp_token_kind_t tok) { } STATIC void emit_native_load_const_small_int(emit_t *emit, machine_int_t arg) { - emit_pre(emit); + emit_native_pre(emit); if (emit->do_viper_types) { emit_post_push_imm(emit, VTYPE_INT, arg); } else { @@ -633,13 +632,13 @@ STATIC void emit_native_load_const_int(emit_t *emit, qstr qstr) { STATIC void emit_native_load_const_dec(emit_t *emit, qstr qstr) { // for viper, a float/complex is just a Python object - emit_pre(emit); + emit_native_pre(emit); emit_call_with_imm_arg(emit, RT_F_LOAD_CONST_DEC, rt_load_const_dec, qstr, REG_ARG_1); emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); } STATIC void emit_native_load_const_id(emit_t *emit, qstr qstr) { - emit_pre(emit); + emit_native_pre(emit); if (emit->do_viper_types) { assert(0); } else { @@ -649,7 +648,7 @@ STATIC void emit_native_load_const_id(emit_t *emit, qstr qstr) { } STATIC void emit_native_load_const_str(emit_t *emit, qstr qstr, bool bytes) { - emit_pre(emit); + emit_native_pre(emit); if (emit->do_viper_types) { // not implemented properly // load a pointer to the asciiz string? @@ -671,7 +670,7 @@ STATIC void emit_native_load_fast(emit_t *emit, qstr qstr, int local_num) { if (vtype == VTYPE_UNBOUND) { printf("ViperTypeError: local %s used before type known\n", qstr_str(qstr)); } - emit_pre(emit); + emit_native_pre(emit); #if N_X64 if (local_num == 0) { emit_post_push_reg(emit, vtype, REG_LOCAL_1); @@ -707,13 +706,13 @@ STATIC void emit_native_load_closure(emit_t *emit, qstr qstr, int local_num) { } STATIC void emit_native_load_name(emit_t *emit, qstr qstr) { - emit_pre(emit); + emit_native_pre(emit); emit_call_with_imm_arg(emit, RT_F_LOAD_NAME, rt_load_name, qstr, REG_ARG_1); emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); } STATIC void emit_native_load_global(emit_t *emit, qstr qstr) { - emit_pre(emit); + emit_native_pre(emit); emit_call_with_imm_arg(emit, RT_F_LOAD_GLOBAL, rt_load_global, qstr, REG_ARG_1); emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); } @@ -739,7 +738,7 @@ STATIC void emit_native_load_method(emit_t *emit, qstr qstr) { } STATIC void emit_native_load_build_class(emit_t *emit) { - emit_pre(emit); + emit_native_pre(emit); emit_call(emit, RT_F_LOAD_BUILD_CLASS, rt_load_build_class); emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); } @@ -890,7 +889,7 @@ STATIC void emit_native_rot_three(emit_t *emit) { } STATIC void emit_native_jump(emit_t *emit, int label) { - emit_pre(emit); + emit_native_pre(emit); #if N_X64 asm_x64_jmp_label(emit->as, label); #elif N_THUMB @@ -944,7 +943,7 @@ STATIC void emit_native_jump_if_false_or_pop(emit_t *emit, int label) { } STATIC void emit_native_setup_loop(emit_t *emit, int label) { - emit_pre(emit); + emit_native_pre(emit); emit_post(emit); } @@ -983,7 +982,7 @@ STATIC void emit_native_get_iter(emit_t *emit) { } STATIC void emit_native_for_iter(emit_t *emit, int label) { - emit_pre(emit); + emit_native_pre(emit); vtype_kind_t vtype; emit_access_stack(emit, 1, &vtype, REG_ARG_1); assert(vtype == VTYPE_PYOBJ); @@ -1001,13 +1000,13 @@ STATIC void emit_native_for_iter(emit_t *emit, int label) { STATIC void emit_native_for_iter_end(emit_t *emit) { // adjust stack counter (we get here from for_iter ending, which popped the value for us) - emit_pre(emit); + emit_native_pre(emit); adjust_stack(emit, -1); emit_post(emit); } STATIC void emit_native_pop_block(emit_t *emit) { - emit_pre(emit); + emit_native_pre(emit); emit_post(emit); } @@ -1062,14 +1061,14 @@ STATIC void emit_native_binary_op(emit_t *emit, rt_binary_op_t op) { STATIC void emit_native_build_tuple(emit_t *emit, int n_args) { // for viper: call runtime, with types of args // if wrapped in byte_array, or something, allocates memory and fills it - emit_pre(emit); + emit_native_pre(emit); emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, n_args); // pointer to items emit_call_with_imm_arg(emit, RT_F_BUILD_TUPLE, rt_build_tuple, n_args, REG_ARG_1); emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new tuple } STATIC void emit_native_build_list(emit_t *emit, int n_args) { - emit_pre(emit); + emit_native_pre(emit); emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, n_args); // pointer to items emit_call_with_imm_arg(emit, RT_F_BUILD_LIST, rt_build_list, n_args, REG_ARG_1); emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new list @@ -1087,7 +1086,7 @@ STATIC void emit_native_list_append(emit_t *emit, int list_index) { } STATIC void emit_native_build_map(emit_t *emit, int n_args) { - emit_pre(emit); + emit_native_pre(emit); emit_call_with_imm_arg(emit, RT_F_BUILD_MAP, rt_build_map, n_args, REG_ARG_1); emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new map } @@ -1115,7 +1114,7 @@ STATIC void emit_native_map_add(emit_t *emit, int map_index) { } STATIC void emit_native_build_set(emit_t *emit, int n_args) { - emit_pre(emit); + emit_native_pre(emit); emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_2, n_args); // pointer to items emit_call_with_imm_arg(emit, RT_F_BUILD_SET, rt_build_set, n_args, REG_ARG_1); emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); // new set @@ -1146,7 +1145,7 @@ STATIC void emit_native_unpack_ex(emit_t *emit, int n_left, int n_right) { STATIC void emit_native_make_function(emit_t *emit, scope_t *scope, int n_dict_params, int n_default_params) { // call runtime, with type info for args, or don't support dict/default params, or only support Python objects for them assert(n_default_params == 0 && n_dict_params == 0); - emit_pre(emit); + emit_native_pre(emit); emit_call_with_imm_arg(emit, RT_F_MAKE_FUNCTION_FROM_ID, rt_make_function_from_id, scope->unique_code_id, REG_ARG_1); emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); } @@ -1183,7 +1182,7 @@ STATIC void emit_native_call_function(emit_t *emit, int n_positional, int n_keyw } else { */ - emit_pre(emit); + emit_native_pre(emit); if (n_positional != 0) { emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional); // pointer to args } @@ -1214,7 +1213,7 @@ STATIC void emit_native_call_method(emit_t *emit, int n_positional, int n_keywor } else { */ - emit_pre(emit); + emit_native_pre(emit); emit_get_stack_pointer_to_reg_for_pop(emit, REG_ARG_3, n_positional + 2); // pointer to items, including meth and self emit_call_with_2_imm_args(emit, RT_F_CALL_METHOD_N_KW, rt_call_method_n_kw, n_positional, REG_ARG_1, n_keyword, REG_ARG_2); emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);