diff --git a/src/libcoreint/interpreter.c b/src/libcoreint/interpreter.c index 05afa3459..789e16553 100644 --- a/src/libcoreint/interpreter.c +++ b/src/libcoreint/interpreter.c @@ -116,9 +116,9 @@ run_int_loop (int_data_t *int_data) completion = __opfuncs[curr->op_idx] (*curr, int_data); JERRY_ASSERT (!ecma_is_completion_value_normal (completion) - || ecma_is_empty_completion_value (completion)); + || ecma_is_completion_value_empty (completion)); } - while (completion.type == ECMA_COMPLETION_TYPE_NORMAL); + while (ecma_is_completion_value_normal (completion)); if (completion.type == ECMA_COMPLETION_TYPE_BREAK || completion.type == ECMA_COMPLETION_TYPE_CONTINUE) @@ -128,10 +128,9 @@ run_int_loop (int_data_t *int_data) continue; } - if (completion.type == ECMA_COMPLETION_TYPE_META) + if (ecma_is_completion_value_meta (completion)) { - completion.type = ECMA_COMPLETION_TYPE_NORMAL; - JERRY_ASSERT (ecma_is_empty_completion_value (completion)); + completion = ecma_make_empty_completion_value (); } return completion; diff --git a/src/libcoreint/opcodes-ecma-relational.c b/src/libcoreint/opcodes-ecma-relational.c index 8b1c30b3d..79bc74e6a 100644 --- a/src/libcoreint/opcodes-ecma-relational.c +++ b/src/libcoreint/opcodes-ecma-relational.c @@ -253,7 +253,7 @@ opfunc_instanceof (opcode_t opdata __unused, /**< operation data */ if (right_value.u.value.value_type != ECMA_TYPE_OBJECT) { - ret_value = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { @@ -298,7 +298,7 @@ opfunc_in (opcode_t opdata __unused, /**< operation data */ if (right_value.u.value.value_type != ECMA_TYPE_OBJECT) { - ret_value = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { diff --git a/src/libcoreint/opcodes-ecma-try-catch-finally.c b/src/libcoreint/opcodes-ecma-try-catch-finally.c index 6aa7745f0..6cb26b44f 100644 --- a/src/libcoreint/opcodes-ecma-try-catch-finally.c +++ b/src/libcoreint/opcodes-ecma-try-catch-finally.c @@ -38,14 +38,14 @@ opfunc_try (opcode_t opdata, /**< operation data */ int_data->pos++; ecma_completion_value_t try_completion = run_int_loop (int_data); - JERRY_ASSERT ((!ecma_is_empty_completion_value (try_completion) && int_data->pos < try_end_oc) - || (ecma_is_empty_completion_value (try_completion) && int_data->pos == try_end_oc)); + JERRY_ASSERT ((!ecma_is_completion_value_empty (try_completion) && int_data->pos < try_end_oc) + || (ecma_is_completion_value_empty (try_completion) && int_data->pos == try_end_oc)); int_data->pos = try_end_oc; opcode_t next_opcode = read_opcode (int_data->pos); JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta); - if (try_completion.type == ECMA_COMPLETION_TYPE_EXIT) + if (ecma_is_completion_value_exit (try_completion)) { return try_completion; } @@ -70,12 +70,12 @@ opfunc_try (opcode_t opdata, /**< operation data */ ecma_completion_value_t completion = ecma_op_create_mutable_binding (catch_env_p, catch_exc_var_name_str_p, false); - JERRY_ASSERT (ecma_is_empty_completion_value (completion)); + JERRY_ASSERT (ecma_is_completion_value_empty (completion)); completion = ecma_op_set_mutable_binding (catch_env_p, catch_exc_var_name_str_p, try_completion.u.value, false); - JERRY_ASSERT (ecma_is_empty_completion_value (completion)); + JERRY_ASSERT (ecma_is_completion_value_empty (completion)); ecma_deref_ecma_string (catch_exc_var_name_str_p); @@ -89,15 +89,15 @@ opfunc_try (opcode_t opdata, /**< operation data */ ecma_deref_object (catch_env_p); } - JERRY_ASSERT ((!ecma_is_empty_completion_value (try_completion) && int_data->pos < catch_end_oc) - || (ecma_is_empty_completion_value (try_completion) && int_data->pos == catch_end_oc)); + JERRY_ASSERT ((!ecma_is_completion_value_empty (try_completion) && int_data->pos < catch_end_oc) + || (ecma_is_completion_value_empty (try_completion) && int_data->pos == catch_end_oc)); int_data->pos = catch_end_oc; } next_opcode = read_opcode (int_data->pos); JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta); - if (try_completion.type == ECMA_COMPLETION_TYPE_EXIT) + if (ecma_is_completion_value_exit (try_completion)) { return try_completion; } @@ -109,11 +109,11 @@ opfunc_try (opcode_t opdata, /**< operation data */ int_data->pos++; ecma_completion_value_t finally_completion = run_int_loop (int_data); - JERRY_ASSERT ((!ecma_is_empty_completion_value (finally_completion) && int_data->pos < finally_end_oc) - || (ecma_is_empty_completion_value (finally_completion) && int_data->pos == finally_end_oc)); + JERRY_ASSERT ((!ecma_is_completion_value_empty (finally_completion) && int_data->pos < finally_end_oc) + || (ecma_is_completion_value_empty (finally_completion) && int_data->pos == finally_end_oc)); int_data->pos = finally_end_oc; - if (!ecma_is_empty_completion_value (finally_completion)) + if (!ecma_is_completion_value_empty (finally_completion)) { ecma_free_completion_value (try_completion); try_completion = finally_completion; diff --git a/src/libcoreint/opcodes-helpers-variables.c b/src/libcoreint/opcodes-helpers-variables.c index 7ff492ae5..ecf03f0cf 100644 --- a/src/libcoreint/opcodes-helpers-variables.c +++ b/src/libcoreint/opcodes-helpers-variables.c @@ -87,8 +87,7 @@ get_variable_value (int_data_t *int_data, /**< interpreter context */ JERRY_ASSERT (!ecma_is_value_empty (reg_value)); - ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_copy_value (reg_value, true)); + ret_value = ecma_make_normal_completion_value (ecma_copy_value (reg_value, true)); } else { @@ -103,7 +102,7 @@ get_variable_value (int_data_t *int_data, /**< interpreter context */ if (unlikely (do_eval_or_arguments_check && do_strict_eval_arguments_check (ref))) { - ret_value = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); + ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); } else { @@ -155,7 +154,7 @@ set_variable_value (int_data_t *int_data, /**< interpreter context */ if (unlikely (do_strict_eval_arguments_check (ref))) { - ret_value = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); + ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); } else { diff --git a/src/libcoreint/opcodes-native-call.c b/src/libcoreint/opcodes-native-call.c index 6c9203cc6..49262a76d 100644 --- a/src/libcoreint/opcodes-native-call.c +++ b/src/libcoreint/opcodes-native-call.c @@ -48,7 +48,7 @@ opfunc_native_call (opcode_t opdata, /**< operation data */ arg_values, &args_read); - if (ecma_is_empty_completion_value (get_arg_completion)) + if (ecma_is_completion_value_empty (get_arg_completion)) { JERRY_ASSERT (args_read == args_number); diff --git a/src/libcoreint/opcodes-varg.c b/src/libcoreint/opcodes-varg.c index f2b2dbc20..2b16ed59e 100644 --- a/src/libcoreint/opcodes-varg.c +++ b/src/libcoreint/opcodes-varg.c @@ -42,7 +42,7 @@ fill_varg_list (int_data_t *int_data, /**< interpreter context */ { ecma_completion_value_t evaluate_arg_completion = run_int_loop (int_data); - if (evaluate_arg_completion.type == ECMA_COMPLETION_TYPE_META) + if (ecma_is_completion_value_meta (evaluate_arg_completion)) { opcode_t next_opcode = read_opcode (int_data->pos); JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta); @@ -66,7 +66,7 @@ fill_varg_list (int_data_t *int_data, /**< interpreter context */ ret_value = evaluate_arg_completion; } - if (!ecma_is_empty_completion_value (ret_value)) + if (!ecma_is_completion_value_empty (ret_value)) { break; } diff --git a/src/libcoreint/opcodes.c b/src/libcoreint/opcodes.c index 218b3d71a..34aee1f4d 100644 --- a/src/libcoreint/opcodes.c +++ b/src/libcoreint/opcodes.c @@ -82,7 +82,7 @@ opfunc_call_1 (opcode_t opdata __unused, int_data_t *int_data) if (!ecma_op_is_callable (func_value.u.value)) { - ret_value = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { @@ -134,16 +134,14 @@ opfunc_assignment (opcode_t opdata, /**< operation data */ { case OPCODE_ARG_TYPE_SIMPLE: { - get_value_completion = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_make_simple_value (src_val_descr)); + get_value_completion = ecma_make_simple_completion_value (src_val_descr); break; } case OPCODE_ARG_TYPE_STRING: { ecma_string_t *ecma_string_p = ecma_new_ecma_string_from_lit_index (src_val_descr); - get_value_completion = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_make_string_value (ecma_string_p)); + get_value_completion = ecma_make_normal_completion_value (ecma_make_string_value (ecma_string_p)); break; } case OPCODE_ARG_TYPE_VARIABLE: @@ -159,8 +157,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */ ecma_number_t *num_p = ecma_alloc_number (); *num_p = deserialize_num_by_id (src_val_descr); - get_value_completion = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_make_number_value (num_p)); + get_value_completion = ecma_make_normal_completion_value (ecma_make_number_value (num_p)); break; } case OPCODE_ARG_TYPE_SMALLINT: @@ -168,8 +165,7 @@ opfunc_assignment (opcode_t opdata, /**< operation data */ ecma_number_t *num_p = ecma_alloc_number (); *num_p = src_val_descr; - get_value_completion = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_make_number_value (num_p)); + get_value_completion = ecma_make_normal_completion_value (ecma_make_number_value (num_p)); break; } } @@ -232,7 +228,7 @@ opfunc_pre_incr (opcode_t opdata, /**< operation data */ ecma_completion_value_t reg_assignment_res = set_variable_value (int_data, dst_var_idx, new_num_value); - JERRY_ASSERT (ecma_is_empty_completion_value (reg_assignment_res)); + JERRY_ASSERT (ecma_is_completion_value_empty (reg_assignment_res)); ecma_dealloc_number (new_num_p); @@ -282,7 +278,7 @@ opfunc_pre_decr (opcode_t opdata, /**< operation data */ ecma_completion_value_t reg_assignment_res = set_variable_value (int_data, dst_var_idx, new_num_value); - JERRY_ASSERT (ecma_is_empty_completion_value (reg_assignment_res)); + JERRY_ASSERT (ecma_is_completion_value_empty (reg_assignment_res)); ecma_dealloc_number (new_num_p); @@ -332,7 +328,7 @@ opfunc_post_incr (opcode_t opdata, /**< operation data */ ecma_completion_value_t reg_assignment_res = set_variable_value (int_data, dst_var_idx, old_value.u.value); - JERRY_ASSERT (ecma_is_empty_completion_value (reg_assignment_res)); + JERRY_ASSERT (ecma_is_completion_value_empty (reg_assignment_res)); ECMA_FINALIZE (old_num_value); ECMA_FINALIZE (old_value); @@ -380,7 +376,7 @@ opfunc_post_decr (opcode_t opdata, /**< operation data */ ecma_completion_value_t reg_assignment_res = set_variable_value (int_data, dst_var_idx, old_value.u.value); - JERRY_ASSERT (ecma_is_empty_completion_value (reg_assignment_res)); + JERRY_ASSERT (ecma_is_completion_value_empty (reg_assignment_res)); ECMA_FINALIZE (old_num_value); ECMA_FINALIZE (old_value); @@ -424,7 +420,7 @@ opfunc_var_decl (opcode_t opdata, /**< operation data */ var_name_string_p, is_configurable_bindings); - JERRY_ASSERT (ecma_is_empty_completion_value (completion)); + JERRY_ASSERT (ecma_is_completion_value_empty (completion)); /* Skipping SetMutableBinding as we have already checked that there were not * any binding with specified name in current lexical environment @@ -692,7 +688,7 @@ opfunc_call_0 (opcode_t opdata, /**< operation data */ if (!ecma_op_is_callable (func_value.u.value)) { - ret_value = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { @@ -744,7 +740,7 @@ opfunc_call_n (opcode_t opdata, /**< operation data */ arg_values, &args_read); - if (ecma_is_empty_completion_value (get_arg_completion)) + if (ecma_is_completion_value_empty (get_arg_completion)) { JERRY_ASSERT (args_read == args_number); @@ -767,7 +763,7 @@ opfunc_call_n (opcode_t opdata, /**< operation data */ if (!ecma_op_is_callable (func_value.u.value)) { - ret_value = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { @@ -833,13 +829,13 @@ opfunc_construct_n (opcode_t opdata, /**< operation data */ arg_values, &args_read); - if (ecma_is_empty_completion_value (get_arg_completion)) + if (ecma_is_completion_value_empty (get_arg_completion)) { JERRY_ASSERT (args_read == args_number); if (!ecma_is_constructor (constructor_value.u.value)) { - ret_value = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { @@ -902,7 +898,7 @@ opfunc_array_decl (opcode_t opdata, /**< operation data */ arg_values, &args_read); - if (ecma_is_empty_completion_value (get_arg_completion)) + if (ecma_is_completion_value_empty (get_arg_completion)) { JERRY_ASSERT (args_read == args_number); @@ -961,7 +957,7 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */ { ecma_completion_value_t evaluate_prop_completion = run_int_loop (int_data); - if (evaluate_prop_completion.type == ECMA_COMPLETION_TYPE_META) + if (ecma_is_completion_value_meta (evaluate_prop_completion)) { opcode_t next_opcode = read_opcode (int_data->pos); JERRY_ASSERT (next_opcode.op_idx == __op__idx_meta); @@ -1071,7 +1067,7 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */ } } - if (ecma_is_empty_completion_value (completion)) + if (ecma_is_completion_value_empty (completion)) { ret_value = set_variable_value (int_data, lhs_var_idx, ecma_make_object_value (obj_p)); } @@ -1097,8 +1093,7 @@ ecma_completion_value_t opfunc_ret (opcode_t opdata __unused, /**< operation data */ int_data_t *int_data __unused) /**< interpreter context */ { - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_RETURN, - ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED)); + return ecma_make_return_completion_value (ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED)); } /* opfunc_ret */ /** @@ -1118,8 +1113,7 @@ opfunc_retval (opcode_t opdata __unused, /**< operation data */ ECMA_TRY_CATCH (expr_val, get_variable_value (int_data, opdata.data.retval.ret_value, false), ret_value); - ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_RETURN, - ecma_copy_value (expr_val.u.value, true)); + ret_value = ecma_make_return_completion_value (ecma_copy_value (expr_val.u.value, true)); ECMA_FINALIZE (expr_val); @@ -1238,10 +1232,7 @@ opfunc_exitval (opcode_t opdata, /**< operation data */ JERRY_ASSERT (opdata.data.exitval.status_code == 0 || opdata.data.exitval.status_code == 1); - ecma_value_t exit_status = ecma_make_simple_value (opdata.data.exitval.status_code == 0 ? ECMA_SIMPLE_VALUE_TRUE - : ECMA_SIMPLE_VALUE_FALSE); - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_EXIT, - exit_status); + return ecma_make_exit_completion_value (opdata.data.exitval.status_code == 0); } /* opfunc_exitval */ /** @@ -1432,7 +1423,7 @@ opfunc_with (opcode_t opdata, /**< operation data */ ecma_completion_value_t evaluation_completion = run_int_loop (int_data); - if (evaluation_completion.type == ECMA_COMPLETION_TYPE_META) + if (ecma_is_completion_value_meta (evaluation_completion)) { opcode_t meta_opcode = read_opcode (int_data->pos); JERRY_ASSERT (meta_opcode.op_idx == __op__idx_meta); @@ -1481,8 +1472,7 @@ opfunc_throw (opcode_t opdata, /**< operation data */ false), ret_value); - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_THROW, - ecma_copy_value (var_value.u.value, true)); + return ecma_make_throw_completion_value (ecma_copy_value (var_value.u.value, true)); ECMA_FINALIZE (var_value); @@ -1665,7 +1655,7 @@ opfunc_delete_var (opcode_t opdata, /**< operation data */ if (ref.is_strict) { - ret_value = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); + ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); } else if (ecma_is_value_undefined (ref.base)) { @@ -1722,7 +1712,7 @@ opfunc_delete_prop (opcode_t opdata, /**< operation data */ { if (int_data->is_strict) { - ret_value = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); + ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); } else { @@ -1774,8 +1764,7 @@ opfunc_meta (opcode_t opdata, /**< operation data */ case OPCODE_META_TYPE_FINALLY: case OPCODE_META_TYPE_END_TRY_CATCH_FINALLY: { - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_META, - ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY)); + return ecma_make_meta_completion_value (); } case OPCODE_META_TYPE_UNDEFINED: case OPCODE_META_TYPE_THIS_ARG: diff --git a/src/libecmaobjects/ecma-helpers-value.c b/src/libecmaobjects/ecma-helpers-value.c index c5e8a4fb3..5a983d699 100644 --- a/src/libecmaobjects/ecma-helpers-value.c +++ b/src/libecmaobjects/ecma-helpers-value.c @@ -343,21 +343,42 @@ ecma_make_simple_completion_value (ecma_simple_value_t simple_value) /**< simple ecma_make_simple_value (simple_value)); } /* ecma_make_simple_completion_value */ +/** + * Normal completion value constructor + * + * @return completion value + */ +ecma_completion_value_t +ecma_make_normal_completion_value (ecma_value_t value) /**< value */ +{ + return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, value); +} /* ecma_make_normal_completion_value */ + +/** + * Throw completion value constructor + * + * @return completion value + */ +ecma_completion_value_t +ecma_make_throw_completion_value (ecma_value_t value) /**< value */ +{ + return ecma_make_completion_value (ECMA_COMPLETION_TYPE_THROW, value); +} /* ecma_make_throw_completion_value */ + /** * Throw completion value constructor. * * @return 'throw' completion value */ ecma_completion_value_t -ecma_make_throw_value (ecma_object_t *exception_p) /**< an object */ +ecma_make_throw_obj_completion_value (ecma_object_t *exception_p) /**< an object */ { JERRY_ASSERT(exception_p != NULL && !exception_p->is_lexical_environment); ecma_value_t exception = ecma_make_object_value (exception_p); - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_THROW, - exception); -} /* ecma_make_throw_value */ + return ecma_make_throw_completion_value (exception); +} /* ecma_make_throw_obj_completion_value */ /** * Empty completion value constructor. @@ -371,6 +392,44 @@ ecma_make_empty_completion_value (void) ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY)); } /* ecma_make_empty_completion_value */ +/** + * Return completion value constructor + * + * @return completion value + */ +ecma_completion_value_t +ecma_make_return_completion_value (ecma_value_t value) /**< value */ +{ + return ecma_make_completion_value (ECMA_COMPLETION_TYPE_RETURN, value); +} /* ecma_make_return_completion_value */ + +/** + * Exit completion value constructor + * + * @return completion value + */ +ecma_completion_value_t +ecma_make_exit_completion_value (bool is_successful) /**< does completion value indicate + successfulness completion + of script execution (true) or not (false) */ +{ + return ecma_make_completion_value (ECMA_COMPLETION_TYPE_EXIT, + ecma_make_simple_value (is_successful ? ECMA_SIMPLE_VALUE_TRUE + : ECMA_SIMPLE_VALUE_FALSE)); +} /* ecma_make_exit_completion_value */ + +/** + * Meta completion value constructor + * + * @return completion value + */ +ecma_completion_value_t +ecma_make_meta_completion_value (void) +{ + return ecma_make_completion_value (ECMA_COMPLETION_TYPE_META, + ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY)); +} /* ecma_make_meta_completion_value */ + /** * Copy ecma-completion value. * @@ -453,6 +512,48 @@ ecma_is_completion_value_return (ecma_completion_value_t value) /**< completion return (value.type == ECMA_COMPLETION_TYPE_RETURN); } /* ecma_is_completion_value_return */ +/** + * Check if the completion value is exit value. + * + * @return true - if the completion type is exit, + * false - otherwise. + */ +bool +ecma_is_completion_value_exit (ecma_completion_value_t value) /**< completion value */ +{ + if (value.type == ECMA_COMPLETION_TYPE_EXIT) + { + JERRY_ASSERT (ecma_is_value_boolean (value.u.value)); + + return true; + } + else + { + return false; + } +} /* ecma_is_completion_value_exit */ + +/** + * Check if the completion value is meta value. + * + * @return true - if the completion type is meta, + * false - otherwise. + */ +bool +ecma_is_completion_value_meta (ecma_completion_value_t value) /**< completion value */ +{ + if (value.type == ECMA_COMPLETION_TYPE_META) + { + JERRY_ASSERT (ecma_is_value_empty (value.u.value)); + + return true; + } + else + { + return false; + } +} /* ecma_is_completion_value_meta */ + /** * Check if the completion value is specified normal simple value. * @@ -465,7 +566,7 @@ ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value, /** ecma_simple_value_t simple_value) /**< simple value to check for equality with */ { - return (value.type == ECMA_COMPLETION_TYPE_NORMAL + return (ecma_is_completion_value_normal (value) && value.u.value.value_type == ECMA_TYPE_SIMPLE && value.u.value.value == simple_value); } /* ecma_is_completion_value_normal_simple_value */ @@ -504,11 +605,11 @@ ecma_is_completion_value_normal_false (ecma_completion_value_t value) /**< compl * false - otherwise. */ bool -ecma_is_empty_completion_value (ecma_completion_value_t value) /**< completion value */ +ecma_is_completion_value_empty (ecma_completion_value_t value) /**< completion value */ { return (ecma_is_completion_value_normal (value) && ecma_is_value_empty (value.u.value)); -} /* ecma_is_empty_completion_value */ +} /* ecma_is_completion_value_empty */ /** * @} diff --git a/src/libecmaobjects/ecma-helpers.h b/src/libecmaobjects/ecma-helpers.h index c0017ef49..8f59d2557 100644 --- a/src/libecmaobjects/ecma-helpers.h +++ b/src/libecmaobjects/ecma-helpers.h @@ -74,19 +74,26 @@ extern ecma_completion_value_t ecma_make_label_completion_value (ecma_completion uint8_t depth_level, uint16_t offset); extern ecma_completion_value_t ecma_make_simple_completion_value (ecma_simple_value_t simple_value); -extern ecma_completion_value_t ecma_make_throw_value (ecma_object_t *exception_p); +extern ecma_completion_value_t ecma_make_normal_completion_value (ecma_value_t value); +extern ecma_completion_value_t ecma_make_throw_completion_value (ecma_value_t value); +extern ecma_completion_value_t ecma_make_throw_obj_completion_value (ecma_object_t *exception_p); extern ecma_completion_value_t ecma_make_empty_completion_value (void); +extern ecma_completion_value_t ecma_make_return_completion_value (ecma_value_t value); +extern ecma_completion_value_t ecma_make_exit_completion_value (bool is_successful); +extern ecma_completion_value_t ecma_make_meta_completion_value (void); extern ecma_completion_value_t ecma_copy_completion_value (ecma_completion_value_t value); extern void ecma_free_completion_value (ecma_completion_value_t completion_value); extern bool ecma_is_completion_value_normal (ecma_completion_value_t value); extern bool ecma_is_completion_value_throw (ecma_completion_value_t value); extern bool ecma_is_completion_value_return (ecma_completion_value_t value); +extern bool ecma_is_completion_value_exit (ecma_completion_value_t value); +extern bool ecma_is_completion_value_meta (ecma_completion_value_t value); extern bool ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value, ecma_simple_value_t simple_value); extern bool ecma_is_completion_value_normal_true (ecma_completion_value_t value); extern bool ecma_is_completion_value_normal_false (ecma_completion_value_t value); -extern bool ecma_is_empty_completion_value (ecma_completion_value_t value); +extern bool ecma_is_completion_value_empty (ecma_completion_value_t value); /* ecma-helpers-string.c */ extern ecma_string_t* ecma_new_ecma_string (const ecma_char_t *string_p); diff --git a/src/libecmaoperations/ecma-array-object.c b/src/libecmaoperations/ecma-array-object.c index 29765ab57..cf4734eee 100644 --- a/src/libecmaoperations/ecma-array-object.c +++ b/src/libecmaoperations/ecma-array-object.c @@ -41,7 +41,7 @@ ecma_reject (bool is_throw) /**< Throw flag */ { if (is_throw) { - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { @@ -212,7 +212,7 @@ ecma_op_array_object_define_own_property (ecma_object_t *obj_p, /**< the array o // d. if (ecma_uint32_to_number (new_len_uint32) != new_len_num) { - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_RANGE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_RANGE)); } else { diff --git a/src/libecmaoperations/ecma-comparison.c b/src/libecmaoperations/ecma-comparison.c index a64a4fc4b..88e47b9a6 100644 --- a/src/libecmaoperations/ecma-comparison.c +++ b/src/libecmaoperations/ecma-comparison.c @@ -244,13 +244,11 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */ if (*num_x_p >= *num_y_p) { - ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE)); + ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); } else { - ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE)); + ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE); } ECMA_FINALIZE(ny); diff --git a/src/libecmaoperations/ecma-conversion.c b/src/libecmaoperations/ecma-conversion.c index 6bc22cc84..165887ff6 100644 --- a/src/libecmaoperations/ecma-conversion.c +++ b/src/libecmaoperations/ecma-conversion.c @@ -50,7 +50,7 @@ ecma_op_check_object_coercible (ecma_value_t value) /**< ecma-value */ if (ecma_is_value_undefined (value) || ecma_is_value_null (value)) { - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else if (ecma_is_value_boolean (value)) { @@ -167,8 +167,7 @@ ecma_op_to_primitive (ecma_value_t value, /**< ecma-value */ case ECMA_TYPE_NUMBER: case ECMA_TYPE_STRING: { - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_copy_value (value, true)); + return ecma_make_normal_completion_value (ecma_copy_value (value, true)); } case ECMA_TYPE_OBJECT: @@ -260,8 +259,7 @@ ecma_op_to_number (ecma_value_t value) /**< ecma-value */ { case ECMA_TYPE_NUMBER: { - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_copy_value (value, true)); + return ecma_make_normal_completion_value (ecma_copy_value (value, true)); } case ECMA_TYPE_SIMPLE: case ECMA_TYPE_STRING: @@ -372,8 +370,7 @@ ecma_op_to_string (ecma_value_t value) /**< ecma-value */ } } - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_make_string_value (res_p)); + return ecma_make_normal_completion_value (ecma_make_string_value (res_p)); } /* ecma_op_to_string */ /** @@ -399,8 +396,7 @@ ecma_op_to_object (ecma_value_t value) /**< ecma-value */ case ECMA_TYPE_OBJECT: { - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_copy_value (value, true)); + return ecma_make_normal_completion_value (ecma_copy_value (value, true)); } } diff --git a/src/libecmaoperations/ecma-function-object.c b/src/libecmaoperations/ecma-function-object.c index e2aa10f37..e60087070 100644 --- a/src/libecmaoperations/ecma-function-object.c +++ b/src/libecmaoperations/ecma-function-object.c @@ -352,7 +352,7 @@ ecma_function_call_setup_args_variables (ecma_object_t *func_obj_p, /**< Functio return completion; } - JERRY_ASSERT (ecma_is_empty_completion_value (completion)); + JERRY_ASSERT (ecma_is_completion_value_empty (completion)); completion = ecma_op_set_mutable_binding (env_p, formal_parameter_name_string_p, @@ -364,7 +364,7 @@ ecma_function_call_setup_args_variables (ecma_object_t *func_obj_p, /**< Functio return completion; } - JERRY_ASSERT (ecma_is_empty_completion_value (completion)); + JERRY_ASSERT (ecma_is_completion_value_empty (completion)); } } @@ -445,10 +445,9 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */ false); if (ecma_is_completion_value_normal (completion)) { - JERRY_ASSERT(ecma_is_empty_completion_value (completion)); + JERRY_ASSERT(ecma_is_completion_value_empty (completion)); - ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_RETURN, - ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED)); + ret_value = ecma_make_return_completion_value (ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED)); } else { @@ -546,8 +545,7 @@ ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */ obj_value = ecma_make_object_value (obj_p); } - ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - obj_value); + ret_value = ecma_make_normal_completion_value (obj_value); ECMA_FINALIZE (call_completion); ECMA_FINALIZE (func_obj_prototype_prop_value); @@ -600,7 +598,7 @@ ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment function_name_p, is_configurable_bindings); - JERRY_ASSERT (ecma_is_empty_completion_value (completion)); + JERRY_ASSERT (ecma_is_completion_value_empty (completion)); } else if (ecma_is_lexical_environment_global (lex_env_p)) { @@ -635,7 +633,7 @@ ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment } else if (existing_prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR) { - completion = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + completion = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { @@ -644,7 +642,7 @@ ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment if (existing_prop_p->u.named_data_property.writable != ECMA_PROPERTY_WRITABLE || existing_prop_p->u.named_data_property.enumerable != ECMA_PROPERTY_ENUMERABLE) { - completion = ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + completion = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } } @@ -659,7 +657,7 @@ ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment } else { - JERRY_ASSERT (ecma_is_empty_completion_value (completion)); + JERRY_ASSERT (ecma_is_completion_value_empty (completion)); // f. ret_value = ecma_op_set_mutable_binding (lex_env_p, diff --git a/src/libecmaoperations/ecma-get-put-value.c b/src/libecmaoperations/ecma-get-put-value.c index 2f34d82ac..c0e41ec1a 100644 --- a/src/libecmaoperations/ecma-get-put-value.c +++ b/src/libecmaoperations/ecma-get-put-value.c @@ -58,7 +58,7 @@ ecma_op_get_value (ecma_reference_t ref) /**< ECMA-reference */ // 3. if (is_unresolvable_reference) { - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE)); } // 4. @@ -114,7 +114,7 @@ ecma_reject_put (bool is_throw) /**< Throw flag */ { if (is_throw) { - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { @@ -149,7 +149,7 @@ ecma_op_put_value (ecma_reference_t ref, /**< ECMA-reference */ // 3.a. if (ref.is_strict) { - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE)); } else { diff --git a/src/libecmaoperations/ecma-lex-env.c b/src/libecmaoperations/ecma-lex-env.c index 06d431244..8afc3e7e7 100644 --- a/src/libecmaoperations/ecma-lex-env.c +++ b/src/libecmaoperations/ecma-lex-env.c @@ -94,8 +94,7 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */ } } - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_make_simple_value (has_binding)); + return ecma_make_simple_completion_value (has_binding); } /* ecma_op_has_binding */ /** @@ -203,7 +202,7 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment } else if (is_strict) { - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } break; @@ -260,15 +259,14 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */ /* is the binding mutable? */ if (property_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE) { - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_copy_value (prop_value, true)); + return ecma_make_normal_completion_value (ecma_copy_value (prop_value, true)); } else if (ecma_is_value_empty (prop_value)) { /* unitialized immutable binding */ if (is_strict) { - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE)); } else { @@ -288,7 +286,7 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */ { if (is_strict) { - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE)); } else { @@ -346,8 +344,7 @@ ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */ } } - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_make_simple_value (ret_val)); + return ecma_make_simple_completion_value (ret_val); } case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND: { @@ -391,8 +388,7 @@ ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p); ecma_ref_object (binding_obj_p); - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_make_object_value (binding_obj_p)); + return ecma_make_normal_completion_value (ecma_make_object_value (binding_obj_p)); } else { diff --git a/src/libecmaoperations/ecma-objects-general.c b/src/libecmaoperations/ecma-objects-general.c index cd1d9d450..69f1c7190 100644 --- a/src/libecmaoperations/ecma-objects-general.c +++ b/src/libecmaoperations/ecma-objects-general.c @@ -40,7 +40,7 @@ ecma_reject (bool is_throw) /**< Throw flag */ { if (is_throw) { - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { @@ -84,8 +84,7 @@ ecma_op_create_object_object_arg (ecma_value_t value) /**< argument of construct case ECMA_TYPE_OBJECT: { // 1.a - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_copy_value (value, true)); + return ecma_make_normal_completion_value (ecma_copy_value (value, true)); } case ECMA_TYPE_NUMBER: case ECMA_TYPE_STRING: @@ -107,8 +106,7 @@ ecma_op_create_object_object_arg (ecma_value_t value) /**< argument of construct ecma_object_t *obj_p = ecma_op_create_object_object_noarg (); - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_make_object_value (obj_p)); + return ecma_make_normal_completion_value (ecma_make_object_value (obj_p)); } } @@ -144,8 +142,7 @@ ecma_op_general_object_get (ecma_object_t *obj_p, /**< the object */ // 3. if (prop_p->type == ECMA_PROPERTY_NAMEDDATA) { - return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_copy_value (prop_p->u.named_data_property.value, true)); + return ecma_make_normal_completion_value (ecma_copy_value (prop_p->u.named_data_property.value, true)); } else { @@ -168,8 +165,7 @@ ecma_op_general_object_get (ecma_object_t *obj_p, /**< the object */ 0), ret_value); - ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL, - ecma_copy_value (call_completion.u.value, true)); + ret_value = ecma_make_normal_completion_value (ecma_copy_value (call_completion.u.value, true)); ECMA_FINALIZE (call_completion); @@ -265,7 +261,7 @@ ecma_op_general_object_put (ecma_object_t *obj_p, /**< the object */ if (is_throw) { // a. - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { @@ -523,7 +519,7 @@ ecma_op_general_object_delete (ecma_object_t *obj_p, /**< the object */ else if (is_throw) { // 4. - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } else { diff --git a/src/libecmaoperations/ecma-objects.c b/src/libecmaoperations/ecma-objects.c index a902fb2d5..00d5746e0 100644 --- a/src/libecmaoperations/ecma-objects.c +++ b/src/libecmaoperations/ecma-objects.c @@ -418,7 +418,7 @@ ecma_op_object_has_instance (ecma_object_t *obj_p, /**< the object */ case ECMA_OBJECT_TYPE_STRING: case ECMA_OBJECT_TYPE_ARGUMENTS: { - return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); + return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } case ECMA_OBJECT_TYPE_FUNCTION: