1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:58:12 +00:00

JSSpecCompiler: Elide nested TreeList nodes

This commit is contained in:
Dan Klishch 2023-09-13 01:28:11 -04:00 committed by Jelle Raaijmakers
parent f30815b534
commit 14a86c8fd6
4 changed files with 23 additions and 12 deletions

View file

@ -83,10 +83,22 @@ Vector<NodeSubtreePointer> IfElseIfChain::subtrees()
return result;
}
TreeList::TreeList(Vector<Tree>&& trees)
{
for (auto const& tree : trees) {
if (tree->is_list()) {
for (auto const& nested_tree : as<TreeList>(tree)->m_trees)
m_trees.append(nested_tree);
} else {
m_trees.append(tree);
}
}
}
Vector<NodeSubtreePointer> TreeList::subtrees()
{
Vector<NodeSubtreePointer> result;
for (auto& expression : m_expressions)
for (auto& expression : m_trees)
result.append({ &expression });
return result;
}