Implement IsRegExp operation (#3321)

Algorithm is based on ECMA-262 v6, 22.1.3.1.1

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2019-11-20 11:50:26 +01:00
committed by Robert Fancsik
parent bd0cb33172
commit c31452c138
12 changed files with 233 additions and 38 deletions
@@ -569,12 +569,20 @@ ecma_builtin_helper_string_prototype_object_index_of (ecma_string_t *original_st
#if ENABLED (JERRY_ES2015_BUILTIN)
/* 4, 6 (startsWith, includes, endsWith) */
if (mode >= ECMA_STRING_STARTS_WITH
&& (ecma_is_value_object (arg1)
&& ecma_object_class_is (ecma_get_object_from_value (arg1), LIT_MAGIC_STRING_REGEXP_UL)))
if (mode >= ECMA_STRING_STARTS_WITH)
{
JERRY_ASSERT (ECMA_STRING_LAST_INDEX_OF < mode && mode <= ECMA_STRING_ENDS_WITH);
return ecma_raise_type_error (ECMA_ERR_MSG ("Search string can't be of type: RegExp"));
ecma_value_t regexp = ecma_op_is_regexp (arg1);
if (ECMA_IS_VALUE_ERROR (regexp))
{
return regexp;
}
if (regexp == ECMA_VALUE_TRUE)
{
JERRY_ASSERT (ECMA_STRING_LAST_INDEX_OF < mode && mode <= ECMA_STRING_ENDS_WITH);
return ecma_raise_type_error (ECMA_ERR_MSG ("Search string can't be of type: RegExp"));
}
}
#endif /* ENABLED (JERRY_ES2015_BUILTIN) */