/* * Copyright (c) 2023, Dan Klishch * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include "Forward.h" namespace JSSpecCompiler { struct TranslationUnit { void adopt_declaration(NonnullRefPtr&& declaration); FunctionDefinitionRef adopt_function(NonnullRefPtr&& definition); StringView filename; Vector functions_to_compile; Vector> declarations_owner; HashMap function_index; }; class FunctionDeclaration : public RefCounted { public: FunctionDeclaration(StringView name); virtual ~FunctionDeclaration() = default; TranslationUnitRef m_translation_unit = nullptr; StringView m_name; }; class FunctionDefinition : public FunctionDeclaration { public: FunctionDefinition(StringView name, Tree ast); void reindex_ssa_variables(); Tree m_ast; NamedVariableDeclarationRef m_return_value; // NOTE: The hash map here is ordered since we do not want random hash changes to break our test // expectations (looking at you, SipHash). OrderedHashMap m_local_variables; Vector m_local_ssa_variables; RefPtr m_cfg; }; }