1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 06:45:08 +00:00
serenity/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Function.h
Dan Klishch 567b1f6e7c JSSpecCompiler: Adopt more C++ terminology
Let's not use strange names like `ExecutionContext`, which nobody will
understand in the future.
2023-10-02 21:15:08 +02:00

44 lines
1,017 B
C++

/*
* Copyright (c) 2023, Dan Klishch <danilklishch@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/HashMap.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/StringView.h>
#include "Forward.h"
namespace JSSpecCompiler {
struct TranslationUnit {
FunctionDefinitionRef adopt_function(NonnullRefPtr<FunctionDefinition>&& function);
Vector<NonnullRefPtr<FunctionDefinition>> function_definitions;
HashMap<StringView, FunctionPointerRef> function_index;
};
class FunctionDeclaration : public RefCounted<FunctionDeclaration> {
public:
FunctionDeclaration(StringView name);
virtual ~FunctionDeclaration() = default;
TranslationUnit* m_translation_unit = nullptr;
StringView m_name;
};
class FunctionDefinition : public FunctionDeclaration {
public:
FunctionDefinition(StringView name, Tree ast);
Tree m_ast;
VariableDeclarationRef m_return_value;
HashMap<StringView, VariableDeclarationRef> m_local_variables;
};
}