mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-03 06:40:05 +00:00
JSSpecCompiler: Let FunctionDeclaration know its name and category
This is achieved by moving ClauseHeader::{AbstractOperation,Accessor, Method} to Function.h itself and storing them in FunctionDeclaration. This commit also introduces QualifiedName class that is used to store function's name split by '.' (just like it appear in the spec).
This commit is contained in:
parent
70cfa60f56
commit
0e7c33b1be
Notes:
sideshowbarker
2024-07-17 01:46:43 +09:00
Author: https://github.com/DanShaders
Commit: 0e7c33b1be
Pull-request: https://github.com/SerenityOS/serenity/pull/23647
Reviewed-by: https://github.com/ADKaster ✅
12 changed files with 170 additions and 96 deletions
|
@ -71,8 +71,8 @@ private:
|
|||
};
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Vector<FunctionArgument>> : AK::Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Vector<FunctionArgument> const& arguments)
|
||||
struct AK::Formatter<ReadonlySpan<FunctionArgument>> : AK::Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, ReadonlySpan<FunctionArgument> const& arguments)
|
||||
{
|
||||
size_t previous_optional_group = 0;
|
||||
for (size_t i = 0; i < arguments.size(); ++i) {
|
||||
|
@ -139,17 +139,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TranslationUnit translation_unit(filename);
|
||||
|
||||
// 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.
|
||||
translation_unit.adopt_declaration(make_ref_counted<FunctionDeclaration>("CompareISODate"sv, Vector<FunctionArgument> {}));
|
||||
translation_unit.adopt_declaration(make_ref_counted<FunctionDeclaration>("CreateDateDurationRecord"sv, Vector<FunctionArgument> {}));
|
||||
translation_unit.adopt_declaration(make_ref_counted<FunctionDeclaration>("AddISODate"sv, Vector<FunctionArgument> {}));
|
||||
translation_unit.adopt_declaration(make_ref_counted<FunctionDeclaration>("ISODaysInMonth"sv, Vector<FunctionArgument> {}));
|
||||
translation_unit.adopt_declaration(make_ref_counted<FunctionDeclaration>("ISODateToEpochDays"sv, Vector<FunctionArgument> {}));
|
||||
translation_unit.adopt_declaration(make_ref_counted<FunctionDeclaration>("truncate"sv, Vector<FunctionArgument> {}));
|
||||
translation_unit.adopt_declaration(make_ref_counted<FunctionDeclaration>("remainder"sv, Vector<FunctionArgument> {}));
|
||||
|
||||
for (auto const& step : pipeline.pipeline()) {
|
||||
step.step->run(&translation_unit);
|
||||
|
||||
|
@ -161,14 +150,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (step.dump_ast) {
|
||||
outln(stderr, "===== AST after {} =====", step.step->name());
|
||||
for (auto const& function : translation_unit.functions_to_compile()) {
|
||||
outln(stderr, "{}({}):", function->m_name, function->m_arguments);
|
||||
outln(stderr, "{}({}):", function->name(), function->arguments());
|
||||
outln(stderr, "{}", function->m_ast);
|
||||
}
|
||||
}
|
||||
if (step.dump_cfg && translation_unit.functions_to_compile().size() && translation_unit.functions_to_compile()[0]->m_cfg != nullptr) {
|
||||
outln(stderr, "===== CFG after {} =====", step.step->name());
|
||||
for (auto const& function : translation_unit.functions_to_compile()) {
|
||||
outln(stderr, "{}({}):", function->m_name, function->m_arguments);
|
||||
outln(stderr, "{}({}):", function->name(), function->arguments());
|
||||
outln(stderr, "{}", *function->m_cfg);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue