mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
LibJS: Replace GlobalObject with VM in remaining AOs [Part 19/19]
This commit is contained in:
parent
25849f8a6d
commit
56b2ae5ac0
Notes:
sideshowbarker
2024-07-17 07:53:23 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/56b2ae5ac0 Pull-request: https://github.com/SerenityOS/serenity/pull/14973 Reviewed-by: https://github.com/davidot ✅
46 changed files with 173 additions and 207 deletions
|
@ -526,14 +526,14 @@ Completion YieldExpression::execute(Interpreter&) const
|
|||
Completion AwaitExpression::execute(Interpreter& interpreter) const
|
||||
{
|
||||
InterpreterNodeScope node_scope { interpreter, *this };
|
||||
auto& global_object = interpreter.global_object();
|
||||
auto& vm = interpreter.vm();
|
||||
|
||||
// 1. Let exprRef be the result of evaluating UnaryExpression.
|
||||
// 2. Let value be ? GetValue(exprRef).
|
||||
auto value = TRY(m_argument->execute(interpreter)).release_value();
|
||||
|
||||
// 3. Return ? Await(value).
|
||||
return await(global_object, value);
|
||||
return await(vm, value);
|
||||
}
|
||||
|
||||
// 14.10.1 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-return-statement-runtime-semantics-evaluation
|
||||
|
@ -883,7 +883,6 @@ struct ForInOfHeadState {
|
|||
{
|
||||
VERIFY(!next_value.is_empty());
|
||||
|
||||
auto& global_object = interpreter.global_object();
|
||||
auto& vm = interpreter.vm();
|
||||
|
||||
Optional<Reference> lhs_reference;
|
||||
|
@ -935,7 +934,7 @@ struct ForInOfHeadState {
|
|||
// j. Else,
|
||||
if (lhs_kind == Assignment) {
|
||||
VERIFY(pattern_lhs);
|
||||
return interpreter.vm().destructuring_assignment_evaluation(*pattern_lhs, next_value, global_object);
|
||||
return interpreter.vm().destructuring_assignment_evaluation(*pattern_lhs, next_value);
|
||||
}
|
||||
VERIFY(expression_lhs && is<VariableDeclaration>(*expression_lhs));
|
||||
auto& for_declaration = static_cast<VariableDeclaration const&>(*expression_lhs);
|
||||
|
@ -944,7 +943,7 @@ struct ForInOfHeadState {
|
|||
|
||||
// At this point iteration_environment is undefined if lhs_kind == VarBinding which means this does both
|
||||
// branch j.ii and j.iii because ForBindingInitialization is just a forwarding call to BindingInitialization.
|
||||
return interpreter.vm().binding_initialization(binding_pattern, next_value, iteration_environment, global_object);
|
||||
return interpreter.vm().binding_initialization(binding_pattern, next_value, iteration_environment);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1165,7 +1164,6 @@ Completion ForAwaitOfStatement::execute(Interpreter& interpreter) const
|
|||
Completion ForAwaitOfStatement::loop_evaluation(Interpreter& interpreter, Vector<FlyString> const& label_set) const
|
||||
{
|
||||
InterpreterNodeScope node_scope { interpreter, *this };
|
||||
auto& global_object = interpreter.global_object();
|
||||
auto& vm = interpreter.vm();
|
||||
|
||||
// 14.7.5.6 ForIn/OfHeadEvaluation ( uninitializedBoundNames, expr, iterationKind ), https://tc39.es/ecma262/#sec-runtime-semantics-forinofheadevaluation
|
||||
|
@ -1197,7 +1195,7 @@ Completion ForAwaitOfStatement::loop_evaluation(Interpreter& interpreter, Vector
|
|||
auto next_result = TRY(call(vm, iterator.next_method, iterator.iterator));
|
||||
|
||||
// b. If iteratorKind is async, set nextResult to ? Await(nextResult).
|
||||
next_result = TRY(await(global_object, next_result));
|
||||
next_result = TRY(await(vm, next_result));
|
||||
|
||||
// c. If Type(nextResult) is not Object, throw a TypeError exception.
|
||||
if (!next_result.is_object())
|
||||
|
@ -2597,7 +2595,6 @@ void ThisExpression::dump(int indent) const
|
|||
Completion AssignmentExpression::execute(Interpreter& interpreter) const
|
||||
{
|
||||
InterpreterNodeScope node_scope { interpreter, *this };
|
||||
auto& global_object = interpreter.global_object();
|
||||
auto& vm = interpreter.vm();
|
||||
|
||||
if (m_op == AssignmentOp::Assignment) {
|
||||
|
@ -2615,7 +2612,7 @@ Completion AssignmentExpression::execute(Interpreter& interpreter) const
|
|||
if (lhs->is_identifier()) {
|
||||
// i. Let rval be ? NamedEvaluation of AssignmentExpression with argument lref.[[ReferencedName]].
|
||||
auto& identifier_name = static_cast<Identifier const&>(*lhs).string();
|
||||
rhs_result = TRY(interpreter.vm().named_evaluation_if_anonymous_function(m_rhs, identifier_name));
|
||||
rhs_result = TRY(vm.named_evaluation_if_anonymous_function(m_rhs, identifier_name));
|
||||
}
|
||||
// d. Else,
|
||||
else {
|
||||
|
@ -2637,7 +2634,7 @@ Completion AssignmentExpression::execute(Interpreter& interpreter) const
|
|||
auto rhs_result = TRY(m_rhs->execute(interpreter)).release_value();
|
||||
|
||||
// 5. Perform ? DestructuringAssignmentEvaluation of assignmentPattern with argument rval.
|
||||
TRY(interpreter.vm().destructuring_assignment_evaluation(pattern, rhs_result, global_object));
|
||||
TRY(vm.destructuring_assignment_evaluation(pattern, rhs_result));
|
||||
|
||||
// 6. Return rval.
|
||||
return rhs_result;
|
||||
|
@ -2910,7 +2907,6 @@ void UpdateExpression::dump(int indent) const
|
|||
Completion VariableDeclaration::execute(Interpreter& interpreter) const
|
||||
{
|
||||
InterpreterNodeScope node_scope { interpreter, *this };
|
||||
auto& global_object = interpreter.global_object();
|
||||
auto& vm = interpreter.vm();
|
||||
|
||||
for (auto& declarator : m_declarations) {
|
||||
|
@ -2931,7 +2927,7 @@ Completion VariableDeclaration::execute(Interpreter& interpreter) const
|
|||
|
||||
Environment* environment = m_declaration_kind == DeclarationKind::Var ? nullptr : interpreter.lexical_environment();
|
||||
|
||||
return vm.binding_initialization(pattern, initializer_result, environment, global_object);
|
||||
return vm.binding_initialization(pattern, initializer_result, environment);
|
||||
}));
|
||||
} else if (m_declaration_kind != DeclarationKind::Var) {
|
||||
VERIFY(declarator.target().has<NonnullRefPtr<Identifier>>());
|
||||
|
@ -3781,7 +3777,6 @@ void ThrowStatement::dump(int indent) const
|
|||
Completion TryStatement::execute(Interpreter& interpreter) const
|
||||
{
|
||||
InterpreterNodeScope node_scope { interpreter, *this };
|
||||
auto& global_object = interpreter.global_object();
|
||||
auto& vm = interpreter.vm();
|
||||
|
||||
// 14.15.2 Runtime Semantics: CatchClauseEvaluation, https://tc39.es/ecma262/#sec-runtime-semantics-catchclauseevaluation
|
||||
|
@ -3815,7 +3810,7 @@ Completion TryStatement::execute(Interpreter& interpreter) const
|
|||
return catch_environment->initialize_binding(vm, parameter, thrown_value);
|
||||
},
|
||||
[&](NonnullRefPtr<BindingPattern> const& pattern) {
|
||||
return vm.binding_initialization(pattern, thrown_value, catch_environment, global_object);
|
||||
return vm.binding_initialization(pattern, thrown_value, catch_environment);
|
||||
});
|
||||
|
||||
// 6. If status is an abrupt completion, then
|
||||
|
|
|
@ -45,9 +45,6 @@ ThrowCompletionOr<Value> Interpreter::run(Script& script_record)
|
|||
// 1. Let globalEnv be scriptRecord.[[Realm]].[[GlobalEnv]].
|
||||
auto& global_environment = script_record.realm().global_environment();
|
||||
|
||||
// NOTE: This isn't in the spec but we require it.
|
||||
auto& global_object = script_record.realm().global_object();
|
||||
|
||||
// 2. Let scriptContext be a new ECMAScript code execution context.
|
||||
ExecutionContext script_context(vm.heap());
|
||||
|
||||
|
@ -74,7 +71,7 @@ ThrowCompletionOr<Value> Interpreter::run(Script& script_record)
|
|||
// FIXME: 9. Suspend the currently running execution context.
|
||||
|
||||
// 10. Push scriptContext onto the execution context stack; scriptContext is now the running execution context.
|
||||
TRY(vm.push_execution_context(script_context, global_object));
|
||||
TRY(vm.push_execution_context(script_context, {}));
|
||||
|
||||
// 11. Let script be scriptRecord.[[ECMAScriptCode]].
|
||||
auto& script = script_record.parse_node();
|
||||
|
|
|
@ -219,7 +219,7 @@ public:
|
|||
};
|
||||
|
||||
// Needs to mess with m_state, and we're not going to expose a non-const getter for that :^)
|
||||
friend ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic_function(GlobalObject&, FunctionObject&, FunctionObject*, FunctionKind, MarkedVector<Value> const&);
|
||||
friend ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic_function(VM&, FunctionObject&, FunctionObject*, FunctionKind, MarkedVector<Value> const&);
|
||||
|
||||
private:
|
||||
friend class ScopePusher;
|
||||
|
|
|
@ -663,7 +663,7 @@ ThrowCompletionOr<Value> perform_eval(VM& vm, Value x, CallerMode strict_caller,
|
|||
eval_context.is_strict_mode = strict_eval;
|
||||
|
||||
// 27. Push evalContext onto the execution context stack; evalContext is now the running execution context.
|
||||
TRY(vm.push_execution_context(eval_context, eval_realm.global_object()));
|
||||
TRY(vm.push_execution_context(eval_context, {}));
|
||||
|
||||
// NOTE: We use a ScopeGuard to automatically pop the execution context when any of the `TRY`s below return a throw completion.
|
||||
ScopeGuard pop_guard = [&] {
|
||||
|
|
|
@ -38,7 +38,6 @@ ThrowCompletionOr<Value> AsyncFunctionConstructor::call()
|
|||
ThrowCompletionOr<Object*> AsyncFunctionConstructor::construct(FunctionObject& new_target)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
// 1. Let C be the active function object.
|
||||
auto* constructor = vm.active_function_object();
|
||||
|
@ -47,7 +46,7 @@ ThrowCompletionOr<Object*> AsyncFunctionConstructor::construct(FunctionObject& n
|
|||
auto& args = vm.running_execution_context().arguments;
|
||||
|
||||
// 3. Return CreateDynamicFunction(C, NewTarget, async, args).
|
||||
return TRY(FunctionConstructor::create_dynamic_function(global_object, *constructor, &new_target, FunctionKind::Async, args));
|
||||
return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Async, args));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,28 +15,28 @@ namespace JS {
|
|||
ThrowCompletionOr<Value> AsyncFunctionDriverWrapper::create(Realm& realm, GeneratorObject* generator_object)
|
||||
{
|
||||
auto wrapper = realm.heap().allocate<AsyncFunctionDriverWrapper>(realm, realm, generator_object);
|
||||
return wrapper->react_to_async_task_completion(realm.vm(), realm.global_object(), js_undefined(), true);
|
||||
return wrapper->react_to_async_task_completion(realm.vm(), js_undefined(), true);
|
||||
}
|
||||
|
||||
AsyncFunctionDriverWrapper::AsyncFunctionDriverWrapper(Realm& realm, GeneratorObject* generator_object)
|
||||
: Promise(*realm.global_object().promise_prototype())
|
||||
, m_generator_object(generator_object)
|
||||
, m_on_fulfillment(NativeFunction::create(realm, "async.on_fulfillment"sv, [this](VM& vm, GlobalObject& global_object) {
|
||||
return react_to_async_task_completion(vm, global_object, vm.argument(0), true);
|
||||
, m_on_fulfillment(NativeFunction::create(realm, "async.on_fulfillment"sv, [this](VM& vm, GlobalObject&) {
|
||||
return react_to_async_task_completion(vm, vm.argument(0), true);
|
||||
}))
|
||||
, m_on_rejection(NativeFunction::create(realm, "async.on_rejection"sv, [this](VM& vm, GlobalObject& global_object) {
|
||||
return react_to_async_task_completion(vm, global_object, vm.argument(0), false);
|
||||
, m_on_rejection(NativeFunction::create(realm, "async.on_rejection"sv, [this](VM& vm, GlobalObject&) {
|
||||
return react_to_async_task_completion(vm, vm.argument(0), false);
|
||||
}))
|
||||
{
|
||||
}
|
||||
|
||||
ThrowCompletionOr<Value> AsyncFunctionDriverWrapper::react_to_async_task_completion(VM& vm, GlobalObject& global_object, Value value, bool is_successful)
|
||||
ThrowCompletionOr<Value> AsyncFunctionDriverWrapper::react_to_async_task_completion(VM& vm, Value value, bool is_successful)
|
||||
{
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto generator_result = is_successful
|
||||
? m_generator_object->next_impl(vm, global_object, value, {})
|
||||
: m_generator_object->next_impl(vm, global_object, {}, value);
|
||||
? m_generator_object->next_impl(vm, value, {})
|
||||
: m_generator_object->next_impl(vm, {}, value);
|
||||
|
||||
if (generator_result.is_throw_completion()) {
|
||||
VERIFY(generator_result.throw_completion().type() == Completion::Type::Throw);
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
virtual ~AsyncFunctionDriverWrapper() override = default;
|
||||
void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
ThrowCompletionOr<Value> react_to_async_task_completion(VM&, GlobalObject&, Value, bool is_successful);
|
||||
ThrowCompletionOr<Value> react_to_async_task_completion(VM&, Value, bool is_successful);
|
||||
|
||||
private:
|
||||
GeneratorObject* m_generator_object { nullptr };
|
||||
|
|
|
@ -39,7 +39,6 @@ ThrowCompletionOr<Value> AsyncGeneratorFunctionConstructor::call()
|
|||
ThrowCompletionOr<Object*> AsyncGeneratorFunctionConstructor::construct(FunctionObject& new_target)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
// 1. Let C be the active function object.
|
||||
auto* constructor = vm.active_function_object();
|
||||
|
@ -48,7 +47,7 @@ ThrowCompletionOr<Object*> AsyncGeneratorFunctionConstructor::construct(Function
|
|||
auto& args = vm.running_execution_context().arguments;
|
||||
|
||||
// 3. Return ? CreateDynamicFunction(C, NewTarget, asyncGenerator, args).
|
||||
return TRY(FunctionConstructor::create_dynamic_function(global_object, *constructor, &new_target, FunctionKind::AsyncGenerator, args));
|
||||
return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::AsyncGenerator, args));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,10 +28,9 @@ BigInt* js_bigint(VM& vm, Crypto::SignedBigInteger big_integer)
|
|||
}
|
||||
|
||||
// 21.2.1.1.1 NumberToBigInt ( number ), https://tc39.es/ecma262/#sec-numbertobigint
|
||||
ThrowCompletionOr<BigInt*> number_to_bigint(GlobalObject& global_object, Value number)
|
||||
ThrowCompletionOr<BigInt*> number_to_bigint(VM& vm, Value number)
|
||||
{
|
||||
VERIFY(number.is_number());
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 1. If IsIntegralNumber(number) is false, throw a RangeError exception.
|
||||
if (!number.is_integral_number())
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -28,6 +28,6 @@ private:
|
|||
|
||||
BigInt* js_bigint(Heap&, Crypto::SignedBigInteger);
|
||||
BigInt* js_bigint(VM&, Crypto::SignedBigInteger);
|
||||
ThrowCompletionOr<BigInt*> number_to_bigint(GlobalObject&, Value);
|
||||
ThrowCompletionOr<BigInt*> number_to_bigint(VM&, Value);
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ void BigIntConstructor::initialize(Realm& realm)
|
|||
ThrowCompletionOr<Value> BigIntConstructor::call()
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
auto value = vm.argument(0);
|
||||
|
||||
|
@ -50,7 +49,7 @@ ThrowCompletionOr<Value> BigIntConstructor::call()
|
|||
|
||||
// 3. If Type(prim) is Number, return ? NumberToBigInt(prim).
|
||||
if (primitive.is_number())
|
||||
return TRY(number_to_bigint(global_object, primitive));
|
||||
return TRY(number_to_bigint(vm, primitive));
|
||||
|
||||
// 4. Otherwise, return ? ToBigInt(prim).
|
||||
return TRY(primitive.to_bigint(vm));
|
||||
|
|
|
@ -36,20 +36,19 @@ void BigIntPrototype::initialize(Realm& realm)
|
|||
}
|
||||
|
||||
// thisBigIntValue ( value ), https://tc39.es/ecma262/#thisbigintvalue
|
||||
static ThrowCompletionOr<BigInt*> this_bigint_value(GlobalObject& global_object, Value value)
|
||||
static ThrowCompletionOr<BigInt*> this_bigint_value(VM& vm, Value value)
|
||||
{
|
||||
if (value.is_bigint())
|
||||
return &value.as_bigint();
|
||||
if (value.is_object() && is<BigIntObject>(value.as_object()))
|
||||
return &static_cast<BigIntObject&>(value.as_object()).bigint();
|
||||
auto& vm = global_object.vm();
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "BigInt");
|
||||
}
|
||||
|
||||
// 21.2.3.3 BigInt.prototype.toString ( [ radix ] ), https://tc39.es/ecma262/#sec-bigint.prototype.tostring
|
||||
JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_string)
|
||||
{
|
||||
auto* bigint = TRY(this_bigint_value(global_object, vm.this_value()));
|
||||
auto* bigint = TRY(this_bigint_value(vm, vm.this_value()));
|
||||
double radix = 10;
|
||||
if (!vm.argument(0).is_undefined()) {
|
||||
radix = TRY(vm.argument(0).to_integer_or_infinity(vm));
|
||||
|
@ -67,7 +66,7 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_locale_string)
|
|||
auto options = vm.argument(1);
|
||||
|
||||
// 1. Let x be ? thisBigIntValue(this value).
|
||||
auto* bigint = TRY(this_bigint_value(global_object, vm.this_value()));
|
||||
auto* bigint = TRY(this_bigint_value(vm, vm.this_value()));
|
||||
|
||||
// 2. Let numberFormat be ? Construct(%NumberFormat%, « locales, options »).
|
||||
auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, *global_object.intl_number_format_constructor(), locales, options)));
|
||||
|
@ -80,7 +79,7 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_locale_string)
|
|||
// 21.2.3.4 BigInt.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-bigint.prototype.valueof
|
||||
JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::value_of)
|
||||
{
|
||||
return TRY(this_bigint_value(global_object, vm.this_value()));
|
||||
return TRY(this_bigint_value(vm, vm.this_value()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,16 +29,15 @@ Completion::Completion(ThrowCompletionOr<Value> const& throw_completion_or_value
|
|||
}
|
||||
|
||||
// 6.2.3.1 Await, https://tc39.es/ecma262/#await
|
||||
ThrowCompletionOr<Value> await(GlobalObject& global_object, Value value)
|
||||
ThrowCompletionOr<Value> await(VM& vm, Value value)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Let asyncContext be the running execution context.
|
||||
// NOTE: This is not needed, as we don't suspend anything.
|
||||
|
||||
// 2. Let promise be ? PromiseResolve(%Promise%, value).
|
||||
auto* promise_object = TRY(promise_resolve(vm, *global_object.promise_constructor(), value));
|
||||
auto* promise_object = TRY(promise_resolve(vm, *realm.global_object().promise_constructor(), value));
|
||||
|
||||
Optional<bool> success;
|
||||
Value result;
|
||||
|
|
|
@ -293,7 +293,7 @@ public:
|
|||
using ThrowCompletionOr<Empty>::ThrowCompletionOr;
|
||||
};
|
||||
|
||||
ThrowCompletionOr<Value> await(GlobalObject&, Value);
|
||||
ThrowCompletionOr<Value> await(VM&, Value);
|
||||
|
||||
// 6.2.3.2 NormalCompletion ( value ), https://tc39.es/ecma262/#sec-normalcompletion
|
||||
inline Completion normal_completion(Optional<Value> value)
|
||||
|
|
|
@ -52,9 +52,8 @@ void DataViewPrototype::initialize(Realm& realm)
|
|||
|
||||
// 25.3.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type ), https://tc39.es/ecma262/#sec-getviewvalue
|
||||
template<typename T>
|
||||
static ThrowCompletionOr<Value> get_view_value(GlobalObject& global_object, Value request_index, Value is_little_endian)
|
||||
static ThrowCompletionOr<Value> get_view_value(VM& vm, Value request_index, Value is_little_endian)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto* view = TRY(DataViewPrototype::typed_this_value(vm));
|
||||
auto get_index = TRY(request_index.to_index(vm));
|
||||
auto little_endian = is_little_endian.to_boolean();
|
||||
|
@ -82,9 +81,8 @@ static ThrowCompletionOr<Value> get_view_value(GlobalObject& global_object, Valu
|
|||
|
||||
// 25.3.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value ), https://tc39.es/ecma262/#sec-setviewvalue
|
||||
template<typename T>
|
||||
static ThrowCompletionOr<Value> set_view_value(GlobalObject& global_object, Value request_index, Value is_little_endian, Value value)
|
||||
static ThrowCompletionOr<Value> set_view_value(VM& vm, Value request_index, Value is_little_endian, Value value)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto* view = TRY(DataViewPrototype::typed_this_value(vm));
|
||||
auto get_index = TRY(request_index.to_index(vm));
|
||||
|
||||
|
@ -122,112 +120,112 @@ static ThrowCompletionOr<Value> set_view_value(GlobalObject& global_object, Valu
|
|||
// 25.3.4.5 DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getbigint64
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_big_int_64)
|
||||
{
|
||||
return get_view_value<i64>(global_object, vm.argument(0), vm.argument(1));
|
||||
return get_view_value<i64>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.6 DataView.prototype.getBigUint64 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getbiguint64
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_big_uint_64)
|
||||
{
|
||||
return get_view_value<u64>(global_object, vm.argument(0), vm.argument(1));
|
||||
return get_view_value<u64>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.7 DataView.prototype.getFloat32 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getfloat32
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_float_32)
|
||||
{
|
||||
return get_view_value<float>(global_object, vm.argument(0), vm.argument(1));
|
||||
return get_view_value<float>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.8 DataView.prototype.getFloat64 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getfloat64
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_float_64)
|
||||
{
|
||||
return get_view_value<double>(global_object, vm.argument(0), vm.argument(1));
|
||||
return get_view_value<double>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.9 DataView.prototype.getInt8 ( byteOffset ), https://tc39.es/ecma262/#sec-dataview.prototype.getint8
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_int_8)
|
||||
{
|
||||
return get_view_value<i8>(global_object, vm.argument(0), Value(true));
|
||||
return get_view_value<i8>(vm, vm.argument(0), Value(true));
|
||||
}
|
||||
|
||||
// 25.3.4.10 DataView.prototype.getInt16 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getint16
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_int_16)
|
||||
{
|
||||
return get_view_value<i16>(global_object, vm.argument(0), vm.argument(1));
|
||||
return get_view_value<i16>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.11 DataView.prototype.getInt32 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getint32
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_int_32)
|
||||
{
|
||||
return get_view_value<i32>(global_object, vm.argument(0), vm.argument(1));
|
||||
return get_view_value<i32>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.12 DataView.prototype.getUint8 ( byteOffset ), https://tc39.es/ecma262/#sec-dataview.prototype.getuint8
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_uint_8)
|
||||
{
|
||||
return get_view_value<u8>(global_object, vm.argument(0), Value(true));
|
||||
return get_view_value<u8>(vm, vm.argument(0), Value(true));
|
||||
}
|
||||
|
||||
// 25.3.4.13 DataView.prototype.getUint16 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getuint16
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_uint_16)
|
||||
{
|
||||
return get_view_value<u16>(global_object, vm.argument(0), vm.argument(1));
|
||||
return get_view_value<u16>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.14 DataView.prototype.getUint32 ( byteOffset [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.getuint32
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::get_uint_32)
|
||||
{
|
||||
return get_view_value<u32>(global_object, vm.argument(0), vm.argument(1));
|
||||
return get_view_value<u32>(vm, vm.argument(0), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.15 DataView.prototype.setBigInt64 ( byteOffset, value [ , littleEndian ] ), https://tc39.es/ecma262/#sec-dataview.prototype.setbigint64
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_big_int_64)
|
||||
{
|
||||
return set_view_value<i64>(global_object, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
return set_view_value<i64>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_big_uint_64)
|
||||
{
|
||||
return set_view_value<u64>(global_object, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
return set_view_value<u64>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_float_32)
|
||||
{
|
||||
return set_view_value<float>(global_object, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
return set_view_value<float>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_float_64)
|
||||
{
|
||||
return set_view_value<double>(global_object, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
return set_view_value<double>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_int_8)
|
||||
{
|
||||
return set_view_value<i8>(global_object, vm.argument(0), Value(true), vm.argument(1));
|
||||
return set_view_value<i8>(vm, vm.argument(0), Value(true), vm.argument(1));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_int_16)
|
||||
{
|
||||
return set_view_value<i16>(global_object, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
return set_view_value<i16>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_int_32)
|
||||
{
|
||||
return set_view_value<i32>(global_object, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
return set_view_value<i32>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_uint_8)
|
||||
{
|
||||
return set_view_value<u8>(global_object, vm.argument(0), Value(true), vm.argument(1));
|
||||
return set_view_value<u8>(vm, vm.argument(0), Value(true), vm.argument(1));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_uint_16)
|
||||
{
|
||||
return set_view_value<u16>(global_object, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
return set_view_value<u16>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::set_uint_32)
|
||||
{
|
||||
return set_view_value<u32>(global_object, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
return set_view_value<u32>(vm, vm.argument(0), vm.argument(2), vm.argument(1));
|
||||
}
|
||||
|
||||
// 25.3.4.1 get DataView.prototype.buffer, https://tc39.es/ecma262/#sec-get-dataview.prototype.buffer
|
||||
|
|
|
@ -16,7 +16,7 @@ class Date final : public Object {
|
|||
|
||||
public:
|
||||
static Date* create(Realm&, double date_value);
|
||||
static Date* now(GlobalObject&);
|
||||
static Date* now(VM&);
|
||||
|
||||
Date(double date_value, Object& prototype);
|
||||
virtual ~Date() override = default;
|
||||
|
|
|
@ -1177,7 +1177,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_temporal_instant)
|
|||
auto t = TRY(this_time_value(vm, vm.this_value()));
|
||||
|
||||
// 2. Let ns be ? NumberToBigInt(t) × ℤ(10^6).
|
||||
auto* ns = TRY(number_to_bigint(global_object, Value(t)));
|
||||
auto* ns = TRY(number_to_bigint(vm, Value(t)));
|
||||
ns = js_bigint(vm, ns->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000'000 }));
|
||||
|
||||
// 3. Return ! CreateTemporalInstant(ns).
|
||||
|
|
|
@ -467,7 +467,7 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::function_declaration_instantia
|
|||
return reference.initialize_referenced_binding(vm, argument_value);
|
||||
} else if (IsSame<NonnullRefPtr<BindingPattern> const&, decltype(param)>) {
|
||||
// Here the difference from hasDuplicates is important
|
||||
return vm.binding_initialization(param, argument_value, used_environment, global_object);
|
||||
return vm.binding_initialization(param, argument_value, used_environment);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
@ -627,7 +627,7 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::prepare_for_ordinary_call(Exec
|
|||
// FIXME: We don't have this concept yet.
|
||||
|
||||
// 12. Push calleeContext onto the execution context stack; calleeContext is now the running execution context.
|
||||
TRY(vm.push_execution_context(callee_context, global_object()));
|
||||
TRY(vm.push_execution_context(callee_context, {}));
|
||||
|
||||
// 13. NOTE: Any exception objects produced after this point are associated with calleeRealm.
|
||||
// 14. Return calleeContext.
|
||||
|
@ -719,7 +719,6 @@ void ECMAScriptFunctionObject::async_function_start(PromiseCapability const& pro
|
|||
void async_block_start(VM& vm, NonnullRefPtr<Statement> const& async_body, PromiseCapability const& promise_capability, ExecutionContext& async_context)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto& global_object = realm.global_object();
|
||||
|
||||
// 1. Assert: promiseCapability is a PromiseCapability Record.
|
||||
|
||||
|
@ -760,7 +759,7 @@ void async_block_start(VM& vm, NonnullRefPtr<Statement> const& async_body, Promi
|
|||
});
|
||||
|
||||
// 4. Push asyncContext onto the execution context stack; asyncContext is now the running execution context.
|
||||
auto push_result = vm.push_execution_context(async_context, global_object);
|
||||
auto push_result = vm.push_execution_context(async_context, {});
|
||||
if (push_result.is_error())
|
||||
return;
|
||||
|
||||
|
|
|
@ -36,12 +36,10 @@ void FunctionConstructor::initialize(Realm& realm)
|
|||
}
|
||||
|
||||
// 20.2.1.1.1 CreateDynamicFunction ( constructor, newTarget, kind, args ), https://tc39.es/ecma262/#sec-createdynamicfunction
|
||||
ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic_function(GlobalObject& global_object, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector<Value> const& args)
|
||||
ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic_function(VM& vm, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector<Value> const& args)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 1. Let currentRealm be the current Realm Record.
|
||||
auto& current_realm = *vm.running_execution_context().realm;
|
||||
auto& current_realm = *vm.current_realm();
|
||||
|
||||
// 2. Perform ? HostEnsureCanCompileStrings(currentRealm).
|
||||
TRY(vm.host_ensure_can_compile_strings(current_realm));
|
||||
|
@ -234,7 +232,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
|
|||
// 30. If kind is generator, then
|
||||
if (kind == FunctionKind::Generator) {
|
||||
// a. Let prototype be OrdinaryObjectCreate(%GeneratorFunction.prototype.prototype%).
|
||||
prototype = Object::create(realm, global_object.generator_function_prototype_prototype());
|
||||
prototype = Object::create(realm, realm.global_object().generator_function_prototype_prototype());
|
||||
|
||||
// b. Perform ! DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }).
|
||||
function->define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||
|
@ -242,7 +240,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
|
|||
// 31. Else if kind is asyncGenerator, then
|
||||
else if (kind == FunctionKind::AsyncGenerator) {
|
||||
// a. Let prototype be OrdinaryObjectCreate(%AsyncGeneratorFunction.prototype.prototype%).
|
||||
prototype = Object::create(realm, global_object.async_generator_function_prototype_prototype());
|
||||
prototype = Object::create(realm, realm.global_object().async_generator_function_prototype_prototype());
|
||||
|
||||
// b. Perform ! DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }).
|
||||
function->define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||
|
@ -250,7 +248,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
|
|||
// 32. Else if kind is normal, perform MakeConstructor(F).
|
||||
else if (kind == FunctionKind::Normal) {
|
||||
// FIXME: Implement MakeConstructor
|
||||
prototype = Object::create(realm, global_object.object_prototype());
|
||||
prototype = Object::create(realm, realm.global_object().object_prototype());
|
||||
prototype->define_direct_property(vm.names.constructor, function, Attribute::Writable | Attribute::Configurable);
|
||||
function->define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||
}
|
||||
|
@ -271,7 +269,6 @@ ThrowCompletionOr<Value> FunctionConstructor::call()
|
|||
ThrowCompletionOr<Object*> FunctionConstructor::construct(FunctionObject& new_target)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
// 1. Let C be the active function object.
|
||||
auto* constructor = vm.active_function_object();
|
||||
|
@ -280,7 +277,7 @@ ThrowCompletionOr<Object*> FunctionConstructor::construct(FunctionObject& new_ta
|
|||
auto& args = vm.running_execution_context().arguments;
|
||||
|
||||
// 3. Return ? CreateDynamicFunction(C, NewTarget, normal, args).
|
||||
return TRY(create_dynamic_function(global_object, *constructor, &new_target, FunctionKind::Normal, args));
|
||||
return TRY(create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Normal, args));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@ class FunctionConstructor final : public NativeFunction {
|
|||
JS_OBJECT(FunctionConstructor, NativeFunction);
|
||||
|
||||
public:
|
||||
static ThrowCompletionOr<ECMAScriptFunctionObject*> create_dynamic_function(GlobalObject& global_object, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector<Value> const& args);
|
||||
static ThrowCompletionOr<ECMAScriptFunctionObject*> create_dynamic_function(VM&, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector<Value> const& args);
|
||||
|
||||
explicit FunctionConstructor(Realm&);
|
||||
virtual void initialize(Realm&) override;
|
||||
|
|
|
@ -37,7 +37,6 @@ ThrowCompletionOr<Value> GeneratorFunctionConstructor::call()
|
|||
ThrowCompletionOr<Object*> GeneratorFunctionConstructor::construct(FunctionObject& new_target)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
// 1. Let C be the active function object.
|
||||
auto* constructor = vm.active_function_object();
|
||||
|
@ -46,7 +45,7 @@ ThrowCompletionOr<Object*> GeneratorFunctionConstructor::construct(FunctionObjec
|
|||
auto& args = vm.running_execution_context().arguments;
|
||||
|
||||
// 3. Return ? CreateDynamicFunction(C, NewTarget, generator, args).
|
||||
return TRY(FunctionConstructor::create_dynamic_function(global_object, *constructor, &new_target, FunctionKind::Generator, args));
|
||||
return TRY(FunctionConstructor::create_dynamic_function(vm, *constructor, &new_target, FunctionKind::Generator, args));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ void GeneratorObject::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_previous_value);
|
||||
}
|
||||
|
||||
ThrowCompletionOr<Value> GeneratorObject::next_impl(VM& vm, GlobalObject& global_object, Optional<Value> next_argument, Optional<Value> value_to_throw)
|
||||
ThrowCompletionOr<Value> GeneratorObject::next_impl(VM& vm, Optional<Value> next_argument, Optional<Value> value_to_throw)
|
||||
{
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& realm = *vm.current_realm();
|
||||
auto bytecode_interpreter = Bytecode::Interpreter::current();
|
||||
VERIFY(bytecode_interpreter);
|
||||
|
||||
|
@ -73,7 +73,7 @@ ThrowCompletionOr<Value> GeneratorObject::next_impl(VM& vm, GlobalObject& global
|
|||
|
||||
auto previous_generated_value = TRY(generated_value(m_previous_value));
|
||||
|
||||
auto result = Object::create(realm, global_object.object_prototype());
|
||||
auto result = Object::create(realm, realm.global_object().object_prototype());
|
||||
result->define_direct_property("value", previous_generated_value, default_attributes);
|
||||
|
||||
if (m_done) {
|
||||
|
@ -95,7 +95,7 @@ ThrowCompletionOr<Value> GeneratorObject::next_impl(VM& vm, GlobalObject& global
|
|||
VERIFY(!m_generating_function->bytecode_executable()->basic_blocks.find_if([next_block](auto& block) { return block == next_block; }).is_end());
|
||||
|
||||
// Temporarily switch to the captured execution context
|
||||
TRY(vm.push_execution_context(m_execution_context, global_object));
|
||||
TRY(vm.push_execution_context(m_execution_context, {}));
|
||||
|
||||
// Pretend that 'yield' returned the passed value, or threw
|
||||
if (value_to_throw.has_value()) {
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
virtual ~GeneratorObject() override = default;
|
||||
void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
ThrowCompletionOr<Value> next_impl(VM&, GlobalObject&, Optional<Value> next_argument, Optional<Value> value_to_throw);
|
||||
ThrowCompletionOr<Value> next_impl(VM&, Optional<Value> next_argument, Optional<Value> value_to_throw);
|
||||
void set_done() { m_done = true; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -31,7 +31,7 @@ void GeneratorPrototype::initialize(Realm& realm)
|
|||
JS_DEFINE_NATIVE_FUNCTION(GeneratorPrototype::next)
|
||||
{
|
||||
auto* generator_object = TRY(typed_this_object(vm));
|
||||
return generator_object->next_impl(vm, global_object, vm.argument(0), {});
|
||||
return generator_object->next_impl(vm, vm.argument(0), {});
|
||||
}
|
||||
|
||||
// 27.5.1.3 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.return
|
||||
|
@ -39,14 +39,14 @@ JS_DEFINE_NATIVE_FUNCTION(GeneratorPrototype::return_)
|
|||
{
|
||||
auto* generator_object = TRY(typed_this_object(vm));
|
||||
generator_object->set_done();
|
||||
return generator_object->next_impl(vm, global_object, {}, {});
|
||||
return generator_object->next_impl(vm, {}, {});
|
||||
}
|
||||
|
||||
// 27.5.1.4 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.throw
|
||||
JS_DEFINE_NATIVE_FUNCTION(GeneratorPrototype::throw_)
|
||||
{
|
||||
auto* generator_object = TRY(typed_this_object(vm));
|
||||
return generator_object->next_impl(vm, global_object, {}, vm.argument(0));
|
||||
return generator_object->next_impl(vm, {}, vm.argument(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -498,9 +498,8 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::eval)
|
|||
}
|
||||
|
||||
// 19.2.6.1.1 Encode ( string, unescapedSet ), https://tc39.es/ecma262/#sec-encode
|
||||
static ThrowCompletionOr<String> encode(GlobalObject& global_object, String const& string, StringView unescaped_set)
|
||||
static ThrowCompletionOr<String> encode(VM& vm, String const& string, StringView unescaped_set)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto utf16_string = Utf16String(string);
|
||||
|
||||
// 1. Let strLen be the length of string.
|
||||
|
@ -554,7 +553,7 @@ static ThrowCompletionOr<String> encode(GlobalObject& global_object, String cons
|
|||
}
|
||||
|
||||
// 19.2.6.1.2 Decode ( string, reservedSet ), https://tc39.es/ecma262/#sec-decode
|
||||
static ThrowCompletionOr<String> decode(GlobalObject& global_object, String const& string, StringView reserved_set)
|
||||
static ThrowCompletionOr<String> decode(VM& vm, String const& string, StringView reserved_set)
|
||||
{
|
||||
StringBuilder decoded_builder;
|
||||
auto code_point_start_offset = 0u;
|
||||
|
@ -563,22 +562,22 @@ static ThrowCompletionOr<String> decode(GlobalObject& global_object, String cons
|
|||
auto code_unit = string[k];
|
||||
if (code_unit != '%') {
|
||||
if (expected_continuation_bytes > 0)
|
||||
return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
return vm.throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
|
||||
decoded_builder.append(code_unit);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (k + 2 >= string.length())
|
||||
return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
return vm.throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
|
||||
auto first_digit = decode_hex_digit(string[k + 1]);
|
||||
if (first_digit >= 16)
|
||||
return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
return vm.throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
|
||||
auto second_digit = decode_hex_digit(string[k + 2]);
|
||||
if (second_digit >= 16)
|
||||
return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
return vm.throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
|
||||
u8 decoded_code_unit = (first_digit << 4) | second_digit;
|
||||
k += 2;
|
||||
|
@ -586,7 +585,7 @@ static ThrowCompletionOr<String> decode(GlobalObject& global_object, String cons
|
|||
decoded_builder.append(decoded_code_unit);
|
||||
expected_continuation_bytes--;
|
||||
if (expected_continuation_bytes == 0 && !Utf8View(decoded_builder.string_view().substring_view(code_point_start_offset)).validate())
|
||||
return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
return vm.throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -600,14 +599,14 @@ static ThrowCompletionOr<String> decode(GlobalObject& global_object, String cons
|
|||
|
||||
auto leading_ones = count_leading_zeroes_safe(static_cast<u8>(~decoded_code_unit));
|
||||
if (leading_ones == 1 || leading_ones > 4)
|
||||
return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
return vm.throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
|
||||
code_point_start_offset = decoded_builder.length();
|
||||
decoded_builder.append(decoded_code_unit);
|
||||
expected_continuation_bytes = leading_ones - 1;
|
||||
}
|
||||
if (expected_continuation_bytes > 0)
|
||||
return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
return vm.throw_completion<URIError>(ErrorType::URIMalformed);
|
||||
return decoded_builder.build();
|
||||
}
|
||||
|
||||
|
@ -615,7 +614,7 @@ static ThrowCompletionOr<String> decode(GlobalObject& global_object, String cons
|
|||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri)
|
||||
{
|
||||
auto uri_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto encoded = TRY(encode(global_object, uri_string, ";/?:@&=+$,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'()#"sv));
|
||||
auto encoded = TRY(encode(vm, uri_string, ";/?:@&=+$,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'()#"sv));
|
||||
return js_string(vm, move(encoded));
|
||||
}
|
||||
|
||||
|
@ -623,7 +622,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri)
|
|||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri)
|
||||
{
|
||||
auto uri_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto decoded = TRY(decode(global_object, uri_string, ";/?:@&=+$,#"sv));
|
||||
auto decoded = TRY(decode(vm, uri_string, ";/?:@&=+$,#"sv));
|
||||
return js_string(vm, move(decoded));
|
||||
}
|
||||
|
||||
|
@ -631,7 +630,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri)
|
|||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri_component)
|
||||
{
|
||||
auto uri_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto encoded = TRY(encode(global_object, uri_string, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'()"sv));
|
||||
auto encoded = TRY(encode(vm, uri_string, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.!~*'()"sv));
|
||||
return js_string(vm, move(encoded));
|
||||
}
|
||||
|
||||
|
@ -639,7 +638,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri_component)
|
|||
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri_component)
|
||||
{
|
||||
auto uri_string = TRY(vm.argument(0).to_string(vm));
|
||||
auto decoded = TRY(decode(global_object, uri_string, ""sv));
|
||||
auto decoded = TRY(decode(vm, uri_string, ""sv));
|
||||
return js_string(vm, move(decoded));
|
||||
}
|
||||
|
||||
|
|
|
@ -125,9 +125,6 @@ ThrowCompletionOr<Object*> iterator_step(VM& vm, Iterator const& iterator_record
|
|||
// NOTE: These only differ in that async awaits the inner value after the call.
|
||||
static Completion iterator_close_impl(VM& vm, Iterator const& iterator_record, Completion completion, IteratorHint iterator_hint)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto& global_object = realm.global_object();
|
||||
|
||||
// 1. Assert: Type(iteratorRecord.[[Iterator]]) is Object.
|
||||
|
||||
// 2. Let iterator be iteratorRecord.[[Iterator]].
|
||||
|
@ -154,7 +151,7 @@ static Completion iterator_close_impl(VM& vm, Iterator const& iterator_record, C
|
|||
// Note: If this is AsyncIteratorClose perform one extra step.
|
||||
if (iterator_hint == IteratorHint::Async && !inner_result.is_error()) {
|
||||
// d. If innerResult.[[Type]] is normal, set innerResult to Completion(Await(innerResult.[[Value]])).
|
||||
inner_result = await(global_object, inner_result.value());
|
||||
inner_result = await(vm, inner_result.value());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,6 @@ NativeFunction::NativeFunction(FlyString name, Object& prototype)
|
|||
ThrowCompletionOr<Value> NativeFunction::internal_call(Value this_argument, MarkedVector<Value> arguments_list)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
// 1. Let callerContext be the running execution context.
|
||||
auto& caller_context = vm.running_execution_context();
|
||||
|
@ -148,7 +147,7 @@ ThrowCompletionOr<Value> NativeFunction::internal_call(Value this_argument, Mark
|
|||
// </8.> --------------------------------------------------------------------------
|
||||
|
||||
// 9. Push calleeContext onto the execution context stack; calleeContext is now the running execution context.
|
||||
TRY(vm.push_execution_context(callee_context, global_object));
|
||||
TRY(vm.push_execution_context(callee_context, {}));
|
||||
|
||||
// 10. Let result be the Completion Record that is the result of evaluating F in a manner that conforms to the specification of F. thisArgument is the this value, argumentsList provides the named parameters, and the NewTarget value is undefined.
|
||||
auto result = call();
|
||||
|
@ -164,7 +163,6 @@ ThrowCompletionOr<Value> NativeFunction::internal_call(Value this_argument, Mark
|
|||
ThrowCompletionOr<Object*> NativeFunction::internal_construct(MarkedVector<Value> arguments_list, FunctionObject& new_target)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
// 1. Let callerContext be the running execution context.
|
||||
auto& caller_context = vm.running_execution_context();
|
||||
|
@ -212,7 +210,7 @@ ThrowCompletionOr<Object*> NativeFunction::internal_construct(MarkedVector<Value
|
|||
// </8.> --------------------------------------------------------------------------
|
||||
|
||||
// 9. Push calleeContext onto the execution context stack; calleeContext is now the running execution context.
|
||||
TRY(vm.push_execution_context(callee_context, global_object));
|
||||
TRY(vm.push_execution_context(callee_context, {}));
|
||||
|
||||
// 10. Let result be the Completion Record that is the result of evaluating F in a manner that conforms to the specification of F. The this value is uninitialized, argumentsList provides the named parameters, and newTarget provides the NewTarget value.
|
||||
auto result = construct(new_target);
|
||||
|
|
|
@ -57,10 +57,8 @@ void NumberConstructor::initialize(Realm& realm)
|
|||
}
|
||||
|
||||
// Most of 21.1.1.1 Number ( value ) factored into a separate function for sharing between call() and construct().
|
||||
static ThrowCompletionOr<Value> get_value_from_constructor_argument(GlobalObject& global_object)
|
||||
static ThrowCompletionOr<Value> get_value_from_constructor_argument(VM& vm)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
Value number;
|
||||
if (vm.argument_count() > 0) {
|
||||
auto primitive = TRY(vm.argument(0).to_numeric(vm));
|
||||
|
@ -80,16 +78,15 @@ static ThrowCompletionOr<Value> get_value_from_constructor_argument(GlobalObject
|
|||
// 21.1.1.1 Number ( value ), https://tc39.es/ecma262/#sec-number-constructor-number-value
|
||||
ThrowCompletionOr<Value> NumberConstructor::call()
|
||||
{
|
||||
return get_value_from_constructor_argument(global_object());
|
||||
return get_value_from_constructor_argument(vm());
|
||||
}
|
||||
|
||||
// 21.1.1.1 Number ( value ), https://tc39.es/ecma262/#sec-number-constructor-number-value
|
||||
ThrowCompletionOr<Object*> NumberConstructor::construct(FunctionObject& new_target)
|
||||
{
|
||||
auto& global_object = this->global_object();
|
||||
auto& vm = this->vm();
|
||||
|
||||
auto number = TRY(get_value_from_constructor_argument(global_object));
|
||||
auto number = TRY(get_value_from_constructor_argument(vm));
|
||||
return TRY(ordinary_create_from_constructor<NumberObject>(vm, new_target, &GlobalObject::number_prototype, number.as_double()));
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ void NumberPrototype::initialize(Realm& realm)
|
|||
}
|
||||
|
||||
// thisNumberValue ( value ), https://tc39.es/ecma262/#thisnumbervalue
|
||||
static ThrowCompletionOr<Value> this_number_value(GlobalObject& global_object, Value value)
|
||||
static ThrowCompletionOr<Value> this_number_value(VM& vm, Value value)
|
||||
{
|
||||
// 1. If Type(value) is Number, return value.
|
||||
if (value.is_number())
|
||||
|
@ -116,8 +116,6 @@ static ThrowCompletionOr<Value> this_number_value(GlobalObject& global_object, V
|
|||
return Value(static_cast<NumberObject&>(value.as_object()).number());
|
||||
}
|
||||
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 3. Throw a TypeError exception.
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Number");
|
||||
}
|
||||
|
@ -128,7 +126,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
|
|||
auto fraction_digits_value = vm.argument(0);
|
||||
|
||||
// 1. Let x be ? thisNumberValue(this value).
|
||||
auto number_value = TRY(this_number_value(global_object, vm.this_value()));
|
||||
auto number_value = TRY(this_number_value(vm, vm.this_value()));
|
||||
|
||||
// 2. Let f be ? ToIntegerOrInfinity(fractionDigits).
|
||||
auto fraction_digits = TRY(fraction_digits_value.to_integer_or_infinity(vm));
|
||||
|
@ -247,7 +245,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
|
|||
JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed)
|
||||
{
|
||||
// 1. Let x be ? thisNumberValue(this value).
|
||||
auto number_value = TRY(this_number_value(global_object, vm.this_value()));
|
||||
auto number_value = TRY(this_number_value(vm, vm.this_value()));
|
||||
|
||||
// 2. Let f be ? ToIntegerOrInfinity(fractionDigits).
|
||||
// 3. Assert: If fractionDigits is undefined, then f is 0.
|
||||
|
@ -324,7 +322,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_locale_string)
|
|||
auto options = vm.argument(1);
|
||||
|
||||
// 1. Let x be ? thisNumberValue(this value).
|
||||
auto number_value = TRY(this_number_value(global_object, vm.this_value()));
|
||||
auto number_value = TRY(this_number_value(vm, vm.this_value()));
|
||||
|
||||
// 2. Let numberFormat be ? Construct(%NumberFormat%, « locales, options »).
|
||||
auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, *global_object.intl_number_format_constructor(), locales, options)));
|
||||
|
@ -341,7 +339,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
|
|||
auto precision_value = vm.argument(0);
|
||||
|
||||
// 1. Let x be ? thisNumberValue(this value).
|
||||
auto number_value = TRY(this_number_value(global_object, vm.this_value()));
|
||||
auto number_value = TRY(this_number_value(vm, vm.this_value()));
|
||||
|
||||
// 2. If precision is undefined, return ! ToString(x).
|
||||
if (precision_value.is_undefined())
|
||||
|
@ -471,7 +469,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
|
|||
JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string)
|
||||
{
|
||||
// 1. Let x be ? thisNumberValue(this value).
|
||||
auto number_value = TRY(this_number_value(global_object, vm.this_value()));
|
||||
auto number_value = TRY(this_number_value(vm, vm.this_value()));
|
||||
|
||||
double radix_mv;
|
||||
|
||||
|
@ -553,7 +551,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string)
|
|||
JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::value_of)
|
||||
{
|
||||
// 1. Return ? thisNumberValue(this value).
|
||||
return this_number_value(global_object, vm.this_value());
|
||||
return this_number_value(vm, vm.this_value());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1133,7 +1133,6 @@ void Object::define_native_function(PropertyKey const& property_key, Function<Th
|
|||
// 20.1.2.3.1 ObjectDefineProperties ( O, Properties ), https://tc39.es/ecma262/#sec-objectdefineproperties
|
||||
ThrowCompletionOr<Object*> Object::define_properties(Value properties)
|
||||
{
|
||||
auto& global_object = this->global_object();
|
||||
auto& vm = this->vm();
|
||||
|
||||
// 1. Let props be ? ToObject(Properties).
|
||||
|
@ -1163,7 +1162,7 @@ ThrowCompletionOr<Object*> Object::define_properties(Value properties)
|
|||
auto descriptor_object = TRY(props->get(property_key));
|
||||
|
||||
// ii. Let desc be ? ToPropertyDescriptor(descObj).
|
||||
auto descriptor = TRY(to_property_descriptor(global_object, descriptor_object));
|
||||
auto descriptor = TRY(to_property_descriptor(vm, descriptor_object));
|
||||
|
||||
// iii. Append the pair (a two element List) consisting of nextKey and desc to the end of descriptors.
|
||||
descriptors.append({ property_key, descriptor });
|
||||
|
|
|
@ -84,10 +84,8 @@ enum class GetOwnPropertyKeysType {
|
|||
};
|
||||
|
||||
// 20.1.2.11.1 GetOwnPropertyKeys ( O, type ), https://tc39.es/ecma262/#sec-getownpropertykeys
|
||||
static ThrowCompletionOr<MarkedVector<Value>> get_own_property_keys(GlobalObject& global_object, Value value, GetOwnPropertyKeysType type)
|
||||
static ThrowCompletionOr<MarkedVector<Value>> get_own_property_keys(VM& vm, Value value, GetOwnPropertyKeysType type)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 1. Let obj be ? ToObject(O).
|
||||
auto* object = TRY(value.to_object(vm));
|
||||
|
||||
|
@ -116,7 +114,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_names)
|
|||
auto& realm = *global_object.associated_realm();
|
||||
|
||||
// 1. Return CreateArrayFromList(? GetOwnPropertyKeys(O, string)).
|
||||
return Array::create_from(realm, TRY(get_own_property_keys(global_object, vm.argument(0), GetOwnPropertyKeysType::String)));
|
||||
return Array::create_from(realm, TRY(get_own_property_keys(vm, vm.argument(0), GetOwnPropertyKeysType::String)));
|
||||
}
|
||||
|
||||
// 20.1.2.11 Object.getOwnPropertySymbols ( O ), https://tc39.es/ecma262/#sec-object.getownpropertysymbols
|
||||
|
@ -125,7 +123,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_symbols)
|
|||
auto& realm = *global_object.associated_realm();
|
||||
|
||||
// 1. Return CreateArrayFromList(? GetOwnPropertyKeys(O, symbol)).
|
||||
return Array::create_from(realm, TRY(get_own_property_keys(global_object, vm.argument(0), GetOwnPropertyKeysType::Symbol)));
|
||||
return Array::create_from(realm, TRY(get_own_property_keys(vm, vm.argument(0), GetOwnPropertyKeysType::Symbol)));
|
||||
}
|
||||
|
||||
// 20.1.2.12 Object.getPrototypeOf ( O ), https://tc39.es/ecma262/#sec-object.getprototypeof
|
||||
|
@ -262,7 +260,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_descriptor)
|
|||
auto* object = TRY(vm.argument(0).to_object(vm));
|
||||
auto key = TRY(vm.argument(1).to_property_key(vm));
|
||||
auto descriptor = TRY(object->internal_get_own_property(key));
|
||||
return from_property_descriptor(global_object, descriptor);
|
||||
return from_property_descriptor(vm, descriptor);
|
||||
}
|
||||
|
||||
// 20.1.2.9 Object.getOwnPropertyDescriptors ( O ), https://tc39.es/ecma262/#sec-object.getownpropertydescriptors
|
||||
|
@ -287,7 +285,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_descriptors)
|
|||
auto desc = TRY(object->internal_get_own_property(property_key));
|
||||
|
||||
// b. Let descriptor be FromPropertyDescriptor(desc).
|
||||
auto descriptor = from_property_descriptor(global_object, desc);
|
||||
auto descriptor = from_property_descriptor(vm, desc);
|
||||
|
||||
// c. If descriptor is not undefined, perform ! CreateDataPropertyOrThrow(descriptors, key, descriptor).
|
||||
if (!descriptor.is_undefined())
|
||||
|
@ -304,7 +302,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::define_property)
|
|||
if (!vm.argument(0).is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, vm.argument(0).to_string_without_side_effects());
|
||||
auto key = TRY(vm.argument(1).to_property_key(vm));
|
||||
auto descriptor = TRY(to_property_descriptor(global_object, vm.argument(2)));
|
||||
auto descriptor = TRY(to_property_descriptor(vm, vm.argument(2)));
|
||||
TRY(vm.argument(0).as_object().define_property_or_throw(key, descriptor));
|
||||
return vm.argument(0);
|
||||
}
|
||||
|
|
|
@ -87,12 +87,12 @@ Utf16View PrimitiveString::utf16_string_view() const
|
|||
return utf16_string().view();
|
||||
}
|
||||
|
||||
Optional<Value> PrimitiveString::get(GlobalObject& global_object, PropertyKey const& property_key) const
|
||||
Optional<Value> PrimitiveString::get(VM& vm, PropertyKey const& property_key) const
|
||||
{
|
||||
if (property_key.is_symbol())
|
||||
return {};
|
||||
if (property_key.is_string()) {
|
||||
if (property_key.as_string() == global_object.vm().names.length.as_string()) {
|
||||
if (property_key.as_string() == vm.names.length.as_string()) {
|
||||
auto length = utf16_string().length_in_code_units();
|
||||
return Value(static_cast<double>(length));
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ Optional<Value> PrimitiveString::get(GlobalObject& global_object, PropertyKey co
|
|||
auto length = str.length_in_code_units();
|
||||
if (length <= index.as_index())
|
||||
return {};
|
||||
return js_string(vm(), str.substring_view(index.as_index(), 1));
|
||||
return js_string(vm, str.substring_view(index.as_index(), 1));
|
||||
}
|
||||
|
||||
PrimitiveString* js_string(Heap& heap, Utf16View const& view)
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
Utf16View utf16_string_view() const;
|
||||
bool has_utf16_string() const { return m_has_utf16_string; }
|
||||
|
||||
Optional<Value> get(GlobalObject&, PropertyKey const&) const;
|
||||
Optional<Value> get(VM&, PropertyKey const&) const;
|
||||
|
||||
private:
|
||||
virtual StringView class_name() const override { return "PrimitiveString"sv; }
|
||||
|
|
|
@ -65,13 +65,13 @@ bool PropertyDescriptor::is_generic_descriptor() const
|
|||
}
|
||||
|
||||
// 6.2.5.4 FromPropertyDescriptor ( Desc ), https://tc39.es/ecma262/#sec-frompropertydescriptor
|
||||
Value from_property_descriptor(GlobalObject& global_object, Optional<PropertyDescriptor> const& property_descriptor)
|
||||
Value from_property_descriptor(VM& vm, Optional<PropertyDescriptor> const& property_descriptor)
|
||||
{
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
if (!property_descriptor.has_value())
|
||||
return js_undefined();
|
||||
auto& vm = global_object.vm();
|
||||
auto* object = Object::create(realm, global_object.object_prototype());
|
||||
auto* object = Object::create(realm, realm.global_object().object_prototype());
|
||||
if (property_descriptor->value.has_value())
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, *property_descriptor->value));
|
||||
if (property_descriptor->writable.has_value())
|
||||
|
@ -88,10 +88,8 @@ Value from_property_descriptor(GlobalObject& global_object, Optional<PropertyDes
|
|||
}
|
||||
|
||||
// 6.2.5.5 ToPropertyDescriptor ( Obj ), https://tc39.es/ecma262/#sec-topropertydescriptor
|
||||
ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject& global_object, Value argument)
|
||||
ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(VM& vm, Value argument)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
||||
// 1. If Type(Obj) is not Object, throw a TypeError exception.
|
||||
if (!argument.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, argument.to_string_without_side_effects());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -14,8 +14,8 @@ namespace JS {
|
|||
|
||||
// 6.2.5 The Property Descriptor Specification Type, https://tc39.es/ecma262/#sec-property-descriptor-specification-type
|
||||
|
||||
Value from_property_descriptor(GlobalObject&, Optional<PropertyDescriptor> const&);
|
||||
ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject&, Value);
|
||||
Value from_property_descriptor(VM&, Optional<PropertyDescriptor> const&);
|
||||
ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(VM&, Value);
|
||||
|
||||
class PropertyDescriptor {
|
||||
public:
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
namespace JS {
|
||||
|
||||
// 10.5.14 ProxyCreate ( target, handler ), https://tc39.es/ecma262/#sec-proxycreate
|
||||
static ThrowCompletionOr<ProxyObject*> proxy_create(GlobalObject& global_object, Value target, Value handler)
|
||||
static ThrowCompletionOr<ProxyObject*> proxy_create(VM& vm, Value target, Value handler)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& realm = *vm.current_realm();
|
||||
if (!target.is_object())
|
||||
return vm.throw_completion<TypeError>(ErrorType::ProxyConstructorBadType, "target", target.to_string_without_side_effects());
|
||||
if (!handler.is_object())
|
||||
|
@ -51,16 +50,16 @@ ThrowCompletionOr<Value> ProxyConstructor::call()
|
|||
ThrowCompletionOr<Object*> ProxyConstructor::construct(FunctionObject&)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
return TRY(proxy_create(global_object(), vm.argument(0), vm.argument(1)));
|
||||
return TRY(proxy_create(vm, vm.argument(0), vm.argument(1)));
|
||||
}
|
||||
|
||||
// 28.2.2.1 Proxy.revocable ( target, handler ), https://tc39.es/ecma262/#sec-proxy.revocable
|
||||
JS_DEFINE_NATIVE_FUNCTION(ProxyConstructor::revocable)
|
||||
{
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Let p be ? ProxyCreate(target, handler).
|
||||
auto* proxy = TRY(proxy_create(global_object, vm.argument(0), vm.argument(1)));
|
||||
auto* proxy = TRY(proxy_create(vm, vm.argument(0), vm.argument(1)));
|
||||
|
||||
// 2. Let revokerClosure be a new Abstract Closure with no parameters that captures nothing and performs the following steps when called:
|
||||
auto revoker_closure = [proxy_handle = make_handle(proxy)](auto&, auto&) -> ThrowCompletionOr<Value> {
|
||||
|
|
|
@ -217,7 +217,6 @@ ThrowCompletionOr<bool> ProxyObject::internal_prevent_extensions()
|
|||
ThrowCompletionOr<Optional<PropertyDescriptor>> ProxyObject::internal_get_own_property(PropertyKey const& property_key) const
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
VERIFY(property_key.is_valid());
|
||||
|
||||
|
@ -274,7 +273,7 @@ ThrowCompletionOr<Optional<PropertyDescriptor>> ProxyObject::internal_get_own_pr
|
|||
auto extensible_target = TRY(m_target.is_extensible());
|
||||
|
||||
// 12. Let resultDesc be ? ToPropertyDescriptor(trapResultObj).
|
||||
auto result_desc = TRY(to_property_descriptor(global_object, trap_result));
|
||||
auto result_desc = TRY(to_property_descriptor(vm, trap_result));
|
||||
|
||||
// 13. Perform CompletePropertyDescriptor(resultDesc).
|
||||
result_desc.complete();
|
||||
|
@ -309,7 +308,6 @@ ThrowCompletionOr<Optional<PropertyDescriptor>> ProxyObject::internal_get_own_pr
|
|||
ThrowCompletionOr<bool> ProxyObject::internal_define_own_property(PropertyKey const& property_key, PropertyDescriptor const& property_descriptor)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
VERIFY(property_key.is_valid());
|
||||
|
||||
|
@ -332,7 +330,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_define_own_property(PropertyKey co
|
|||
}
|
||||
|
||||
// 7. Let descObj be FromPropertyDescriptor(Desc).
|
||||
auto descriptor_object = from_property_descriptor(global_object, property_descriptor);
|
||||
auto descriptor_object = from_property_descriptor(vm, property_descriptor);
|
||||
|
||||
// 8. Let booleanTrapResult be ToBoolean(? Call(trap, handler, « target, P, descObj »)).
|
||||
auto trap_result = TRY(call(vm, *trap, &m_handler, &m_target, property_key_to_value(vm, property_key), descriptor_object)).to_boolean();
|
||||
|
|
|
@ -116,7 +116,7 @@ ThrowCompletionOr<Value> Reference::get_value(VM& vm) const
|
|||
// OPTIMIZATION: For various primitives we can avoid actually creating a new object for them.
|
||||
Object* base_obj = nullptr;
|
||||
if (m_base_value.is_string()) {
|
||||
auto string_value = m_base_value.as_string().get(global_object, m_name);
|
||||
auto string_value = m_base_value.as_string().get(vm, m_name);
|
||||
if (string_value.has_value())
|
||||
return *string_value;
|
||||
base_obj = global_object.string_prototype();
|
||||
|
|
|
@ -102,7 +102,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::define_property)
|
|||
auto key = TRY(property_key.to_property_key(vm));
|
||||
|
||||
// 3. Let desc be ? ToPropertyDescriptor(attributes).
|
||||
auto descriptor = TRY(to_property_descriptor(global_object, attributes));
|
||||
auto descriptor = TRY(to_property_descriptor(vm, attributes));
|
||||
|
||||
// 4. Return ? target.[[DefineOwnProperty]](key, desc).
|
||||
return Value(TRY(target.as_object().internal_define_own_property(key, descriptor)));
|
||||
|
@ -166,7 +166,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get_own_property_descriptor)
|
|||
auto descriptor = TRY(target.as_object().internal_get_own_property(key));
|
||||
|
||||
// 4. Return FromPropertyDescriptor(desc).
|
||||
return from_property_descriptor(global_object, descriptor);
|
||||
return from_property_descriptor(vm, descriptor);
|
||||
}
|
||||
|
||||
// 28.1.7 Reflect.getPrototypeOf ( target ), https://tc39.es/ecma262/#sec-reflect.getprototypeof
|
||||
|
|
|
@ -161,7 +161,7 @@ ThrowCompletionOr<Value> perform_shadow_realm_eval(VM& vm, StringView source_tex
|
|||
eval_context.is_strict_mode = strict_eval;
|
||||
|
||||
// 15. Push evalContext onto the execution context stack; evalContext is now the running execution context.
|
||||
TRY(vm.push_execution_context(eval_context, eval_realm.global_object()));
|
||||
TRY(vm.push_execution_context(eval_context, {}));
|
||||
|
||||
// 16. Let result be Completion(EvalDeclarationInstantiation(body, varEnv, lexEnv, null, strictEval)).
|
||||
auto eval_result = eval_declaration_instantiation(vm, program, variable_environment, lexical_environment, nullptr, strict_eval);
|
||||
|
@ -204,6 +204,9 @@ ThrowCompletionOr<Value> perform_shadow_realm_eval(VM& vm, StringView source_tex
|
|||
// 3.1.4 ShadowRealmImportValue ( specifierString: a String, exportNameString: a String, callerRealm: a Realm Record, evalRealm: a Realm Record, evalContext: an execution context, ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealmimportvalue
|
||||
ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, String specifier_string, String export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context)
|
||||
{
|
||||
// FIXME: evalRealm isn't being used anywhere in this AO (spec issue)
|
||||
(void)eval_realm;
|
||||
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Assert: evalContext is an execution context associated to a ShadowRealm instance's [[ExecutionContext]].
|
||||
|
@ -216,7 +219,7 @@ ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, String specifier_stri
|
|||
// NOTE: We don't support this concept yet.
|
||||
|
||||
// 5. Push evalContext onto the execution context stack; evalContext is now the running execution context.
|
||||
TRY(vm.push_execution_context(eval_context, eval_realm.global_object()));
|
||||
TRY(vm.push_execution_context(eval_context, {}));
|
||||
|
||||
// 6. Perform HostImportModuleDynamically(null, specifierString, innerCapability).
|
||||
vm.host_import_module_dynamically(Empty {}, ModuleRequest { move(specifier_string) }, inner_capability);
|
||||
|
|
|
@ -38,20 +38,19 @@ void SymbolPrototype::initialize(Realm& realm)
|
|||
}
|
||||
|
||||
// thisSymbolValue ( value ), https://tc39.es/ecma262/#thissymbolvalue
|
||||
static ThrowCompletionOr<Symbol*> this_symbol_value(GlobalObject& global_object, Value value)
|
||||
static ThrowCompletionOr<Symbol*> this_symbol_value(VM& vm, Value value)
|
||||
{
|
||||
if (value.is_symbol())
|
||||
return &value.as_symbol();
|
||||
if (value.is_object() && is<SymbolObject>(value.as_object()))
|
||||
return &static_cast<SymbolObject&>(value.as_object()).primitive_symbol();
|
||||
auto& vm = global_object.vm();
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Symbol");
|
||||
}
|
||||
|
||||
// 20.4.3.2 get Symbol.prototype.description, https://tc39.es/ecma262/#sec-symbol.prototype.description
|
||||
JS_DEFINE_NATIVE_FUNCTION(SymbolPrototype::description_getter)
|
||||
{
|
||||
auto* symbol = TRY(this_symbol_value(global_object, vm.this_value()));
|
||||
auto* symbol = TRY(this_symbol_value(vm, vm.this_value()));
|
||||
auto& description = symbol->raw_description();
|
||||
if (!description.has_value())
|
||||
return js_undefined();
|
||||
|
@ -61,21 +60,21 @@ JS_DEFINE_NATIVE_FUNCTION(SymbolPrototype::description_getter)
|
|||
// 20.4.3.3 Symbol.prototype.toString ( ), https://tc39.es/ecma262/#sec-symbol.prototype.tostring
|
||||
JS_DEFINE_NATIVE_FUNCTION(SymbolPrototype::to_string)
|
||||
{
|
||||
auto* symbol = TRY(this_symbol_value(global_object, vm.this_value()));
|
||||
auto* symbol = TRY(this_symbol_value(vm, vm.this_value()));
|
||||
return js_string(vm, symbol->to_string());
|
||||
}
|
||||
|
||||
// 20.4.3.4 Symbol.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-symbol.prototype.valueof
|
||||
JS_DEFINE_NATIVE_FUNCTION(SymbolPrototype::value_of)
|
||||
{
|
||||
return TRY(this_symbol_value(global_object, vm.this_value()));
|
||||
return TRY(this_symbol_value(vm, vm.this_value()));
|
||||
}
|
||||
|
||||
// 20.4.3.5 Symbol.prototype [ @@toPrimitive ] ( hint ), https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive
|
||||
JS_DEFINE_NATIVE_FUNCTION(SymbolPrototype::symbol_to_primitive)
|
||||
{
|
||||
// The hint argument is ignored.
|
||||
return TRY(this_symbol_value(global_object, vm.this_value()));
|
||||
return TRY(this_symbol_value(vm, vm.this_value()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_seconds)
|
|||
auto epoch_seconds_value = TRY(vm.argument(0).to_number(vm));
|
||||
|
||||
// 2. Set epochSeconds to ? NumberToBigInt(epochSeconds).
|
||||
auto* epoch_seconds = TRY(number_to_bigint(global_object, epoch_seconds_value));
|
||||
auto* epoch_seconds = TRY(number_to_bigint(vm, epoch_seconds_value));
|
||||
|
||||
// 3. Let epochNanoseconds be epochSeconds × 10^9ℤ.
|
||||
auto* epoch_nanoseconds = js_bigint(vm, epoch_seconds->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000'000'000 }));
|
||||
|
@ -106,7 +106,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_milliseconds)
|
|||
auto epoch_milliseconds_value = TRY(vm.argument(0).to_number(vm));
|
||||
|
||||
// 2. Set epochMilliseconds to ? NumberToBigInt(epochMilliseconds).
|
||||
auto* epoch_milliseconds = TRY(number_to_bigint(global_object, epoch_milliseconds_value));
|
||||
auto* epoch_milliseconds = TRY(number_to_bigint(vm, epoch_milliseconds_value));
|
||||
|
||||
// 3. Let epochNanoseconds be epochMilliseconds × 10^6ℤ.
|
||||
auto* epoch_nanoseconds = js_bigint(vm, epoch_milliseconds->big_integer().multiplied_by(Crypto::UnsignedBigInteger { 1'000'000 }));
|
||||
|
|
|
@ -255,16 +255,16 @@ ThrowCompletionOr<Value> VM::named_evaluation_if_anonymous_function(ASTNode cons
|
|||
}
|
||||
|
||||
// 13.15.5.2 Runtime Semantics: DestructuringAssignmentEvaluation, https://tc39.es/ecma262/#sec-runtime-semantics-destructuringassignmentevaluation
|
||||
ThrowCompletionOr<void> VM::destructuring_assignment_evaluation(NonnullRefPtr<BindingPattern> const& target, Value value, GlobalObject& global_object)
|
||||
ThrowCompletionOr<void> VM::destructuring_assignment_evaluation(NonnullRefPtr<BindingPattern> const& target, Value value)
|
||||
{
|
||||
// Note: DestructuringAssignmentEvaluation is just like BindingInitialization without an environment
|
||||
// And it allows member expressions. We thus trust the parser to disallow member expressions
|
||||
// in any non assignment binding and just call BindingInitialization with a nullptr environment
|
||||
return binding_initialization(target, value, nullptr, global_object);
|
||||
return binding_initialization(target, value, nullptr);
|
||||
}
|
||||
|
||||
// 8.5.2 Runtime Semantics: BindingInitialization, https://tc39.es/ecma262/#sec-runtime-semantics-bindinginitialization
|
||||
ThrowCompletionOr<void> VM::binding_initialization(FlyString const& target, Value value, Environment* environment, GlobalObject&)
|
||||
ThrowCompletionOr<void> VM::binding_initialization(FlyString const& target, Value value, Environment* environment)
|
||||
{
|
||||
// 1. Let name be StringValue of Identifier.
|
||||
// 2. Return ? InitializeBoundName(name, value, environment).
|
||||
|
@ -272,7 +272,7 @@ ThrowCompletionOr<void> VM::binding_initialization(FlyString const& target, Valu
|
|||
}
|
||||
|
||||
// 8.5.2 Runtime Semantics: BindingInitialization, https://tc39.es/ecma262/#sec-runtime-semantics-bindinginitialization
|
||||
ThrowCompletionOr<void> VM::binding_initialization(NonnullRefPtr<BindingPattern> const& target, Value value, Environment* environment, GlobalObject& global_object)
|
||||
ThrowCompletionOr<void> VM::binding_initialization(NonnullRefPtr<BindingPattern> const& target, Value value, Environment* environment)
|
||||
{
|
||||
auto& vm = *this;
|
||||
|
||||
|
@ -285,7 +285,7 @@ ThrowCompletionOr<void> VM::binding_initialization(NonnullRefPtr<BindingPattern>
|
|||
|
||||
// BindingInitialization of ObjectBindingPattern
|
||||
// 1. Perform ? PropertyBindingInitialization of BindingPropertyList with arguments value and environment.
|
||||
TRY(property_binding_initialization(*target, value, environment, global_object));
|
||||
TRY(property_binding_initialization(*target, value, environment));
|
||||
|
||||
// 2. Return unused.
|
||||
return {};
|
||||
|
@ -296,7 +296,7 @@ ThrowCompletionOr<void> VM::binding_initialization(NonnullRefPtr<BindingPattern>
|
|||
auto iterator_record = TRY(get_iterator(vm, value));
|
||||
|
||||
// 2. Let result be Completion(IteratorBindingInitialization of ArrayBindingPattern with arguments iteratorRecord and environment).
|
||||
auto result = iterator_binding_initialization(*target, iterator_record, environment, global_object);
|
||||
auto result = iterator_binding_initialization(*target, iterator_record, environment);
|
||||
|
||||
// 3. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iteratorRecord, result).
|
||||
if (!iterator_record.done) {
|
||||
|
@ -314,10 +314,11 @@ ThrowCompletionOr<void> VM::binding_initialization(NonnullRefPtr<BindingPattern>
|
|||
|
||||
// 13.15.5.3 Runtime Semantics: PropertyDestructuringAssignmentEvaluation, https://tc39.es/ecma262/#sec-runtime-semantics-propertydestructuringassignmentevaluation
|
||||
// 14.3.3.1 Runtime Semantics: PropertyBindingInitialization, https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-propertybindinginitialization
|
||||
ThrowCompletionOr<void> VM::property_binding_initialization(BindingPattern const& binding, Value value, Environment* environment, GlobalObject& global_object)
|
||||
ThrowCompletionOr<void> VM::property_binding_initialization(BindingPattern const& binding, Value value, Environment* environment)
|
||||
{
|
||||
auto& vm = *this;
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto* object = TRY(value.to_object(vm));
|
||||
|
||||
HashTable<PropertyKey> seen_names;
|
||||
|
@ -335,7 +336,7 @@ ThrowCompletionOr<void> VM::property_binding_initialization(BindingPattern const
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
auto* rest_object = Object::create(realm, global_object.object_prototype());
|
||||
auto* rest_object = Object::create(realm, realm.global_object().object_prototype());
|
||||
VERIFY(rest_object);
|
||||
|
||||
TRY(rest_object->copy_data_properties(vm, object, seen_names));
|
||||
|
@ -393,7 +394,7 @@ ThrowCompletionOr<void> VM::property_binding_initialization(BindingPattern const
|
|||
}
|
||||
|
||||
if (auto* binding_ptr = property.alias.get_pointer<NonnullRefPtr<BindingPattern>>()) {
|
||||
TRY(binding_initialization(*binding_ptr, value_to_assign, environment, global_object));
|
||||
TRY(binding_initialization(*binding_ptr, value_to_assign, environment));
|
||||
} else {
|
||||
VERIFY(reference_to_assign_to.has_value());
|
||||
if (!environment)
|
||||
|
@ -408,10 +409,10 @@ ThrowCompletionOr<void> VM::property_binding_initialization(BindingPattern const
|
|||
|
||||
// 13.15.5.5 Runtime Semantics: IteratorDestructuringAssignmentEvaluation, https://tc39.es/ecma262/#sec-runtime-semantics-iteratordestructuringassignmentevaluation
|
||||
// 8.5.3 Runtime Semantics: IteratorBindingInitialization, https://tc39.es/ecma262/#sec-runtime-semantics-iteratorbindinginitialization
|
||||
ThrowCompletionOr<void> VM::iterator_binding_initialization(BindingPattern const& binding, Iterator& iterator_record, Environment* environment, GlobalObject& global_object)
|
||||
ThrowCompletionOr<void> VM::iterator_binding_initialization(BindingPattern const& binding, Iterator& iterator_record, Environment* environment)
|
||||
{
|
||||
auto& vm = *this;
|
||||
auto& realm = *global_object.associated_realm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// FIXME: this method is nearly identical to destructuring assignment!
|
||||
for (size_t i = 0; i < binding.entries.size(); i++) {
|
||||
|
@ -530,7 +531,7 @@ ThrowCompletionOr<void> VM::iterator_binding_initialization(BindingPattern const
|
|||
}
|
||||
|
||||
if (auto* binding_ptr = entry.alias.get_pointer<NonnullRefPtr<BindingPattern>>()) {
|
||||
TRY(binding_initialization(*binding_ptr, value, environment, global_object));
|
||||
TRY(binding_initialization(*binding_ptr, value, environment));
|
||||
} else if (!entry.alias.has<Empty>()) {
|
||||
VERIFY(assignment_target.has_value());
|
||||
if (!environment)
|
||||
|
|
|
@ -93,7 +93,10 @@ public:
|
|||
m_execution_context_stack.append(&context);
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> push_execution_context(ExecutionContext& context, GlobalObject&)
|
||||
// TODO: Rename this function instead of providing a second argument, now that the global object is no longer passed in.
|
||||
struct CheckStackSpaceLimitTag { };
|
||||
|
||||
ThrowCompletionOr<void> push_execution_context(ExecutionContext& context, CheckStackSpaceLimitTag)
|
||||
{
|
||||
// Ensure we got some stack space left, so the next function call doesn't kill us.
|
||||
if (did_reach_stack_space_limit())
|
||||
|
@ -203,9 +206,9 @@ public:
|
|||
|
||||
CustomData* custom_data() { return m_custom_data; }
|
||||
|
||||
ThrowCompletionOr<void> destructuring_assignment_evaluation(NonnullRefPtr<BindingPattern> const& target, Value value, GlobalObject& global_object);
|
||||
ThrowCompletionOr<void> binding_initialization(FlyString const& target, Value value, Environment* environment, GlobalObject&);
|
||||
ThrowCompletionOr<void> binding_initialization(NonnullRefPtr<BindingPattern> const& target, Value value, Environment* environment, GlobalObject& global_object);
|
||||
ThrowCompletionOr<void> destructuring_assignment_evaluation(NonnullRefPtr<BindingPattern> const& target, Value value);
|
||||
ThrowCompletionOr<void> binding_initialization(FlyString const& target, Value value, Environment* environment);
|
||||
ThrowCompletionOr<void> binding_initialization(NonnullRefPtr<BindingPattern> const& target, Value value, Environment* environment);
|
||||
|
||||
ThrowCompletionOr<Value> named_evaluation_if_anonymous_function(ASTNode const& expression, FlyString const& name);
|
||||
|
||||
|
@ -239,8 +242,8 @@ public:
|
|||
private:
|
||||
explicit VM(OwnPtr<CustomData>);
|
||||
|
||||
ThrowCompletionOr<void> property_binding_initialization(BindingPattern const& binding, Value value, Environment* environment, GlobalObject&);
|
||||
ThrowCompletionOr<void> iterator_binding_initialization(BindingPattern const& binding, Iterator& iterator_record, Environment* environment, GlobalObject&);
|
||||
ThrowCompletionOr<void> property_binding_initialization(BindingPattern const& binding, Value value, Environment* environment);
|
||||
ThrowCompletionOr<void> iterator_binding_initialization(BindingPattern const& binding, Iterator& iterator_record, Environment* environment);
|
||||
|
||||
ThrowCompletionOr<NonnullRefPtr<Module>> resolve_imported_module(ScriptOrModule referencing_script_or_module, ModuleRequest const& module_request);
|
||||
ThrowCompletionOr<void> link_and_eval_module(Module& module);
|
||||
|
|
|
@ -402,7 +402,7 @@ ThrowCompletionOr<void> SourceTextModule::initialize_environment(VM& vm)
|
|||
// Note: We're already working on that one.
|
||||
|
||||
// 17. Push moduleContext onto the execution context stack; moduleContext is now the running execution context.
|
||||
TRY(vm.push_execution_context(m_execution_context, realm().global_object()));
|
||||
TRY(vm.push_execution_context(m_execution_context, {}));
|
||||
|
||||
// 18. Let code be module.[[ECMAScriptCode]].
|
||||
|
||||
|
@ -655,7 +655,7 @@ ThrowCompletionOr<void> SourceTextModule::execute_module(VM& vm, Optional<Promis
|
|||
// a. Assert: capability is not present.
|
||||
VERIFY(!capability.has_value());
|
||||
// b. Push moduleContext onto the execution context stack; moduleContext is now the running execution context.
|
||||
TRY(vm.push_execution_context(module_context, realm().global_object()));
|
||||
TRY(vm.push_execution_context(module_context, {}));
|
||||
|
||||
// c. Let result be the result of evaluating module.[[ECMAScriptCode]].
|
||||
auto result = m_ecmascript_code->execute(vm.interpreter());
|
||||
|
|
|
@ -95,7 +95,7 @@ ThrowCompletionOr<Promise*> SyntheticModule::evaluate(VM& vm)
|
|||
module_context.lexical_environment = environment();
|
||||
|
||||
// 8. Push moduleContext on to the execution context stack; moduleContext is now the running execution context.
|
||||
TRY(vm.push_execution_context(module_context, realm().global_object()));
|
||||
TRY(vm.push_execution_context(module_context, {}));
|
||||
|
||||
// 9. Let result be the result of performing module.[[EvaluationSteps]](module).
|
||||
auto result = m_evaluation_steps(*this);
|
||||
|
|
Loading…
Reference in a new issue