-
Notifications
You must be signed in to change notification settings - Fork 683
Implemented Array.prototype.sort() #95
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
Conversation
f939751
to
233dd6e
Compare
ecma_value_t comparefn) /**< compare function */ | ||
{ | ||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); | ||
int child = 2 * index; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we're using 2 here?
233dd6e
to
0fd2a85
Compare
Hi @egavrin, |
* Loop ended, either current child does not exist, or is less than swap. | ||
* This means that 'swap' should be placed in the parent node. | ||
*/ | ||
array[(child - 1) / 2] = swap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbatyai, could you, please, add assertions with bound checking in the function?
0fd2a85
to
761c079
Compare
@ruben-ayrapetyan, I've added asserts to make sure we stay in bounds. |
@dbatyai, thank you! |
May we push it? |
* sort to the end of the result, followed by non-existent property values. | ||
*/ | ||
ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); | ||
ecma_number_t *result = ecma_alloc_number (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add _p
suffix.
761c079
to
7fe0d39
Compare
I've updated the patch. |
Looks good to me. |
{ | ||
/* Casting len to ecma_length_t may overflow, but since ecma_length_t is still at lest 16 bits long, | ||
with an array of that size, we would run out of memory way before this happens. */ | ||
JERRY_ASSERT ((ecma_length_t) len == len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add FIXME
to the comment.
Seems that we should change the ecma_op_create_array_object
interface to take another type for length argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you, please, raise an issue about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added FIXME
, and opened an issue about it: #133
7fe0d39
to
9a88ef0
Compare
@dbatyai great! |
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan szledan.u-szeged@partner.samsung.com
9a88ef0
to
0fc82e2
Compare
merged: 6b8e34a |
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
JerryScript-DCO-1.0-Signed-off-by: Szilard Ledan szledan.u-szeged@partner.samsung.com