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

Array.prototype.reduce() #104

Closed

Conversation

lvidacs
Copy link
Contributor

@lvidacs lvidacs commented May 27, 2015

JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]

lvidacs added 3 commits May 27, 2015 11:16
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]
@galpeter galpeter added the ecma builtins Related to ECMA built-in routines label May 27, 2015
@galpeter galpeter added this to the ECMA builtins milestone May 27, 2015
@egavrin egavrin self-assigned this May 27, 2015
@egavrin
Copy link
Contributor

egavrin commented May 27, 2015

Just briefly checked, seems ok.
@galpeter could you, please, recheck me?

if (len_number == ECMA_NUMBER_ZERO && ecma_is_value_undefined (arg1))
{
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The code following this should be in the else case of the condition I think.

@ILyoan ILyoan mentioned this pull request May 27, 2015
25 tasks
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]
@lvidacs
Copy link
Contributor Author

lvidacs commented May 27, 2015

The code is updated according to review comments.

assert(e instanceof TypeError);
}

// various checks
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a check for empty array + no/undefined initialValue to see if that results a TypeError as described in the 5th step.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check is in lines 28-35 with empty array + no initial value.

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh... true :) sorry

@galpeter
Copy link
Contributor

lgtm

ecma_number_t *num_p = ecma_alloc_number ();
ecma_object_t *func_object_p;

ecma_completion_value_t to_object_comp = ecma_op_to_object (arg1);
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to perform the conversion, since ecma_op_is_callable returned true for the value.
So, we could just assert that ecma_is_value_object and perform ecma_get_object_from_value.

@lvidacs
Copy link
Contributor Author

lvidacs commented May 29, 2015

Thanks for the detailed review, the patch is updated.

JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]
@lvidacs lvidacs force-pushed the array_prototype_reduce branch from e45bc7c to 35441b7 Compare May 29, 2015 12:21
@egavrin
Copy link
Contributor

egavrin commented May 29, 2015

make push

@galpeter
Copy link
Contributor

galpeter commented Jun 1, 2015

Rebased & merged in: 89e5444

@galpeter galpeter closed this Jun 1, 2015
@egavrin egavrin deleted the array_prototype_reduce branch June 1, 2015 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecma builtins Related to ECMA built-in routines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants