You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
boa/boa/src/syntax/parser/expression/primary/function_expression/mod.rs
Line 45 in 586a689
boa/boa/src/syntax/parser/expression/primary/async_function_expression/mod.rs
Line 50 in 586a689
boa/boa/src/syntax/parser/statement/declaration/hoistable/function_decl/mod.rs
Line 51 in 586a689
boa/boa/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs
Line 51 in 586a689
For reference, here's also the arrow function parser:
boa/boa/src/syntax/parser/expression/assignment/arrow_function.rs
Line 71 in e2f9ecd
Function AST nodes
boa/boa/src/syntax/ast/node/declaration/function_decl/mod.rs
Line 40 in 39764b9
boa/boa/src/syntax/ast/node/declaration/function_expr/mod.rs
Line 37 in 39764b9
boa/boa/src/syntax/ast/node/declaration/async_function_decl/mod.rs
Line 30 in 39764b9
boa/boa/src/syntax/ast/node/declaration/async_function_expr/mod.rs
Line 31 in 39764b9
boa/boa/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs
Line 33 in 39764b9
Declarative and function environment records
Declarative and function environments are almost identical in their implementation. Fixed in #1156.
boa/boa/src/environment/declarative_environment_record.rs
Line 40 in 39764b9
boa/boa/src/environment/function_environment_record.rs
Line 96 in 39764b9
Loops
While and Do-While loops:
For-In and For-Of loops:
boa/boa/src/syntax/ast/node/iteration/for_in_loop/mod.rs
Line 94 in 39764b9
boa/boa/src/syntax/ast/node/iteration/for_of_loop/mod.rs
Line 84 in 39764b9
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.
boa/boa/src/object/gcobject.rs
Line 118 in 39764b9
boa/boa/src/object/gcobject.rs
Line 214 in 39764b9
The text was updated successfully, but these errors were encountered: