mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:57:36 +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
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)
|
if (binary_operation->m_operation != BinaryOperator::Declaration)
|
||||||
return RecursionDecision::Recurse;
|
return RecursionDecision::Recurse;
|
||||||
|
|
||||||
|
binary_operation->m_operation = BinaryOperator::Assignment;
|
||||||
|
|
||||||
if (auto variable_name = as<UnresolvedReference>(binary_operation->m_left); variable_name) {
|
if (auto variable_name = as<UnresolvedReference>(binary_operation->m_left); variable_name) {
|
||||||
auto name = variable_name->m_name;
|
auto name = variable_name->m_name;
|
||||||
if (!m_function->m_local_variables.contains(name))
|
if (!m_function->m_local_variables.contains(name))
|
||||||
|
|
|
@ -86,21 +86,21 @@ TreeList
|
||||||
IfElseIfChain
|
IfElseIfChain
|
||||||
UnresolvedReference cond1
|
UnresolvedReference cond1
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var a
|
Var a
|
||||||
MathematicalConstant 1
|
MathematicalConstant 1
|
||||||
IfElseIfChain
|
IfElseIfChain
|
||||||
UnresolvedReference cond2
|
UnresolvedReference cond2
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
Var a
|
Var a
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
MathematicalConstant 3
|
MathematicalConstant 3
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
MathematicalConstant 4
|
MathematicalConstant 4
|
||||||
ReturnNode
|
ReturnNode
|
||||||
|
@ -112,21 +112,21 @@ TreeList
|
||||||
IfElseIfChain
|
IfElseIfChain
|
||||||
UnresolvedReference cond1
|
UnresolvedReference cond1
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var a
|
Var a
|
||||||
MathematicalConstant 1
|
MathematicalConstant 1
|
||||||
IfElseIfChain
|
IfElseIfChain
|
||||||
UnresolvedReference cond2
|
UnresolvedReference cond2
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
Var a
|
Var a
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
MathematicalConstant 3
|
MathematicalConstant 3
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
MathematicalConstant 4
|
MathematicalConstant 4
|
||||||
ReturnNode
|
ReturnNode
|
||||||
|
@ -149,7 +149,7 @@ BinaryOperation Assignment
|
||||||
ControlFlowJump jump=1
|
ControlFlowJump jump=1
|
||||||
|
|
||||||
3:
|
3:
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var a
|
Var a
|
||||||
MathematicalConstant 1
|
MathematicalConstant 1
|
||||||
ControlFlowBranch true=5 false=6
|
ControlFlowBranch true=5 false=6
|
||||||
|
@ -159,19 +159,19 @@ ControlFlowBranch true=5 false=6
|
||||||
ControlFlowJump jump=2
|
ControlFlowJump jump=2
|
||||||
|
|
||||||
5:
|
5:
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
Var a
|
Var a
|
||||||
ControlFlowJump jump=4
|
ControlFlowJump jump=4
|
||||||
|
|
||||||
6:
|
6:
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
MathematicalConstant 3
|
MathematicalConstant 3
|
||||||
ControlFlowJump jump=4
|
ControlFlowJump jump=4
|
||||||
|
|
||||||
7:
|
7:
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
MathematicalConstant 4
|
MathematicalConstant 4
|
||||||
ControlFlowJump jump=2
|
ControlFlowJump jump=2
|
||||||
|
@ -188,21 +188,21 @@ TreeList
|
||||||
IfElseIfChain
|
IfElseIfChain
|
||||||
UnresolvedReference cond1
|
UnresolvedReference cond1
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var a
|
Var a
|
||||||
MathematicalConstant 1
|
MathematicalConstant 1
|
||||||
IfElseIfChain
|
IfElseIfChain
|
||||||
UnresolvedReference cond2
|
UnresolvedReference cond2
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
Var a
|
Var a
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
MathematicalConstant 3
|
MathematicalConstant 3
|
||||||
TreeList
|
TreeList
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
MathematicalConstant 4
|
MathematicalConstant 4
|
||||||
ReturnNode
|
ReturnNode
|
||||||
|
@ -225,26 +225,26 @@ BinaryOperation Assignment
|
||||||
ControlFlowJump jump=1
|
ControlFlowJump jump=1
|
||||||
|
|
||||||
3:
|
3:
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var a
|
Var a
|
||||||
MathematicalConstant 1
|
MathematicalConstant 1
|
||||||
ControlFlowBranch true=4 false=5
|
ControlFlowBranch true=4 false=5
|
||||||
UnresolvedReference cond2
|
UnresolvedReference cond2
|
||||||
|
|
||||||
4:
|
4:
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
Var a
|
Var a
|
||||||
ControlFlowJump jump=2
|
ControlFlowJump jump=2
|
||||||
|
|
||||||
5:
|
5:
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
MathematicalConstant 3
|
MathematicalConstant 3
|
||||||
ControlFlowJump jump=2
|
ControlFlowJump jump=2
|
||||||
|
|
||||||
6:
|
6:
|
||||||
BinaryOperation Declaration
|
BinaryOperation Assignment
|
||||||
Var b
|
Var b
|
||||||
MathematicalConstant 4
|
MathematicalConstant 4
|
||||||
ControlFlowJump jump=2
|
ControlFlowJump jump=2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue