Update the RegExp constructor to ECMA-262 v6 (#3538)

The following methods have been implemented:
- RegExpAlloc, based on ECMA-262 v6, 21.2.3.2.1
- RegExpInitialize, based on ECMA-262 v6, 22.2.3.2.2
- RegExpCreate, based on ECMA-262 v6, 21.2.3.2.3

Co-authored-by: Robert Fancsik frobert@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2020-03-27 10:37:06 +01:00
committed by GitHub
parent 56832d772e
commit d539d30bf9
18 changed files with 618 additions and 358 deletions
+11 -4
View File
@@ -1106,17 +1106,24 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
ecma_dealloc_number (num_p);
break;
}
#if ENABLED (JERRY_ES2015)
case LIT_INTERNAL_MAGIC_STRING_REGEXP_PROTO:
{
jmem_heap_free_block (ECMA_GET_INTERNAL_VALUE_POINTER (void, ext_object_p->u.class_prop.u.value),
ECMA_REGEXP_PROTO_COMPILED_CODE_SIZE);
break;
}
#endif /* ENABLED (JERRY_ES2015) */
case LIT_MAGIC_STRING_REGEXP_UL:
{
ecma_compiled_code_t *bytecode_p;
bytecode_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t,
ext_object_p->u.class_prop.u.value);
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t,
ext_object_p->u.class_prop.u.value);
if (bytecode_p != NULL)
{
ecma_bytecode_deref (bytecode_p);
}
break;
}
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
+7
View File
@@ -940,6 +940,13 @@ typedef struct
* If regexp, the other flags must be RE_FLAG... */
} ecma_compiled_code_t;
/**
* The proper memory size for the RegExp.prototype. We have to align the header's size manually, because
* in the struct, it is aligned to 8 bytes during the compilation.
*/
#define ECMA_REGEXP_PROTO_COMPILED_CODE_SIZE \
(JERRY_ALIGNUP (sizeof (ecma_compiled_code_t), JMEM_ALIGNMENT) + sizeof (ecma_value_t))
#if ENABLED (JERRY_SNAPSHOT_EXEC)
/**
+22
View File
@@ -1494,6 +1494,28 @@ ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *b
} /* ecma_compiled_code_get_tagged_template_collection */
#endif /* ENABLED (JERRY_ES2015) */
/**
* Helper function to check if the given value is a class
*
* @return pointer to the extended object - if 'this' is a class
* NULL- otherwise
*/
ecma_extended_object_t *
ecma_op_check_object_type_is_class (ecma_value_t this) /**< this value */
{
if (ecma_is_value_object (this))
{
ecma_object_t *obj_p = ecma_get_object_from_value (this);
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_CLASS)
{
return (ecma_extended_object_t *) obj_p;
}
}
return NULL;
} /* ecma_op_check_object_type_is_class */
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM) || ENABLED (JERRY_ES2015)
/**
* Get the number of formal parameters of the compiled code
+1
View File
@@ -430,6 +430,7 @@ uint8_t ecma_get_object_builtin_id (ecma_object_t *object_p);
ecma_lexical_environment_type_t JERRY_ATTR_PURE ecma_get_lex_env_type (const ecma_object_t *object_p);
ecma_object_t JERRY_ATTR_PURE *ecma_get_lex_env_binding_object (const ecma_object_t *object_p);
ecma_object_t *ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, bool copy_values);
ecma_extended_object_t *ecma_op_check_object_type_is_class (ecma_value_t this);
ecma_property_value_t *
ecma_create_named_data_property (ecma_object_t *object_p, ecma_string_t *name_p, uint8_t prop_attributes,