mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
JSSpecCompiler: Replace all declarations with assignments
We assume that variable shadowing is impossible, so then there is no reason to keep distinct Declaration and Assignment operators after ReferenceResolvingPass.
This commit is contained in:
parent
12072dbac5
commit
23164bc570
Notes:
sideshowbarker
2024-07-17 17:49:11 +09:00
Author: https://github.com/DanShaders Commit: https://github.com/SerenityOS/serenity/commit/23164bc570 Pull-request: https://github.com/SerenityOS/serenity/pull/22289 Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 22 additions and 20 deletions
|
@ -18,6 +18,8 @@ RecursionDecision ReferenceResolvingPass::on_entry(Tree tree)
|
|||
if (binary_operation->m_operation != BinaryOperator::Declaration)
|
||||
return RecursionDecision::Recurse;
|
||||
|
||||
binary_operation->m_operation = BinaryOperator::Assignment;
|
||||
|
||||
if (auto variable_name = as<UnresolvedReference>(binary_operation->m_left); variable_name) {
|
||||
auto name = variable_name->m_name;
|
||||
if (!m_function->m_local_variables.contains(name))
|
||||
|
|
|
@ -86,21 +86,21 @@ TreeList
|
|||
IfElseIfChain
|
||||
UnresolvedReference cond1
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var a
|
||||
MathematicalConstant 1
|
||||
IfElseIfChain
|
||||
UnresolvedReference cond2
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
Var a
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
MathematicalConstant 3
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
MathematicalConstant 4
|
||||
ReturnNode
|
||||
|
@ -112,21 +112,21 @@ TreeList
|
|||
IfElseIfChain
|
||||
UnresolvedReference cond1
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var a
|
||||
MathematicalConstant 1
|
||||
IfElseIfChain
|
||||
UnresolvedReference cond2
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
Var a
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
MathematicalConstant 3
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
MathematicalConstant 4
|
||||
ReturnNode
|
||||
|
@ -149,7 +149,7 @@ BinaryOperation Assignment
|
|||
ControlFlowJump jump=1
|
||||
|
||||
3:
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var a
|
||||
MathematicalConstant 1
|
||||
ControlFlowBranch true=5 false=6
|
||||
|
@ -159,19 +159,19 @@ ControlFlowBranch true=5 false=6
|
|||
ControlFlowJump jump=2
|
||||
|
||||
5:
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
Var a
|
||||
ControlFlowJump jump=4
|
||||
|
||||
6:
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
MathematicalConstant 3
|
||||
ControlFlowJump jump=4
|
||||
|
||||
7:
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
MathematicalConstant 4
|
||||
ControlFlowJump jump=2
|
||||
|
@ -188,21 +188,21 @@ TreeList
|
|||
IfElseIfChain
|
||||
UnresolvedReference cond1
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var a
|
||||
MathematicalConstant 1
|
||||
IfElseIfChain
|
||||
UnresolvedReference cond2
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
Var a
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
MathematicalConstant 3
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
MathematicalConstant 4
|
||||
ReturnNode
|
||||
|
@ -225,26 +225,26 @@ BinaryOperation Assignment
|
|||
ControlFlowJump jump=1
|
||||
|
||||
3:
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var a
|
||||
MathematicalConstant 1
|
||||
ControlFlowBranch true=4 false=5
|
||||
UnresolvedReference cond2
|
||||
|
||||
4:
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
Var a
|
||||
ControlFlowJump jump=2
|
||||
|
||||
5:
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
MathematicalConstant 3
|
||||
ControlFlowJump jump=2
|
||||
|
||||
6:
|
||||
BinaryOperation Declaration
|
||||
BinaryOperation Assignment
|
||||
Var b
|
||||
MathematicalConstant 4
|
||||
ControlFlowJump jump=2
|
||||
|
|
Loading…
Reference in a new issue