6 ECMAScriptのデータ型と値

この仕様内のアルゴリズムは、それぞれに関連付けられた型を持つ値を操作します。可能な値の型は、この節で定義されるものに正確に限られます。型はさらにECMAScript言語型と仕様型に分類されます。

6.1 ECMAScript言語型

ECMAScript言語型は、ECMAScriptプログラマーがECMAScript言語を使用して直接操作する値に対応します。ECMAScript言語型はUndefined、Null、Boolean、String、Symbol、Number、BigInt、およびObjectです。ECMAScript言語値とは、ECMAScript言語型によって特徴付けられる値です。

6.1.1 Undefined型

Undefined型は、undefinedと呼ばれるちょうど1つの値を持ちます。値が代入されていない任意の変数は、値undefinedを持ちます。

6.1.2 Null型

Null型は、nullと呼ばれるちょうど1つの値を持ちます。

6.1.3 Boolean型

Boolean型は、trueおよびfalseと呼ばれる2つの値を持つ論理的実体を表します。

6.1.4 String型

String型は、最大長253 - 1要素までの、0個以上の16ビット符号なし整数値(“要素”)のすべての順序列の集合です。String型は一般に、実行中のECMAScriptプログラム内でテキストデータを表すために使用され、その場合、String内の各要素はUTF-16コード単位値として扱われます。各要素は、その列内の位置を占めるものと見なされます。これらの位置は非負整数でインデックス付けされます。最初の要素(存在する場合)はindex 0にあり、次の要素(存在する場合)はindex 1にあり、以下同様です。Stringの長さは、その中の要素(すなわち16ビット値)の数です。空のStringは長さ0であり、したがって要素を含みません。

Stringの内容を解釈しないECMAScript操作は、それ以上の意味論を適用しません。String値を解釈する操作は、各要素を単一のUTF-16コード単位として扱います。しかし、ECMAScriptはこれらのコード単位の値や相互関係を制限しないため、Stringの内容をUTF-16でエンコードされたUnicode符号位置列としてさらに解釈する操作は、不正な部分列を考慮しなければなりません。そのような操作は、0xD800から0xDBFFまでの包含区間内の数値を持つすべてのコード単位(Unicode Standardによってleading surrogate、またはより正式にはhigh-surrogate code unitとして定義される)と、0xDC00から0xDFFFまでの包含区間内の数値を持つすべてのコード単位(trailing surrogate、またはより正式にはlow-surrogate code unitとして定義される)に対して、以下の規則を使用して特別な扱いを適用します:

  • leading surrogateでもtrailing surrogateでもないコード単位は、同じ値を持つ符号位置として解釈されます。
  • 2つのコード単位の列であって、最初のコード単位c1leading surrogateであり、2番目のコード単位c2trailing surrogateであるものは、surrogate pairであり、値(c1 - 0xD800) × 0x400 + (c2 - 0xDC00) + 0x10000を持つ符号位置として解釈されます。(11.1.3を参照)
  • leading surrogateまたはtrailing surrogateであるが、surrogate pairの一部ではないコード単位は、同じ値を持つ符号位置として解釈されます。

関数String.prototype.normalize22.1.3.15を参照)は、String値を明示的に正規化するために使用できます。String.prototype.localeCompare22.1.3.12を参照)は内部的にString値を正規化しますが、他の操作はそれが作用する文字列を暗黙に正規化しません。別途述べられない限り、操作結果は言語および/またはlocaleに依存しません。

Note

この設計の根拠は、Stringsの実装を可能な限り単純かつ高性能に保つことでした。ECMAScript source textがNormalized Form Cである場合、Unicode escape sequencesを含まない限り、文字列リテラルも正規化されていることが保証されます。

この仕様では、“A, B, ...のstring-concatenation”(各argumentがString値、コード単位、またはコード単位列である場合)という句は、各argumentのコード単位(順序どおり)の連結(順序どおり)であるコード単位列を持つString値を表します。

inclusiveStartからexclusiveEndまでのstringsubstring”(stringがString値またはコード単位列であり、inclusiveStartおよびexclusiveEndが整数である場合)という句は、index inclusiveStartから始まりindex exclusiveEndの直前で終わる、stringの連続するコード単位からなるString値を表します(inclusiveStart = exclusiveEndの場合は空のString)。"to"接尾辞が省略された場合、stringの長さがexclusiveEndの値として使用されます。

the ASCII word characters”という句は、Unicode Basic Latinブロック内のすべての文字および数字にU+005F(LOW LINE)を加えたもののみからなる、以下のString値を表します:
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_".
歴史的な理由により、これはさまざまなアルゴリズムにおいて重要性を持ちます。

6.1.4.1 StringIndexOf ( string, searchValue, fromIndex )

The abstract operation StringIndexOf takes arguments string (a String), searchValue (a String), and fromIndex (a non-negative integer) and returns a non-negative integer or not-found. It performs the following steps when called:

  1. lengthstringの長さとする。
  2. searchValueが空のStringであり、fromIndexlengthなら、fromIndexを返す。
  3. searchLengthsearchValueの長さとする。
  4. fromIndexilength - searchLengthである各整数iについて、昇順で、以下を行う
    1. candidatestringiからi + searchLengthまでのsubstringとする。
    2. candidatesearchValueなら、iを返す。
  5. not-foundを返す。
Note 1

searchValueが空のStringであり、fromIndexstringの長さである場合、このアルゴリズムはfromIndexを返します。空のStringは、最後のコード単位の後を含め、文字列内のすべての位置で実質的に見つかります。

Note 2

このアルゴリズムは、fromIndex + searchValueの長さ > stringの長さである場合、常にnot-foundを返します。

6.1.4.2 StringLastIndexOf ( string, searchValue, fromIndex )

The abstract operation StringLastIndexOf takes arguments string (a String), searchValue (a String), and fromIndex (a non-negative integer) and returns a non-negative integer or not-found. It performs the following steps when called:

  1. lengthstringの長さとする。
  2. searchLengthsearchValueの長さとする。
  3. Assert: fromIndex + searchLengthlength
  4. 0 ≤ ifromIndexである各整数iについて、降順で、以下を行う
    1. candidatestringiからi + searchLengthまでのsubstringとする。
    2. candidatesearchValueなら、iを返す。
  5. not-foundを返す。
Note

searchValueが空のStringである場合、このアルゴリズムはfromIndexを返します。空のStringは、最後のコード単位の後を含め、文字列内のすべての位置で実質的に見つかります。

6.1.5 Symbol型

Symbol型は、Objectプロパティのキーとして使用できるすべての非String値の集合です(6.1.7)。

各Symbolは一意で不変です。

各Symbolは不変の[[Description]] internal slotを持ち、その値はStringまたはundefinedのいずれかです。

6.1.5.1 Well-Known Symbols

well-known symbolsは、この仕様のアルゴリズムによって明示的に参照される組み込みSymbol値です。それらは通常、仕様アルゴリズムの拡張点として機能する値を持つプロパティのキーとして使用されます。別途指定されない限り、well-known symbols値はすべてのrealmsによって共有されます(9.3)。

この仕様内では、well-known symbolは、Table 1に列挙される値の1つであるintrinsicを用いて、標準のintrinsic notationで参照されます。

Note
この仕様の以前の版では、現在の版で%Symbol.name%を使用する箇所に@@nameという形式の記法を使用していました。特に、以下の名前が使用されていました:@@asyncIterator、@@hasInstance、@@isConcatSpreadable、@@iterator、@@match、@@matchAll、@@replace、@@search、@@species、@@split、@@toPrimitive、@@toStringTag、および@@unscopables。
Table 1: よく知られたシンボル
仕様名 [[Description]] 値と目的
%Symbol.asyncDispose% "Symbol.asyncDispose" オブジェクト上で非同期にリソースのクリーンアップを実行するメソッド。それを含むスコープの評価が完了したときに、AsyncDisposableStack オブジェクトおよび await using 宣言によって呼び出される。
%Symbol.asyncIterator% "Symbol.asyncIterator" オブジェクトのデフォルト非同期イテレータを返すメソッド。for-await-of 文のセマンティクスによって呼び出される。
%Symbol.dispose% "Symbol.dispose" オブジェクト上で明示的なリソースのクリーンアップを実行するメソッド。それを含むスコープの評価が完了したときに、DisposableStack オブジェクト、AsyncDisposableStack オブジェクト、および using 宣言によって呼び出される。
%Symbol.hasInstance% "Symbol.hasInstance" コンストラクタオブジェクトが、あるオブジェクトをそのコンストラクタのインスタンスの1つとして認識するかどうかを判定するメソッド。instanceof 演算子のセマンティクスによって呼び出される。
%Symbol.isConcatSpreadable% "Symbol.isConcatSpreadable" true の場合、オブジェクトが Array.prototype.concat によってその配列要素へと平坦化されるべきことを示す Boolean 値のプロパティ。
%Symbol.iterator% "Symbol.iterator" オブジェクトのデフォルトイテレータを返すメソッド。for-of 文のセマンティクスによって呼び出される。
%Symbol.match% "Symbol.match" 正規表現を文字列に照合する正規表現メソッド。String.prototype.match メソッドによって呼び出される。
%Symbol.matchAll% "Symbol.matchAll" 文字列に対する正規表現の一致を yield するイテレータを返す正規表現メソッド。String.prototype.matchAll メソッドによって呼び出される。
%Symbol.replace% "Symbol.replace" 文字列の一致した部分文字列を置換する正規表現メソッド。String.prototype.replace メソッドによって呼び出される。
%Symbol.search% "Symbol.search" 正規表現に一致する文字列内のインデックスを返す正規表現メソッド。String.prototype.search メソッドによって呼び出される。
%Symbol.species% "Symbol.species" 派生オブジェクトを作成するために使用されるコンストラクタ関数である、関数値のプロパティ。
%Symbol.split% "Symbol.split" 正規表現に一致するインデックスで文字列を分割する正規表現メソッド。String.prototype.split メソッドによって呼び出される。
%Symbol.toPrimitive% "Symbol.toPrimitive" オブジェクトを対応するプリミティブ値へ変換するメソッド。ToPrimitive 抽象操作によって呼び出される。
%Symbol.toStringTag% "Symbol.toStringTag" オブジェクトのデフォルトの文字列表現を作成する際に使用される String 値のプロパティ。組み込みメソッド Object.prototype.toString によってアクセスされる。
%Symbol.unscopables% "Symbol.unscopables" 自身および継承されたプロパティ名が、関連付けられたオブジェクトの with 環境束縛から除外されるプロパティ名である、オブジェクト値のプロパティ。

6.1.6 数値型

ECMAScriptには2つの組み込み数値型、NumberとBigIntがあります。以下の抽象操作は、これらの数値型上で定義されます。“Result”列は戻り型を示し、その操作の一部の呼び出しがabrupt completionを返す可能性があるかどうかも示します。

Table 2: Numeric Type Operations
操作 例のsource ...のEvaluation意味論によって呼び出される 結果
Number::unaryMinus -x Unary - Operator Number
BigInt::unaryMinus BigInt
Number::bitwiseNOT ~x Bitwise NOT Operator ( ~ ) Number
BigInt::bitwiseNOT BigInt
Number::exponentiate x ** y Exponentiation Operator およびMath.pow ( base, exponent ) Number
BigInt::exponentiate BigIntを含むnormal completionまたはthrow completionのいずれか
Number::multiply x * y Multiplicative Operators Number
BigInt::multiply BigInt
Number::divide x / y Multiplicative Operators Number
BigInt::divide BigIntを含むnormal completionまたはthrow completionのいずれか
Number::remainder x % y Multiplicative Operators Number
BigInt::remainder BigIntを含むnormal completionまたはthrow completionのいずれか
Number::add x ++
++ x
x + y
Postfix Increment Operator, Prefix Increment Operator, およびThe Addition Operator ( + ) Number
BigInt::add BigInt
Number::subtract x --
-- x
x - y
Postfix Decrement Operator, Prefix Decrement Operator, およびThe Subtraction Operator ( - ) Number
BigInt::subtract BigInt
Number::leftShift x << y The Left Shift Operator ( << ) Number
BigInt::leftShift BigInt
Number::signedRightShift x >> y The Signed Right Shift Operator ( >> ) Number
BigInt::signedRightShift BigInt
Number::unsignedRightShift x >>> y The Unsigned Right Shift Operator ( >>> ) Number
BigInt::unsignedRightShift throw completion
Number::lessThan x < y
x > y
x <= y
x >= y
Relational Operators, IsLessThan ( x, y, leftFirst )経由 Booleanまたはundefined(順序不能な入力の場合)
BigInt::lessThan Boolean
Number::equal x == y
x != y
x === y
x !== y
Equality Operators, IsStrictlyEqual ( x, y )経由 Boolean
BigInt::equal
Number::sameValue Object.is(x, y) Object internal methods, 正確な値の等価性をテストするためにSameValue ( x, y )経由 Boolean
Number::sameValueZero [x].includes(y) Array、Map、およびSetメソッドにおけるように、+0𝔽-0𝔽の違いを無視して値の等価性をテストするために、SameValueZero ( x, y )経由 Boolean
Number::bitwiseAND x & y Binary Bitwise Operators Number
BigInt::bitwiseAND BigInt
Number::bitwiseXOR x ^ y Number
BigInt::bitwiseXOR BigInt
Number::bitwiseOR x | y Number
BigInt::bitwiseOR BigInt
Number::toString String(x) 多くの式および組み込み関数、ToString ( arg )経由 String
BigInt::toString

数値型は一般に、精度の損失や切り捨てなしには変換できないため、ECMAScript言語はこれらの型間の暗黙変換を提供しません。プログラマーは、別の型を必要とする関数を呼び出すとき、型間で変換するためにNumberおよびBigInt関数を明示的に呼び出さなければなりません。

Note

ECMAScriptの第1版およびその後の版は、特定の演算子について、精度を失ったり切り捨てたりする可能性のある暗黙の数値変換を提供してきました。これらのlegacy implicit conversionsは後方互換性のために維持されていますが、プログラマーのエラーの機会を最小化し、将来の版における一般化されたvalue typesの選択肢を残すため、BigIntには提供されません。

6.1.6.1 Number型

Number型は、正確に18,437,736,874,454,810,627個(すなわち264 - 253 + 3個)の値を持ち、IEEE Standard for Binary Floating-Point Arithmeticで指定されるIEEE 754-2019 binary64の倍精度浮動小数点値を表します。ただし、IEEE Standardの9,007,199,254,740,990個(すなわち253 - 2個)の異なるNaN値は、ECMAScriptでは単一の特別なNaN値として表されます。(NaN値はプログラム式NaNによって生成されることに注意してください。)一部の実装では、外部コードがさまざまなNaN値の違いを検出できる場合がありますが、そのような振る舞いはimplementation-definedです。ECMAScriptコードにとって、すべてのNaN値は互いに区別できません。

Note

Number値がArrayBuffer(25.1を参照)またはSharedArrayBuffer(25.2を参照)に格納された後に観測され得るビットパターンは、ECMAScript実装によって使用されるそのNumber値の内部表現と必ずしも同じではありません。

他に2つの特別な値があり、positive Infinityおよびnegative Infinityと呼ばれます。簡潔さのため、これらの値は説明目的でそれぞれ記号+∞𝔽および-∞𝔽によっても参照されます。(これら2つの無限Number値は、プログラム式+Infinity(または単にInfinity)および-Infinityによって生成されることに注意してください。)

その他の18,437,736,874,454,810,624個(すなわち264 - 253個)の値はfinite numbersと呼ばれます。これらの半分は正の数であり、半分は負の数です。各有限の正のNumber値には、同じ大きさを持つ対応する負の値があります。

positive zeronegative zeroの双方が存在することに注意してください。簡潔さのため、これらの値は説明目的でそれぞれ記号+0𝔽および-0𝔽によっても参照されます。(これら2つの異なるzero Number値は、プログラム式+0(または単に0)および-0によって生成されることに注意してください。)

18,437,736,874,454,810,622個(すなわち264 - 253 - 2個)の有限非ゼロ値には2種類あります:

そのうち18,428,729,675,200,069,632個(すなわち264 - 254個)はnormalizedであり、次の形式を持ちます

s × m × 2e

ここでsは1または-1、mは252(inclusive)から253(exclusive)までのinterval内のintegereは-1074から971までの包含区間内のintegerです。

残りの9,007,199,254,740,990個(すなわち253 - 2個)の値はdenormalizedであり、次の形式を持ちます

s × m × 2e

ここでsは1または-1、mは0(exclusive)から252(exclusive)までのinterval内のintegereは-1074です。

大きさが253以下であるすべての正および負のintegersは、Number型で表現可能であることに注意してください。integer 0はNumber型において2つの表現を持ちます:+0𝔽および-0𝔽です。

有限数は、非ゼロであり、それを表現するために使用されるinteger m(上に示した2つの形式のいずれか)が奇数である場合、odd significandを持ちます。それ以外の場合、even significandを持ちます。

この仕様では、“xNumber value for”という句は、xが正確な実数数学量(πのような無理数であってもよい)を表す場合、以下の方法で選ばれたNumber値を意味します。Number型のすべてのfinite valuesの集合から-0𝔽を取り除き、Number型では表現できない2つの追加値、すなわち21024(これは+1 × 253 × 2971)および-21024(これは-1 × 253 × 2971)を加えた集合を考えます。この集合のメンバーのうち、値がxに最も近いものを選びます。集合内の2つの値が等しく近い場合、even significandを持つものが選ばれます。この目的のため、追加の2つの値21024および-21024はeven significandsを持つものと見なされます。最後に、21024が選ばれた場合、それを+∞𝔽で置き換えます。-21024が選ばれた場合、それを-∞𝔽で置き換えます。+0𝔽が選ばれた場合、x < 0である場合に限り、それを-0𝔽で置き換えます。その他の選ばれた値は変更せずに使用されます。その結果がxのNumber valueです。(この手続きはIEEE 754-2019 roundTiesToEven modeの振る舞いに正確に対応します。)

+∞のNumber valueは+∞𝔽であり、-∞のNumber valueは-∞𝔽です。

一部のECMAScript演算子は、-231から231 - 1までの包含区間や、0から216 - 1までの包含区間など、特定範囲のintegersのみを扱います。これらの演算子はNumber型の任意の値を受け入れますが、まずそのような各値を期待される範囲内のinteger値へ変換します。7.1内の数値変換操作の記述を参照してください。

6.1.6.1.1 Number::unaryMinus ( number )

The abstract operation Number::unaryMinus takes argument number (a Number) and returns a Number. It performs the following steps when called:

  1. numberNaNなら、NaNを返す。
  2. numberの否定を返す。すなわち、同じ大きさで反対の符号を持つNumberを計算する。

6.1.6.1.2 Number::bitwiseNOT ( number )

The abstract operation Number::bitwiseNOT takes argument number (a Number) and returns an integral Number. It performs the following steps when called:

  1. oldValueを ! ToInt32(number) とする。
  2. oldValueのビットごとの補数を返す。結果のmathematical valueは32ビットtwo's complement bit stringとして正確に表現可能です。

6.1.6.1.3 Number::exponentiate ( base, exponent )

The abstract operation Number::exponentiate takes arguments base (a Number) and exponent (a Number) and returns a Number. これはbaseexponent乗した結果を表すimplementation-approximatedな値を返します。 It performs the following steps when called:

  1. exponentNaNなら、NaNを返す。
  2. exponent+0𝔽または-0𝔽のいずれかなら、1𝔽を返す。
  3. baseNaNなら、NaNを返す。
  4. base+∞𝔽なら、
    1. exponent > +0𝔽なら、+∞𝔽を返す。
    2. +0𝔽を返す。
  5. base-∞𝔽なら、
    1. exponent > +0𝔽なら、
      1. exponentがodd integral Numberなら、-∞𝔽を返す。
      2. +∞𝔽を返す。
    2. exponentがodd integral Numberなら、-0𝔽を返す。
    3. +0𝔽を返す。
  6. base+0𝔽なら、
    1. exponent > +0𝔽なら、+0𝔽を返す。
    2. +∞𝔽を返す。
  7. base-0𝔽なら、
    1. exponent > +0𝔽なら、
      1. exponentがodd integral Numberなら、-0𝔽を返す。
      2. +0𝔽を返す。
    2. exponentがodd integral Numberなら、-∞𝔽を返す。
    3. +∞𝔽を返す。
  8. Assert: basefiniteであり、+0𝔽でも-0𝔽でもない。
  9. exponent+∞𝔽なら、
    1. abs((base)) > 1なら、+∞𝔽を返す。
    2. abs((base)) = 1なら、NaNを返す。
    3. +0𝔽を返す。
  10. exponent-∞𝔽なら、
    1. abs((base)) > 1なら、+0𝔽を返す。
    2. abs((base)) = 1なら、NaNを返す。
    3. +∞𝔽を返す。
  11. Assert: exponentfiniteであり、+0𝔽でも-0𝔽でもない。
  12. base < -0𝔽かつexponentintegral Numberでないなら、NaNを返す。
  13. (base)を(exponent)乗した結果を表すimplementation-approximatedなNumber値を返す。
Note

base1𝔽または-1𝔽であり、exponent+∞𝔽または-∞𝔽である場合、またはbase1𝔽でありexponentNaNである場合のbase ** exponentの結果は、IEEE 754-2019とは異なります。ECMAScriptの第1版はこの操作の結果をNaNと指定していましたが、IEEE 754の後の改訂では1𝔽と指定しました。歴史的なECMAScriptの振る舞いは互換性の理由により保持されています。

6.1.6.1.4 Number::multiply ( x, y )

The abstract operation Number::multiply takes arguments x (a Number) and y (a Number) and returns a Number. IEEE 754-2019 binary double-precision arithmeticの規則に従って乗算を実行し、xyの積を生成します。 It performs the following steps when called:

  1. xNaNまたはyNaNなら、NaNを返す。
  2. x+∞𝔽または-∞𝔽のいずれかなら、
    1. y+0𝔽または-0𝔽のいずれかなら、NaNを返す。
    2. y > +0𝔽なら、xを返す。
    3. -xを返す。
  3. y+∞𝔽または-∞𝔽のいずれかなら、
    1. x+0𝔽または-0𝔽のいずれかなら、NaNを返す。
    2. x > +0𝔽なら、yを返す。
    3. -yを返す。
  4. x-0𝔽なら、
    1. y-0𝔽またはy < -0𝔽なら、+0𝔽を返す。
    2. -0𝔽を返す。
  5. y-0𝔽なら、
    1. x < -0𝔽なら、+0𝔽を返す。
    2. -0𝔽を返す。
  6. 𝔽((x) × (y))を返す。
Note

有限精度の乗算は可換ですが、常に結合的であるとは限りません。

6.1.6.1.5 Number::divide ( x, y )

The abstract operation Number::divide takes arguments x (a Number) and y (a Number) and returns a Number. IEEE 754-2019 binary double-precision arithmeticの規則に従って除算を実行し、xをdividend、yをdivisorとするxyのquotientを生成します。 It performs the following steps when called:

  1. xNaNまたはyNaNなら、NaNを返す。
  2. x+∞𝔽または-∞𝔽のいずれかなら、
    1. y+∞𝔽または-∞𝔽のいずれかなら、NaNを返す。
    2. y+0𝔽またはy > +0𝔽なら、xを返す。
    3. -xを返す。
  3. y+∞𝔽なら、
    1. x+0𝔽またはx > +0𝔽なら、+0𝔽を返す。
    2. -0𝔽を返す。
  4. y-∞𝔽なら、
    1. x+0𝔽またはx > +0𝔽なら、-0𝔽を返す。
    2. +0𝔽を返す。
  5. x+0𝔽または-0𝔽のいずれかなら、
    1. y+0𝔽または-0𝔽のいずれかなら、NaNを返す。
    2. y > +0𝔽なら、xを返す。
    3. -xを返す。
  6. y+0𝔽なら、
    1. x > +0𝔽なら、+∞𝔽を返す。
    2. -∞𝔽を返す。
  7. y-0𝔽なら、
    1. x > +0𝔽なら、-∞𝔽を返す。
    2. +∞𝔽を返す。
  8. 𝔽((x) / (y))を返す。

6.1.6.1.6 Number::remainder ( numerator, denominator )

The abstract operation Number::remainder takes arguments numerator (a Number) and denominator (a Number) and returns a Number. numeratorをdividend、denominatorをdivisorとする、そのオペランドの暗黙の除算からremainderを生成します。 It performs the following steps when called:

  1. numeratorNaNまたはdenominatorNaNなら、NaNを返す。
  2. numerator+∞𝔽または-∞𝔽のいずれかなら、NaNを返す。
  3. denominator+∞𝔽または-∞𝔽のいずれかなら、numeratorを返す。
  4. denominator+0𝔽または-0𝔽のいずれかなら、NaNを返す。
  5. numerator+0𝔽または-0𝔽のいずれかなら、numeratorを返す。
  6. Assert: numeratordenominatorfiniteかつnon-zeroである。
  7. quotient(numerator) / (denominator)とする。
  8. truncatedQuotienttruncate(quotient)とする。
  9. remainder(numerator) - ((denominator) × truncatedQuotient)とする。
  10. remainder = 0かつnumerator < -0𝔽なら、-0𝔽を返す。
  11. 𝔽(remainder)を返す。
Note 1

CおよびC++では、remainder演算子はintegral operandsのみを受け入れます。ECMAScriptでは、floating-point operandsも受け入れます。

Note 2
%演算子によって計算されるfloating-point remainder操作の結果は、IEEE 754-2019で定義される“remainder”操作と同じではありません。IEEE 754-2019の“remainder”操作は、truncating divisionではなくrounding divisionからremainderを計算するため、その振る舞いは通常のinteger remainder演算子の振る舞いとは類似していません。その代わり、ECMAScript言語はfloating-point操作上の%を、Javaのinteger remainder演算子に類似した方法で振る舞うよう定義します。これはCライブラリ関数fmodと比較され得ます。

6.1.6.1.7 Number::add ( x, y )

The abstract operation Number::add takes arguments x (a Number) and y (a Number) and returns a Number. IEEE 754-2019 binary double-precision arithmeticの規則に従って加算を実行し、そのargumentsの和を生成します。 It performs the following steps when called:

  1. xNaNまたはyNaNなら、NaNを返す。
  2. x+∞𝔽かつy-∞𝔽なら、NaNを返す。
  3. x-∞𝔽かつy+∞𝔽なら、NaNを返す。
  4. x+∞𝔽または-∞𝔽のいずれかなら、xを返す。
  5. y+∞𝔽または-∞𝔽のいずれかなら、yを返す。
  6. Assert: xyはともにfiniteである。
  7. x-0𝔽かつy-0𝔽なら、-0𝔽を返す。
  8. 𝔽((x) + (y))を返す。
Note

有限精度の加算は可換ですが、常に結合的であるとは限りません。

6.1.6.1.8 Number::subtract ( x, y )

The abstract operation Number::subtract takes arguments x (a Number) and y (a Number) and returns a Number. 減算を実行し、そのオペランドの差を生成します。xはminuendであり、yはsubtrahendです。 It performs the following steps when called:

  1. Number::add(x, Number::unaryMinus(y))を返す。
Note

x - yは常にx + (-y)と同じ結果を生成します。

6.1.6.1.9 Number::leftShift ( x, y )

The abstract operation Number::leftShift takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. leftNumberを ! ToInt32(x) とする。
  2. rightNumberを ! ToUint32(y) とする。
  3. shiftCount(rightNumber) modulo 32とする。
  4. leftNumbershiftCountビット左シフトした結果を返す。結果のmathematical valueは32ビットtwo's complement bit stringとして正確に表現可能です。

6.1.6.1.10 Number::signedRightShift ( x, y )

The abstract operation Number::signedRightShift takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. leftNumberを ! ToInt32(x) とする。
  2. rightNumberを ! ToUint32(y) とする。
  3. shiftCount(rightNumber) modulo 32とする。
  4. leftNumbershiftCountビットだけsign-extending right shiftした結果を返す。最上位ビットが伝播されます。結果のmathematical valueは32ビットtwo's complement bit stringとして正確に表現可能です。

6.1.6.1.11 Number::unsignedRightShift ( x, y )

The abstract operation Number::unsignedRightShift takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. leftNumberを ! ToUint32(x) とする。
  2. rightNumberを ! ToUint32(y) とする。
  3. shiftCount(rightNumber) modulo 32とする。
  4. leftNumbershiftCountビットだけzero-filling right shiftした結果を返す。空いたビットはゼロで埋められます。結果のmathematical valueは32ビットunsigned bit stringとして正確に表現可能です。

6.1.6.1.12 Number::lessThan ( x, y )

The abstract operation Number::lessThan takes arguments x (a Number) and y (a Number) and returns a Boolean or undefined. It performs the following steps when called:

  1. xNaNなら、undefinedを返す。
  2. yNaNなら、undefinedを返す。
  3. xyなら、falseを返す。
  4. x+0𝔽かつy-0𝔽なら、falseを返す。
  5. x-0𝔽かつy+0𝔽なら、falseを返す。
  6. x+∞𝔽なら、falseを返す。
  7. y+∞𝔽なら、trueを返す。
  8. y-∞𝔽なら、falseを返す。
  9. x-∞𝔽なら、trueを返す。
  10. Assert: xyfiniteである。
  11. (x) < (y)なら、trueを返す。
  12. falseを返す。

6.1.6.1.13 Number::equal ( x, y )

The abstract operation Number::equal takes arguments x (a Number) and y (a Number) and returns a Boolean. It performs the following steps when called:

  1. xNaNなら、falseを返す。
  2. yNaNなら、falseを返す。
  3. xyなら、trueを返す。
  4. x+0𝔽かつy-0𝔽なら、trueを返す。
  5. x-0𝔽かつy+0𝔽なら、trueを返す。
  6. falseを返す。

6.1.6.1.14 Number::sameValue ( x, y )

The abstract operation Number::sameValue takes arguments x (a Number) and y (a Number) and returns a Boolean. It performs the following steps when called:

  1. xNaNかつyNaNなら、trueを返す。
  2. x+0𝔽かつy-0𝔽なら、falseを返す。
  3. x-0𝔽かつy+0𝔽なら、falseを返す。
  4. xyなら、trueを返す。
  5. falseを返す。

6.1.6.1.15 Number::sameValueZero ( x, y )

The abstract operation Number::sameValueZero takes arguments x (a Number) and y (a Number) and returns a Boolean. It performs the following steps when called:

  1. xNaNかつyNaNなら、trueを返す。
  2. x+0𝔽かつy-0𝔽なら、trueを返す。
  3. x-0𝔽かつy+0𝔽なら、trueを返す。
  4. xyなら、trueを返す。
  5. falseを返す。

6.1.6.1.16 NumberBitwiseOp ( op, x, y )

The abstract operation NumberBitwiseOp takes arguments op (&, ^, or |), x (a Number), and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. leftNumberを ! ToInt32(x) とする。
  2. rightNumberを ! ToInt32(y) とする。
  3. leftBits(leftNumber)を表す32ビットtwo's complement bit stringとする。
  4. rightBits(rightNumber)を表す32ビットtwo's complement bit stringとする。
  5. op&なら、
    1. resultleftBitsおよびrightBitsにbitwise AND操作を適用した結果とする。
  6. そうでなく、op^なら、
    1. resultleftBitsおよびrightBitsにbitwise exclusive OR(XOR)操作を適用した結果とする。
  7. そうでなければ、
    1. Assert: op|である。
    2. resultleftBitsおよびrightBitsにbitwise inclusive OR操作を適用した結果とする。
  8. 32ビットtwo's complement bit string resultによって表されるintegerのNumber valueを返す。

6.1.6.1.17 Number::bitwiseAND ( x, y )

The abstract operation Number::bitwiseAND takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. NumberBitwiseOp(&, x, y)を返す。

6.1.6.1.18 Number::bitwiseXOR ( x, y )

The abstract operation Number::bitwiseXOR takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. NumberBitwiseOp(^, x, y)を返す。

6.1.6.1.19 Number::bitwiseOR ( x, y )

The abstract operation Number::bitwiseOR takes arguments x (a Number) and y (a Number) and returns an integral Number. It performs the following steps when called:

  1. NumberBitwiseOp(|, x, y)を返す。

6.1.6.1.20 Number::toString ( x, radix )

The abstract operation Number::toString takes arguments x (a Number) and radix (an integer in the inclusive interval from 2 to 36) and returns a String. radixを基数とする位取り記数法を使用してxをStringとして表します。基数rを使用する数の表現に用いられるdigitsは、"0123456789abcdefghijklmnopqrstuvwxyz"の最初のr個のコード単位から順に取られます。大きさが1𝔽以上の数の表現は、leading zeroesを決して含みません。 It performs the following steps when called:

  1. xNaNなら、"NaN"を返す。
  2. x+0𝔽または-0𝔽のいずれかなら、"0"を返す。
  3. x < -0𝔽なら、"-"Number::toString(-x, radix)のstring-concatenationを返す。
  4. x+∞𝔽なら、"Infinity"を返す。
  5. nk、およびsを、k ≥ 1、radixk - 1s < radixk𝔽(s × radixn - k) がxであり、かつkが可能な限り小さいようなintegersとする。kradixを用いるsの表現内のdigitsの数であり、sradixで割り切れず、sの最下位digitはこれらの基準によって必ずしも一意に決定されないことに注意。
  6. radix ≠ 10またはnが-5から21までの包含区間内にあるなら、
    1. nkなら、
      1. 以下のstring-concatenationを返す:
        • radixを使用するsの表現のk個のdigitsのコード単位
        • コード単位0x0030(DIGIT ZERO)のn - k回の出現
    2. n > 0なら、
      1. 以下のstring-concatenationを返す:
        • radixを使用するsの表現の最上位n個のdigitsのコード単位
        • コード単位0x002E(FULL STOP)
        • radixを使用するsの表現の残りのk - n個のdigitsのコード単位
    3. Assert: n ≤ 0。
    4. 以下のstring-concatenationを返す:
      • コード単位0x0030(DIGIT ZERO)
      • コード単位0x002E(FULL STOP)
      • コード単位0x0030(DIGIT ZERO)の-n回の出現
      • radixを使用するsの表現のk個のdigitsのコード単位
  7. NOTE: この場合、入力は1.2e+3のような科学的E記法を使用して表されます。
  8. Assert: radixは10である。
  9. n < 0なら、
    1. exponentSignをコード単位0x002D(HYPHEN-MINUS)とする。
  10. そうでなければ、
    1. exponentSignをコード単位0x002B(PLUS SIGN)とする。
  11. k = 1なら、
    1. 以下のstring-concatenationを返す:
      • sの単一digitのコード単位
      • コード単位0x0065(LATIN SMALL LETTER E)
      • exponentSign
      • abs(n - 1)の10進表現のコード単位
  12. 以下のstring-concatenationを返す:
    • sの10進表現の最上位digitのコード単位
    • コード単位0x002E(FULL STOP)
    • sの10進表現の残りのk - 1個のdigitsのコード単位
    • コード単位0x0065(LATIN SMALL LETTER E)
    • exponentSign
    • abs(n - 1)の10進表現のコード単位
Note 1

以下の観察は実装の指針として有用である場合がありますが、この標準の規範的要件の一部ではありません:

  • xが-0𝔽以外の任意のNumber値である場合、ToNumber(ToString(x))はxです。
  • sの最下位digitは、ステップ5に列挙された要件によって常に一意に決定されるとは限りません。
Note 2

上記の規則で要求されるより正確な変換を提供する実装については、ステップ5の以下の代替版を指針として使用することが推奨されます:

  1. nk、およびsを、k ≥ 1、radixk - 1s < radixk𝔽(s × radixn - k) がxであり、かつkが可能な限り小さいようなintegersとする。sに複数の可能性がある場合、s × radixn - k(x)に最も近くなるようにsを選ぶ。そのようなsの値が2つある場合、偶数であるものを選ぶ。kradixを使用するsの表現内のdigitsの数であり、sradixで割り切れないことに注意。
Note 3

ECMAScriptの実装者は、floating-point numbersのbinary-to-decimal変換についてDavid M. Gayが書いた論文およびコードを有用と感じるかもしれません:

Gay, David M. Correctly Rounded Binary-Decimal and Decimal-Binary Conversions. Numerical Analysis, Manuscript 90-10. AT&T Bell Laboratories (Murray Hill, New Jersey). 30 November 1990. Available as
https://ampl.com/_archive/first-website/REFS/rounding.pdf. Associated code available as
http://netlib.sandia.gov/fp/dtoa.c and as
http://netlib.sandia.gov/fp/g_fmt.c and may also be found at the various netlib mirror sites.

6.1.6.2 BigInt型

BigInt型integer値を表します。その値は任意の大きさであってよく、特定のbit-widthに制限されません。一般に、別途注記されない限り、操作は正確な数学的答えを返すように設計されています。二項操作では、BigIntsはtwo's complement binary stringsとして振る舞い、負の数は左側に無限にbitsが設定されているものとして扱われます。

6.1.6.2.1 BigInt::unaryMinus ( bigint )

The abstract operation BigInt::unaryMinus takes argument bigint (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. bigint = 0なら、0を返す。
  2. -bigintを返す。

6.1.6.2.2 BigInt::bitwiseNOT ( bigint )

The abstract operation BigInt::bitwiseNOT takes argument bigint (a BigInt) and returns a BigInt. bigintのone's complementを返します。 It performs the following steps when called:

  1. -bigint - 1を返す。

6.1.6.2.3 BigInt::exponentiate ( base, exponent )

The abstract operation BigInt::exponentiate takes arguments base (a BigInt) and exponent (a BigInt) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:

  1. exponent < 0なら、RangeError例外をthrowする。
  2. base = 0かつexponent = 0なら、1を返す。
  3. baseexponent乗したものを返す。

6.1.6.2.4 BigInt::multiply ( x, y )

The abstract operation BigInt::multiply takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. x × yを返す。
Note
結果が入力よりはるかに大きなbit widthを持つ場合でも、正確な数学的答えが与えられます。

6.1.6.2.5 BigInt::divide ( x, y )

The abstract operation BigInt::divide takes arguments x (a BigInt) and y (a BigInt) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:

  1. y = 0なら、RangeError例外をthrowする。
  2. quotient(x) / (y)とする。
  3. (truncate(quotient))を返す。

6.1.6.2.6 BigInt::remainder ( numerator, denominator )

The abstract operation BigInt::remainder takes arguments numerator (a BigInt) and denominator (a BigInt) and returns either a normal completion containing a BigInt or a throw completion. It performs the following steps when called:

  1. denominator = 0なら、RangeError例外をthrowする。
  2. numerator = 0なら、0を返す。
  3. quotient(numerator) / (denominator)とする。
  4. truncatedQuotient(truncate(quotient))とする。
  5. numerator - (denominator × truncatedQuotient)を返す。
Note
結果の符号はdividendの符号です。

6.1.6.2.7 BigInt::add ( x, y )

The abstract operation BigInt::add takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. x + yを返す。

6.1.6.2.8 BigInt::subtract ( x, y )

The abstract operation BigInt::subtract takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. x - yを返す。

6.1.6.2.9 BigInt::leftShift ( x, y )

The abstract operation BigInt::leftShift takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. y < 0なら、
    1. (floor((x) / 2-(y)))を返す。
  2. x × 2yを返す。
Note
ここでの意味論は、BigIntを無限長のbinary two's complement digitsの文字列として扱うbitwise shiftと等価であるべきです。

6.1.6.2.10 BigInt::signedRightShift ( x, y )

The abstract operation BigInt::signedRightShift takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. BigInt::leftShift(x, -y)を返す。

6.1.6.2.11 BigInt::unsignedRightShift ( x, y )

The abstract operation BigInt::unsignedRightShift takes arguments x (a BigInt) and y (a BigInt) and returns a throw completion. It performs the following steps when called:

  1. TypeError例外をthrowする。

6.1.6.2.12 BigInt::lessThan ( x, y )

The abstract operation BigInt::lessThan takes arguments x (a BigInt) and y (a BigInt) and returns a Boolean. It performs the following steps when called:

  1. (x) < (y)なら、trueを返す。
  2. falseを返す。

6.1.6.2.13 BigInt::equal ( x, y )

The abstract operation BigInt::equal takes arguments x (a BigInt) and y (a BigInt) and returns a Boolean. It performs the following steps when called:

  1. (x) = (y)なら、trueを返す。
  2. falseを返す。

6.1.6.2.14 BinaryAnd ( x, y )

The abstract operation BinaryAnd takes arguments x (0 or 1) and y (0 or 1) and returns 0 or 1. It performs the following steps when called:

  1. x = 1かつy = 1なら、1を返す。
  2. 0を返す。

6.1.6.2.15 BinaryOr ( x, y )

The abstract operation BinaryOr takes arguments x (0 or 1) and y (0 or 1) and returns 0 or 1. It performs the following steps when called:

  1. x = 1またはy = 1なら、1を返す。
  2. 0を返す。

6.1.6.2.16 BinaryXor ( x, y )

The abstract operation BinaryXor takes arguments x (0 or 1) and y (0 or 1) and returns 0 or 1. It performs the following steps when called:

  1. x = 1かつy = 0なら、1を返す。
  2. x = 0かつy = 1なら、1を返す。
  3. 0を返す。

6.1.6.2.17 BigIntBitwiseOp ( op, x, y )

The abstract operation BigIntBitwiseOp takes arguments op (&, ^, or |), x (a BigInt), and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. x(x)に設定する。
  2. y(y)に設定する。
  3. resultを0とする。
  4. shiftを0とする。
  5. (x = 0またはx = -1)かつ(y = 0またはy = -1)になるまで、繰り返す
    1. xDigitx modulo 2とする。
    2. yDigity modulo 2とする。
    3. op&なら、
      1. resultresult + 2shift × BinaryAnd(xDigit, yDigit)に設定する。
    4. そうでなく、op|なら、
      1. resultresult + 2shift × BinaryOr(xDigit, yDigit)に設定する。
    5. そうでなければ、
      1. Assert: op^である。
      2. resultresult + 2shift × BinaryXor(xDigit, yDigit)に設定する。
    6. shiftshift + 1に設定する。
    7. xを(x - xDigit) / 2に設定する。
    8. yを(y - yDigit) / 2に設定する。
  6. op&なら、
    1. signBitBinaryAnd(x modulo 2, y modulo 2)とする。
  7. そうでなく、op|なら、
    1. signBitBinaryOr(x modulo 2, y modulo 2)とする。
  8. そうでなければ、
    1. Assert: op^である。
    2. signBitBinaryXor(x modulo 2, y modulo 2)とする。
  9. signBit ≠ 0なら、
    1. resultresult - 2shiftに設定する。
    2. NOTE: これは符号を拡張します。
  10. resultのBigInt valueを返す。

6.1.6.2.18 BigInt::bitwiseAND ( x, y )

The abstract operation BigInt::bitwiseAND takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. BigIntBitwiseOp(&, x, y)を返す。

6.1.6.2.19 BigInt::bitwiseXOR ( x, y )

The abstract operation BigInt::bitwiseXOR takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. BigIntBitwiseOp(^, x, y)を返す。

6.1.6.2.20 BigInt::bitwiseOR ( x, y )

The abstract operation BigInt::bitwiseOR takes arguments x (a BigInt) and y (a BigInt) and returns a BigInt. It performs the following steps when called:

  1. BigIntBitwiseOp(|, x, y)を返す。

6.1.6.2.21 BigInt::toString ( x, radix )

The abstract operation BigInt::toString takes arguments x (a BigInt) and radix (an integer in the inclusive interval from 2 to 36) and returns a String. radixを基数とする位取り記数法を使用してxをStringとして表します。基数rを使用するBigIntの表現に用いられるdigitsは、"0123456789abcdefghijklmnopqrstuvwxyz"の最初のr個のコード単位から順に取られます。0以外のBigIntsの表現は、leading zeroesを決して含みません。 It performs the following steps when called:

  1. x < 0なら、"-"BigInt::toString(-x, radix)のstring-concatenationを返す。
  2. radixを使用するxの表現からなるString値を返す。

6.1.7 Object型

Object型の各インスタンス(単に“Object”とも呼ばれる)は、プロパティの集合を表します。各プロパティは、data propertyまたはaccessor propertyのいずれかです:

  • data propertyは、キー値をECMAScript言語値およびBoolean属性の集合に関連付けます。
  • accessor propertyは、キー値を1つまたは2つのaccessor functions、およびBoolean属性の集合に関連付けます。accessor functionsは、そのプロパティに関連付けられたECMAScript言語値を格納または取得するために使用されます。

オブジェクトのプロパティは、property keysを使用して一意に識別されます。property keyは、StringまたはSymbolのいずれかです。空のStringを含め、すべてのStringsおよびSymbolsはproperty keysとして有効です。property nameは、Stringであるproperty keyです。

integer indexは、CanonicalNumericIndexString(n)が+0𝔽から𝔽(253 - 1)までの包含区間内のintegral Numberを返すようなproperty name nです。array indexは、CanonicalNumericIndexString(n)が+0𝔽から𝔽(232 - 2)までの包含区間内のintegral Numberを返すようなinteger index nです。

Note

すべての非負のsafe integerには、対応するinteger indexがあります。232 - 1を除くすべての32ビット符号なし整数には、対応するarray indexがあります。"-0"integer indexでもarray indexでもありません。

Property keysは、プロパティおよびその値へアクセスするために使用されます。プロパティへのアクセスには2種類あります:値の取得および代入にそれぞれ対応するgetおよびsetです。getおよびsetアクセスを通じてアクセス可能なプロパティには、オブジェクトの直接の一部であるown propertiesと、プロパティ継承関係を通じて別の関連付けられたオブジェクトによって提供されるinherited propertiesの両方が含まれます。Inherited propertiesは、その関連付けられたオブジェクトのown propertiesまたはinherited propertiesのいずれであってもよいです。オブジェクトの各own propertyは、そのオブジェクトの他のown propertiesのキー値とは異なるキー値をそれぞれ持たなければなりません。

すべてのオブジェクトは論理的にはプロパティの集合ですが、そのプロパティへのアクセスおよび操作の意味論が異なる複数の形式のオブジェクトがあります。複数の形式のオブジェクトの定義については、6.1.7.2を参照してください。

加えて、一部のオブジェクトはcallableです。これらはfunctionsまたはfunction objectsと呼ばれ、以下でさらに説明されます。ECMAScriptにおけるすべてのfunctionsはObject型のメンバーです。

6.1.7.1 プロパティ属性

属性は、この仕様において、Table 3に記述されるObjectプロパティの状態を定義し説明するために使用されます。明示的に指定されない限り、各属性の初期値はそのDefault Valueです。

Table 3: Attributes of an Object property
属性名 それが存在するプロパティの種類 値のドメイン Default Value 説明
[[Value]] data property ECMAScript言語値 undefined プロパティのgetアクセスによって取得される値。
[[Writable]] data property Boolean false falseの場合、ECMAScriptコードが[[Set]]を使用してそのプロパティの[[Value]]属性を変更しようとしても成功しません。
[[Get]] accessor property Objectまたはundefined undefined 値がObjectである場合、それはfunction objectでなければなりません。プロパティのgetアクセスが実行されるたびに、プロパティ値を取得するため、空のarguments listでそのfunctionの[[Call]] internal method(Table 5)が呼び出されます。
[[Set]] accessor property Objectまたはundefined undefined 値がObjectである場合、それはfunction objectでなければなりません。プロパティのsetアクセスが実行されるたびに、代入された値を唯一のargumentとして含むarguments listでそのfunctionの[[Call]] internal method(Table 5)が呼び出されます。プロパティの[[Set]] internal methodの効果は、そのプロパティの[[Get]] internal methodへの後続の呼び出しによって返される値に影響を及ぼすことがありますが、必須ではありません。
[[Enumerable]] data propertyまたはaccessor property Boolean false trueの場合、そのプロパティはfor-in列挙(14.7.5を参照)によって列挙されます。そうでない場合、そのプロパティはnon-enumerableであると言われます。
[[Configurable]] data propertyまたはaccessor property Boolean false falseの場合、そのプロパティを削除したり、data propertyからaccessor propertyへ、またはaccessor propertyからdata propertyへ変更したり、その属性に変更を加えたり(既存の[[Value]]を置き換えること、または[[Writable]]falseに設定することを除く)しようとしても失敗します。

6.1.7.2 Object Internal Methods and Internal Slots

ECMAScriptにおけるオブジェクトの実際の意味論は、internal methodsと呼ばれるアルゴリズムを通じて指定されます。ECMAScriptエンジン内の各オブジェクトは、その実行時の振る舞いを定義するinternal methodsの集合に関連付けられています。これらのinternal methodsはECMAScript言語の一部ではありません。これらは、この仕様によって説明目的でのみ定義されます。しかし、ECMAScriptの実装内の各オブジェクトは、それに関連付けられたinternal methodsによって指定されるとおりに振る舞わなければなりません。これが実現される正確な方法は実装によって決定されます。

Internal method namesは多態的です。これは、共通のinternal method nameが異なるオブジェクト値に対して呼び出されたとき、それらが異なるアルゴリズムを実行し得ることを意味します。internal methodが呼び出される実際のオブジェクトは、その呼び出しの“target”です。実行時に、あるアルゴリズムの実装が、そのオブジェクトがサポートしていないinternal methodを使用しようとした場合、TypeError例外がthrowされます。

Internal slotsは、オブジェクト、Symbols、またはPrivate Namesに関連付けられ、さまざまなECMAScript仕様アルゴリズムによって使用される内部状態に対応します。Internal slotsはオブジェクトのプロパティではなく、継承されません。特定のinternal slot仕様に応じて、そのような状態は任意のECMAScript言語型の値、または特定のECMAScript仕様型の値で構成される場合があります。明示的に別途指定されない限り、internal slotsはオブジェクト、Symbol、またはPrivate Nameを作成する過程の一部として割り当てられ、動的に追加されることはありません。別途指定されない限り、internal slotの初期値は値undefinedです。この仕様内のさまざまなアルゴリズムは、internal slotsを持つ値を作成します。しかし、ECMAScript言語はinternal slotsを操作する直接の方法を提供しません。

すべてのオブジェクトは[[PrivateElements]]という名前のinternal slotを持ち、これはPrivateElementsListです。このListは、そのオブジェクトのprivate fields、methods、およびaccessorsの値を表します。初期状態では、空のListです。

Internal methodsおよびinternal slotsは、この仕様内では二重角括弧[[ ]]で囲まれた名前を使用して識別されます。

Table 4は、この仕様で使用され、ECMAScriptコードによって作成または操作されるすべてのオブジェクトに適用可能なessential internal methodsを要約します。すべてのオブジェクトは、すべてのessential internal methodsについてアルゴリズムを持たなければなりません。しかし、すべてのオブジェクトがそれらのメソッドについて同じアルゴリズムを使用するとは限りません。

ordinary objectは、以下のすべての基準を満たすオブジェクトです:

  • Table 4に列挙されるinternal methodsについて、そのオブジェクトは10.1で定義されるものを使用します。
  • そのオブジェクトが[[Call]] internal methodを持つ場合、10.2.1で定義されるもの、または10.3.1で定義されるもののいずれかを使用します。
  • そのオブジェクトが[[Construct]] internal methodを持つ場合、10.2.2で定義されるもの、または10.3.2で定義されるもののいずれかを使用します。

exotic objectは、ordinary objectではないオブジェクトです。

この仕様は、exotic objectsの異なる種類を、それらのオブジェクトのinternal methodsによって認識します。特定の種類のexotic objectArray exotic objectbound function exotic objectなど)と振る舞い上は等価であるが、その種類について指定されたinternal methodsの同じ集合を持たないオブジェクトは、その種類のexotic objectとして認識されません。

Table 4および他の同様の表の“Signature”列は、各internal methodの呼び出しパターンを記述します。呼び出しパターンは常に、説明的なparameter namesの括弧付きリストを含みます。parameter nameがECMAScript型名と同じである場合、その名前はparameter値の必要な型を記述します。internal methodが明示的に値を返す場合、そのparameter listの後に記号“→”および返される値の型名が続きます。signaturesで使用される型名は、6節で定義される型に、以下の追加名を加えたものを指します。“any”は、その値が任意のECMAScript言語型であってよいことを意味します。

internal methodは、そのparametersに加えて、常にそのmethod invocationのtargetであるオブジェクトへアクセスできます。

internal methodは暗黙的にCompletion Recordを返します。これは、その呼び出しパターンに示された戻り型の値を包むnormal completion、またはthrow completionのいずれかです。

Table 4: Essential Internal Methods
Internal Method Signature 説明
[[GetPrototypeOf]] ( ) Object | Null このオブジェクトにinherited propertiesを提供するオブジェクトを決定します。null値は、inherited propertiesが存在しないことを示します。
[[SetPrototypeOf]] (Object | Null) Boolean このオブジェクトを、inherited propertiesを提供する別のオブジェクトに関連付けます。nullを渡すことは、inherited propertiesが存在しないことを示します。操作が正常に完了したことを示すtrue、または操作が成功しなかったことを示すfalseを返します。
[[IsExtensible]] ( ) Boolean このオブジェクトに追加のプロパティを加えることが許可されているかどうかを決定します。
[[PreventExtensions]] ( ) Boolean このオブジェクトに新しいプロパティを追加できるかどうかを制御します。操作が成功した場合はtrue、操作が失敗した場合はfalseを返します。
[[GetOwnProperty]] (propertyKey) Undefined | Property Descriptor キーがpropertyKeyであるこのオブジェクトのown propertyについてProperty Descriptorを返すか、そのようなプロパティが存在しない場合はundefinedを返します。
[[DefineOwnProperty]] (propertyKey, propertyDesc) Boolean キーがpropertyKeyであるown propertyを作成または変更し、propertyDescによって記述される状態を持たせます。そのプロパティが正常に作成/更新された場合はtrueを返し、プロパティを作成または更新できなかった場合はfalseを返します。
[[HasProperty]] (propertyKey) Boolean このオブジェクトが、キーがpropertyKeyであるownまたはinherited propertyのいずれかを既に持っているかどうかを示すBoolean値を返します。
[[Get]] (propertyKey, receiver) any このオブジェクトから、キーがpropertyKeyであるプロパティの値を返します。プロパティ値を取得するために何らかのECMAScriptコードを実行する必要がある場合、receiverはそのコードを評価する際のthis値として使用されます。
[[Set]] (propertyKey, value, receiver) Boolean キーがpropertyKeyであるプロパティの値をvalueに設定します。プロパティ値を設定するために何らかのECMAScriptコードを実行する必要がある場合、receiverはそのコードを評価する際のthis値として使用されます。プロパティ値が設定された場合はtrue、設定できなかった場合はfalseを返します。
[[Delete]] (propertyKey) Boolean キーがpropertyKeyであるown propertyをこのオブジェクトから削除します。プロパティが削除されず、まだ存在している場合はfalseを返します。プロパティが削除された、または存在しない場合はtrueを返します。
[[OwnPropertyKeys]] ( ) List of property keys 要素がそのオブジェクトのすべてのown property keysであるListを返します。

Table 5は、functionsとして呼び出され得るオブジェクトによってサポートされる追加のessential internal methodsを要約します。function objectは、[[Call]] internal methodをサポートするオブジェクトです。constructorは、[[Construct]] internal methodをサポートするオブジェクトです。[[Construct]]をサポートするすべてのオブジェクトは[[Call]]をサポートしなければなりません。すなわち、すべてのconstructorfunction objectでなければなりません。したがって、constructorconstructor functionまたはconstructor function objectとも呼ばれ得ます。

Table 5: Additional Essential Internal Methods of Function Objects
Internal Method Signature 説明
[[Call]] (any, a List of any) any このオブジェクトに関連付けられたコードを実行します。function call expressionを通じて呼び出されます。internal methodへのargumentsは、this値と、call expressionによってfunctionに渡されたargumentsを要素とするListです。このinternal methodを実装するオブジェクトはcallableです。
[[Construct]] (a List of any, Object) Object オブジェクトを作成します。new演算子またはsuper呼び出しを通じて呼び出されます。internal methodへの最初のargumentは、constructor呼び出しまたはsuper呼び出しのargumentsを要素とするListです。2番目のargumentは、new演算子が最初に適用されたオブジェクトです。このinternal methodを実装するオブジェクトはconstructorsと呼ばれます。function objectは必ずしもconstructorではなく、そのようなnon-constructor function objects[[Construct]] internal methodを持ちません。

ordinary objectsおよびstandard exotic objectsについてのessential internal methodsの意味論は、10節で指定されます。exotic objectのinternal methodの指定された使用が実装によってサポートされない場合、その使用が試みられたときにTypeError例外をthrowしなければなりません。

6.1.7.3 Essential Internal Methodsの不変条件

ECMAScriptエンジンのObjectsのInternal Methodsは、以下で指定される不変条件の一覧に従わなければなりません。通常のECMAScript Objectsおよびこの仕様におけるすべてのstandard exotic objectsは、これらの不変条件を維持します。ECMAScript Proxy objectsは、[[ProxyHandler]]オブジェクト上で呼び出されるtrapsの結果に対するruntime checksによって、これらの不変条件を維持します。

実装が提供する任意のexotic objectsも、それらのオブジェクトについてこれらの不変条件を維持しなければなりません。これらの不変条件に違反すると、ECMAScriptコードが予測不能な振る舞いを示し、セキュリティ問題を生じさせる可能性があります。ただし、これらの不変条件への違反が実装のメモリ安全性を損なうことは決してあってはなりません。

実装は、その不変条件を強制せずにessential internal methodsの機能を実装する代替インターフェイスを提供するなど、いかなる方法でもこれらの不変条件が迂回されることを許してはなりません。

定義:

  • internal methodのtargetは、そのinternal methodが呼び出されるオブジェクトです。
  • targetは、その[[IsExtensible]] internal methodからfalseを返すこと、またはその[[PreventExtensions]] internal methodからtrueを返すことが観測されている場合、non-extensibleです。
  • non-existentプロパティは、non-extensible target上にown propertyとして存在しないプロパティです。
  • SameValueへのすべての参照は、SameValueアルゴリズムの定義に従います。

戻り値:

任意のinternal methodによって返される値は、以下のいずれかを持つCompletion Recordでなければなりません:

  • [[Type]] = normal[[Target]] = empty、および[[Value]] = そのinternal methodについて下に示される“normal return type”の値、または
  • [[Type]] = throw[[Target]] = empty、および[[Value]] = 任意のECMAScript言語値
Note 1

internal methodは、continue completionbreak completion、またはreturn completionを返してはなりません。

[[GetPrototypeOf]] ( )

  • normal return typeはObjectまたはNullのいずれかです。
  • targetがnon-extensibleであり、[[GetPrototypeOf]]が値protoを返す場合、[[GetPrototypeOf]]への将来の呼び出しはSameValueprotoとして返すべきです。
Note 2

オブジェクトのprototype chainは有限長であるべきです(すなわち、任意のオブジェクトから開始して、[[GetPrototypeOf]] internal methodをその結果に再帰的に適用すると、最終的に値nullに到達するべきです)。しかし、prototype chainに、[[GetPrototypeOf]]についてordinary object定義を使用しないexotic objectsが含まれる場合、この要件をオブジェクトレベルの不変条件として強制することはできません。そのような循環prototype chainは、オブジェクトプロパティへアクセスする際に無限ループをもたらす可能性があります。

[[SetPrototypeOf]] ( proto )

  • normal return typeはBooleanです。
  • targetがnon-extensibleである場合、protoがtargetの観測された[[GetPrototypeOf]]値とSameValueでない限り、[[SetPrototypeOf]]falseを返さなければなりません。

[[IsExtensible]] ( )

  • normal return typeはBooleanです。
  • [[IsExtensible]]falseを返す場合、target上の[[IsExtensible]]への将来のすべての呼び出しはfalseを返さなければなりません。

[[PreventExtensions]] ( )

  • normal return typeはBooleanです。
  • [[PreventExtensions]]trueを返す場合、target上の[[IsExtensible]]への将来のすべての呼び出しはfalseを返さなければならず、targetは現在non-extensibleと見なされます。

[[GetOwnProperty]] ( propertyKey )

  • normal return typeはProperty DescriptorまたはUndefinedのいずれかです。
  • 戻り値がProperty Descriptorである場合、それはfully populated Property Descriptorでなければなりません。
  • propertyKeyがnon-configurable、non-writable own data propertyとして記述される場合、[[GetOwnProperty]] ( propertyKey )への将来のすべての呼び出しは、[[Value]]propertyKey[[Value]]属性とSameValueであるProperty Descriptorを返さなければなりません。
  • [[Writable]]および[[Value]]以外のpropertyKeyの属性が時間の経過とともに変化し得る場合、またはそのプロパティが削除され得る場合、propertyKey[[Configurable]]属性はtrueでなければなりません。
  • [[Writable]]属性がfalseからtrueへ変化し得る場合、[[Configurable]]属性はtrueでなければなりません。
  • targetがnon-extensibleであり、propertyKeyがnon-existentである場合、target上の[[GetOwnProperty]] (propertyKey)への将来のすべての呼び出しは、propertyKeyをnon-existentとして記述しなければなりません(すなわち、[[GetOwnProperty]] (propertyKey)はundefinedを返さなければなりません)。
Note 3

3番目の不変条件の結果として、あるプロパティがdata propertyとして記述され、時間の経過とともに異なる値を返し得る場合、他のessential internal methodsを通じて値を変更する仕組みが公開されていない場合でも、[[Writable]]属性および[[Configurable]]属性のいずれか一方または両方がtrueでなければなりません。

[[DefineOwnProperty]] ( propertyKey, propertyDesc )

  • normal return typeはBooleanです。
  • propertyKeyが以前にtargetのnon-configurable own propertyとして観測されている場合、以下のいずれかでない限り、[[DefineOwnProperty]]falseを返さなければなりません:
    1. propertyKeyがwritable data propertyである。non-configurable writable data propertyは、non-configurable non-writable data propertyに変更できます。
    2. propertyDescのすべての属性がpropertyKeyの属性とSameValueである。
  • targetがnon-extensibleであり、propertyKeyがnon-existent own propertyである場合、[[DefineOwnProperty]] (propertyKey, propertyDesc)はfalseを返さなければなりません。すなわち、non-extensible target objectは新しいプロパティで拡張できません。

[[HasProperty]] ( propertyKey )

  • normal return typeはBooleanです。
  • propertyKeyが以前にtargetのnon-configurable own dataまたはaccessor propertyとして観測されている場合、[[HasProperty]]trueを返さなければなりません。

[[Get]] ( propertyKey, receiver )

  • normal return typeは任意のECMAScript言語型です。
  • propertyKeyが以前に、targetの値valueを持つnon-configurable、non-writable own data propertyとして観測されている場合、[[Get]]valueSameValueを返さなければなりません。
  • propertyKeyが以前に、[[Get]]属性がundefinedであるtargetのnon-configurable own accessor propertyとして観測されている場合、[[Get]]操作はundefinedを返さなければなりません。

[[Set]] ( propertyKey, value, receiver )

  • normal return typeはBooleanです。
  • propertyKeyが以前にtargetのnon-configurable、non-writable own data propertyとして観測されている場合、valuepropertyKey[[Value]]属性とSameValueでない限り、[[Set]]falseを返さなければなりません。
  • propertyKeyが以前に、[[Set]]属性がundefinedであるtargetのnon-configurable own accessor propertyとして観測されている場合、[[Set]]操作はfalseを返さなければなりません。

[[Delete]] ( propertyKey )

  • normal return typeはBooleanです。
  • propertyKeyが以前にtargetのnon-configurable own dataまたはaccessor propertyとして観測されている場合、[[Delete]]falseを返さなければなりません。

[[OwnPropertyKeys]] ( )

  • normal return typeはListです。
  • 返されるListは重複するentriesを含んではなりません。
  • 返されるListの各要素はproperty keyでなければなりません。
  • 返されるListは、以前に観測されたすべてのnon-configurable own propertiesのkeysを少なくとも含まなければなりません。
  • targetがnon-extensibleである場合、返されるListは、[[GetOwnProperty]]を使用して観測可能なtargetのすべてのown propertiesのkeysのみを含まなければなりません。

[[Call]] ( )

[[Construct]] ( )

  • normal return typeはObjectです。
  • targetは[[Call]] internal methodも持たなければなりません。

6.1.7.4 Well-Known Intrinsic Objects

well-known intrinsicsは、この仕様のアルゴリズムによって明示的に参照される組み込みオブジェクトであり、通常realm固有のidentityを持ちます。別途指定されない限り、各intrinsic objectは実際には、realmごとに1つずつ、類似したオブジェクトの集合に対応します。

この仕様内では、%name%のような参照は、current realmに関連付けられ、そのnameに対応するintrinsic objectを意味します。%name.a.b%のような参照は、ECMAScriptコードが評価される前にintrinsic object %name%の"a"プロパティの値の"b"プロパティにアクセスしたかのように意味します。current realmおよびそのintrinsicsの決定は9.4で記述されます。well-known intrinsicsはTable 6に列挙されます。

Table 6: よく知られた組込みオブジェクト
組込み名 グローバル名 ECMAScript 言語での関連付け
%AggregateError% "AggregateError" AggregateError コンストラクタ (20.5.7.1)
%Array% "Array" Array コンストラクタ (23.1.1)
%ArrayBuffer% "ArrayBuffer" ArrayBuffer コンストラクタ (25.1.4)
%ArrayIteratorPrototype% Array Iterator オブジェクトのプロトタイプ (23.1.5)
%AsyncDisposableStack% "AsyncDisposableStack" AsyncDisposableStack コンストラクタ (27.4.1)
%AsyncFromSyncIteratorPrototype% Async-from-Sync Iterator オブジェクトのプロトタイプ (27.1.5)
%AsyncFunction% async 関数オブジェクトのコンストラクタ (27.10.1)
%AsyncGeneratorFunction% async generator 関数オブジェクトのコンストラクタ (27.7.1)
%AsyncGeneratorPrototype% async generator オブジェクトのプロトタイプ (27.9)
%AsyncIteratorPrototype% すべての標準組込み async iterator オブジェクトが間接的に継承するオブジェクト
%Atomics% "Atomics" Atomics オブジェクト (25.4)
%BigInt% "BigInt" BigInt コンストラクタ (21.2.1)
%BigInt64Array% "BigInt64Array" BigInt64Array コンストラクタ (23.2)
%BigUint64Array% "BigUint64Array" BigUint64Array コンストラクタ (23.2)
%Boolean% "Boolean" Boolean コンストラクタ (20.3.1)
%DataView% "DataView" DataView コンストラクタ (25.3.2)
%Date% "Date" Date コンストラクタ (21.4.2)
%decodeURI% "decodeURI" decodeURI 関数 (19.2.6.1)
%decodeURIComponent% "decodeURIComponent" decodeURIComponent 関数 (19.2.6.2)
%DisposableStack% "DisposableStack" DisposableStack コンストラクタ (27.3.1)
%encodeURI% "encodeURI" encodeURI 関数 (19.2.6.3)
%encodeURIComponent% "encodeURIComponent" encodeURIComponent 関数 (19.2.6.4)
%Error% "Error" Error コンストラクタ (20.5.1)
%eval% "eval" eval 関数 (19.2.1)
%EvalError% "EvalError" EvalError コンストラクタ (20.5.5.1)
%FinalizationRegistry% "FinalizationRegistry" FinalizationRegistry コンストラクタ (26.2.1)
%Float16Array% "Float16Array" Float16Array コンストラクタ (23.2)
%Float32Array% "Float32Array" Float32Array コンストラクタ (23.2)
%Float64Array% "Float64Array" Float64Array コンストラクタ (23.2)
%ForInIteratorPrototype% For-In Iterator オブジェクトのプロトタイプ (14.7.5.10)
%Function% "Function" Function コンストラクタ (20.2.1)
%GeneratorFunction% generator 関数オブジェクトのコンストラクタ (27.6.1)
%GeneratorPrototype% generator オブジェクトのプロトタイプ (27.8)
%Int8Array% "Int8Array" Int8Array コンストラクタ (23.2)
%Int16Array% "Int16Array" Int16Array コンストラクタ (23.2)
%Int32Array% "Int32Array" Int32Array コンストラクタ (23.2)
%isFinite% "isFinite" isFinite 関数 (19.2.2)
%isNaN% "isNaN" isNaN 関数 (19.2.3)
%Iterator% "Iterator" Iterator コンストラクタ (27.1.3.1)
%IteratorHelperPrototype% Iterator Helper オブジェクトのプロトタイプ (27.1.2.1)
%JSON% "JSON" JSON オブジェクト (25.5)
%Map% "Map" Map コンストラクタ (24.1.1)
%MapIteratorPrototype% Map Iterator オブジェクトのプロトタイプ (24.1.5)
%Math% "Math" Math オブジェクト (21.3)
%Number% "Number" Number コンストラクタ (21.1.1)
%Object% "Object" Object コンストラクタ (20.1.1)
%parseFloat% "parseFloat" parseFloat 関数 (19.2.4)
%parseInt% "parseInt" parseInt 関数 (19.2.5)
%Promise% "Promise" Promise コンストラクタ (27.5.3)
%Proxy% "Proxy" Proxy コンストラクタ (28.2.1)
%RangeError% "RangeError" RangeError コンストラクタ (20.5.5.2)
%ReferenceError% "ReferenceError" ReferenceError コンストラクタ (20.5.5.3)
%Reflect% "Reflect" Reflect オブジェクト (28.1)
%RegExp% "RegExp" RegExp コンストラクタ (22.2.4)
%RegExpStringIteratorPrototype% RegExp String Iterator オブジェクトのプロトタイプ (22.2.9)
%Set% "Set" Set コンストラクタ (24.2.2)
%SetIteratorPrototype% Set Iterator オブジェクトのプロトタイプ (24.2.6)
%SharedArrayBuffer% "SharedArrayBuffer" SharedArrayBuffer コンストラクタ (25.2.3)
%String% "String" String コンストラクタ (22.1.1)
%StringIteratorPrototype% String Iterator オブジェクトのプロトタイプ (22.1.5)
%SuppressedError% "SuppressedError" SuppressedError コンストラクタ (20.5.8.1)
%Symbol% "Symbol" Symbol コンストラクタ (20.4.1)
%SyntaxError% "SyntaxError" SyntaxError コンストラクタ (20.5.5.4)
%ThrowTypeError% 無条件に %TypeError% の新しいインスタンスを投げる関数オブジェクト
%TypedArray% すべての typed Array コンストラクタのスーパークラス (23.2.1)
%TypeError% "TypeError" TypeError コンストラクタ (20.5.5.5)
%Uint8Array% "Uint8Array" Uint8Array コンストラクタ (23.2)
%Uint8ClampedArray% "Uint8ClampedArray" Uint8ClampedArray コンストラクタ (23.2)
%Uint16Array% "Uint16Array" Uint16Array コンストラクタ (23.2)
%Uint32Array% "Uint32Array" Uint32Array コンストラクタ (23.2)
%URIError% "URIError" URIError コンストラクタ (20.5.5.6)
%WeakMap% "WeakMap" WeakMap コンストラクタ (24.3.1)
%WeakRef% "WeakRef" WeakRef コンストラクタ (26.1.1)
%WeakSet% "WeakSet" WeakSet コンストラクタ (24.4.1)
%WrapForValidIteratorPrototype% Iterator.from によって返されるラップ済みイテレータオブジェクトのプロトタイプ (27.1.3.2.2.1)
Note

Table 103に追加のentriesがあります。

6.2 ECMAScript仕様型

仕様型は、ECMAScript言語構文およびECMAScript言語型の意味論を記述するためにアルゴリズム内で使用されるメタ値に対応します。仕様型には、Reference RecordListCompletion RecordProperty DescriptorEnvironment RecordAbstract Closure、およびData Blockが含まれます。仕様型値は、ECMAScript実装内の特定の実体に必ずしも対応しない仕様上の人工物です。仕様型値は、ECMAScript式評価の中間結果を記述するために使用される場合がありますが、そのような値をオブジェクトのプロパティやECMAScript言語変数の値として格納することはできません。

6.2.1 Enum仕様型

Enumsは、仕様内部の値であり、ECMAScriptコードから直接観測できません。Enumsはsans-serif書体を使用したupper kebab caseで表記されます。たとえば、Completion Record[[Type]]フィールドは、normalreturn、またはthrowのような値を取ります。Enumsはその名前以外の特徴を持ちません。enumの名前は、それを他のenumsと区別すること以外の目的を持たず、文脈におけるその使用法や意味について何も含意しません。

6.2.2 ListおよびRecord仕様型

List型は、new式、関数呼び出し、および単純な順序付き値リストが必要な他のアルゴリズムにおけるargument lists(13.3.8を参照)の評価を説明するために使用されます。List型の値は、個々の値を含むlist elementsの単純な順序列です。これらの列は任意の長さであってよいです。listの要素は、0-origin indicesを使用してランダムアクセスできます。表記上の便宜のため、List要素へアクセスするためにarray-like syntaxを使用できます。たとえば、args[2]はList argsの3rd要素を表す省略表現です。

アルゴリズムが順序を指定せずにListの要素を反復する場合、使用される順序はList内の要素の順序です。

この仕様内では、表記上の便宜のため、新しいList値を表現するためにliteral syntaxを使用できます。たとえば、« 1, 2 »は、それぞれ特定の値に初期化された2つの要素を持つList値を定義します。新しい空のListは« »として表現できます。

この仕様では、“A, B, ...のlist-concatenation”(各argumentが空であってもよいListである場合)という句は、各argumentの要素(順序どおり)の連結(順序どおり)を要素とする新しいList値を表します。

StringsのListに適用される場合、“lexicographic code unit orderに従ってソートされる”という句は、より短い文字列の長さまで各コード単位の数値でソートし、すべてが等しい場合はより短い文字列をより長い文字列の前にソートすることを意味します。これは抽象操作IsLessThanで記述されます。

Record型は、この仕様のアルゴリズム内のデータ集約を記述するために使用されます。Record型値は、1つ以上の名前付きフィールドで構成されます。各フィールドの値はECMAScript言語値または仕様値です。フィールド名は常に二重角括弧で囲まれます。たとえば[[Value]]です。

この仕様内では、表記上の便宜のため、Record値を表現するためにobject literal-like syntaxを使用できます。たとえば、{ [[Field1]]: 42, [[Field2]]: false, [[Field3]]: empty }は、それぞれ特定の値に初期化された3つのフィールドを持つRecord値を定義します。フィールド名の順序は重要ではありません。明示的に列挙されていないフィールドは存在しないものと見なされます。

仕様テキストおよびアルゴリズムでは、Record値の特定のフィールドを参照するためにdot notationを使用できます。たとえば、Rが前段落に示されたrecordである場合、R.[[Field2]]は“Rの[[Field2]]という名前のフィールド”を表す省略表現です。

一般的に使用されるRecordフィールドの組み合わせに対するSchemaには名前が付けられる場合があり、その名前は、記述されている特定の種類の集約を識別するためにliteral Record値の接頭辞として使用できます。例:PropertyDescriptor { [[Value]]: 42, [[Writable]]: false, [[Configurable]]: true }。

6.2.3 SetおよびRelation仕様型

Set型は、memory modelで使用するための順序なし要素の集合を説明するために使用されます。これは同じ名前のECMAScriptコレクション型とは異なります。曖昧さを避けるため、この仕様内ではECMAScriptコレクションのインスタンスは一貫して“Set objects”と呼ばれます。Set型の値は要素の単純な集合であり、同じ要素が複数回現れることはありません。要素はSetsへ追加されたり、Setsから削除されたりできます。Setsは互いにunion、intersection、またはsubtractionを行うことができます。

Relation型は、Sets上の制約を説明するために使用されます。Relation型の値は、その値域からの値の順序対のSetです。たとえば、Memory events上のRelationは、Memory eventsの順序対の集合です。Relation Rと、Rの値域内の2つの値aおよびbについて、a R bは、順序対(a, b)がRのメンバーであることを表す省略表現です。Relationは、ある条件に関して、その条件を満たす最小のRelationである場合、least Relationです。

strict partial orderは、以下を満たすRelation値Rです。

  • Rのdomain内のすべてのab、およびcについて:

    • a R aではなく、かつ
    • a R bかつb R cなら、a R cである。
Note 1

上記の2つの性質は、それぞれirreflexivityおよびtransitivityと呼ばれます。

strict total orderは、以下を満たすRelation値Rです。

  • Rのdomain内のすべてのab、およびcについて:

    • abである、またはa R bである、またはb R aであり、かつ
    • a R aではなく、かつ
    • a R bかつb R cなら、a R cである。
Note 2

上記の3つの性質は、それぞれtotality、irreflexivity、およびtransitivityと呼ばれます。

6.2.4 Completion Record仕様型

Completion Record仕様型は、値の実行時伝播および、制御の非局所的移動を行う文(breakcontinuereturnおよびthrow)の振る舞いなどの制御フローを説明するために使用されます。

Completion Recordsは、Table 7で定義されるフィールドを持ちます。

Table 7: Completion Record Fields
フィールド名 意味
[[Type]] normal, break, continue, return, or throw 発生したcompletionの種類。
[[Value]] Completion Recordを除く任意の値 生成された値。
[[Target]] Stringまたはempty directed control transfersのtarget label。

以下の省略用語は、Completion Recordsを参照するために使用されることがあります。

  • normal completionは、[[Type]]値がnormalである任意のCompletion Recordを指します。
  • break completionは、[[Type]]値がbreakである任意のCompletion Recordを指します。
  • continue completionは、[[Type]]値がcontinueである任意のCompletion Recordを指します。
  • return completionは、[[Type]]値がreturnである任意のCompletion Recordを指します。
  • throw completionは、[[Type]]値がthrowである任意のCompletion Recordを指します。
  • abrupt completionは、[[Type]]値がnormal以外である任意のCompletion Recordを指します。
  • ある型の値を含むnormal completionは、その[[Value]]フィールドにその型の値を持つnormal completionを指します。

この仕様で定義されるcallable objectsは、normal completionまたはthrow completionのみを返します。他の種類のCompletion Recordを返すことは編集上の誤りと見なされます。

Implementation-defined callable objectsは、normal completionまたはthrow completionのいずれかを返さなければなりません。

6.2.4.1 NormalCompletion ( value )

The abstract operation NormalCompletion takes argument value (any value except a Completion Record) and returns a normal completion. It performs the following steps when called:

  1. Completion Record { [[Type]]: normal, [[Value]]: value, [[Target]]: empty }を返す。

6.2.4.2 ThrowCompletion ( value )

The abstract operation ThrowCompletion takes argument value (an ECMAScript language value) and returns a throw completion. It performs the following steps when called:

  1. Completion Record { [[Type]]: throw, [[Value]]: value, [[Target]]: empty }を返す。

6.2.4.3 ReturnCompletion ( value )

The abstract operation ReturnCompletion takes argument value (an ECMAScript language value) and returns a return completion. It performs the following steps when called:

  1. Completion Record { [[Type]]: return, [[Value]]: value, [[Target]]: empty }を返す。

6.2.4.4 UpdateEmpty ( completionRecord, value )

The abstract operation UpdateEmpty takes arguments completionRecord (a Completion Record) and value (any value except a Completion Record) and returns a Completion Record. It performs the following steps when called:

  1. Assert: completionRecordreturn completionまたはthrow completionのいずれかであるなら、completionRecord.[[Value]]emptyではない。
  2. completionRecord.[[Value]]emptyでないなら、? completionRecordを返す。
  3. Completion Record { [[Type]]: completionRecord.[[Type]], [[Value]]: value, [[Target]]: completionRecord.[[Target]] }を返す。

6.2.5 Reference Record仕様型

Reference Record型は、deletetypeof、代入演算子、superキーワード、およびその他の言語機能のような演算子の振る舞いを説明するために使用されます。たとえば、代入の左辺オペランドはReference Recordを生成することが期待されます。

Reference Recordは、解決済みの名前または(まだ解決されていない可能性のある)プロパティ束縛です。そのフィールドはTable 8によって定義されます。

Table 8: Reference Record Fields
フィールド名 意味
[[Base]] ECMAScript言語値Environment Record、またはunresolvable 束縛を保持する値またはEnvironment Recordunresolvable[[Base]]は、その束縛を解決できなかったことを示します。
[[ReferencedName]] ECMAScript言語値またはPrivate Name 束縛の名前。[[Base]]値がEnvironment Recordである場合は常にStringです。そうでない場合、ToPropertyKeyが実行されるまでは、StringまたはSymbol以外のECMAScript言語値である場合があります。
[[Strict]] Boolean Reference Recordstrict mode codeに由来する場合はtrue、そうでない場合はfalse
[[ThisValue]] ECMAScript言語値またはempty emptyでない場合、そのReference Recordsuperキーワードを使用して表現されたプロパティ束縛を表します。これはSuper Reference Recordと呼ばれ、その[[Base]]値は決してEnvironment Recordにはなりません。この場合、[[ThisValue]]フィールドはReference Recordが作成された時点のthis値を保持します。

以下の抽象操作は、この仕様においてReference Recordsを操作するために使用されます:

6.2.5.1 IsPropertyReference ( refRecord )

The abstract operation IsPropertyReference takes argument refRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:

  1. refRecord.[[Base]]unresolvableなら、falseを返す。
  2. refRecord.[[Base]]Environment Recordなら、falseを返す。
  3. trueを返す。

6.2.5.2 IsUnresolvableReference ( refRecord )

The abstract operation IsUnresolvableReference takes argument refRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:

  1. refRecord.[[Base]]unresolvableなら、trueを返す。
  2. falseを返す。

6.2.5.3 IsSuperReference ( refRecord )

The abstract operation IsSuperReference takes argument refRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:

  1. refRecord.[[ThisValue]]emptyなら、falseを返す。
  2. trueを返す。

6.2.5.4 IsPrivateReference ( refRecord )

The abstract operation IsPrivateReference takes argument refRecord (a Reference Record) and returns a Boolean. It performs the following steps when called:

  1. refRecord.[[ReferencedName]]Private Nameなら、trueを返す。
  2. falseを返す。

6.2.5.5 GetValue ( refRecord )

