Minor fix to RegExp.prototype.compile (#4112)

Fixed tests from the exclude list:
<test id="annexB/built-ins/RegExp/prototype/compile/length.js"><reason></reason></test>
<test id="annexB/built-ins/RegExp/prototype/compile/pattern-regexp-flags-defined.js"><reason></reason></test>
<test id="annexB/built-ins/RegExp/prototype/compile/pattern-regexp-immutable-lastindex.js"><reason></reason></test>

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2020-08-26 15:16:55 +02:00
committed by GitHub
parent 09c8d28b2c
commit 138151832a
4 changed files with 84 additions and 23 deletions
@@ -265,7 +265,7 @@ ecma_builtin_regexp_prototype_get_source (ecma_extended_object_t *re_obj_p) /**<
* The RegExp.prototype object's 'compile' routine
*
* See also:
* ECMA-262 v5, B.2.5.1
* ECMA-262 v11, B.2.5.1
*
* @return undefined - if compiled successfully
* error ecma value - otherwise
@@ -289,17 +289,6 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this */
re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t,
re_obj_p->u.class_prop.u.value);
ecma_value_t status = ecma_builtin_helper_def_prop (this_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
ecma_make_uint32_value (0),
ECMA_PROPERTY_FLAG_WRITABLE | ECMA_PROP_IS_THROW);
if (ECMA_IS_VALUE_ERROR (status))
{
return status;
}
JERRY_ASSERT (ecma_is_value_true (status));
ecma_value_t ret_value;
if (ecma_object_is_regexp_object (pattern_arg))
@@ -313,19 +302,28 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this */
re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t,
pattern_obj_p->u.class_prop.u.value);
ecma_ref_object (this_obj_p);
ret_value = ecma_op_create_regexp_from_bytecode (this_obj_p, bc_p);
ecma_bytecode_deref ((ecma_compiled_code_t *) old_bc_p);
return ret_value;
}
ret_value = ecma_op_create_regexp_from_pattern (this_obj_p, pattern_arg, flags_arg);
else
{
ret_value = ecma_op_create_regexp_from_pattern (this_obj_p, pattern_arg, flags_arg);
}
if (!ECMA_IS_VALUE_ERROR (ret_value))
{
ecma_ref_object (this_obj_p);
ecma_value_t status = ecma_builtin_helper_def_prop (this_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
ecma_make_uint32_value (0),
ECMA_PROPERTY_FLAG_WRITABLE | ECMA_PROP_IS_THROW);
ecma_bytecode_deref ((ecma_compiled_code_t *) old_bc_p);
if (ECMA_IS_VALUE_ERROR (status))
{
return status;
}
ecma_ref_object (this_obj_p);
}
return ret_value;
@@ -91,7 +91,7 @@ NUMBER_VALUE (LIT_MAGIC_STRING_LASTINDEX_UL,
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_BUILTIN_ANNEXB)
ROUTINE (LIT_MAGIC_STRING_COMPILE, ECMA_REGEXP_PROTOTYPE_ROUTINE_COMPILE, 2, 1)
ROUTINE (LIT_MAGIC_STRING_COMPILE, ECMA_REGEXP_PROTOTYPE_ROUTINE_COMPILE, 2, 2)
#endif /* ENABLED (JERRY_BUILTIN_ANNEXB) */
ROUTINE (LIT_MAGIC_STRING_EXEC, ECMA_REGEXP_PROTOTYPE_ROUTINE_EXEC, 1, 1)
ROUTINE (LIT_MAGIC_STRING_TEST, ECMA_REGEXP_PROTOTYPE_ROUTINE_TEST, 1, 1)