mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 06:09:08 +00:00
JSSpecCompiler: Add converter from LibCpp's AST
This will effectively allow us to use C++ code as an input for the compiler. This would be useful for testing, since otherwise we would have had to specify tests as a spec-like XML, which is not exactly the most developer-friendly experience.
This commit is contained in:
parent
567b1f6e7c
commit
75fd28014c
Notes:
sideshowbarker
2024-07-17 03:35:24 +09:00
Author: https://github.com/DanShaders
Commit: 75fd28014c
Pull-request: https://github.com/SerenityOS/serenity/pull/21263
Reviewed-by: https://github.com/gmta ✅
3 changed files with 214 additions and 1 deletions
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Dan Klishch <danilklishch@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibCpp/AST.h>
|
||||
|
||||
#include "Forward.h"
|
||||
|
||||
namespace JSSpecCompiler {
|
||||
|
||||
class CppASTConverter {
|
||||
public:
|
||||
CppASTConverter(RefPtr<Cpp::FunctionDeclaration> const& function)
|
||||
: m_function(function)
|
||||
{
|
||||
}
|
||||
|
||||
NonnullRefPtr<FunctionDefinition> convert();
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
NullableTree convert_node(T const&);
|
||||
NullableTree as_nullable_tree(Cpp::Statement const* statement);
|
||||
Tree as_tree(Cpp::Statement const* statement);
|
||||
Tree as_possibly_empty_tree(Cpp::Statement const* statement);
|
||||
|
||||
RefPtr<Cpp::FunctionDeclaration> m_function;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue