Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ pub(crate) fn same_value<'a, V1: Copy + Into<Value<'a>>, V2: Copy + Into<Value<'
/// The abstract operation SameValueZero takes arguments x (an ECMAScript
/// language value) and y (an ECMAScript language value) and returns a Boolean.
/// It determines whether or not the two arguments are the same value (ignoring
/// the difference between +0𝔽 and -0𝔽). It performs the following steps when
/// called:
/// the difference between +0𝔽 and -0𝔽).
pub(crate) fn same_value_zero<'a>(
agent: &impl PrimitiveHeapIndexable,
x: impl Copy + Into<Value<'a>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ pub enum PreferredType {
/// returns either a normal completion containing an ECMAScript language value
/// or a throw completion. It converts its input argument to a non-Object type.
/// If an object is capable of converting to more than one primitive type, it
/// may use the optional hint preferredType to favour that type. It performs
/// the following steps when called:
/// may use the optional hint preferredType to favour that type.
///
/// > NOTE: When ToPrimitive is called without a hint, then it generally
/// > behaves as if the hint were NUMBER. However, objects may over-ride this
Expand Down
131 changes: 0 additions & 131 deletions nova_vm/src/ecmascript/builtins/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,79 +44,6 @@ use crate::{

use super::{ScopedArgumentsList, ordinary::shape::ObjectShape};

// 10.4.4.1 [[GetOwnProperty]] ( P )

// The [[GetOwnProperty]] internal method of an arguments exotic object args takes argument P (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

// 1. Let desc be OrdinaryGetOwnProperty(args, P).
// 2. If desc is undefined, return undefined.
// 3. Let map be args.[[ParameterMap]].
// 4. Let isMapped be ! HasOwnProperty(map, P).
// 5. If isMapped is true, then
// a. Set desc.[[Value]] to ! Get(map, P).
// 6. Return desc.

// 10.4.4.2 [[DefineOwnProperty]] ( P, Desc )

// The [[DefineOwnProperty]] internal method of an arguments exotic object args takes arguments P (a property key) and Desc (a Property Descriptor) and returns a normal completion containing a Boolean. It performs the following steps when called:

// 1. Let map be args.[[ParameterMap]].
// 2. Let isMapped be ! HasOwnProperty(map, P).
// 3. Let newArgDesc be Desc.
// 4. If isMapped is true and IsDataDescriptor(Desc) is true, then
// a. If Desc does not have a [[Value]] field, Desc has a [[Writable]] field, and Desc.[[Writable]] is false, then
// i. Set newArgDesc to a copy of Desc.
// ii. Set newArgDesc.[[Value]] to ! Get(map, P).
// 5. Let allowed be ! OrdinaryDefineOwnProperty(args, P, newArgDesc).
// 6. If allowed is false, return false.
// 7. If isMapped is true, then
// a. If IsAccessorDescriptor(Desc) is true, then
// i. Perform ! map.[[Delete]](P).
// b. Else,
// i. If Desc has a [[Value]] field, then
// 1. Assert: The following Set will succeed, since formal parameters mapped by arguments objects are always writable.
// 2. Perform ! Set(map, P, Desc.[[Value]], false).
// ii. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, then
// 1. Perform ! map.[[Delete]](P).
// 8. Return true.

// 10.4.4.3 [[Get]] ( P, Receiver )

// The [[Get]] internal method of an arguments exotic object args takes arguments P (a property key) and Receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

// 1. Let map be args.[[ParameterMap]].
// 2. Let isMapped be ! HasOwnProperty(map, P).
// 3. If isMapped is false, then
// a. Return ? OrdinaryGet(args, P, Receiver).
// 4. Else,
// a. Assert: map contains a formal parameter mapping for P.
// b. Return ! Get(map, P).

// 10.4.4.4 [[Set]] ( P, V, Receiver )

// The [[Set]] internal method of an arguments exotic object args takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

// 1. If SameValue(args, Receiver) is false, then
// a. Let isMapped be false.
// 2. Else,
// a. Let map be args.[[ParameterMap]].
// b. Let isMapped be ! HasOwnProperty(map, P).
// 3. If isMapped is true, then
// a. Assert: The following Set will succeed, since formal parameters mapped by arguments objects are always writable.
// b. Perform ! Set(map, P, V, false).
// 4. Return ? OrdinarySet(args, P, V, Receiver).

// 10.4.4.5 [[Delete]] ( P )

// The [[Delete]] internal method of an arguments exotic object args takes argument P (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

// 1. Let map be args.[[ParameterMap]].
// 2. Let isMapped be ! HasOwnProperty(map, P).
// 3. Let result be ? OrdinaryDelete(args, P).
// 4. If result is true and isMapped is true, then
// a. Perform ! map.[[Delete]](P).
// 5. Return result.

/// ### [10.4.4.6 CreateUnmappedArgumentsObject ( argumentsList )](https://tc39.es/ecma262/#sec-createunmappedargumentsobject)
///
/// The abstract operation CreateUnmappedArgumentsObject takes argument
Expand Down Expand Up @@ -217,61 +144,3 @@ pub(crate) fn create_unmapped_arguments_object<'a, 'b>(
// 9. Return obj.
Ok(Object::Arguments(obj))
}

// 10.4.4.7 CreateMappedArgumentsObject ( func, formals, argumentsList, env )

// The abstract operation CreateMappedArgumentsObject takes arguments func (an Object), formals (a Parse Node), argumentsList (a List of ECMAScript language values), and env (an Environment Record) and returns an arguments exotic object. It performs the following steps when called:

// 1. Assert: formals does not contain a rest parameter, any binding patterns, or any initializers. It may contain duplicate identifiers.
// 2. Let len be the number of elements in argumentsList.
// 3. Let obj be MakeBasicObject(« [[Prototype]], [[Extensible]], [[ParameterMap]] »).
// 4. Set obj.[[GetOwnProperty]] as specified in 10.4.4.1.
// 5. Set obj.[[DefineOwnProperty]] as specified in 10.4.4.2.
// 6. Set obj.[[Get]] as specified in 10.4.4.3.
// 7. Set obj.[[Set]] as specified in 10.4.4.4.
// 8. Set obj.[[Delete]] as specified in 10.4.4.5.
// 9. Set obj.[[Prototype]] to %Object.prototype%.
// 10. Let map be OrdinaryObjectCreate(null).
// 11. Set obj.[[ParameterMap]] to map.
// 12. Let parameterNames be the BoundNames of formals.
// 13. Let numberOfParameters be the number of elements in parameterNames.
// 14. Let index be 0.
// 15. Repeat, while index < len,
// a. Let val be argumentsList[index].
// b. Perform ! CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), val).
// c. Set index to index + 1.
// 16. Perform ! DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(len), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
// 17. Let mappedNames be a new empty List.
// 18. Set index to numberOfParameters - 1.
// 19. Repeat, while index ≥ 0,
// a. Let name be parameterNames[index].
// b. If mappedNames does not contain name, then
// i. Append name to mappedNames.
// ii. If index < len, then
// 1. Let g be MakeArgGetter(name, env).
// 2. Let p be MakeArgSetter(name, env).
// 3. Perform ! map.[[DefineOwnProperty]](! ToString(𝔽(index)), PropertyDescriptor { [[Set]]: p, [[Get]]: g, [[Enumerable]]: false, [[Configurable]]: true }).
// c. Set index to index - 1.
// 20. Perform ! DefinePropertyOrThrow(obj, @@iterator, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
// 21. Perform ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Value]]: func, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
// 22. Return obj.

// 10.4.4.7.1 MakeArgGetter ( name, env )

// The abstract operation MakeArgGetter takes arguments name (a String) and env (an Environment Record) and returns a function object. It creates a built-in function object that when executed returns the value bound for name in env. It performs the following steps when called:

// 1. Let getterClosure be a new Abstract Closure with no parameters that captures name and env and performs the following steps when called:
// a. Return env.GetBindingValue(name, false).
// 2. Let getter be CreateBuiltinFunction(getterClosure, 0, "", « »).
// 3. NOTE: getter is never directly accessible to ECMAScript code.
// 4. Return getter.

// 10.4.4.7.2 MakeArgSetter ( name, env )

// The abstract operation MakeArgSetter takes arguments name (a String) and env (an Environment Record) and returns a function object. It creates a built-in function object that when executed sets the value bound for name in env. It performs the following steps when called:

// 1. Let setterClosure be a new Abstract Closure with parameters (value) that captures name and env and performs the following steps when called:
// a. Return ! env.SetMutableBinding(name, value, false).
// 2. Let setter be CreateBuiltinFunction(setterClosure, 1, "", « »).
// 3. NOTE: setter is never directly accessible to ECMAScript code.
// 4. Return setter.
Loading
Loading