CppASTConverter.h 713 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2023, Dan Klishch <danilklishch@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibCpp/AST.h>
  8. #include "Forward.h"
  9. namespace JSSpecCompiler {
  10. class CppASTConverter {
  11. public:
  12. CppASTConverter(RefPtr<Cpp::FunctionDeclaration> const& function)
  13. : m_function(function)
  14. {
  15. }
  16. NonnullRefPtr<FunctionDefinition> convert();
  17. private:
  18. template<typename T>
  19. NullableTree convert_node(T const&);
  20. NullableTree as_nullable_tree(Cpp::Statement const* statement);
  21. Tree as_tree(Cpp::Statement const* statement);
  22. Tree as_possibly_empty_tree(Cpp::Statement const* statement);
  23. RefPtr<Cpp::FunctionDeclaration> m_function;
  24. };
  25. }