mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 19:25:07 +00:00
JSSpecCompiler: Add if branch merging pass
It merges standalone IfBranch/ElseIfBranch nodes into IfElseIfChain nodes. This will ease CFG generation later.
This commit is contained in:
parent
092ed1cc8a
commit
4c4e1e1aed
8 changed files with 184 additions and 0 deletions
|
@ -71,6 +71,18 @@ Vector<NodeSubtreePointer> ElseIfBranch::subtrees()
|
|||
return { { &m_branch } };
|
||||
}
|
||||
|
||||
Vector<NodeSubtreePointer> IfElseIfChain::subtrees()
|
||||
{
|
||||
Vector<NodeSubtreePointer> result;
|
||||
for (size_t i = 0; i < branches_count(); ++i) {
|
||||
result.append({ &m_conditions[i] });
|
||||
result.append({ &m_branches[i] });
|
||||
}
|
||||
if (m_else_branch)
|
||||
result.append({ &m_else_branch });
|
||||
return result;
|
||||
}
|
||||
|
||||
Vector<NodeSubtreePointer> TreeList::subtrees()
|
||||
{
|
||||
Vector<NodeSubtreePointer> result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue