CFGBuildingPass.h 904 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2023, Dan Klishch <danilklishch@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/TypeCasts.h>
  8. #include "Compiler/ControlFlowGraph.h"
  9. #include "Compiler/GenericASTPass.h"
  10. namespace JSSpecCompiler {
  11. class CFGBuildingPass
  12. : public IntraproceduralCompilerPass
  13. , private RecursiveASTVisitor {
  14. public:
  15. inline static constexpr StringView name = "cfg-building"sv;
  16. using IntraproceduralCompilerPass::IntraproceduralCompilerPass;
  17. protected:
  18. void process_function() override;
  19. RecursionDecision on_entry(Tree tree) override;
  20. void on_leave(Tree tree) override;
  21. private:
  22. BasicBlockRef create_empty_block();
  23. BasicBlockRef exchange_current_with_empty();
  24. void will_be_used_as_expression(Tree const& tree);
  25. ControlFlowGraph* m_cfg;
  26. BasicBlockRef m_current_block;
  27. Vector<bool> m_is_expression_stack;
  28. };
  29. }