mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:57:35 +00:00
JSSpecCompiler: Add control flow building pass
This commit is contained in:
parent
c74e2d04d1
commit
ff44aea917
10 changed files with 222 additions and 2 deletions
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Dan Klishch <danilklishch@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/TypeCasts.h>
|
||||
|
||||
#include "Compiler/ControlFlowGraph.h"
|
||||
#include "Compiler/GenericASTPass.h"
|
||||
|
||||
namespace JSSpecCompiler {
|
||||
|
||||
class CFGBuildingPass
|
||||
: public IntraproceduralCompilerPass
|
||||
, private RecursiveASTVisitor {
|
||||
public:
|
||||
inline static constexpr StringView name = "cfg-building"sv;
|
||||
|
||||
using IntraproceduralCompilerPass::IntraproceduralCompilerPass;
|
||||
|
||||
protected:
|
||||
void process_function() override;
|
||||
RecursionDecision on_entry(Tree tree) override;
|
||||
void on_leave(Tree tree) override;
|
||||
|
||||
private:
|
||||
BasicBlockRef create_empty_block();
|
||||
BasicBlockRef exchange_current_with_empty();
|
||||
void will_be_used_as_expression(Tree const& tree);
|
||||
|
||||
ControlFlowGraph* m_cfg;
|
||||
BasicBlockRef m_current_block;
|
||||
Vector<bool> m_is_expression_stack;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue