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 ECMA262 RegExp builtin object and RegExp engine #169

Merged
merged 7 commits into from
Jun 26, 2015

Conversation

LaszloLango
Copy link
Contributor

JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan [email protected]
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]

@LaszloLango LaszloLango added ecma core Related to core ECMA functionality ecma builtins Related to ECMA built-in routines labels Jun 10, 2015
@LaszloLango LaszloLango added this to the ECMA builtins milestone Jun 10, 2015
@LaszloLango
Copy link
Contributor Author

The RegExp engine is not feature complete, but the core features are working. The patch is huge, so we can start the review process now. The RegExp engine is blocking a few string builtin function, so we need this patch with the core features and we can add the unimplemented things in a separate PR.

@sand1k sand1k added the development Feature implementation label Jun 10, 2015
@LaszloLango
Copy link
Contributor Author

@egavrin, please review

@egavrin egavrin added the critical Raises security concerns label Jun 12, 2015
ECMA_TRY_CATCH (obj_this, ecma_op_to_object (this_arg), ret_value);

ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_property_t *bytecode_prop = ecma_get_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_REGEXP_BYTECODE);
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if there is no bytecode on the this object?
For example:

var re = new RegExp("a")
re.exec.call({}, "a")

@LaszloLango
Copy link
Contributor Author

I've updated the PR.

string_desc_p->is_stack_var = false;
string_desc_p->container = ECMA_STRING_CONTAINER_HEAP_CHUNKS;
string_desc_p->hash = ecma_chars_buffer_calc_hash_last_chars (string_p, length);

Copy link
Contributor

Choose a reason for hiding this comment

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

Extra new line.

for (uint32_t i = 0; i < re_ctx.num_of_captures; i += 2)
{
ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (i / 2);
if (re_ctx.saved_p[i] && re_ctx.saved_p[i + 1] && re_ctx.saved_p[i + 1] >= re_ctx.saved_p[i])
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing empty line

@egavrin
Copy link
Contributor

egavrin commented Jun 24, 2015

@LaszloLango we're leaving too many things for "unicode integration". General coding style, including comments provided by reviewers can be fixed within 3-4 hours. And the whole PR would be really OK. I clearly understand the fact that not all components of the engine follow the common style, but we definitely should fix this. So, I have no intention to increase technical debt of the project. Please, fix all issues in the pull request carefully.

@zherczeg
Copy link
Member

Please reorganize existing 36 commits into:

  1. regexp parser (jerry-core/parser/regexp) with unit tests (are there any?)
  2. helpers for raising ecma-exceptions
  3. helpers for working with ecma characters
  4. ecma-runtime support of regexp (jerry-core/ecma/base)
  5. RegExp and RegExp.prototype built-in implementation
    (jerry-core/ecma/builtin-objects)
  6. regexp support in byte-code and vm (jerry-core/vm)
  7. enable regexp parse in js parser (jerry-core/parser/js), add regexp tests

I wouldn't mind creating a single patch from the work, but creating 7 requires too much work. At least another week. This is just slowing us down unnecessarily, especially with such a tight deadlines.

Regex is required for full conformance, and the success of Jerry project. Working on this forever would jeopardize our aims!

@LaszloLango LaszloLango force-pushed the regexp_dev branch 2 times, most recently from 727b54f to a59cd65 Compare June 25, 2015 08:41
@LaszloLango
Copy link
Contributor Author

@egavrin, I've updated the PR. Please check

@LaszloLango
Copy link
Contributor Author

@egavrin, I've updated the PR. Please check

* @return unsigned integer
*/
uint32_t
ecma_char_hex_to_int (char hex)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you removed this function from lexer.cpp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan [email protected]
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan [email protected]
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
…ber of characters, instead of zero-terminated string.

JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan [email protected]
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
…ion, ECMA-262 v5, 15.10.2.6); move hex_to_int from lexer to jerry-core/ecma/base/ecma-helpers-char.cpp, renaming it to ecma_char_hex_to_int.

JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan [email protected]
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan [email protected]
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
…, RegExp and RegExp.prototype built-in objects.

JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan [email protected]
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
- add regular expressions support to JS parser and interpreter;
- add tests for regular expressions.

JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan [email protected]
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical Raises security concerns development Feature implementation ecma builtins Related to ECMA built-in routines ecma core Related to core ECMA functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants