Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement AnnexB RegExp.prototype.compile() #579

Merged
merged 1 commit into from
Aug 24, 2015

Conversation

dbatyai
Copy link
Member

@dbatyai dbatyai commented Aug 17, 2015

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]

@dbatyai dbatyai added ecma builtins Related to ECMA built-in routines development Feature implementation labels Aug 17, 2015
@dbatyai dbatyai added this to the ECMA builtins milestone Aug 17, 2015
{
flags_value = args[1];
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need variable arguments here? Can't we simply have two arguments?

@zherczeg
Copy link
Member

Quite a good patch, just a few things

void
re_initialize_props (ecma_object_t *re_obj_p,
ecma_string_t *source_p,
uint8_t flags)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comments.

@dbatyai
Copy link
Member Author

dbatyai commented Aug 19, 2015

@zherczeg, @ruben-ayrapetyan I've updated the patch based on your comments.

re_bytecode_t *new_bc_p = NULL;
ecma_completion_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_completion_value_normal (bc_comp));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ecma_is_completion_value_empty? In the case, completion value doesn't need to be freed.

@ruben-ayrapetyan
Copy link
Contributor

After fixing #579 (comment) and #579 (comment) the changes would look good to me.

assert (re2.ignoreCase === re1.ignoreCase);
assert (re2.multiline === re1.multiline);
assert (re2.source === re1.source);
assert (re2.lastIndex === 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question: can we rewrite non-configurable properties? E.g. re2.compile(re1); what is happening, if re2.global is non configurable? It would worth adding a test to show that it works.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, because we use the internal API to do it. Also, all flag properties are already non-configurable, so the currently added test cases should cover testing this.

@zherczeg
Copy link
Member

LGTM in general, but please check whether we can overwrite non-configurable properties.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]
@dbatyai dbatyai merged commit 13941df into jerryscript-project:master Aug 24, 2015
@dbatyai dbatyai deleted the regexp-compile branch August 26, 2015 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Feature implementation ecma builtins Related to ECMA built-in routines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants