diff --git a/spec/abstract-operations.html b/spec/abstract-operations.html index f1970a6..850f57d 100644 --- a/spec/abstract-operations.html +++ b/spec/abstract-operations.html @@ -769,8 +769,8 @@

SameValueNonNumericSameValueNonGeneric ( - _x_: an ECMAScript language value, but not a Number or a BigInt, - _y_: an ECMAScript language value, but not a Number or a BigInt, + _x_: an ECMAScript language value, but not a Number, a BigInt, a Record, a Tuple, or a Box, + _y_: an ECMAScript language value, but not a Number, a BigInt, a Record, a Tuple, or a Box, )

@@ -778,7 +778,6 @@

It returns a completion record whose [[Type]] is ~normal~ and whose [[Value]] is a Boolean.

- 1. Assert: Type(_x_) is not Number or BigInt. 1. Assert: Type(_x_) is the same as Type(_y_). 1. If Type(_x_) is Undefined, return *true*. 1. If Type(_x_) is Null, return *true*. diff --git a/spec/data-types-and-values.html b/spec/data-types-and-values.html index 5159fc4..8aefc4d 100644 --- a/spec/data-types-and-values.html +++ b/spec/data-types-and-values.html @@ -159,8 +159,7 @@

The Box Type

-

The Box type is the set of all the possible singleton primitive wrappers around any ECMAScript value. Each box value holds an associated [[Value]] containing an ECMAScript value. The [[Value]] internal slot is never modified.

- +

The Box type is the set of all the possible singleton primitive wrappers around any ECMAScript value. Each box value holds an associated [[Value]] containing an ECMAScript value and a [[Realm]] containing the Realm of the Box function which created the Box value. The [[Value]] and [[Realm]] internal slots are never modified.

@@ -170,8 +169,7 @@

- 1. Let _valueString_ be ? ToString(_argument_.[[Value]]). - 1. Return the string-concatenation of *"Box("*, _valueString_, and *")"*. + 1. Return *"[object Box]"*.
@@ -184,6 +182,7 @@

+ 1. If _x_.[[Realm]] is not _y_.[[Realm]], return *false*. 1. Let _xValue_ be _x_.[[Value]]. 1. Let _yValue_ be _y_.[[Value]]. 1. Return ! SameValue(_xValue_, _yValue_.) @@ -199,6 +198,7 @@

+ 1. If _x_.[[Realm]] is not _y_.[[Realm]], return *false*. 1. Let _xValue_ be _x_.[[Value]]. 1. Let _yValue_ be _y_.[[Value]]. 1. Return ! SameValueZero(_xValue_, _yValue_.) diff --git a/spec/immutable-data-structures.html b/spec/immutable-data-structures.html index fd65394..8d89466 100644 --- a/spec/immutable-data-structures.html +++ b/spec/immutable-data-structures.html @@ -637,7 +637,8 @@

Box ( _arg_ )

When the `Box` function is called, the following steps are taken:

1. If NewTarget is not *undefined*, throw a *TypeError* exception. - 1. Return a new Box value whose [[Value]] is _arg_. + 1. Let _realm_ be the current Realm Record. + 1. Return a new Box value whose [[Value]] is _arg_ and whose [[Realm]] is _realm_.
@@ -675,6 +676,17 @@

RecursiveContainsBoxes ( _value_ )

+ +

Box.unbox ( _value_ )

+

The `unbox` function extracts the wrapped ECMAScript language value from _box_, throwing if it has been wrapped by a different Realm's Box constructor. When called, the following steps are taken:

+ + 1. Let _box_ be ? thisBoxValue(_value_). + 1. Let _realm_ be the current Realm Record. + 1. If _box_.[[Realm]] is not _realm_, throw a TypeError exception. + 1. Return _box_.[[Value]]. + +
+

Box.prototype

The initial value of *Box.prototype* is %Box.prototype%

@@ -715,14 +727,6 @@

Box.prototype [ @@toStringTag ]

The initial value of *Box.prototype[@@toStringTag]* is the String value *"Box"*.

This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

- -

Box.prototype.unbox ( )

-

When the `unbox` function is called, the following steps are taken:

- - 1. Let _box_ be ? thisBoxValue(*this* value). - 1. Return _box_.[[Value]] - -
diff --git a/spec/ordinary-and-exotic-object-behaviours.html b/spec/ordinary-and-exotic-object-behaviours.html index 8d92a57..e0dc65b 100644 --- a/spec/ordinary-and-exotic-object-behaviours.html +++ b/spec/ordinary-and-exotic-object-behaviours.html @@ -378,7 +378,7 @@

Box Exotic Objects

-

A Box object is an exotic object that encapsuates a Box value and exposes virtual integer-indexed data properties corresponding to the individual entries set on the underlying Box value. All keys properties are non-writable and non-configurable.

+

A Box object is an exotic object that encapsulates a Box value. It doesn't have any own key.

An object is a Box exotic object (or simply, a Box object) if its following internal methods use the following implementations and it is an Immutable Prototype Exotic Object.

diff --git a/spec/structured-data.html b/spec/structured-data.html index e586ec8..22e7cdc 100644 --- a/spec/structured-data.html +++ b/spec/structured-data.html @@ -135,23 +135,12 @@

1. Let _value_ be ? Get(_holder_, _key_). - 1. Let _toJSONCalled_ be *false*. - 1. If Type(_value_) is Object or BigInt, then + 1. If Type(_value_) is Object, Box, or BigInt, then 1. Let _toJSON_ be ? GetV(_value_, *"toJSON"*). 1. If IsCallable(_toJSON_) is *true*, then 1. Set _value_ to ? Call(_toJSON_, _value_, « _key_ »). - 1. Set _toJSONCalled_ to *true*. 1. If _state_.[[ReplacerFunction]] is not *undefined*, then 1. Set _value_ to ? Call(_state_.[[ReplacerFunction]], _holder_, « _key_, _value_ »). - 1. Set _value_ to ! MaybeUnwrapBox(_value_). - 1. Else, - 1. Set _value_ to ! MaybeUnwrapBox(_value_). - 1. If _toJSONCalled_ is *false*, then - 1. If Type(_value_) is Object or BigInt, then - 1. Let _toJSON_ be ? GetV(_value_, *"toJSON"*). - 1. If IsCallable(_toJSON_) is *true*, then - 1. Set _value_ to ? Call(_toJSON_, _value_, « _key_ »). - 1. Set _value_ to ! MaybeUnwrapBox(_value_). 1. If Type(_value_) is Object, then 1. If _value_ has a [[NumberData]] internal slot, then 1. Set _value_ to ? ToNumber(_value_). @@ -169,7 +158,7 @@

1. If Type(_value_) is Number, then 1. If _value_ is finite, return ! ToString(_value_). 1. Return *"null"*. - 1. If Type(_value_) is BigInt, throw a *TypeError* exception. + 1. If Type(_value_) is BigInt or Box, throw a *TypeError* exception. 1. If Type(_value_) is Object and IsCallable(_value_) is *false*, then 1. Let _isArray_ be ? IsArray(_value_). 1. If ! IsTuple(_value_) is *true*, then @@ -181,21 +170,6 @@

1. Return *undefined*. - - -

- MaybeUnwrapBox ( - _value_: an ECMAScript language value, - ) -

-
- - 1. If Type(_value_) is Object and _value_ has a [[BoxData]] internal slot, - 1. Set _value_ to _value_.[[BoxData]]. - 1. If Type(_value_) is Box, return ! MaybeUnwrapBox(_value_.[[Value]]). - 1. Return _value_. - -