Implement RegExp.prototype.compile()

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
This commit is contained in:
Dániel Bátyai
2015-08-17 15:16:44 +02:00
parent 63d3e02b59
commit 13941df8dd
8 changed files with 341 additions and 58 deletions
+14 -5
View File
@@ -633,7 +633,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
* Returned value must be freed with ecma_free_completion_value
*/
ecma_completion_value_t
re_compile_bytecode (ecma_property_t *bytecode_p, /**< bytecode */
re_compile_bytecode (re_bytecode_t **out_bytecode_p, /**< out:pointer to bytecode */
ecma_string_t *pattern_str_p, /**< pattern */
uint8_t flags) /**< flags */
{
@@ -684,12 +684,21 @@ re_compile_bytecode (ecma_property_t *bytecode_p, /**< bytecode */
}
ECMA_FINALIZE (empty);
/* The RegExp bytecode contains at least a RE_OP_SAVE_AT_START opdoce, so it cannot be NULL. */
JERRY_ASSERT (bc_ctx.block_start_p != NULL);
ECMA_SET_POINTER (bytecode_p->u.internal_property.value, bc_ctx.block_start_p);
MEM_FINALIZE_LOCAL_ARRAY (pattern_start_p);
if (!ecma_is_completion_value_empty (ret_value))
{
/* Compilation failed, free bytecode. */
mem_heap_free_block (bc_ctx.block_start_p);
*out_bytecode_p = NULL;
}
else
{
/* The RegExp bytecode contains at least a RE_OP_SAVE_AT_START opdoce, so it cannot be NULL. */
JERRY_ASSERT (bc_ctx.block_start_p != NULL);
*out_bytecode_p = bc_ctx.block_start_p;
}
#ifdef JERRY_ENABLE_LOG
re_dump_bytecode (&bc_ctx);
#endif