Skip to content

Implement Builtin Iterator.prototype.filter, Iterator.prototype.reduce method - #1454

Merged
clover2123 merged 4 commits into
Samsung:masterfrom
kwonjeomsim:builtin
Jul 3, 2025
Merged

clover2123 merged 4 commits into
Samsung:masterfrom
kwonjeomsim:builtin

Conversation

@kwonjeomsim

Copy link
Copy Markdown
Contributor

These commits implement filter, reduce method for javascript iterator.

  • I did not remove
    built-ins/Iterator/prototype/filter/argument-validation-failure-closes-underlying,
    built-ins/Iterator/prototype/reduce/argument-validation-failure-closes-underlying
    test because other methods which are already implemented also did not remove that test from exclude list.

Comment thread src/builtins/BuiltinIterator.cpp Outdated
Comment on lines +191 to +195
struct IteratorFilterData : public gc {
StorePositiveNumberAsOddNumber counter;
Value predicate;

IteratorFilterData(Value predicate)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This struct looks same as IteratorMapData.
What about reusing the IteratorMapData instead?
(the name of structure needs to be changed too)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This struct looks same as IteratorMapData. What about reusing the IteratorMapData instead? (the name of structure needs to be changed too)

Is it fine combining two structs into IteratorData struct?
And I'd like to change Value variable name to callback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it fine combining two structs into IteratorData struct?

no problem!
The name of Value should be redefined accordingly :)

Comment thread src/builtins/BuiltinIterator.cpp Outdated
Comment on lines +232 to +236
if (selected.toBoolean()) {
return std::make_pair(value.value(), false);
} else {
return iteratorFilterClosure(state, obj, data);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would you please re-check this part?
It seems that its different from the spec

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would you please re-check this part? It seems that its different from the spec

Can you tell me which part is exactly matter?
I wonder where is problem part, absence of completion error check or return recursive else part.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I cannot find the recursive call part in the spec..

Comment on lines +226 to +228
if (selected.toBoolean()) {
return std::make_pair(value.value(), false);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This part seems to be related to the generator feature, but it's not sufficient
we may update it further later on

@clover2123 clover2123 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

@clover2123
clover2123 merged commit cebb533 into Samsung:master Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants