1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

JSSpecCompiler: Save references to return value and function arguments

This commit is contained in:
Dan Klishch 2023-10-21 21:18:58 -04:00 committed by Andrew Kaster
parent 7f47340c82
commit 5825eaa264
10 changed files with 89 additions and 49 deletions

View file

@ -24,7 +24,11 @@ NonnullRefPtr<FunctionDefinition> CppASTConverter::convert()
}
auto tree = make_ref_counted<TreeList>(move(toplevel_statements));
return make_ref_counted<FunctionDefinition>(name, tree);
Vector<StringView> arguments;
for (auto const& parameter : m_function->parameters())
arguments.append(parameter->full_name());
return make_ref_counted<FunctionDefinition>(name, tree, move(arguments));
}
template<>

View file

@ -196,11 +196,12 @@ void SpecParsingStep::run(TranslationUnitRef translation_unit)
auto spec_function = SpecFunction::create(&m_document->root()).release_value_but_fixme_should_propagate_errors();
auto* function = translation_unit->adopt_function(
make_ref_counted<FunctionDefinition>(spec_function.m_name, spec_function.m_algorithm.m_tree));
Vector<StringView> argument_names;
for (auto const& argument : spec_function.m_arguments)
function->m_local_variables.set(argument.name, make_ref_counted<NamedVariableDeclaration>(argument.name));
argument_names.append(argument.name);
translation_unit->adopt_function(
make_ref_counted<FunctionDefinition>(spec_function.m_name, spec_function.m_algorithm.m_tree, move(argument_names)));
}
}