mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-21 10:32:51 +00:00
JSSpecCompiler: Prepare for building SSA
This commit introduces NamedVariableDeclaration and SSAVariableDeclaration and allows storing both of them in Variable node. Also, it adds additional structures in FunctionDefinition and BasicBlock, which will be used to store SSA form related information.
This commit is contained in:
parent
23164bc570
commit
0aeb7a26e9
Notes:
sideshowbarker
2024-07-17 02:29:45 +09:00
Author: https://github.com/DanShaders
Commit: 0aeb7a26e9
Pull-request: https://github.com/SerenityOS/serenity/pull/22289
Reviewed-by: https://github.com/ADKaster ✅
11 changed files with 173 additions and 13 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
||||
#include "AST/AST.h"
|
||||
|
@ -17,6 +18,15 @@ ErrorOr<void> AK::Formatter<ControlFlowGraph>::format(FormatBuilder& format_buil
|
|||
|
||||
for (auto const& block : control_flow_graph.blocks) {
|
||||
builder.appendff("{}:\n", block->m_index);
|
||||
for (auto const& phi_node : block->m_phi_nodes) {
|
||||
builder.appendff("{} = phi(", phi_node.var->name());
|
||||
for (auto const& branches : phi_node.branches) {
|
||||
builder.appendff("{}: {}", branches.block->m_index, branches.value->name());
|
||||
if (&branches != &phi_node.branches.last())
|
||||
builder.appendff(", ");
|
||||
}
|
||||
builder.appendff(")\n");
|
||||
}
|
||||
for (auto const& expression : block->m_expressions)
|
||||
builder.appendff("{}", expression);
|
||||
builder.appendff("{}\n", Tree(block->m_continuation));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue