JSSpecCompiler: Adopt more C++ terminology

Let's not use strange names like `ExecutionContext`, which nobody will
understand in the future.
This commit is contained in:
Dan Klishch 2023-09-19 10:29:57 -04:00 committed by Jelle Raaijmakers
parent 4578004ad6
commit 567b1f6e7c
Notes: sideshowbarker 2024-07-16 23:13:25 +09:00
9 changed files with 51 additions and 21 deletions

View file

@ -19,12 +19,12 @@ ErrorOr<int> serenity_main(Main::Arguments)
{
using namespace JSSpecCompiler;
ExecutionContext context;
TranslationUnit translation_unit;
// Functions referenced in DifferenceISODate
// TODO: This is here just for testing. In a long run, we need some place, which is not
// `serenity_main`, to store built-in functions.
auto& functions = context.m_functions;
auto& functions = translation_unit.function_index;
functions.set("CompareISODate"sv, make_ref_counted<FunctionPointer>("CompareISODate"sv));
functions.set("CreateDateDurationRecord"sv, make_ref_counted<FunctionPointer>("CreateDateDurationRecord"sv));
functions.set("AddISODate"sv, make_ref_counted<FunctionPointer>("AddISODate"sv));
@ -50,7 +50,8 @@ ErrorOr<int> serenity_main(Main::Arguments)
}
auto spec_function = maybe_function.value();
auto function = make_ref_counted<JSSpecCompiler::Function>(&context, spec_function.m_name, spec_function.m_algorithm.m_tree);
auto* function = translation_unit.adopt_function(
make_ref_counted<FunctionDefinition>(spec_function.m_name, spec_function.m_algorithm.m_tree));
for (auto const& argument : spec_function.m_arguments)
function->m_local_variables.set(argument.name, make_ref_counted<VariableDeclaration>(argument.name));