forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibJS: Port Value::get_method() to GCPtr
- Loading branch information
1 parent
9279b07
commit b33b0d6
Showing
13 changed files
with
36 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -887,7 +887,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter | |
if (!@js_name@@[email protected]_object()) | ||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObject, TRY_OR_THROW_OOM(vm, @js_name@@[email protected]_string_without_side_effects())); | ||
auto* iterator_method@recursion_depth@ = TRY(@js_name@@[email protected]_method(vm, vm.well_known_symbol_iterator())); | ||
auto iterator_method@recursion_depth@ = TRY(@js_name@@[email protected]_method(vm, vm.well_known_symbol_iterator())); | ||
if (!iterator_method@recursion_depth@) | ||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotIterable, TRY_OR_THROW_OOM(vm, @js_name@@[email protected]_string_without_side_effects())); | ||
)~~~"); | ||
|
@@ -1169,7 +1169,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter | |
if (sequence_type) { | ||
// 1. Let method be ? GetMethod(V, @@iterator). | ||
union_generator.append(R"~~~( | ||
auto* method = TRY(@js_name@@[email protected]_method(vm, vm.well_known_symbol_iterator())); | ||
auto method = TRY(@js_name@@[email protected]_method(vm, vm.well_known_symbol_iterator())); | ||
)~~~"); | ||
|
||
// 2. If method is not undefined, return the result of creating a sequence of that type from V and method. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2021-2022, Linus Groh <[email protected]> | ||
* Copyright (c) 2021-2023, Linus Groh <[email protected]> | ||
* Copyright (c) 2021, Luke Wilde <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
|
@@ -678,10 +678,10 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double | |
} | ||
|
||
// b. Let dateAdd be ? GetMethod(calendar, "dateAdd"). | ||
auto* date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
|
||
// c. Let dateUntil be ? GetMethod(calendar, "dateUntil"). | ||
auto* date_until = TRY(Value(calendar).get_method(vm, vm.names.dateUntil)); | ||
auto date_until = TRY(Value(calendar).get_method(vm, vm.names.dateUntil)); | ||
|
||
// d. Repeat, while years ≠ 0, | ||
while (years != 0) { | ||
|
@@ -719,7 +719,7 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double | |
} | ||
|
||
// b. Let dateAdd be ? GetMethod(calendar, "dateAdd"). | ||
auto* date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
|
||
// c. Repeat, while years ≠ 0, | ||
while (years != 0) { | ||
|
@@ -762,7 +762,7 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double | |
} | ||
|
||
// ii. Let dateAdd be ? GetMethod(calendar, "dateAdd"). | ||
auto* date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
|
||
// iii. Repeat, while years ≠ 0, | ||
while (years != 0) { | ||
|
@@ -856,7 +856,7 @@ ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double y | |
// 10. If largestUnit is "year", then | ||
if (largest_unit == "year"sv) { | ||
// a. Let dateAdd be ? GetMethod(calendar, "dateAdd"). | ||
auto* date_add = TRY(Value(&calendar).get_method(vm, vm.names.dateAdd)); | ||
auto date_add = TRY(Value(&calendar).get_method(vm, vm.names.dateAdd)); | ||
|
||
// b. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneYear, dateAdd). | ||
auto move_result = TRY(move_relative_date(vm, calendar, *relative_to, *one_year, date_add)); | ||
|
@@ -922,7 +922,7 @@ ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double y | |
new_relative_to = TRY(calendar_date_add(vm, calendar, relative_to, *one_year, nullptr, date_add)); | ||
|
||
// k. Let dateUntil be ? GetMethod(calendar, "dateUntil"). | ||
auto* date_until = TRY(Value(&calendar).get_method(vm, vm.names.dateUntil)); | ||
auto date_until = TRY(Value(&calendar).get_method(vm, vm.names.dateUntil)); | ||
|
||
// l. Let untilOptions be OrdinaryObjectCreate(null). | ||
auto until_options = Object::create(realm, nullptr); | ||
|
@@ -966,7 +966,7 @@ ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double y | |
// 11. Else if largestUnit is "month", then | ||
else if (largest_unit == "month"sv) { | ||
// a. Let dateAdd be ? GetMethod(calendar, "dateAdd"). | ||
auto* date_add = TRY(Value(&calendar).get_method(vm, vm.names.dateAdd)); | ||
auto date_add = TRY(Value(&calendar).get_method(vm, vm.names.dateAdd)); | ||
|
||
// b. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneMonth, dateAdd). | ||
auto move_result = TRY(move_relative_date(vm, calendar, *relative_to, *one_month, date_add)); | ||
|
@@ -1004,7 +1004,7 @@ ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double y | |
VERIFY(largest_unit == "week"sv); | ||
|
||
// b. Let dateAdd be ? GetMethod(calendar, "dateAdd"). | ||
auto* date_add = TRY(Value(&calendar).get_method(vm, vm.names.dateAdd)); | ||
auto date_add = TRY(Value(&calendar).get_method(vm, vm.names.dateAdd)); | ||
|
||
// c. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneWeek, dateAdd). | ||
auto move_result = TRY(move_relative_date(vm, calendar, *relative_to, *one_week, date_add)); | ||
|
@@ -1094,7 +1094,7 @@ ThrowCompletionOr<DurationRecord> add_duration(VM& vm, double years1, double mon | |
auto* date_duration2 = MUST(create_temporal_duration(vm, years2, months2, weeks2, days2, 0, 0, 0, 0, 0, 0)); | ||
|
||
// d. Let dateAdd be ? GetMethod(calendar, "dateAdd"). | ||
auto* date_add = TRY(Value(&calendar).get_method(vm, vm.names.dateAdd)); | ||
auto date_add = TRY(Value(&calendar).get_method(vm, vm.names.dateAdd)); | ||
|
||
// e. Let intermediate be ? CalendarDateAdd(calendar, relativeTo, dateDuration1, undefined, dateAdd). | ||
auto* intermediate = TRY(calendar_date_add(vm, calendar, &relative_to, *date_duration1, nullptr, date_add)); | ||
|
@@ -1282,7 +1282,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m | |
auto* years_duration = MUST(create_temporal_duration(vm, years, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | ||
|
||
// b. Let dateAdd be ? GetMethod(calendar, "dateAdd"). | ||
auto* date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
|
||
// c. Let yearsLater be ? CalendarDateAdd(calendar, relativeTo, yearsDuration, undefined, dateAdd). | ||
auto* years_later = TRY(calendar_date_add(vm, *calendar, relative_to, *years_duration, nullptr, date_add)); | ||
|
@@ -1372,7 +1372,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m | |
auto* years_months = MUST(create_temporal_duration(vm, years, months, 0, 0, 0, 0, 0, 0, 0, 0)); | ||
|
||
// b. Let dateAdd be ? GetMethod(calendar, "dateAdd"). | ||
auto* date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
|
||
// c. Let yearsMonthsLater be ? CalendarDateAdd(calendar, relativeTo, yearsMonths, undefined, dateAdd). | ||
auto* years_months_later = TRY(calendar_date_add(vm, *calendar, relative_to, *years_months, nullptr, date_add)); | ||
|
@@ -1449,7 +1449,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m | |
auto* one_week = MUST(create_temporal_duration(vm, 0, 0, sign, 0, 0, 0, 0, 0, 0, 0)); | ||
|
||
// c. Let dateAdd be ? GetMethod(calendar, "dateAdd"). | ||
auto* date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
auto date_add = TRY(Value(calendar).get_method(vm, vm.names.dateAdd)); | ||
|
||
// d. Let moveResult be ? MoveRelativeDate(calendar, relativeTo, oneWeek, dateAdd). | ||
auto move_result = TRY(move_relative_date(vm, *calendar, *relative_to, *one_week, date_add)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters