summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-10-29 01:08:49 +0300
committerIdan Horowitz <idan.horowitz@gmail.com>2021-10-29 21:29:24 +0300
commit040e29c7b9a16d153f8c8268ce90bc59830cd0f7 (patch)
tree006c237c284bdc8f79d217b5c6dd48cee3e2ccc7
parent658056233eb47a4493a11d56dd84d591e4717edf (diff)
downloadserenity-040e29c7b9a16d153f8c8268ce90bc59830cd0f7.zip
LibJS: Convert ShadowRealmPrototype functions to ThrowCompletionOr
-rw-r--r--Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp26
-rw-r--r--Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h4
2 files changed, 14 insertions, 16 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp
index e0dd77bf79..074739396c 100644
--- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp
@@ -22,27 +22,25 @@ void ShadowRealmPrototype::initialize(GlobalObject& global_object)
Object::initialize(global_object);
u8 attr = Attribute::Writable | Attribute::Configurable;
- define_old_native_function(vm.names.evaluate, evaluate, 1, attr);
- define_old_native_function(vm.names.importValue, import_value, 2, attr);
+ define_native_function(vm.names.evaluate, evaluate, 1, attr);
+ define_native_function(vm.names.importValue, import_value, 2, attr);
// 3.4.3 ShadowRealm.prototype [ @@toStringTag ], https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, vm.names.ShadowRealm.as_string()), Attribute::Configurable);
}
// 3.4.1 ShadowRealm.prototype.evaluate ( sourceText ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype.evaluate
-JS_DEFINE_OLD_NATIVE_FUNCTION(ShadowRealmPrototype::evaluate)
+JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::evaluate)
{
auto source_text = vm.argument(0);
// 1. Let O be this value.
// 2. Perform ? ValidateShadowRealmObject(O).
- auto* object = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* object = TRY(typed_this_object(global_object));
// 3. If Type(sourceText) is not String, throw a TypeError exception.
- if (!source_text.is_string()) {
- vm.throw_exception<TypeError>(global_object, ErrorType::NotAString, source_text);
- return {};
- }
+ if (!source_text.is_string())
+ return vm.throw_completion<TypeError>(global_object, ErrorType::NotAString, source_text);
// 4. Let callerRealm be the current Realm Record.
auto* caller_realm = vm.current_realm();
@@ -51,24 +49,24 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ShadowRealmPrototype::evaluate)
auto& eval_realm = object->shadow_realm();
// 6. Return ? PerformShadowRealmEval(sourceText, callerRealm, evalRealm).
- return TRY_OR_DISCARD(perform_shadow_realm_eval(global_object, source_text.as_string().string(), *caller_realm, eval_realm));
+ return perform_shadow_realm_eval(global_object, source_text.as_string().string(), *caller_realm, eval_realm);
}
// 3.4.2 ShadowRealm.prototype.importValue ( specifier, exportName ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype.importvalue
-JS_DEFINE_OLD_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
+JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
{
auto specifier = vm.argument(0);
auto export_name = vm.argument(1);
// 1. Let O be this value.
// 2. Perform ? ValidateShadowRealmObject(O).
- auto* object = TRY_OR_DISCARD(typed_this_object(global_object));
+ auto* object = TRY(typed_this_object(global_object));
// 3. Let specifierString be ? ToString(specifier).
- auto specifier_string = TRY_OR_DISCARD(specifier.to_string(global_object));
+ auto specifier_string = TRY(specifier.to_string(global_object));
// 4. Let exportNameString be ? ToString(exportName).
- auto export_name_string = TRY_OR_DISCARD(export_name.to_string(global_object));
+ auto export_name_string = TRY(export_name.to_string(global_object));
// 5. Let callerRealm be the current Realm Record.
auto* caller_realm = vm.current_realm();
@@ -80,7 +78,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
auto& eval_context = object->execution_context();
// 8. Return ? ShadowRealmImportValue(specifierString, exportNameString, callerRealm, evalRealm, evalContext).
- return TRY_OR_DISCARD(shadow_realm_import_value(global_object, move(specifier_string), move(export_name_string), *caller_realm, eval_realm, eval_context));
+ return shadow_realm_import_value(global_object, move(specifier_string), move(export_name_string), *caller_realm, eval_realm, eval_context);
}
}
diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h
index 10d810bc9f..74786eb20b 100644
--- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h
+++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.h
@@ -20,8 +20,8 @@ public:
virtual ~ShadowRealmPrototype() override = default;
private:
- JS_DECLARE_OLD_NATIVE_FUNCTION(evaluate);
- JS_DECLARE_OLD_NATIVE_FUNCTION(import_value);
+ JS_DECLARE_NATIVE_FUNCTION(evaluate);
+ JS_DECLARE_NATIVE_FUNCTION(import_value);
};
}