Skip to content

for..in WIP - #671

Closed
jcdickinson wants to merge 1 commit into
boa-dev:masterfrom
jcdickinson:feature-forin
Closed

jcdickinson wants to merge 1 commit into
boa-dev:masterfrom
jcdickinson:feature-forin

Conversation

@jcdickinson

Copy link
Copy Markdown
Contributor

This Pull Request fixes/closes 670.

It changes the following:

  • Adds for..in support

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)]
struct InnerForInLoop {
variable: Node,

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 really smells.

I think we might need an AST node that can represent a single const, let or var. Thoughts?

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 will probably be really difficult for execution, too.

/// Inner structure to avoid multiple indirections in the heap.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)]
struct InnerForInLoop {

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.

I'm wondering if this should be IterableForLoop containing an enum (In, Of), because both are basically the same syntax and In is supposed to use an iterator internally (according to 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.

This would block this implementation on #576.

Ok(ForInLoop::new(variable, object, body).into())
}
Some(tok) if tok.kind() == &TokenKind::identifier("of") => {
Some(tok) if tok.kind() == &TokenKind::identifier("of") && can_iterate => {

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.

Is TokenKind::identifier("of") a placeholder, or intentional? i.e. Should there be TokenKind::Keyword(Keyword::Of)?

@jcdickinson

Copy link
Copy Markdown
Contributor Author

Dropping in favor of the existing work done for #576.

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.

1 participant