mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 20:28:11 +00: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:
parent
24cf56896b
commit
59e9e7cc61
4 changed files with 198 additions and 28 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue