Skip to content

Implement for..in - #976

Merged
RageKnify merged 14 commits into
boa-dev:masterfrom
tofpie:for-in
Jan 1, 2021
Merged

RageKnify merged 14 commits into
boa-dev:masterfrom
tofpie:for-in

Conversation

@tofpie

@tofpie tofpie commented Dec 16, 2020

Copy link
Copy Markdown
Contributor

This Pull Request closes #670.

It changes the following:

  • The tokenizer to prevent interpreting in as a binary operator in a for statement
  • The parser to add for..in management
  • The ForOfLoop node (renamed ForInOfLoop) to execute the for..in logic

@codecov

codecov Bot commented Dec 16, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #976 (11a3e72) into master (4cede75) will increase coverage by 0.12%.
The diff coverage is 65.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #976      +/-   ##
==========================================
+ Coverage   60.07%   60.20%   +0.12%     
==========================================
  Files         167      169       +2     
  Lines       11132    11359     +227     
==========================================
+ Hits         6688     6839     +151     
- Misses       4444     4520      +76     
Impacted Files Coverage Δ
boa/src/builtins/mod.rs 23.52% <ø> (ø)
boa/src/builtins/object/mod.rs 67.27% <ø> (ø)
...oa/src/syntax/ast/node/iteration/while_loop/mod.rs 59.37% <0.00%> (-3.96%) ⬇️
boa/src/syntax/parser/error.rs 38.23% <ø> (ø)
boa/src/object/mod.rs 51.23% <22.22%> (-0.74%) ⬇️
...oa/src/syntax/parser/statement/labelled_stm/mod.rs 68.42% <33.33%> (-18.25%) ⬇️
...a/src/syntax/ast/node/iteration/for_of_loop/mod.rs 57.14% <37.50%> (-1.84%) ⬇️
...src/syntax/ast/node/iteration/do_while_loop/mod.rs 48.57% <40.00%> (+0.84%) ⬆️
boa/src/syntax/ast/node/mod.rs 46.96% <50.00%> (+0.04%) ⬆️
...a/src/syntax/ast/node/iteration/for_in_loop/mod.rs 63.49% <63.49%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4cede75...11a3e72. Read the comment docs.

@tofpie

tofpie commented Dec 16, 2020

Copy link
Copy Markdown
Contributor Author

This is really a WIP and I plan to add unit tests as soon as #974 and #972 are merged, but I submit it anyway to have some guidance. I am not quite sure of what I have done, especially around the lexer and parser.

@jcdickinson If you have some time, I would be happy to have your feedback

Comment thread boa/src/builtins/object/tests.rs Resolved
@jcdickinson

Copy link
Copy Markdown
Contributor

This looks good to me, but I haven't touched the codebase in a while so I'm out of touch with the new parser.

@Razican Razican added A-Enhancement New feature or request A-Execution Issues or PRs related to code execution C-Parser Issues surrounding the parser labels Dec 17, 2020
@Razican Razican added this to the v0.11.0 milestone Dec 17, 2020
@Razican

Razican commented Dec 17, 2020 •

Copy link
Copy Markdown
Member

I didn't check the code yet, but this is looking very good:

Test262 conformance changes:

Test result master count PR count difference
Total 78,493 78,493 0
Passed 20,904 22,328 +1,424
Ignored 15,585 15,585 0
Failed 42,004 40,580 -1,424
Panics 388 388 0
Conformance 26.63 28.45 +1.81%

@tofpie

tofpie commented Dec 18, 2020

Copy link
Copy Markdown
Contributor Author

I have implemented break and continue in for..in, and I have added some unit tests. It is now ready for review.

@Razican Razican left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's looking good. I did a small review, but I need to spend a bit more time with it. I'm not sure about unifying for...in and for...of, mostly because that will probably not be space efficient.

Comment thread boa/src/syntax/parser/error.rs Resolved

@Razican Razican left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is impressive. The conformance improvement is vastly good, and I have checked the implementation, and I see improvements in many other loops. Thanks for implementing the changes I proposed!

@Razican
Razican requested a review from RageKnify January 1, 2021 13:01
@RageKnify
RageKnify merged commit 57d5679 into boa-dev:master Jan 1, 2021
@tofpie
tofpie deleted the for-in branch January 1, 2021 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Enhancement New feature or request A-Execution Issues or PRs related to code execution C-Parser Issues surrounding the parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement for..in for objects

5 participants