diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c index da9d7e625..8552fe331 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c @@ -63,156 +63,157 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this argument ecma_value_t pattern_arg, /**< pattern or RegExp object */ ecma_value_t flags_arg) /**< flags */ { - ecma_value_t ret_value = ECMA_VALUE_EMPTY; - if (!ecma_is_value_object (this_arg) || !ecma_object_class_is (ecma_get_object_from_value (this_arg), LIT_MAGIC_STRING_REGEXP_UL)) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incomplete RegExp type")); + return ecma_raise_type_error (ECMA_ERR_MSG ("Incomplete RegExp type")); } - else + + uint16_t flags = 0; + + if (ecma_is_value_object (pattern_arg) + && ecma_object_class_is (ecma_get_object_from_value (pattern_arg), LIT_MAGIC_STRING_REGEXP_UL)) { - uint16_t flags = 0; - - if (ecma_is_value_object (pattern_arg) - && ecma_object_class_is (ecma_get_object_from_value (pattern_arg), LIT_MAGIC_STRING_REGEXP_UL)) + if (!ecma_is_value_undefined (flags_arg)) { - if (!ecma_is_value_undefined (flags_arg)) - { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument of RegExp compile.")); - } - else - { - /* Compile from existing RegExp pbject. */ - ecma_object_t *target_p = ecma_get_object_from_value (pattern_arg); - - /* Get source. */ - ecma_string_t *magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_SOURCE); - ecma_value_t source_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p); - ecma_string_t *pattern_string_p = ecma_get_string_from_value (source_value); - - /* Get flags. */ - magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GLOBAL); - ecma_value_t global_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p); - - JERRY_ASSERT (ecma_is_value_boolean (global_value)); - - if (ecma_is_value_true (global_value)) - { - flags |= RE_FLAG_GLOBAL; - } - - magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_IGNORECASE_UL); - ecma_value_t ignore_case_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p); - - JERRY_ASSERT (ecma_is_value_boolean (ignore_case_value)); - - if (ecma_is_value_true (ignore_case_value)) - { - flags |= RE_FLAG_IGNORE_CASE; - } - - magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MULTILINE); - ecma_value_t multiline_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p); - - JERRY_ASSERT (ecma_is_value_boolean (multiline_value)); - - if (ecma_is_value_true (multiline_value)) - { - flags |= RE_FLAG_MULTILINE; - } - - ECMA_TRY_CATCH (obj_this, ecma_op_to_object (this_arg), ret_value); - ecma_object_t *this_obj_p = ecma_get_object_from_value (obj_this); - - /* Get bytecode property. */ - ecma_value_t *bc_prop_p = &(((ecma_extended_object_t *) this_obj_p)->u.class_prop.u.value); - - /* TODO: We currently have to re-compile the bytecode, because - * we can't copy it without knowing its length. */ - const re_compiled_code_t *new_bc_p = NULL; - ecma_value_t bc_comp = re_compile_bytecode (&new_bc_p, pattern_string_p, flags); - /* Should always succeed, since we're compiling from a source that has been compiled previously. */ - JERRY_ASSERT (ecma_is_value_empty (bc_comp)); - - ecma_deref_ecma_string (pattern_string_p); - - re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (re_compiled_code_t, *bc_prop_p); - - if (old_bc_p != NULL) - { - /* Free the old bytecode */ - ecma_bytecode_deref ((ecma_compiled_code_t *) old_bc_p); - } - - ECMA_SET_INTERNAL_VALUE_POINTER (*bc_prop_p, new_bc_p); - - re_initialize_props (this_obj_p, pattern_string_p, flags); - - ret_value = ECMA_VALUE_UNDEFINED; - - ECMA_FINALIZE (obj_this); - } + return ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument of RegExp compile.")); } - else + /* Compile from existing RegExp pbject. */ + ecma_object_t *target_p = ecma_get_object_from_value (pattern_arg); + + /* Get source. */ + ecma_string_t *magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_SOURCE); + ecma_value_t source_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p); + ecma_string_t *pattern_string_p = ecma_get_string_from_value (source_value); + + /* Get flags. */ + magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GLOBAL); + ecma_value_t global_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p); + + JERRY_ASSERT (ecma_is_value_boolean (global_value)); + + if (ecma_is_value_true (global_value)) { - ecma_string_t *pattern_string_p = NULL; + flags |= RE_FLAG_GLOBAL; + } - /* Get source string. */ - ret_value = ecma_regexp_read_pattern_str_helper (pattern_arg, &pattern_string_p); + magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_IGNORECASE_UL); + ecma_value_t ignore_case_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p); - /* Parse flags. */ - if (ecma_is_value_empty (ret_value) && !ecma_is_value_undefined (flags_arg)) - { - ECMA_TRY_CATCH (flags_str_value, - ecma_op_to_string (flags_arg), - ret_value); + JERRY_ASSERT (ecma_is_value_boolean (ignore_case_value)); - ECMA_TRY_CATCH (flags_dummy, - re_parse_regexp_flags (ecma_get_string_from_value (flags_str_value), &flags), - ret_value); - ECMA_FINALIZE (flags_dummy); - ECMA_FINALIZE (flags_str_value); - } + if (ecma_is_value_true (ignore_case_value)) + { + flags |= RE_FLAG_IGNORE_CASE; + } - if (ecma_is_value_empty (ret_value)) - { - ECMA_TRY_CATCH (obj_this, ecma_op_to_object (this_arg), ret_value); - ecma_object_t *this_obj_p = ecma_get_object_from_value (obj_this); + magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MULTILINE); + ecma_value_t multiline_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p); - ecma_value_t *bc_prop_p = &(((ecma_extended_object_t *) this_obj_p)->u.class_prop.u.value); + JERRY_ASSERT (ecma_is_value_boolean (multiline_value)); - /* Try to compile bytecode from new source. */ - const re_compiled_code_t *new_bc_p = NULL; - ECMA_TRY_CATCH (bc_dummy, - re_compile_bytecode (&new_bc_p, pattern_string_p, flags), - ret_value); + if (ecma_is_value_true (multiline_value)) + { + flags |= RE_FLAG_MULTILINE; + } - re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (re_compiled_code_t, *bc_prop_p); + ecma_value_t obj_this = ecma_op_to_object (this_arg); + if (ECMA_IS_VALUE_ERROR (obj_this)) + { + return obj_this; + } + ecma_object_t *this_obj_p = ecma_get_object_from_value (obj_this); - if (old_bc_p != NULL) - { - /* Free the old bytecode */ - ecma_bytecode_deref ((ecma_compiled_code_t *) old_bc_p); - } + /* Get bytecode property. */ + ecma_value_t *bc_prop_p = &(((ecma_extended_object_t *) this_obj_p)->u.class_prop.u.value); - ECMA_SET_INTERNAL_VALUE_POINTER (*bc_prop_p, new_bc_p); - re_initialize_props (this_obj_p, pattern_string_p, flags); - ret_value = ECMA_VALUE_UNDEFINED; + /* TODO: We currently have to re-compile the bytecode, because + * we can't copy it without knowing its length. */ + const re_compiled_code_t *new_bc_p = NULL; + ecma_value_t bc_comp = re_compile_bytecode (&new_bc_p, pattern_string_p, flags); + /* Should always succeed, since we're compiling from a source that has been compiled previously. */ + JERRY_ASSERT (ecma_is_value_empty (bc_comp)); - ECMA_FINALIZE (bc_dummy); + ecma_deref_ecma_string (pattern_string_p); - ECMA_FINALIZE (obj_this); - } + re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (re_compiled_code_t, *bc_prop_p); - if (pattern_string_p != NULL) - { - ecma_deref_ecma_string (pattern_string_p); - } + if (old_bc_p != NULL) + { + /* Free the old bytecode */ + ecma_bytecode_deref ((ecma_compiled_code_t *) old_bc_p); + } + + ECMA_SET_INTERNAL_VALUE_POINTER (*bc_prop_p, new_bc_p); + + re_initialize_props (this_obj_p, pattern_string_p, flags); + ecma_free_value (obj_this); + + return ECMA_VALUE_UNDEFINED; + } + + ecma_string_t *pattern_string_p = NULL; + + /* Get source string. */ + ecma_value_t ret_value = ecma_regexp_read_pattern_str_helper (pattern_arg, &pattern_string_p); + if (ECMA_IS_VALUE_ERROR (ret_value)) + { + JERRY_ASSERT (pattern_string_p == NULL); + return ret_value; + } + JERRY_ASSERT (ecma_is_value_empty (ret_value)); + + /* Parse flags. */ + if (!ecma_is_value_undefined (flags_arg)) + { + ecma_value_t flags_str_value = ecma_op_to_string (flags_arg); + if (ECMA_IS_VALUE_ERROR (flags_str_value)) + { + ecma_deref_ecma_string (pattern_string_p); + return flags_str_value; + } + + ecma_value_t parsed_flags_val = re_parse_regexp_flags (ecma_get_string_from_value (flags_str_value), &flags); + ecma_free_value (flags_str_value); + if (ECMA_IS_VALUE_ERROR (parsed_flags_val)) + { + ecma_deref_ecma_string (pattern_string_p); + return parsed_flags_val; } } - return ret_value; + /* Try to compile bytecode from new source. */ + const re_compiled_code_t *new_bc_p = NULL; + ecma_value_t bc_val = re_compile_bytecode (&new_bc_p, pattern_string_p, flags); + if (ECMA_IS_VALUE_ERROR (bc_val)) + { + ecma_deref_ecma_string (pattern_string_p); + return bc_val; + } + + ecma_value_t obj_this = ecma_op_to_object (this_arg); + if (ECMA_IS_VALUE_ERROR (obj_this)) + { + ecma_deref_ecma_string (pattern_string_p); + return obj_this; + } + ecma_object_t *this_obj_p = ecma_get_object_from_value (obj_this); + ecma_value_t *bc_prop_p = &(((ecma_extended_object_t *) this_obj_p)->u.class_prop.u.value); + + re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (re_compiled_code_t, *bc_prop_p); + + if (old_bc_p != NULL) + { + /* Free the old bytecode */ + ecma_bytecode_deref ((ecma_compiled_code_t *) old_bc_p); + } + + ECMA_SET_INTERNAL_VALUE_POINTER (*bc_prop_p, new_bc_p); + re_initialize_props (this_obj_p, pattern_string_p, flags); + ecma_free_value (obj_this); + ecma_deref_ecma_string (pattern_string_p); + + return ECMA_VALUE_UNDEFINED; } /* ecma_builtin_regexp_prototype_compile */ #endif /* !CONFIG_DISABLE_ANNEXB_BUILTIN */ @@ -232,48 +233,49 @@ static ecma_value_t ecma_builtin_regexp_prototype_exec (ecma_value_t this_arg, /**< this argument */ ecma_value_t arg) /**< routine's argument */ { - ecma_value_t ret_value = ECMA_VALUE_EMPTY; - if (!ecma_is_value_object (this_arg) || !ecma_object_class_is (ecma_get_object_from_value (this_arg), LIT_MAGIC_STRING_REGEXP_UL)) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incomplete RegExp type")); + return ecma_raise_type_error (ECMA_ERR_MSG ("Incomplete RegExp type")); + } + + ecma_value_t obj_this = ecma_op_to_object (this_arg); + if (ECMA_IS_VALUE_ERROR (obj_this)) + { + return obj_this; + } + + ecma_value_t input_str_value = ecma_op_to_string (arg); + if (ECMA_IS_VALUE_ERROR (input_str_value)) + { + ecma_free_value (obj_this); + return input_str_value; + } + + ecma_object_t *obj_p = ecma_get_object_from_value (obj_this); + ecma_value_t *bytecode_prop_p = &(((ecma_extended_object_t *) obj_p)->u.class_prop.u.value); + + void *bytecode_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (void, *bytecode_prop_p); + + ecma_value_t ret_value; + if (bytecode_p == NULL) + { + /* Missing bytecode means empty RegExp: '/(?:)/', so always return empty string. */ + ecma_value_t empty_str_val = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY); + ret_value = ecma_op_create_array_object (&empty_str_val, 1, false); + re_set_result_array_properties (ecma_get_object_from_value (ret_value), + ecma_get_string_from_value (input_str_value), + 1, + 0); } else { - ECMA_TRY_CATCH (obj_this, ecma_op_to_object (this_arg), ret_value); - - ECMA_TRY_CATCH (input_str_value, - ecma_op_to_string (arg), - ret_value); - - ecma_object_t *obj_p = ecma_get_object_from_value (obj_this); - ecma_value_t *bytecode_prop_p = &(((ecma_extended_object_t *) obj_p)->u.class_prop.u.value); - - void *bytecode_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (void, *bytecode_prop_p); - - if (bytecode_p == NULL) - { - /* Missing bytecode means empty RegExp: '/(?:)/', so always return empty string. */ - ecma_value_t arguments_list[1]; - arguments_list[0] = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY); - - ret_value = ecma_op_create_array_object (arguments_list, 1, false); - - re_set_result_array_properties (ecma_get_object_from_value (ret_value), - ecma_get_string_from_value (input_str_value), - 1, - 0); - } - else - { - ret_value = ecma_regexp_exec_helper (obj_this, input_str_value, false); - } - - ECMA_FINALIZE (input_str_value); - ECMA_FINALIZE (obj_this); + ret_value = ecma_regexp_exec_helper (obj_this, input_str_value, false); } + ecma_free_value (obj_this); + ecma_free_value (input_str_value); + return ret_value; } /* ecma_builtin_regexp_prototype_exec */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c index d4c5857e5..7f1240fed 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c @@ -64,7 +64,6 @@ ecma_value_t ecma_builtin_regexp_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_length_t arguments_list_len) /**< number of arguments */ { - ecma_value_t ret_value = ECMA_VALUE_EMPTY; ecma_value_t pattern_value = ECMA_VALUE_UNDEFINED; ecma_value_t flags_value = ECMA_VALUE_UNDEFINED; @@ -84,54 +83,46 @@ ecma_builtin_regexp_dispatch_construct (const ecma_value_t *arguments_list_p, /* { if (ecma_is_value_undefined (flags_value)) { - ret_value = ecma_copy_value (pattern_value); - } - else - { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument of RegExp call.")); + return ecma_copy_value (pattern_value); } + + return ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument of RegExp call.")); } - else + + ecma_string_t *pattern_string_p = NULL; + ecma_value_t ret_value = ecma_regexp_read_pattern_str_helper (pattern_value, &pattern_string_p); + if (ECMA_IS_VALUE_ERROR (ret_value)) { - ecma_string_t *pattern_string_p = NULL; - ecma_string_t *flags_string_p = NULL; + return ret_value; + } + JERRY_ASSERT (ecma_is_value_empty (ret_value)); - ret_value = ecma_regexp_read_pattern_str_helper (pattern_value, &pattern_string_p); + uint16_t flags = 0; + if (!ecma_is_value_undefined (flags_value)) + { + ecma_value_t flags_str_value = ecma_op_to_string (flags_value); - if (ecma_is_value_empty (ret_value) && !ecma_is_value_undefined (flags_value)) - { - ECMA_TRY_CATCH (flags_str_value, - ecma_op_to_string (flags_value), - ret_value); - - flags_string_p = ecma_get_string_from_value (flags_str_value); - ecma_ref_ecma_string (flags_string_p); - - ECMA_FINALIZE (flags_str_value); - } - - uint16_t flags = 0; - if (ecma_is_value_empty (ret_value) && (flags_string_p != NULL)) - { - ret_value = re_parse_regexp_flags (flags_string_p, &flags); - } - - if (ecma_is_value_empty (ret_value)) - { - ret_value = ecma_op_create_regexp_object (pattern_string_p, flags); - } - - if (pattern_string_p != NULL) + if (ECMA_IS_VALUE_ERROR (flags_str_value)) { ecma_deref_ecma_string (pattern_string_p); + return flags_str_value; } - if (flags_string_p != NULL) + ecma_string_t *flags_string_p = ecma_get_string_from_value (flags_str_value); + JERRY_ASSERT (flags_string_p != NULL); + ret_value = re_parse_regexp_flags (flags_string_p, &flags); + ecma_free_value (flags_str_value); // implicit frees flags_string_p + + if (ECMA_IS_VALUE_ERROR (ret_value)) { - ecma_deref_ecma_string (flags_string_p); + ecma_deref_ecma_string (pattern_string_p); + return ret_value; } + JERRY_ASSERT (ecma_is_value_empty (ret_value)); } + ret_value = ecma_op_create_regexp_object (pattern_string_p, flags); + ecma_deref_ecma_string (pattern_string_p); return ret_value; } /* ecma_builtin_regexp_dispatch_construct */ diff --git a/jerry-core/ecma/operations/ecma-comparison.c b/jerry-core/ecma/operations/ecma-comparison.c index 3a145f4ea..8ddddfdef 100644 --- a/jerry-core/ecma/operations/ecma-comparison.c +++ b/jerry-core/ecma/operations/ecma-comparison.c @@ -286,12 +286,18 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */ ecma_value_t ret_value = ECMA_VALUE_EMPTY; /* 1., 2. */ - ECMA_TRY_CATCH (prim_first_converted_value, - ecma_op_to_primitive (x, ECMA_PREFERRED_TYPE_NUMBER), - ret_value); - ECMA_TRY_CATCH (prim_second_converted_value, - ecma_op_to_primitive (y, ECMA_PREFERRED_TYPE_NUMBER), - ret_value); + ecma_value_t prim_first_converted_value = ecma_op_to_primitive (x, ECMA_PREFERRED_TYPE_NUMBER); + if (ECMA_IS_VALUE_ERROR (prim_first_converted_value)) + { + return prim_first_converted_value; + } + + ecma_value_t prim_second_converted_value = ecma_op_to_primitive (y, ECMA_PREFERRED_TYPE_NUMBER); + if (ECMA_IS_VALUE_ERROR (prim_second_converted_value)) + { + ecma_free_value (prim_first_converted_value); + return prim_second_converted_value; + } const ecma_value_t px = left_first ? prim_first_converted_value : prim_second_converted_value; const ecma_value_t py = left_first ? prim_second_converted_value : prim_first_converted_value; @@ -393,8 +399,8 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */ ret_value = ecma_make_boolean_value (is_px_less); } - ECMA_FINALIZE (prim_second_converted_value); - ECMA_FINALIZE (prim_first_converted_value); + ecma_free_value (prim_second_converted_value); + ecma_free_value (prim_first_converted_value); return ret_value; } /* ecma_op_abstract_relational_compare */ diff --git a/jerry-core/ecma/operations/ecma-regexp-object.c b/jerry-core/ecma/operations/ecma-regexp-object.c index 225837987..64a8f13f6 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.c +++ b/jerry-core/ecma/operations/ecma-regexp-object.c @@ -250,7 +250,6 @@ ecma_op_create_regexp_object (ecma_string_t *pattern_p, /**< input pattern */ uint16_t flags) /**< flags */ { JERRY_ASSERT (pattern_p != NULL); - ecma_value_t ret_value = ECMA_VALUE_EMPTY; ecma_object_t *re_prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_REGEXP_PROTOTYPE); @@ -264,22 +263,20 @@ ecma_op_create_regexp_object (ecma_string_t *pattern_p, /**< input pattern */ /* Compile bytecode. */ const re_compiled_code_t *bc_p = NULL; - ECMA_TRY_CATCH (empty, re_compile_bytecode (&bc_p, pattern_p, flags), ret_value); + ecma_value_t ret_value = re_compile_bytecode (&bc_p, pattern_p, flags); + if (ECMA_IS_VALUE_ERROR (ret_value)) + { + ecma_deref_object (object_p); + return ret_value; + } + + JERRY_ASSERT (ecma_is_value_empty (ret_value)); /* Set [[Class]] and bytecode internal properties. */ ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_REGEXP_UL; ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.class_prop.u.value, bc_p); - ret_value = ecma_make_object_value (object_p); - - ECMA_FINALIZE (empty); - - if (ECMA_IS_VALUE_ERROR (ret_value)) - { - ecma_deref_object (object_p); - } - - return ret_value; + return ecma_make_object_value (object_p); } /* ecma_op_create_regexp_object */ /** @@ -1280,7 +1277,7 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */ const lit_utf8_byte_t *sub_str_p = NULL; uint8_t *bc_start_p = (uint8_t *) (bc_p + 1); - while (ecma_is_value_empty (ret_value)) + while (!ECMA_IS_VALUE_ERROR (ret_value)) { if (index < 0 || index > (int32_t) input_str_len) { @@ -1297,13 +1294,13 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */ } else { - ECMA_TRY_CATCH (match_value, re_match_regexp (&re_ctx, - bc_start_p, - input_curr_p, - &sub_str_p), - ret_value); + ret_value = re_match_regexp (&re_ctx, bc_start_p, input_curr_p, &sub_str_p); + if (ECMA_IS_VALUE_ERROR (ret_value)) + { + break; + } - if (ecma_is_value_true (match_value)) + if (ecma_is_value_true (ret_value)) { is_match = true; break; @@ -1314,8 +1311,6 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */ lit_utf8_incr (&input_curr_p); } index++; - - ECMA_FINALIZE (match_value); } } @@ -1341,7 +1336,7 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */ } /* 3. Fill the result array or return with 'undefiend' */ - if (ecma_is_value_empty (ret_value)) + if (!ECMA_IS_VALUE_ERROR (ret_value)) { if (is_match) { diff --git a/jerry-core/parser/regexp/re-compiler.c b/jerry-core/parser/regexp/re-compiler.c index 89df5829a..f0e5d60d7 100644 --- a/jerry-core/parser/regexp/re-compiler.c +++ b/jerry-core/parser/regexp/re-compiler.c @@ -262,7 +262,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context ret_value = next_token_result; break; } - JERRY_ASSERT (next_token_result == ECMA_VALUE_EMPTY); + JERRY_ASSERT (ecma_is_value_empty (next_token_result)); uint32_t new_atom_start_offset = re_get_bytecode_length (re_ctx_p->bytecode_ctx_p);