mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +02:00
LibWeb: Add a very basic and ad-hoc version of IDL overload resolution
This initial version lays down the basic foundation of IDL overload resolution, but much of it will have to be replaced with the actual IDL overload resolution algorithms once we start implementing more complex IDL overloading scenarios.
This commit is contained in:
committed by
Andreas Kling
parent
24cf56896b
commit
59e9e7cc61
Notes:
sideshowbarker
2024-07-17 17:53:59 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/59e9e7cc61 Pull-request: https://github.com/SerenityOS/serenity/pull/12891
@@ -311,7 +311,7 @@ Function Parser::parse_function(HashMap<String, String>& extended_attributes, In
|
||||
consume_whitespace();
|
||||
assert_specific(';');
|
||||
|
||||
Function function { move(return_type), name, move(parameters), move(extended_attributes) };
|
||||
Function function { move(return_type), name, move(parameters), move(extended_attributes), {}, false };
|
||||
|
||||
// "Defining a special operation with an identifier is equivalent to separating the special operation out into its own declaration without an identifier."
|
||||
if (is_special_operation == IsSpecialOperation::No || (is_special_operation == IsSpecialOperation::Yes && !name.is_empty())) {
|
||||
@@ -803,6 +803,31 @@ NonnullOwnPtr<Interface> Parser::parse()
|
||||
}
|
||||
}
|
||||
|
||||
// Create overload sets
|
||||
for (auto& function : interface->functions) {
|
||||
auto& overload_set = interface->overload_sets.ensure(function.name);
|
||||
function.overload_index = overload_set.size();
|
||||
overload_set.append(function);
|
||||
}
|
||||
for (auto& overload_set : interface->overload_sets) {
|
||||
if (overload_set.value.size() == 1)
|
||||
continue;
|
||||
for (auto& overloaded_function : overload_set.value)
|
||||
overloaded_function.is_overloaded = true;
|
||||
}
|
||||
for (auto& function : interface->static_functions) {
|
||||
auto& overload_set = interface->static_overload_sets.ensure(function.name);
|
||||
function.overload_index = overload_set.size();
|
||||
overload_set.append(function);
|
||||
}
|
||||
for (auto& overload_set : interface->static_overload_sets) {
|
||||
if (overload_set.value.size() == 1)
|
||||
continue;
|
||||
for (auto& overloaded_function : overload_set.value)
|
||||
overloaded_function.is_overloaded = true;
|
||||
}
|
||||
// FIXME: Add support for overloading constructors
|
||||
|
||||
interface->imported_modules = move(imports);
|
||||
|
||||
return interface;
|
||||
|
||||
Reference in New Issue
Block a user