The abstract operation GetValue takes argument refRecord (a Reference Record or an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It performs the following steps when called:

  1. refRecordReference Recordでないなら、refRecordを返す。
  2. IsUnresolvableReference(refRecord)がtrueなら、ReferenceError例外をthrowする。
  3. IsPropertyReference(refRecord)がtrueなら、
    1. baseObjを ? ToObject(refRecord.[[Base]]) とする。
    2. IsPrivateReference(refRecord)がtrueなら、
      1. PrivateGet(baseObj, refRecord.[[ReferencedName]])を返す。
    3. refRecord.[[ReferencedName]]property keyでないなら、
      1. refRecord.[[ReferencedName]]を ? ToPropertyKey(refRecord.[[ReferencedName]]) に設定する。
    4. baseObj.[[Get]](refRecord.[[ReferencedName]], GetThisValue(refRecord))を返す。
  4. baserefRecord.[[Base]]とする。
  5. Assert: baseEnvironment Recordである。
  6. base.GetBindingValue(refRecord.[[ReferencedName]], refRecord.[[Strict]])を返す(9.1を参照)。
Note

ステップ3.aで作成され得るオブジェクトは、上記の抽象操作およびordinary object [[Get]] internal methodの外部からはアクセスできません。実装は、そのオブジェクトの実際の作成を避けることを選択する場合があります。

6.2.5.6 PutValue ( refRecord, value )

The abstract operation PutValue takes arguments refRecord (a Reference Record or an ECMAScript language value) and value (an ECMAScript language value) and returns either a normal completion containing unused or an abrupt completion. It performs the following steps when called:

  1. refRecordReference Recordでないなら、ReferenceError例外をthrowする。
  2. IsUnresolvableReference(refRecord)がtrueなら、
    1. refRecord.[[Strict]]trueなら、ReferenceError例外をthrowする。
    2. globalObjGetGlobalObject()とする。
    3. Set(globalObj, refRecord.[[ReferencedName]], value, false)を実行する。
    4. unusedを返す。
  3. IsPropertyReference(refRecord)がtrueなら、
    1. baseObjを ? ToObject(refRecord.[[Base]]) とする。
    2. IsPrivateReference(refRecord)がtrueなら、
      1. PrivateSet(baseObj, refRecord.[[ReferencedName]], value)を返す。
    3. refRecord.[[ReferencedName]]property keyでないなら、
      1. refRecord.[[ReferencedName]]を ? ToPropertyKey(refRecord.[[ReferencedName]]) に設定する。
    4. succeededを ? baseObj.[[Set]](refRecord.[[ReferencedName]], value, GetThisValue(refRecord)) とする。
    5. succeededfalseかつrefRecord.[[Strict]]trueなら、TypeError例外をthrowする。
    6. unusedを返す。
  4. baserefRecord.[[Base]]とする。
  5. Assert: baseEnvironment Recordである。
  6. base.SetMutableBinding(refRecord.[[ReferencedName]], value, refRecord.[[Strict]])を返す(9.1を参照)。
Note

ステップ3.aで作成され得るオブジェクトは、上記の抽象操作およびordinary object [[Set]] internal methodの外部からはアクセスできません。実装は、そのオブジェクトの実際の作成を避けることを選択する場合があります。

6.2.5.7 GetThisValue ( refRecord )

The abstract operation GetThisValue takes argument refRecord (a Reference Record) and returns an ECMAScript language value. It performs the following steps when called:

  1. Assert: IsPropertyReference(refRecord)はtrueである。
  2. IsSuperReference(refRecord)がtrueなら、refRecord.[[ThisValue]]を返す。
  3. refRecord.[[Base]]を返す。

6.2.5.8 InitializeReferencedBinding ( refRecord, value )

The abstract operation InitializeReferencedBinding takes arguments refRecord (a Reference Record) and value (an ECMAScript language value) and returns either a normal completion containing unused or an abrupt completion. It performs the following steps when called:

  1. Assert: IsUnresolvableReference(refRecord)はfalseである。
  2. baserefRecord.[[Base]]とする。
  3. Assert: baseEnvironment Recordである。
  4. base.InitializeBinding(refRecord.[[ReferencedName]], value)を返す。

6.2.5.9 MakePrivateReference ( baseValue, privateIdentifier )

The abstract operation MakePrivateReference takes arguments baseValue (an ECMAScript language value) and privateIdentifier (a String) and returns a Reference Record. It performs the following steps when called:

  1. privateEnvrunning execution contextのPrivateEnvironmentとする。
  2. Assert: privateEnvnullでない。
  3. privateNameResolvePrivateIdentifier(privateEnv, privateIdentifier)とする。
  4. Reference Record { [[Base]]: baseValue, [[ReferencedName]]: privateName, [[Strict]]: true, [[ThisValue]]: empty }を返す。

6.2.6 Property Descriptor仕様型

Property Descriptor型は、Objectプロパティ属性の操作および具象化を説明するために使用されます。Property Descriptorは0個以上のフィールドを持つRecordであり、各フィールドの名前は属性名であり、その値は6.1.7.1で指定される対応する属性値です。この仕様内でProperty Descriptor recordsのliteral descriptionsにタグ付けするために使用されるschema nameは“PropertyDescriptor”です。

Property Descriptor値は、特定のフィールドの存在または使用に基づいて、data Property Descriptorsおよびaccessor Property Descriptorsにさらに分類される場合があります。data Property Descriptorは、[[Value]]または[[Writable]]という名前のフィールドのいずれかを含むものです。accessor Property Descriptorは、[[Get]]または[[Set]]という名前のフィールドのいずれかを含むものです。任意のProperty Descriptorは、[[Enumerable]]および[[Configurable]]という名前のフィールドを持つことができます。Property Descriptor値はdata Property Descriptorかつaccessor Property Descriptorの両方であってはなりません。ただし、どちらでもない場合があります(その場合、それはgeneric Property Descriptorです)。fully populated Property Descriptorは、accessor Property Descriptorまたはdata Property Descriptorのいずれかであり、Table 3で定義される対応するフィールドのすべてを持つものです。

以下の抽象操作は、この仕様においてProperty Descriptor値を操作するために使用されます:

6.2.6.1 IsAccessorDescriptor ( propertyDesc )

The abstract operation IsAccessorDescriptor takes argument propertyDesc (a Property Descriptor) and returns a Boolean. It performs the following steps when called:

  1. propertyDesc[[Get]]フィールドを持つなら、trueを返す。
  2. propertyDesc[[Set]]フィールドを持つなら、trueを返す。
  3. falseを返す。

6.2.6.2 IsDataDescriptor ( propertyDesc )

The abstract operation IsDataDescriptor takes argument propertyDesc (a Property Descriptor) and returns a Boolean. It performs the following steps when called:

  1. propertyDesc[[Value]]フィールドを持つなら、trueを返す。
  2. propertyDesc[[Writable]]フィールドを持つなら、trueを返す。
  3. falseを返す。

6.2.6.3 IsGenericDescriptor ( propertyDesc )

The abstract operation IsGenericDescriptor takes argument propertyDesc (a Property Descriptor) and returns a Boolean. It performs the following steps when called:

  1. IsAccessorDescriptor(propertyDesc)がtrueなら、falseを返す。
  2. IsDataDescriptor(propertyDesc)がtrueなら、falseを返す。
  3. trueを返す。

6.2.6.4 FromPropertyDescriptor ( propertyDesc )

The abstract operation FromPropertyDescriptor takes argument propertyDesc (a Property Descriptor or undefined) and returns an Object or undefined. It performs the following steps when called:

  1. propertyDescundefinedなら、undefinedを返す。
  2. objOrdinaryObjectCreate(%Object.prototype%)とする。
  3. Assert: objはown propertiesを持たないextensible ordinary objectである。
  4. propertyDesc[[Value]]フィールドを持つなら、
    1. CreateDataPropertyOrThrow(obj, "value", propertyDesc.[[Value]])を実行する。
  5. propertyDesc[[Writable]]フィールドを持つなら、
    1. CreateDataPropertyOrThrow(obj, "writable", propertyDesc.[[Writable]])を実行する。
  6. propertyDesc[[Get]]フィールドを持つなら、
    1. CreateDataPropertyOrThrow(obj, "get", propertyDesc.[[Get]])を実行する。
  7. propertyDesc[[Set]]フィールドを持つなら、
    1. CreateDataPropertyOrThrow(obj, "set", propertyDesc.[[Set]])を実行する。
  8. propertyDesc[[Enumerable]]フィールドを持つなら、
    1. CreateDataPropertyOrThrow(obj, "enumerable", propertyDesc.[[Enumerable]])を実行する。
  9. propertyDesc[[Configurable]]フィールドを持つなら、
    1. CreateDataPropertyOrThrow(obj, "configurable", propertyDesc.[[Configurable]])を実行する。
  10. objを返す。

6.2.6.5 ToPropertyDescriptor ( obj )

The abstract operation ToPropertyDescriptor takes argument obj (an ECMAScript language value) and returns either a normal completion containing a Property Descriptor or a throw completion. It performs the following steps when called:

  1. objがObjectでないなら、TypeError例外をthrowする。
  2. propertyDescを、初期状態でフィールドを持たない新しいProperty Descriptorとする。
  3. hasEnumerableを ? HasProperty(obj, "enumerable") とする。
  4. hasEnumerabletrueなら、
    1. enumerableToBoolean(? Get(obj, "enumerable"))とする。
    2. propertyDesc.[[Enumerable]]enumerableに設定する。
  5. hasConfigurableを ? HasProperty(obj, "configurable") とする。
  6. hasConfigurabletrueなら、
    1. configurableToBoolean(? Get(obj, "configurable"))とする。
    2. propertyDesc.[[Configurable]]configurableに設定する。
  7. hasValueを ? HasProperty(obj, "value") とする。
  8. hasValuetrueなら、
    1. valueを ? Get(obj, "value") とする。
    2. propertyDesc.[[Value]]valueに設定する。
  9. hasWritableを ? HasProperty(obj, "writable") とする。
  10. hasWritabletrueなら、
    1. writableToBoolean(? Get(obj, "writable"))とする。
    2. propertyDesc.[[Writable]]writableに設定する。
  11. hasGetを ? HasProperty(obj, "get") とする。
  12. hasGettrueなら、
    1. getterを ? Get(obj, "get") とする。
    2. IsCallable(getter)がfalseかつgetterundefinedでないなら、TypeError例外をthrowする。
    3. propertyDesc.[[Get]]getterに設定する。
  13. hasSetを ? HasProperty(obj, "set") とする。
  14. hasSettrueなら、
    1. setterを ? Get(obj, "set") とする。
    2. IsCallable(setter)がfalseかつsetterundefinedでないなら、TypeError例外をthrowする。
    3. propertyDesc.[[Set]]setterに設定する。
  15. propertyDesc[[Get]]フィールドを持つ、またはpropertyDesc[[Set]]フィールドを持つなら、
    1. propertyDesc[[Value]]フィールドを持つ、またはpropertyDesc[[Writable]]フィールドを持つなら、TypeError例外をthrowする。
  16. propertyDescを返す。

6.2.6.6 CompletePropertyDescriptor ( propertyDesc )

The abstract operation CompletePropertyDescriptor takes argument propertyDesc (a Property Descriptor) and returns unused. It performs the following steps when called:

  1. likeRecord { [[Value]]: undefined, [[Writable]]: false, [[Get]]: undefined, [[Set]]: undefined, [[Enumerable]]: false, [[Configurable]]: false }とする。
  2. IsGenericDescriptor(propertyDesc)がtrueまたはIsDataDescriptor(propertyDesc)がtrueなら、
    1. propertyDesc[[Value]]フィールドを持たないなら、propertyDesc.[[Value]]like.[[Value]]に設定する。
    2. propertyDesc[[Writable]]フィールドを持たないなら、propertyDesc.[[Writable]]like.[[Writable]]に設定する。
  3. そうでなければ、
    1. propertyDesc[[Get]]フィールドを持たないなら、propertyDesc.[[Get]]like.[[Get]]に設定する。
    2. propertyDesc[[Set]]フィールドを持たないなら、propertyDesc.[[Set]]like.[[Set]]に設定する。
  4. propertyDesc[[Enumerable]]フィールドを持たないなら、propertyDesc.[[Enumerable]]like.[[Enumerable]]に設定する。
  5. propertyDesc[[Configurable]]フィールドを持たないなら、propertyDesc.[[Configurable]]like.[[Configurable]]に設定する。
  6. unusedを返す。

6.2.7 Environment Record仕様型

Environment Record型は、ネストされた関数およびブロックにおける名前解決の振る舞いを説明するために使用されます。この型およびそれに対する操作は、9.1で定義されます。

6.2.8 Abstract Closure仕様型

Abstract Closure仕様型は、値の集合とともにアルゴリズムステップを参照するために使用されます。Abstract Closuresはメタ値であり、closure(arg1, arg2)のような関数適用形式を使用して呼び出されます。抽象操作と同様に、呼び出しはAbstract Closureによって記述されたアルゴリズムステップを実行します。

Abstract Closureを作成するアルゴリズムステップでは、値は動詞“capture”の後にaliasesのリストを続けることで捕捉されます。Abstract Closureが作成されると、その時点で各aliasに関連付けられている値を捕捉します。Abstract Closureが呼び出されたときに実行されるアルゴリズムを指定するステップでは、各捕捉された値は、その値を捕捉するために使用されたaliasによって参照されます。

Abstract ClosureがCompletion Recordを返す場合、そのCompletion Recordnormal completionまたはthrow completionのいずれかでなければなりません。

Abstract Closuresは、他のアルゴリズムの一部としてインラインで作成されます。以下の例に示します。

  1. addendを41とする。
  2. closureを、parameters (x)を持ち、addendをcaptureし、呼び出されたときに以下のステップを実行する新しいAbstract Closureとする:
    1. x + addendを返す。
  3. valueclosure(1)とする。
  4. Assert: valueは42である。

6.2.9 Data Blocks

Data Block仕様型は、byte-sized(8 bit)の数値の、別個で可変な列を記述するために使用されます。byte valueは、0から255までの包含区間内の整数です。Data Block値は、各byteが初期値0を持つ固定数のbytesで作成されます。

この仕様内では、表記上の便宜のため、Data Block値の個々のbytesへアクセスするためにarray-like syntaxを使用できます。この表記は、Data Block値を0-basedのinteger-indexedなbytes列として提示します。たとえば、dataBlockが5 byteのData Block値である場合、dataBlock[2]を使用してその3rd byteへアクセスできます。

複数のagentsから同時に参照できるメモリ内に存在するdata blockは、Shared Data Blockと指定されます。Shared Data Blockは、(Shared Data Block値の等価性テストの目的で)address-freeであるidentityを持ちます。すなわち、それはblockが任意のprocess内でマップされるvirtual addressesに結び付くのではなく、そのblockが表すメモリ内のlocationsの集合に結び付きます。2つのdata blocksは、それらが含むlocationsの集合が等しい場合に限り等しく、それ以外の場合は等しくなく、それらが含むlocationsの集合のintersectionは空です。最後に、Shared Data BlocksはData Blocksから区別できます。

Shared Data Blocksの意味論は、memory modelによってShared Data Block eventsを使用して定義されます。以下の抽象操作はShared Data Block eventsを導入し、評価意味論とmemory modelのevent semanticsとの間のinterfaceとして機能します。eventsはcandidate executionを形成し、その上でmemory modelがfilterとして機能します。完全な意味論についてはmemory modelを参照してください。

Shared Data Block eventsは、memory modelで定義されるRecordsによってモデル化されます。

以下の抽象操作は、この仕様においてData Block値を操作するために使用されます:

6.2.9.1 CreateByteDataBlock ( size )

The abstract operation CreateByteDataBlock takes argument size (a non-negative integer) and returns either a normal completion containing a Data Block or a throw completion. It performs the following steps when called:

  1. size > 253 - 1なら、RangeError例外をthrowする。
  2. dataBlocksize bytesからなる新しいData Block値とする。そのようなData Blockを作成することが不可能な場合、RangeError例外をthrowする。
  3. dataBlockのすべてのbytesを0に設定する。
  4. dataBlockを返す。

6.2.9.2 CreateSharedByteDataBlock ( size )

The abstract operation CreateSharedByteDataBlock takes argument size (a non-negative integer) and returns either a normal completion containing a Shared Data Block or a throw completion. It performs the following steps when called:

  1. dataBlocksize bytesからなる新しいShared Data Block値とする。そのようなShared Data Blockを作成することが不可能な場合、RangeError例外をthrowする。
  2. agentRecordsurrounding agentAgent Recordとする。
  3. executionagentRecord.[[CandidateExecution]]とする。
  4. eventsRecordを、[[AgentSignifier]]AgentSignifier()であるexecution.[[EventsRecords]]Agent Events Recordとする。
  5. zeroを« 0 »とする。
  6. dataBlockの各index indexについて、以下を行う
    1. WriteSharedMemory { [[Order]]: init, [[NoTear]]: true, [[Block]]: dataBlock, [[ByteIndex]]: index, [[ElementSize]]: 1, [[Payload]]: zero }をeventsRecord.[[EventList]]へappendする。
  7. dataBlockを返す。

6.2.9.3 CopyDataBlockBytes ( toBlock, toIndex, fromBlock, fromIndex, count )

The abstract operation CopyDataBlockBytes takes arguments toBlock (a Data Block or a Shared Data Block), toIndex (a non-negative integer), fromBlock (a Data Block or a Shared Data Block), fromIndex (a non-negative integer), and count (a non-negative integer) and returns unused. It performs the following steps when called:

  1. Assert: fromBlocktoBlockは別個の値である。
  2. fromSizefromBlock内のbytesの数とする。
  3. Assert: fromIndex + countfromSize
  4. toSizetoBlock内のbytesの数とする。
  5. Assert: toIndex + counttoSize
  6. count > 0の間、繰り返す
    1. fromBlockShared Data Blockなら、
      1. agentRecordsurrounding agentAgent Recordとする。
      2. executionagentRecord.[[CandidateExecution]]とする。
      3. eventsRecordを、[[AgentSignifier]]AgentSignifier()であるexecution.[[EventsRecords]]Agent Events Recordとする。
      4. bytesを、唯一の要素が非決定的に選択されたbyte valueであるListとする。
      5. NOTE: 実装では、bytesは基礎となるハードウェア上のnon-atomic read instructionの結果です。この非決定性は、weak consistencyを持つハードウェアの観測可能な振る舞いを記述するためのmemory modelの意味論的規定です。
      6. readEventReadSharedMemory { [[Order]]: unordered, [[NoTear]]: true, [[Block]]: fromBlock, [[ByteIndex]]: fromIndex, [[ElementSize]]: 1 }とする。
      7. readEventeventsRecord.[[EventList]]へappendする。
      8. Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: bytes }をexecution.[[ChosenValues]]へappendする。
      9. toBlockShared Data Blockなら、
        1. WriteSharedMemory { [[Order]]: unordered, [[NoTear]]: true, [[Block]]: toBlock, [[ByteIndex]]: toIndex, [[ElementSize]]: 1, [[Payload]]: bytes }をeventsRecord.[[EventList]]へappendする。
      10. そうでなければ、
        1. toBlock[toIndex]をbytes[0]に設定する。
    2. そうでなければ、
      1. Assert: toBlockShared Data Blockではない。
      2. toBlock[toIndex]をfromBlock[fromIndex]に設定する。
    3. toIndextoIndex + 1に設定する。
    4. fromIndexfromIndex + 1に設定する。
    5. countcount - 1に設定する。
  7. unusedを返す。

6.2.10 PrivateElement仕様型

PrivateElement型は、private class fields、methods、およびaccessorsの仕様で使用されるRecordです。Property Descriptorsはprivate elementsには使用されませんが、private fieldsはnon-configurable、non-enumerable、writable data propertiesと同様に振る舞い、private methodsはnon-configurable、non-enumerable、non-writable data propertiesと同様に振る舞い、private accessorsはnon-configurable、non-enumerable accessor propertiesと同様に振る舞います。

PrivateElement型の値は、Table 9によって定義されるフィールドを持つRecord値です。そのような値はPrivateElementsと呼ばれます。

Table 9: PrivateElement Fields
フィールド名 それが存在する[[Kind]]フィールドの値 意味
[[Key]] All Private Name field、method、またはaccessorの名前。
[[Kind]] All field, method, or accessor elementの種類。
[[Value]] field and method ECMAScript言語値 fieldの値。
[[Get]] accessor function objectまたはundefined private accessorのgetter。
[[Set]] accessor function objectまたはundefined private accessorのsetter。

6.2.11 ClassFieldDefinition Record仕様型

ClassFieldDefinition型は、class fieldsの仕様で使用されるRecordです。

ClassFieldDefinition型の値は、Table 10によって定義されるフィールドを持つRecord値です。そのような値はClassFieldDefinition Recordsと呼ばれます。

Table 10: ClassFieldDefinition Record Fields
フィールド名 意味
[[Name]] Private Name、String、またはSymbol fieldの名前。
[[Initializer]] ECMAScript function objectまたはempty fieldのinitializer(存在する場合)。

6.2.12 Private Names

Private Name仕様型は、private class element(field、method、またはaccessor)のキーを表す、グローバルに一意な値(それ以外は区別できない場合でも、他のいかなるPrivate Nameとも異なるもの)を記述するために使用されます。各Private Nameは、不変の[[Description]] internal slotを持ち、これはStringです。Private NameはPrivateFieldAddまたはPrivateMethodOrAccessorAddによって任意のECMAScriptオブジェクトにインストールでき、その後PrivateGetおよびPrivateSetを使用して読み書きできます。

6.2.13 ClassStaticBlockDefinition Record仕様型

ClassStaticBlockDefinition Recordは、class static initialization blockの実行可能コードをカプセル化するために使用されるRecord値です。

ClassStaticBlockDefinition Recordsは、Table 11に列挙されるフィールドを持ちます。

Table 11: ClassStaticBlockDefinition Record Fields
フィールド名 意味
[[BodyFunction]] ECMAScript function object classのstatic initialization中に呼び出されるfunction object