mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
JSSpecCompiler: Make TranslationUnit fields private
For some reason I was afraid to add trivial accessors to classes in earlier PRs, so we now have dozens of classes with public fields. I'm not exactly looking forward to refactoring them all at once but I'll do so gradually.
This commit is contained in:
parent
a2f7849238
commit
3aec6952a2
8 changed files with 46 additions and 24 deletions
|
@ -10,21 +10,36 @@
|
|||
|
||||
namespace JSSpecCompiler {
|
||||
|
||||
TranslationUnit::TranslationUnit(StringView filename)
|
||||
: m_filename(filename)
|
||||
{
|
||||
}
|
||||
|
||||
TranslationUnit::~TranslationUnit() = default;
|
||||
|
||||
void TranslationUnit::adopt_declaration(NonnullRefPtr<FunctionDeclaration>&& declaration)
|
||||
{
|
||||
declaration->m_translation_unit = this;
|
||||
function_index.set(declaration->m_name, declaration.ptr());
|
||||
declarations_owner.append(move(declaration));
|
||||
m_function_index.set(declaration->m_name, declaration.ptr());
|
||||
m_declarations_owner.append(move(declaration));
|
||||
}
|
||||
|
||||
FunctionDefinitionRef TranslationUnit::adopt_function(NonnullRefPtr<FunctionDefinition>&& function)
|
||||
FunctionDefinitionRef TranslationUnit::adopt_function(NonnullRefPtr<FunctionDefinition>&& definition)
|
||||
{
|
||||
FunctionDefinitionRef result = function.ptr();
|
||||
functions_to_compile.append(result);
|
||||
adopt_declaration(function);
|
||||
FunctionDefinitionRef result = definition.ptr();
|
||||
m_functions_to_compile.append(result);
|
||||
adopt_declaration(definition);
|
||||
return result;
|
||||
}
|
||||
|
||||
FunctionDeclarationRef TranslationUnit::find_declaration_by_name(StringView name) const
|
||||
{
|
||||
auto it = m_function_index.find(name);
|
||||
if (it == m_function_index.end())
|
||||
return nullptr;
|
||||
return it->value;
|
||||
}
|
||||
|
||||
FunctionDeclaration::FunctionDeclaration(StringView name)
|
||||
: m_name(name)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue