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

Switch impl #451

Merged
merged 74 commits into from
Jun 12, 2020
Merged

Switch impl #451

merged 74 commits into from
Jun 12, 2020

Conversation

Lan2u
Copy link

@Lan2u Lan2u commented Jun 3, 2020

This Pull Request implements #439 and #301.

It changes the following:

  • Implements parsing and running of switch statements

A function parse_generalised in statement list was created as part of this and is a more generalised version of StatementList::parse() which allows statement lists to be terminated by tokens other than '}'. It's a separate function for now so that the performance impact of replacing parse can be established.

This pull request is based of PR #422.

Paul Lancaster and others added 30 commits May 26, 2020 09:04
Co-authored-by: Iban Eguia <razican@protonmail.ch>
Divided up GetConstField, GetField
seperated out
@Razican Razican added enhancement New feature or request execution Issues or PRs related to code execution parser Issues surrounding the parser labels Jun 6, 2020
@Razican Razican added this to the v0.9.0 milestone Jun 6, 2020
Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

Let's wait for #422 to land to easily see the changes here.

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

It's looking very good. Check my comments, I think we can improve this to avoid having tens of flags in the future :)

boa/src/exec/mod.rs Outdated Show resolved Hide resolved

impl Executable for Break {
fn run(&self, interpreter: &mut Interpreter) -> ResultValue {
interpreter.is_break = true;
Copy link
Member

Choose a reason for hiding this comment

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

Here, we could have a break(label: &str) function (signature might differ) in interpreter, which would change the state.

@HalidOdat HalidOdat removed the blocked Waiting for another code change label Jun 10, 2020
Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

Could we also add tests for breaks in loop statements?

boa/src/exec/return_smt/mod.rs Show resolved Hide resolved
@Lan2u
Copy link
Author

Lan2u commented Jun 10, 2020

Could we also add tests for breaks in loop statements?

Done, I also got rid of the .is_return() etc. in favour of just matching on get_current_state() based on the assumption that almost all the time in the code if .is_return() needs to be handled then so does .is_break() so might as-well make this required to prevent accidental omissions.

I haven't attempted to actually add any handling of break labels https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label (this might be better as a separate issue?)

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks!

@Razican Razican merged commit 542b2cc into boa-dev:master Jun 12, 2020
@Lan2u Lan2u deleted the switch_run_break_impl branch June 12, 2020 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request execution Issues or PRs related to code execution parser Issues surrounding the parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement break handling in switch statements Implementing the switch statement in the new parser
4 participants