mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-21 18:42:53 +00:00
JSSpecCompiler: Add --dump-cfg
option
This commit is contained in:
parent
ff44aea917
commit
ce6b987330
Notes:
sideshowbarker
2024-07-17 01:55:29 +09:00
Author: https://github.com/DanShaders
Commit: ce6b987330
Pull-request: https://github.com/SerenityOS/serenity/pull/22222
4 changed files with 53 additions and 0 deletions
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Dan Klishch <danilklishch@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/StringBuilder.h>
|
||||
|
||||
#include "AST/AST.h"
|
||||
#include "Compiler/ControlFlowGraph.h"
|
||||
|
||||
using namespace JSSpecCompiler;
|
||||
|
||||
ErrorOr<void> AK::Formatter<ControlFlowGraph>::format(FormatBuilder& format_builder, ControlFlowGraph const& control_flow_graph)
|
||||
{
|
||||
auto& builder = format_builder.builder();
|
||||
|
||||
for (auto const& block : control_flow_graph.blocks) {
|
||||
builder.appendff("{}:\n", block->m_index);
|
||||
for (auto const& expression : block->m_expressions)
|
||||
builder.appendff("{}", expression);
|
||||
builder.appendff("{}\n", Tree(block->m_continuation));
|
||||
}
|
||||
|
||||
// Remove trailing \n
|
||||
builder.trim(1);
|
||||
|
||||
return {};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue