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

Duplicate code in Boa #1184

Closed
0x7D2B opened this issue Mar 22, 2021 · 2 comments
Closed

Duplicate code in Boa #1184

0x7D2B opened this issue Mar 22, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@0x7D2B
Copy link
Contributor

0x7D2B commented Mar 22, 2021

I've been coming across a lot of duplicate or very similar code in Boa. I think a lot of it can be combined to simplify things. Some examples:

Function parsers

There are four very similar parsers for function declarations and statements, one for each combination of async/non-async function expression/declaration:

For reference, here's also the arrow function parser:

Function AST nodes

Declarative and function environment records

Declarative and function environments are almost identical in their implementation. Fixed in #1156.

Loops

While and Do-While loops:

For-In and For-Of loops:

Fixed issues

Fixed

ConstDeclList, LetDeclList, VarDeclList and ConstDecl, LetDecl, VarDecl (Fixed in #1181)

Six declaration container objects which are almost identical.

Function calls and object constructors (Fixed in #1273)

This already resulted in an issue where one of these implementations had a bug while the other had it fixed.

@Razican Razican added the enhancement New feature or request label Mar 22, 2021
@0x7D2B
Copy link
Contributor Author

0x7D2B commented May 23, 2021

#1273 fixes the function call and constructor one.

@jedel1043
Copy link
Member

Closing since most of the deduplication was removed when we created the VM interpreter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants