10 通常および特殊なオブジェクトの挙動

10.1 通常オブジェクトの内部メソッドと内部スロット

すべての通常オブジェクトは [[Prototype]] と呼ばれる内部 スロットを持つ。この内部スロットの値は null またはオ ブジェクトのいずれかであり、継承を実装するために用いられ る。通常オブジェクト obj から propertyKey という名 前のプロパティが欠けているが、その [[Prototype]] オブジ ェクト上には存在していると仮定する。propertyKey[[Prototype]] オブジェクト上のデータプロパティを参照す る場合、obj は get アクセスについてそれを継承し、 propertyKeyobj のプロパティであるかのように振 る舞う。propertyKey[[Prototype]] オブジェクト上 の書込み可能なデータプロパティを参照する場合、obj 上 の propertyKey への set アクセスは、obj 上に propertyKey という名前の新たなデータプロパティを作成 する。propertyKey[[Prototype]] オブジェクト上の 書込み不可なデータプロパティを参照する場合、obj 上の propertyKey への set アクセスは失敗する。 propertyKey[[Prototype]] オブジェクト上のアクセ サプロパティを参照する場合、そのアクセサは get アクセス と set アクセスの両方について obj に継承される。

すべての通常オブジェクトは Boolean 値の [[Extensible]] 内部スロットを持ち、これは 6.1.7.3 で 規定される拡張可能性関連の内部メソッド不変条件を満たすた めに用いられる。すなわち、オブジェクトの [[Extensible]] 内部スロットの値がいったん false に設定されると、その オブジェクトにプロパティを追加すること、オブジェクトの [[Prototype]] 内部スロットの値を変更すること、またはその 後に [[Extensible]] の値を true に変更することは、も はや不可能となる。

以下のアルゴリズム記述において、obj は通常オブジェク ト、propertyKeyproperty key 値、value は任意 の ECMAScript 言語値、そして descProperty Descriptor レコードであると仮定する。

各通常オブジェクト内部メソッドは、同様の名前を持つ抽象操 作へ委譲する。そのような抽象操作が別の内部メソッドに依存 する場合、その内部メソッドは、同様の名前を持つ抽象操作を 直接呼び出すのではなく obj に対して呼び出される。これ らの意味論により、通常オブジェクト内部メソッドが特殊オブ ジェクトに適用されたとき、それらの上書きされた内部メソッ ドが呼び出されることが保証される。

10.1.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of an ordinary object obj takes no arguments and returns a normal completion containing either an Object or null. It performs the following steps when called:

  1. OrdinaryGetPrototypeOf(obj) を返す。

10.1.1.1 OrdinaryGetPrototypeOf ( obj )

The abstract operation OrdinaryGetPrototypeOf takes argument obj (an Object) and returns an Object or null. It performs the following steps when called:

  1. obj.[[Prototype]] を返す。

10.1.2 [[SetPrototypeOf]] ( proto )

The [[SetPrototypeOf]] internal method of an ordinary object obj takes argument proto (an Object or null) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. OrdinarySetPrototypeOf(obj, proto) を返す。

10.1.2.1 OrdinarySetPrototypeOf ( obj, proto )

The abstract operation OrdinarySetPrototypeOf takes arguments obj (an Object) and proto (an Object or null) and returns a Boolean. It performs the following steps when called:

  1. currentobj.[[Prototype]] とする。
  2. SameValue(proto, current) が true なら、true を返す。
  3. extensibleobj.[[Extensible]] とする。
  4. extensiblefalse なら、false を返す。
  5. cursorproto とする。
  6. donefalse とする。
  7. donefalse の間、繰り返す
    1. cursornull なら、
      1. donetrue に設定する。
    2. Else if SameValue(cursor, obj) が true なら、
      1. false を返す。
    3. Else,
      1. cursor.[[GetPrototypeOf]]10.1.1 で定義された通常オブジェクト内部メソッドで なければ、donetrue に設定する。
      2. Else, cursorcursor.[[Prototype]] に設定 する。
  8. obj.[[Prototype]]proto に設定する。
  9. true を返す。
Note

手順 7 のループは、[[GetPrototypeOf]][[SetPrototypeOf]] に通常オブジェクト定義を用いるオ ブジェクトのみを含む prototype chain に循環が生じないこ とを保証する。

10.1.3 [[IsExtensible]] ( )

The [[IsExtensible]] internal method of an ordinary object obj takes no arguments and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. OrdinaryIsExtensible(obj) を返す。

10.1.3.1 OrdinaryIsExtensible ( obj )

The abstract operation OrdinaryIsExtensible takes argument obj (an Object) and returns a Boolean. It performs the following steps when called:

  1. obj.[[Extensible]] を返す。

10.1.4 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of an ordinary object obj takes no arguments and returns a normal completion containing true. It performs the following steps when called:

  1. OrdinaryPreventExtensions(obj) を返す。

10.1.4.1 OrdinaryPreventExtensions ( obj )

The abstract operation OrdinaryPreventExtensions takes argument obj (an Object) and returns true. It performs the following steps when called:

  1. obj.[[Extensible]]false に設定する。
  2. true を返す。

10.1.5 [[GetOwnProperty]] ( propertyKey )

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

  1. OrdinaryGetOwnProperty(obj, propertyKey) を返す。

10.1.5.1 OrdinaryGetOwnProperty ( obj, propertyKey )

The abstract operation OrdinaryGetOwnProperty takes arguments obj (an Object) and propertyKey (a property key) and returns a Property Descriptor or undefined. It performs the following steps when called:

  1. obj が key propertyKey を持つ own property を 持たないなら、undefined を返す。
  2. desc を、フィールドを持たない新しく作成された Property Descriptor とする。
  3. ownProperty を、key が propertyKey である obj の own property とする。
  4. ownPropertydata property なら、
    1. desc.[[Value]]ownProperty[[Value]] 属性の値に設定する。
    2. desc.[[Writable]]ownProperty[[Writable]] 属性の値に設定する。
  5. Else,
    1. Assert: ownPropertyaccessor property で ある。
    2. desc.[[Get]]ownProperty[[Get]] 属性の値に設定する。
    3. desc.[[Set]]ownProperty[[Set]] 属性の値に設定する。
  6. desc.[[Enumerable]]ownProperty[[Enumerable]] 属性の値に設定する。
  7. desc.[[Configurable]]ownProperty[[Configurable]] 属性の値に設定する。
  8. desc を返す。

10.1.6 [[DefineOwnProperty]] ( propertyKey, desc )

The [[DefineOwnProperty]] internal method of an ordinary object obj takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. OrdinaryDefineOwnProperty(obj, propertyKey, desc) を返す。

10.1.6.1 OrdinaryDefineOwnProperty ( obj, propertyKey, desc )

The abstract operation OrdinaryDefineOwnProperty takes arguments obj (an Object), propertyKey (a property key), and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. current を ? obj.[[GetOwnProperty]](propertyKey) とする。
  2. extensible を ? IsExtensible(obj) とする。
  3. ValidateAndApplyPropertyDescriptor(obj, propertyKey, extensible, desc, current) を 返す。

10.1.6.2 IsCompatiblePropertyDescriptor ( extensible, desc, current )

The abstract operation IsCompatiblePropertyDescriptor takes arguments extensible (a Boolean), desc (a Property Descriptor), and current (a Property Descriptor or undefined) and returns a Boolean. It performs the following steps when called:

  1. ValidateAndApplyPropertyDescriptor(undefined, "", extensible, desc, current) を返す。

10.1.6.3 ValidateAndApplyPropertyDescriptor ( obj, propertyKey, extensible, desc, current )

The abstract operation ValidateAndApplyPropertyDescriptor takes arguments obj (an Object or undefined), propertyKey (a property key), extensible (a Boolean), desc (a Property Descriptor), and current (a Property Descriptor or undefined) and returns a Boolean. これは、desc が、指定された extensibility と現 在のプロパティ current を持つオブジェクトのプロパティと して、不変条件を保ちながら 適用できる場合に限り true を返す。そのような適用が可能 であり、かつ objundefined でない場合、それは propertyKey という名前のプロパティ(必要であれば作成 される)に対して実行される。 It performs the following steps when called:

  1. Assert: propertyKeyproperty key である。
  2. currentundefined なら、
    1. extensiblefalse なら、false を返す。
    2. objundefined なら、true を返す。
    3. IsAccessorDescriptor(desc) が true なら、
      1. objpropertyKey という名前の own accessor property を作成し、その [[Get]][[Set]][[Enumerable]][[Configurable]] 属性を、desc がそのフィールドを持つ場合は 対応する値に、そうでなければその属性の 既定値 に設定する。
    4. Else,
      1. objpropertyKey という名前の own data property を作成し、その [[Value]][[Writable]][[Enumerable]][[Configurable]] 属性を、desc がそのフィ ールドを持つ場合は対応する値に、そうでなけれ ばその属性の 既定値 に設定 する。
    5. true を返す。
  3. Assert: current は fully populated な Property Descriptor である。
  4. desc がいかなるフィールドも持たないなら、 true を返す。
  5. current.[[Configurable]]false なら、
    1. desc[[Configurable]] フィールドを持ち、 かつ desc.[[Configurable]]true なら、 false を返す。
    2. desc[[Enumerable]] フィールドを持ち、 かつ desc.[[Enumerable]]current.[[Enumerable]] と異なるなら、false を返す。
    3. IsGenericDescriptor(desc) が false であり、 かつ IsAccessorDescriptor(desc) が IsAccessorDescriptor(current) と異なるなら、 false を返す。
    4. IsAccessorDescriptor(current) が true なら、
      1. desc[[Get]] フィールドを持ち、かつ SameValue(desc.[[Get]], current.[[Get]]) が false なら、false を返す。
      2. desc[[Set]] フィールドを持ち、かつ SameValue(desc.[[Set]], current.[[Set]]) が false なら、false を返す。
    5. Else if current.[[Writable]]false なら、
      1. desc[[Writable]] フィールドを持ち、かつ desc.[[Writable]]true なら、false を返す。
      2. NOTE: SameValueNaN 値に対して true を返すが、これは他の手段で区別できる場合があ る。ここで返ることにより、obj の既存プロパ ティが変更されないことが保証される。
      3. desc[[Value]] フィールドを持つなら、 SameValue(desc.[[Value]], current.[[Value]]) を返す。
  6. objundefined でないなら、
    1. IsDataDescriptor(current) が true であり、 かつ IsAccessorDescriptor(desc) が true なら、
      1. desc[[Configurable]] フィールドを持つ なら、configurabledesc.[[Configurable]] とする; そうでなけれ ば configurablecurrent.[[Configurable]] とする。
      2. desc[[Enumerable]] フィールドを持つな ら、enumerabledesc.[[Enumerable]] と する; そうでなければ enumerablecurrent.[[Enumerable]] とする。
      3. objpropertyKey という名前のプロパ ティを accessor property に置き換え、その [[Configurable]] および [[Enumerable]] 属性 をそれぞれ configurable および enumerable に設定し、[[Get]] および [[Set]] 属性を、desc がそのフィールドを持 つ場合は対応する値に、そうでなければその属性 の 既定値 に設定する。
    2. Else if IsAccessorDescriptor(current) が true であり、かつ IsDataDescriptor(desc) が true なら、
      1. desc[[Configurable]] フィールドを持つ なら、configurabledesc.[[Configurable]] とする; そうでなけれ ば configurablecurrent.[[Configurable]] とする。
      2. desc[[Enumerable]] フィールドを持つな ら、enumerabledesc.[[Enumerable]] と する; そうでなければ enumerablecurrent.[[Enumerable]] とする。
      3. objpropertyKey という名前のプロパ ティを data property に置き換え、その [[Configurable]] および [[Enumerable]] 属性 をそれぞれ configurable および enumerable に設定し、[[Value]] および [[Writable]] 属性を、desc がそのフィールド を持つ場合は対応する値に、そうでなければその 属性の 既定値 に設定する。
    3. Else,
      1. desc の各フィールド名 fieldName につい て、objpropertyKey という名前のプロ パティの fieldName という属性を、 descfieldName フィールドの値に設定 する。
  7. true を返す。

10.1.7 [[HasProperty]] ( propertyKey )

The [[HasProperty]] internal method of an ordinary object obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. OrdinaryHasProperty(obj, propertyKey) を返 す。

10.1.7.1 OrdinaryHasProperty ( obj, propertyKey )

The abstract operation OrdinaryHasProperty takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. hasOwn を ? obj.[[GetOwnProperty]](propertyKey) とする。
  2. hasOwnundefined でなければ、true を返 す。
  3. parent を ? obj.[[GetPrototypeOf]]() とする。
  4. parentnull でなければ、
    1. parent.[[HasProperty]](propertyKey) を返す。
  5. false を返す。

10.1.8 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of an ordinary object obj takes arguments propertyKey (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. OrdinaryGet(obj, propertyKey, receiver) を返 す。

10.1.8.1 OrdinaryGet ( obj, propertyKey, receiver )

The abstract operation OrdinaryGet takes arguments obj (an Object), propertyKey (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. desc を ? obj.[[GetOwnProperty]](propertyKey) とする。
  2. descundefined なら、
    1. parent を ? obj.[[GetPrototypeOf]]() とする。
    2. parentnull なら、undefined を返す。
    3. parent.[[Get]](propertyKey, receiver) を返す。
  3. IsDataDescriptor(desc) が true なら、 desc.[[Value]] を返す。
  4. Assert: IsAccessorDescriptor(desc) is true.
  5. getterdesc.[[Get]] とする。
  6. getterundefined なら、undefined を返す。
  7. Call(getter, receiver) を返す。

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

The [[Set]] internal method of an ordinary object obj takes arguments propertyKey (a property key), value (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. OrdinarySet(obj, propertyKey, value, receiver) を返す。

10.1.9.1 OrdinarySet ( obj, propertyKey, value, receiver )

The abstract operation OrdinarySet takes arguments obj (an Object), propertyKey (a property key), value (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. ownDesc を ? obj.[[GetOwnProperty]](propertyKey) とする。
  2. OrdinarySetWithOwnDescriptor(obj, propertyKey, value, receiver, ownDesc) を返す。

10.1.9.2 OrdinarySetWithOwnDescriptor ( obj, propertyKey, value, receiver, ownDesc )

The abstract operation OrdinarySetWithOwnDescriptor takes arguments obj (an Object), propertyKey (a property key), value (an ECMAScript language value), receiver (an ECMAScript language value), and ownDesc (a Property Descriptor or undefined) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ownDescundefined なら、
    1. parent を ? obj.[[GetPrototypeOf]]() とする。
    2. parentnull でなければ、 ? parent.[[Set]](propertyKey, value, receiver) を返す。
    3. ownDesc を PropertyDescriptor { [[Value]]: undefined, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true } に設定する。
  2. IsDataDescriptor(ownDesc) が true なら、
    1. ownDesc.[[Writable]]false なら、false を返す。
    2. receiver が Object でなければ、false を返 す。
    3. existingDescriptor を ? receiver.[[GetOwnProperty]](propertyKey) とする。
    4. existingDescriptorundefined なら、
      1. Assert: receiver は現在 propertyKey という プロパティを持たない。
      2. CreateDataProperty(receiver, propertyKey, value) を返す。
    5. IsAccessorDescriptor(existingDescriptor) が true なら、false を返す。
    6. existingDescriptor.[[Writable]]false な ら、false を返す。
    7. valueDesc を PropertyDescriptor { [[Value]]: value } とする。
    8. receiver.[[DefineOwnProperty]](propertyKey, valueDesc) を返す。
  3. Assert: IsAccessorDescriptor(ownDesc) is true.
  4. setterownDesc.[[Set]] とする。
  5. setterundefined なら、false を返す。
  6. Call(setter, receiver, « value ») を実行す る。
  7. true を返す。

10.1.10 [[Delete]] ( propertyKey )

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

  1. OrdinaryDelete(obj, propertyKey) を返す。

10.1.10.1 OrdinaryDelete ( obj, propertyKey )

The abstract operation OrdinaryDelete takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. desc を ? obj.[[GetOwnProperty]](propertyKey) とする。
  2. descundefined なら、true を返す。
  3. desc.[[Configurable]]true なら、
    1. obj から名前が propertyKey である own property を除去する。
    2. true を返す。
  4. false を返す。

10.1.11 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of an ordinary object obj takes no arguments and returns a normal completion containing a List of property keys. It performs the following steps when called:

  1. OrdinaryOwnPropertyKeys(obj) を返す。

10.1.11.1 OrdinaryOwnPropertyKeys ( obj )

The abstract operation OrdinaryOwnPropertyKeys takes argument obj (an Object) and returns a List of property keys. It performs the following steps when called:

  1. keys を新しい空の List とする。
  2. obj の各 own property key propertyKey につい て、propertyKeyarray index であるものを、 数値 index 昇順で処理し、
    1. propertyKeykeys に append する。
  3. obj の各 own property key propertyKey につい て、propertyKey が String であり、かつ array index ではないものを、プロパティ作成時刻の 昇順で処理し、
    1. propertyKeykeys に append する。
  4. obj の各 own property key propertyKey につい て、propertyKey が Symbol であるものを、プロ パティ作成時刻の昇順で処理し、
    1. propertyKeykeys に append する。
  5. keys を返す。

10.1.12 OrdinaryObjectCreate ( proto [ , additionalInternalSlotsList ] )

The abstract operation OrdinaryObjectCreate takes argument proto (an Object or null) and optional argument additionalInternalSlotsList (a List of names of internal slots) and returns an Object. これは、新しい通常オブジェクトの実行時作成を規定する ために用いられる。additionalInternalSlotsList は、 [[Prototype]][[Extensible]] に加えて、そのオブジェ クトの一部として定義されなければならない追加内部スロット の名前を含む。additionalInternalSlotsList が与えられ ない場合、新しい空の List が用いられる。 It performs the following steps when called:

  1. internalSlotsList を « [[Prototype]], [[Extensible]] » とする。
  2. additionalInternalSlotsList が存在する場合、 internalSlotsListinternalSlotsListadditionalInternalSlotsListlist-concatenation に設定する。
  3. objMakeBasicObject(internalSlotsList) と する。
  4. obj.[[Prototype]]proto に設定する。
  5. obj を返す。
Note

OrdinaryObjectCreate は MakeBasicObject を呼び出す以 上のことはほとんど行わないが、その使用は特殊オブジェクト ではなく通常オブジェクトを作成する意図を伝える。したがっ て、この仕様では、その後にオブジェクトの内部メソッドを変 更して結果を非通常なものにするようなアルゴリズムからは呼 び出されない。特殊オブジェクトを作成する操作は MakeBasicObject を直接呼び出す。

10.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )

The abstract operation OrdinaryCreateFromConstructor takes arguments constructor (a function object) and intrinsicDefaultProto (a String) and optional argument internalSlotsList (a List of names of internal slots) and returns either a normal completion containing an Object or a throw completion. これは、[[Prototype]] 値が constructor"prototype" プロパティから取得される通常オブジェクトを 作成する。存在しない場合は、intrinsicDefaultProto に よって指定された intrinsic が [[Prototype]] に用いられ る。internalSlotsList は、そのオブジェクトの一部とし て定義されなければならない追加内部スロットの名前を含む。 internalSlotsList が与えられない場合、新しい空の List が用いられる。 It performs the following steps when called:

  1. Assert: intrinsicDefaultProto は、この仕様にお ける intrinsic object の名前である。対応する object は、オブジェクトの [[Prototype]] 値として 使用されることが意図された intrinsic でなければ ならない。
  2. proto を ? GetPrototypeFromConstructor( constructor, intrinsicDefaultProto) とする。
  3. internalSlotsList が存在する場合、slotsListinternalSlotsList とする。
  4. Else, slotsList を新しい空の List とする。
  5. OrdinaryObjectCreate(proto, slotsList) を返 す。

10.1.14 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )

The abstract operation GetPrototypeFromConstructor takes arguments constructor (a function object) and intrinsicDefaultProto (a String) and returns either a normal completion containing an Object or a throw completion. これは、特定の constructor に対応するオブジェクト を作成する際に使用すべき [[Prototype]] 値を決定する。そ の値は、存在する場合、constructor"prototype" プロパティから取得される。そうでなければ、 intrinsicDefaultProto によって指定された intrinsic が [[Prototype]] に用いられる。 It performs the following steps when called:

  1. Assert: intrinsicDefaultProto は、この仕様にお ける intrinsic object の名前である。対応する object は、オブジェクトの [[Prototype]] 値として 使用されることが意図された intrinsic でなければ ならない。
  2. proto を ? Get(constructor, "prototype") と する。
  3. proto が Object でないなら、
    1. realm を ? GetFunctionRealm(constructor) とする。
    2. protorealmintrinsicDefaultProto という名前の intrinsic object に設定する。
  4. proto を返す。
Note

constructor[[Prototype]] 値を提供しない場 合、用いられる既定値は、running execution context か らではなく constructor 関数の realm から取得され る。

10.1.15 RequireInternalSlot ( obj, internalSlot )

The abstract operation RequireInternalSlot takes arguments obj (an ECMAScript language value) and internalSlot (an internal slot name) and returns either a normal completion containing unused or a throw completion. これは、obj が Object であり、かつ与えられた internal slot を持つのでない限り例外を送出する。 It performs the following steps when called:

  1. obj が Object でなければ、TypeError 例外を送 出する。
  2. objinternalSlot internal slot を持たなけ れば、TypeError 例外を送出する。
  3. unused を返す。

10.2 ECMAScript 関数オブジェクト

ECMAScript 関数オブジェクトは、レキシカル環境を閉包 した、パラメータ化された ECMAScript コードをカプセル化 し、そのコードの動的評価をサポートする。ECMAScript 関数 オブジェクトは通常オブジェクトであり、他の通常オブジェク トと同じ内部スロットおよび同じ内部メソッドを持つ。 ECMAScript 関数オブジェクトのコードは、strict mode code11.2.2) であっても non-strict code であってもよい。コードが strict mode code である ECMAScript 関数オブジェクト は、strict function と呼ばれる。コードが strict mode code でないものは、 non-strict function と呼ばれる。

[[Extensible]][[Prototype]] に加えて、 ECMAScript 関数オブジェクトは Table 25 に列挙された内部スロットも持つ。

Table 25: Internal Slots of ECMAScript Function Objects
内部スロット 説明
[[Environment]] an Environment Record 関数が閉包した Environment Record。関数のコード を評価する際に outer environment として用いら れる。
[[PrivateEnvironment]] a PrivateEnvironment Record or null 関数が閉包した Private Name のための PrivateEnvironment Record。この関数が構文上 class の内部に含まれていない場合は null。 関数のコードを評価する際、内側の class に対する outer PrivateEnvironment として用いられる。
[[FormalParameters]] a Parse Node 関数の仮引数リストを定義する source text の root parse node。
[[ECMAScriptCode]] a Parse Node 関数本体を定義する source text の root parse node。
[[ConstructorKind]] base or derived 関数が derived class constructor であるかど うか。
[[Realm]] a Realm Record 関数が作成された realm であり、関数評価時にア クセスされる任意の intrinsic object を提供す る。
[[ScriptOrModule]] a Script Record or a Module Record 関数が作成された script または module。
[[ThisMode]] lexical, strict, or global 関数の仮引数およびコード本体内で this 参照 がどのように解釈されるかを定義する。lexical は、this がレキシカルに外側の関数の this 値を参照することを意味する。strict は、 this 値が関数呼出しによって与えられたとおり に正確に使われることを意味する。global は、 undefined または nullthis 値が global object への参照として解釈され、それ以 外の this 値はまず ToObject に渡されること を意味する。
[[Strict]] a Boolean これが strict function であれば truenon-strict function であれば false
[[HomeObject]] an Object or undefined 関数が super を使用する場合、これは super プロパティ探索が開始されるオブジェク トを [[GetPrototypeOf]] が提供する、そのオブ ジェクトである。
[[SourceText]] a sequence of Unicode code points 関数を定義する source text
[[Fields]] a List of ClassFieldDefinition Records 関数が class である場合、これは class の非 static field と、それに対応する initializer を表す Record の list である。
[[PrivateMethods]] a List of PrivateElements 関数が class である場合、これは class の非 static private method および accessor を表 す list である。
[[ClassFieldInitializerName]] a String, a Symbol, a Private Name, or empty 関数が class field の initializer として作 成された場合、その field の NamedEvaluation に使用する名前; それ以外では empty
[[IsClassConstructor]] a Boolean 関数が class constructor であるかどうかを示 す。(true の場合、その関数の [[Call]] を呼 び出すと直ちに TypeError 例外が送出され る。)

すべての ECMAScript 関数オブジェクトは、ここで定義 される [[Call]] 内部メソッドを持つ。さらに constructor でもある ECMAScript 関数は、[[Construct]] 内部メソッ ドも持つ。

10.2.1 [[Call]] ( thisArgument, argumentsList )

The [[Call]] internal method of an ECMAScript function object func takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. callerContextrunning execution context とする。
  2. calleeContextPrepareForOrdinaryCall(func, undefined) とする。
  3. Assert: calleeContext はいま running execution context である。
  4. func.[[IsClassConstructor]]true なら、
    1. error を新しく作成された TypeError object とする。
    2. NOTE: errorcalleeContext において func に関連付けられた Realm Record を用い て作成される。
    3. calleeContextexecution context stack から取り除き、callerContextrunning execution context として復元する。
    4. error を送出する。
  5. OrdinaryCallBindThis(func, calleeContext, thisArgument) を実行する。
  6. resultCompletion( OrdinaryCallEvaluateBody(func, argumentsList)) とする。
  7. calleeContextexecution context stack から取り除き、 callerContextrunning execution context として復元する。
  8. resultreturn completion なら、 result.[[Value]] を返す。
  9. Assert: resultthrow completion であ る。
  10. result を返す。
Note

手順 7 において calleeContextexecution context stack から取り除かれるとき、それ が suspend され、後でアクセス可能な Generator による 再開のために保持されている場合には、破棄してはならな い。

10.2.1.1 PrepareForOrdinaryCall ( func, newTarget )

The abstract operation PrepareForOrdinaryCall takes arguments func (an ECMAScript function object) and newTarget (an Object or undefined) and returns an execution context. It performs the following steps when called:

  1. callerContextrunning execution context とする。
  2. calleeContext を新しい ECMAScript code execution context とする。
  3. calleeContext の Function を func に設 定する。
  4. calleeRealmfunc.[[Realm]] とする。
  5. calleeContextRealmcalleeRealm に 設定する。
  6. calleeContext の ScriptOrModule を func.[[ScriptOrModule]] に設定する。
  7. localEnvNewFunctionEnvironment(func, newTarget) とする。
  8. calleeContext の LexicalEnvironment を localEnv に設定する。
  9. calleeContext の VariableEnvironment を localEnv に設定する。
  10. calleeContext の PrivateEnvironment を func.[[PrivateEnvironment]] に設定する。
  11. callerContext がまだ suspend されていなけ れば、callerContext を suspend する。
  12. calleeContextexecution context stack に push する; calleeContext はいま running execution context である。
  13. NOTE: これ以降に生成されるいかなる exception object も calleeRealm に関連付けられる。
  14. calleeContext を返す。

10.2.1.2 OrdinaryCallBindThis ( func, calleeContext, thisArgument )

The abstract operation OrdinaryCallBindThis takes arguments func (an ECMAScript function object), calleeContext (an execution context), and thisArgument (an ECMAScript language value) and returns unused. It performs the following steps when called:

  1. thisModefunc.[[ThisMode]] とする。
  2. thisModelexical なら、unused を返す。
  3. calleeRealmfunc.[[Realm]] とする。
  4. localEnvcalleeContext の LexicalEnvironment とする。
  5. thisModestrict なら、
    1. thisValuethisArgument とする。
  6. Else,
    1. thisArgumentundefined または null のいずれかなら、
      1. globalEnvcalleeRealm.[[GlobalEnv]] とする。
      2. Assert: globalEnvGlobal Environment Record である。
      3. thisValueglobalEnv.[[GlobalThisValue]] とする。
    2. Else,
      1. thisValue を ! ToObject(thisArgument) とする。
      2. NOTE: ToObjectcalleeRealm を用いて wrapper object を生成する。
  7. Assert: localEnvFunction Environment Record である。
  8. Assert: 次の手順が abrupt completion を返す ことは決してない。なぜなら localEnv.[[ThisBindingStatus]]initialized ではないからである。
  9. BindThisValue(localEnv, thisValue) を 実行する。
  10. unused を返す。

10.2.1.3 Runtime Semantics: EvaluateBody

The syntax-directed operation EvaluateBody takes arguments func (an ECMAScript function object) and argumentsList (a List of ECMAScript language values) and returns a return completion or a throw completion. It is defined piecewise over the following productions:

FunctionBody : FunctionStatementList
  1. func および argumentsList を引数として FunctionBodyEvaluateFunctionBody を ? 返す。
ConciseBody : ExpressionBody
  1. func および argumentsList を引数として ConciseBodyEvaluateConciseBody を ? 返す。
GeneratorBody : FunctionBody
  1. func および argumentsList を引数として GeneratorBodyEvaluateGeneratorBody を ? 返す。
AsyncGeneratorBody : FunctionBody
  1. func および argumentsList を引数として AsyncGeneratorBodyEvaluateAsyncGeneratorBody を ? 返す。
AsyncFunctionBody : FunctionBody
  1. func および argumentsList を引数として AsyncFunctionBodyEvaluateAsyncFunctionBody を ? 返す。
AsyncConciseBody : ExpressionBody
  1. func および argumentsList を引数として AsyncConciseBodyEvaluateAsyncConciseBody を ? 返す。
Initializer : = AssignmentExpression
  1. Assert: argumentsList は空である。
  2. Assert: func.[[ClassFieldInitializerName]]empty ではない。
  3. IsAnonymousFunctionDefinition( AssignmentExpression) が true なら、
    1. value を、func.[[ClassFieldInitializerName]] を引数とする InitializerNamedEvaluation の ? とする。
  4. Else,
    1. rhsAssignmentExpression の ? Evaluation とする。
    2. value を ? GetValue(rhs) とする。
  5. ReturnCompletion(value) を返す。
Note

field initializer は関数境界を構成するが、 FunctionDeclarationInstantiation を呼び出しても観測 可能な効果はないため、省略される。

ClassStaticBlockBody : ClassStaticBlockStatementList
  1. Assert: argumentsList は空である。
  2. func を引数として ClassStaticBlockBodyEvaluateClassStaticBlockBody を ? 返す。

10.2.1.4 OrdinaryCallEvaluateBody ( func, argumentsList )

The abstract operation OrdinaryCallEvaluateBody takes arguments func (an ECMAScript function object) and argumentsList (a List of ECMAScript language values) and returns a return completion or a throw completion. It performs the following steps when called:

  1. func および argumentsList を引数として func.[[ECMAScriptCode]]EvaluateBody を ? 返す。

10.2.2 [[Construct]] ( argumentsList, newTarget )

The [[Construct]] internal method of an ECMAScript function object func takes arguments argumentsList (a List of ECMAScript language values) and newTarget (a constructor) and returns either a normal completion containing an Object or a throw completion. It performs the following steps when called:

  1. callerContextrunning execution context とする。
  2. kindfunc.[[ConstructorKind]] とする。
  3. kindbase なら、
    1. thisArgument を ? OrdinaryCreateFromConstructor(newTarget, "%Object.prototype%") とする。
  4. calleeContextPrepareForOrdinaryCall(func, newTarget) とす る。
  5. Assert: calleeContext はいま running execution context である。
  6. kindbase なら、
    1. OrdinaryCallBindThis(func, calleeContext, thisArgument) を実行する。
    2. initializeResultCompletion( InitializeInstanceElements(thisArgument, func)) とする。
    3. initializeResultabrupt completion なら、
      1. calleeContextexecution context stack から取り除き、callerContextrunning execution context として復元する。
      2. initializeResult を返す。
  7. constructorEnvcalleeContext の LexicalEnvironment とする。
  8. resultCompletion( OrdinaryCallEvaluateBody(func, argumentsList)) とする。
  9. calleeContextexecution context stack から取り除き、callerContextrunning execution context として復元する。
  10. resultthrow completion なら、
    1. result を返す。
  11. Assert: resultreturn completion であ る。
  12. result.[[Value]] が Object なら、 result.[[Value]] を返す。
  13. kindbase なら、thisArgument を返す。
  14. result.[[Value]]undefined でないなら、 TypeError 例外を送出する。
  15. thisBinding を ? constructorEnv.GetThisBinding() とする。
  16. Assert: thisBinding は Object である。
  17. thisBinding を返す。

10.2.3 OrdinaryFunctionCreate ( functionPrototype, sourceText, parameterList, body, thisMode, env, privateEnv )

The abstract operation OrdinaryFunctionCreate takes arguments functionPrototype (an Object), sourceText (a sequence of Unicode code points), parameterList (a Parse Node), body (a Parse Node), thisMode (lexical-this or non-lexical-this), env (an Environment Record), and privateEnv (a PrivateEnvironment Record or null) and returns an ECMAScript function object. これは、既定の [[Call]] 内部メソッドを持ち、 [[Construct]] 内部メソッドを持たない(ただし MakeConstructor のような操作によって後から追加される 場合はある)新しい関数の実行時作成を規定するために用いら れる。sourceText は、作成される関数の構文定義の source text である。 It performs the following steps when called:

  1. internalSlotsListTable 25 に列挙された内部スロットとする。
  2. funcOrdinaryObjectCreate( functionPrototype, internalSlotsList) とす る。
  3. func.[[Call]]10.2.1 で規定された定義に設定する。
  4. func.[[SourceText]]sourceText に設定す る。
  5. func.[[FormalParameters]]parameterList に設定する。
  6. func.[[ECMAScriptCode]]body に設定する。
  7. strictIsStrict(body) とする。
  8. func.[[Strict]]strict に設定する。
  9. thisModelexical-this なら、 func.[[ThisMode]]lexical に設定する。
  10. Else if stricttrue なら、 func.[[ThisMode]]strict に設定する。
  11. Else, func.[[ThisMode]]global に設定す る。
  12. func.[[IsClassConstructor]]false に設 定する。
  13. func.[[Environment]]env に設定する。
  14. func.[[PrivateEnvironment]]privateEnv に設定する。
  15. func.[[ScriptOrModule]]GetActiveScriptOrModule() に設定する。
  16. func.[[Realm]]current Realm Record に 設定する。
  17. func.[[HomeObject]]undefined に設定す る。
  18. func.[[Fields]] を新しい空の List に設定す る。
  19. func.[[PrivateMethods]] を新しい空の List に 設定する。
  20. func.[[ClassFieldInitializerName]]empty に設定する。
  21. lenparameterListExpectedArgumentCount とする。
  22. SetFunctionLength(func, len) を実行する。
  23. func を返す。

10.2.4 AddRestrictedFunctionProperties ( func, realm )

The abstract operation AddRestrictedFunctionProperties takes arguments func (a function object) and realm (a Realm Record) and returns unused. It performs the following steps when called:

  1. Assert: realm.[[Intrinsics]].[[%ThrowTypeError%]] は存在し、かつ初期化されている。
  2. throwerrealm.[[Intrinsics]].[[%ThrowTypeError%]] とす る。
  3. DefinePropertyOrThrow(func, "caller", PropertyDescriptor { [[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: true }) を実行する。
  4. DefinePropertyOrThrow(func, "arguments", PropertyDescriptor { [[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: true }) を実行する。
  5. unused を返す。

10.2.4.1 %ThrowTypeError% ( )

この関数は %ThrowTypeError% intrinsic object である。

これは、各 realm ごとに 1 度定義される匿名の built-in function object である。

呼び出されると、次の手順を実行する:

  1. TypeError 例外を送出する。

この関数の [[Extensible]] 内部スロットの値は false である。

この関数の "length" プロパティは { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } という属性を持つ。

この関数の "name" プロパティは { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } という属性を持つ。

10.2.5 MakeConstructor ( func [ , writablePrototype [ , prototype ] ] )

The abstract operation MakeConstructor takes argument func (an ECMAScript function object or a built-in function object) and optional arguments writablePrototype (a Boolean) and prototype (an Object) and returns unused. これは funcconstructor に変換する。 It performs the following steps when called:

  1. func が ECMAScript function object なら、
    1. Assert: IsConstructor(func) is false.
    2. Assert: func"prototype" own property を持たない拡張可能オブジェクトである。
    3. func.[[Construct]]10.2.2 で規定された定義に設定する。
  2. Else,
    1. func.[[Construct]]10.3.2 で規定された定義に設定する。
  3. func.[[ConstructorKind]]base に設定する。
  4. writablePrototype が存在しないなら、 writablePrototypetrue に設定する。
  5. prototype が存在しないなら、
    1. prototypeOrdinaryObjectCreate( %Object.prototype%) に設定する。
    2. DefinePropertyOrThrow(prototype, "constructor", PropertyDescriptor { [[Value]]: func, [[Writable]]: writablePrototype, [[Enumerable]]: false, [[Configurable]]: true }) を実行する。
  6. DefinePropertyOrThrow(func, "prototype", PropertyDescriptor { [[Value]]: prototype, [[Writable]]: writablePrototype, [[Enumerable]]: false, [[Configurable]]: false }) を実行する。
  7. unused を返す。

10.2.6 MakeClassConstructor ( func )

The abstract operation MakeClassConstructor takes argument func (an ECMAScript function object) and returns unused. It performs the following steps when called:

  1. Assert: func.[[IsClassConstructor]] is false.
  2. func.[[IsClassConstructor]]true に設定す る。
  3. unused を返す。

10.2.7 MakeMethod ( func, homeObject )

The abstract operation MakeMethod takes arguments func (an ECMAScript function object) and homeObject (an Object) and returns unused. これは func を method として構成する。 It performs the following steps when called:

  1. Assert: homeObject は通常オブジェクトである。
  2. func.[[HomeObject]]homeObject に設定す る。
  3. unused を返す。

10.2.8 DefineMethodProperty ( homeObject, key, closure, enumerable )

The abstract operation DefineMethodProperty takes arguments homeObject (an Object), key (a property key or Private Name), closure (a function object), and enumerable (a Boolean) and returns either a normal completion containing either a PrivateElement or unused, or an abrupt completion. It performs the following steps when called:

  1. Assert: homeObject は通常かつ拡張可能なオブジェ クトである。
  2. keyPrivate Name なら、 PrivateElement { [[Key]]: key, [[Kind]]: method, [[Value]]: closure } を返す。
  3. desc を PropertyDescriptor { [[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true } とす る。
  4. DefinePropertyOrThrow(homeObject, key, desc) を実行する。
  5. NOTE: DefinePropertyOrThrowabrupt completion を返すのは、key"prototype" である class static method を定義しようとす る場合に限られる。
  6. unused を返す。

10.2.9 SetFunctionName ( func, name [ , prefix ] )

The abstract operation SetFunctionName takes arguments func (a function object) and name (a property key or Private Name) and optional argument prefix (a String) and returns unused. これは func"name" プロパティを追加する。 It performs the following steps when called:

  1. Assert: func"name" own property を持た ない拡張可能オブジェクトである。
  2. name が Symbol なら、
    1. descriptionname.[[Description]] とす る。
    2. descriptionundefined なら、name を 空の String に設定する。
    3. Else, name"["description"]"string-concatenation に設定す る。
  3. Else if namePrivate Name なら、
    1. namename.[[Description]] に設定す る。
  4. func[[InitialName]] internal slot を持つ なら、
    1. func.[[InitialName]]name に設定する。
  5. prefix が存在するなら、
    1. nameprefix と code unit 0x0020 (SPACE) と namestring-concatenation に設定する。
    2. func[[InitialName]] internal slot を持 つなら、
      1. NOTE: 次の手順における選択は、この抽象操作が 呼び出されるたびに独立して行われる。
      2. 任意で、func.[[InitialName]]name に 設定する。
  6. DefinePropertyOrThrow(func, "name", PropertyDescriptor { [[Value]]: name, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }) を実行する。
  7. unused を返す。

10.2.10 SetFunctionLength ( func, length )

The abstract operation SetFunctionLength takes arguments func (a function object) and length (a non-negative integer or +∞) and returns unused. これは func"length" プロパティを追加する。 It performs the following steps when called:

  1. Assert: func"length" own property を持 たない拡張可能オブジェクトである。
  2. DefinePropertyOrThrow(func, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }) を実行する。
  3. unused を返す。

10.2.11 FunctionDeclarationInstantiation ( func, argumentsList )

The abstract operation FunctionDeclarationInstantiation takes arguments func (an ECMAScript function object) and argumentsList (a List of ECMAScript language values) and returns either a normal completion containing unused or a throw completion. funcexecution context が確立される対象の 関数オブジェクトである。

Note

ECMAScript 関数を評価するための execution context が確立されると、新しい Function Environment Record が作成され、各仮引数に対する束縛がその Environment Record においてインスタンス化される。関 数本体内の各宣言もインスタンス化される。関数の仮引数に default value initializer が含まれない場合、本体の宣 言は仮引数と同じ Environment Record 内でインスタンス 化される。default value parameter initializer が 存在する場合、本体の宣言のために 2 つ目の Environment Record が作成される。仮引数および関数は FunctionDeclarationInstantiation の一部として初期 化される。他のすべての束縛は、関数本体の評価中に初期化 される。

呼び出されると、次の手順を実行する:

  1. calleeContextrunning execution context とする。
  2. codefunc.[[ECMAScriptCode]] とする。
  3. strictfunc.[[Strict]] とする。
  4. formalsfunc.[[FormalParameters]] とす る。
  5. parameterNamesformalsBoundNames とする。
  6. parameterNames が重複する要素を持つなら、 hasDuplicatestrue とする; そうでなけ れば hasDuplicatesfalse とする。
  7. simpleParameterListformalsIsSimpleParameterList とする。
  8. hasParameterExpressionsformalsContainsExpression とする。
  9. varNamescodeVarDeclaredNames と する。
  10. varDeclarationscodeVarScopedDeclarations とする。
  11. lexicalNamescodeLexicallyDeclaredNames とする。
  12. functionNames を新しい空の List とする。
  13. functionsToInitialize を新しい空の List とす る。
  14. varDeclarations の各要素 varDecl につい て、List の逆順で、次を行う
    1. varDeclVariableDeclaration でも ForBinding でも BindingIdentifier でも ないなら、
      1. Assert: varDeclFunctionDeclarationGeneratorDeclarationAsyncFunctionDeclarationAsyncGeneratorDeclaration のいずれか である。
      2. fnvarDeclBoundNames の唯一の 要素とする。
      3. functionNamesfn を含まないなら、
        1. fnfunctionNames の先頭要素として 挿入する。
        2. NOTE: 同じ名前に対して複数の function declaration がある場合、最後の宣言が用い られる。
        3. varDeclfunctionsToInitialize の先頭要素として挿入する。
  15. argumentsObjectNeededtrue とする。
  16. func.[[ThisMode]]lexical なら、
    1. NOTE: Arrow function は決して arguments object を持たない。
    2. argumentsObjectNeededfalse に設定 する。
  17. Else if parameterNames"arguments" を 含むなら、
    1. argumentsObjectNeededfalse に設定 する。
  18. Else if hasParameterExpressionsfalse なら、
    1. functionNames"arguments" を含むか、 または lexicalNames"arguments" を 含むなら、
      1. argumentsObjectNeededfalse に設 定する。
  19. stricttrue または hasParameterExpressionsfalse なら、
    1. NOTE: strict mode code 内の eval 呼出し は eval の外から見える新しい束縛を作成で きないため、仮引数に対して必要な Environment Record は 1 つだけである。
    2. envcalleeContext の LexicalEnvironment とする。
  20. Else,
    1. NOTE: 仮引数リストにおける direct eval 呼 出しによって作成された束縛が、仮引数が宣言さ れる環境の外側になることを保証するために、別 の Environment Record が必要である。
    2. calleeEnvcalleeContext の LexicalEnvironment とする。
    3. envNewDeclarativeEnvironment( calleeEnv) とする。
    4. Assert: calleeContext の VariableEnvironment と calleeEnv は同 じ Environment Record である。
    5. calleeContext の LexicalEnvironment を env に設定する。
  21. parameterNames の各 String paramName に ついて、次を行う
    1. alreadyDeclared を ! env.HasBinding(paramName) とする。
    2. NOTE: early error により、重複仮引数名が 起こり得るのは、parameter default value や rest parameter を持たない non-strict function に限られる。
    3. alreadyDeclaredfalse なら、
      1. env.CreateMutableBinding(paramName, false) を実行する。
      2. hasDuplicatestrue なら、
        1. env.InitializeBinding(paramName, undefined) を実行する。
  22. argumentsObjectNeededtrue なら、
    1. stricttrue または simpleParameterListfalse なら、
      1. aoCreateUnmappedArgumentsObject( argumentsList) とする。
    2. Else,
      1. NOTE: mapped argument object は、rest parameter、parameter default value initializer、または destructured parameter を持たない non-strict function に対してのみ提供される。
      2. aoCreateMappedArgumentsObject( func, formals, argumentsList, env) とする。
    3. stricttrue なら、
      1. env.CreateImmutableBinding( "arguments", false) を実行する。
      2. NOTE: strict mode code では early error によりこの束縛への代入の試みは防が れるため、その可変性は観測不能である。
    4. Else,
      1. env.CreateMutableBinding( "arguments", false) を実行する。
    5. env.InitializeBinding("arguments", ao) を実行する。
    6. parameterBindingsparameterNames と « "arguments" » の list-concatenation とする。
  23. Else,
    1. parameterBindingsparameterNames とする。
  24. iteratorRecordCreateListIteratorRecord(argumentsList) とす る。
  25. hasDuplicatestrue なら、
    1. usedEnvundefined とする。
  26. Else,
    1. usedEnvenv とする。
  27. NOTE: 次の手順が ReturnCompletion を返すこと はない。なぜなら、式位置でそのような completion が生じる唯一の方法は YieldExpression の使用 によるが、これは 15.5.1 および 15.6.1early error 規則により parameter list では禁止されているからである。
  28. iteratorRecord および usedEnv を引数とす る formalsIteratorBindingInitialization を ? 実行する。
  29. hasParameterExpressionsfalse なら、
    1. NOTE: 仮引数および top-level var に必要な Environment Record は 1 つだけである。
    2. instantiatedVarNamesList parameterBindings の copy とする。
    3. varNames の各要素 n について、次を行う
      1. instantiatedVarNamesn を含まなけ れば、
        1. ninstantiatedVarNames に append する。
        2. env.CreateMutableBinding(n, false) を実行する。
        3. env.InitializeBinding(n, undefined) を実行する。
    4. varEnvenv とする。
  30. Else,
    1. NOTE: 仮引数リスト内の式によって作成された closure が、関数本体内の宣言を可視にしない ことを保証するために、別の Environment Record が必要である。
    2. varEnvNewDeclarativeEnvironment( env) とする。
    3. calleeContext の VariableEnvironment を varEnv に設定する。
    4. instantiatedVarNames を新しい空の List とする。
    5. varNames の各要素 n について、次を行う
      1. instantiatedVarNamesn を含まなけ れば、
        1. ninstantiatedVarNames に append する。
        2. varEnv.CreateMutableBinding(n, false) を実行する。
        3. parameterBindingsn を含まない か、または functionNamesn を 含むなら、
          1. initialValueundefined とする。
        4. Else,
          1. initialValue を ! env.GetBindingValue(n, false) とする。
        5. varEnv.InitializeBinding(n, initialValue) を実行する。
        6. NOTE: 仮引数と同名の var は、初期状態で 対応する初期化済み仮引数と同じ値を持つ。
  31. stricttrue なら、
    1. lexEnvvarEnv とする。
  32. Else,
    1. ホスト が web browser であるか、または ブロックレベル Function Declaration の Web レガシー互換性意味論 をサポートするなら、
      1. code Contains xtrue である 任意の BlockCaseClauseDefaultClause xStatementList に直接含まれる各 FunctionDeclaration fnDecl について、次を行う
        1. funcNamefnDeclBindingIdentifierStringValue と する。
        2. FunctionDeclaration fnDeclfuncNameBindingIdentifier と する VariableStatement に置き換えて も func に対していかなる early error も生じず、かつ parameterNamesfuncName を含まないなら、
          1. NOTE: funcName に対する var 束縛 は、それが VarDeclaredName でも、仮 引数名でも、別の FunctionDeclaration でもない場合に 限ってここでインスタンス化される。
          2. instantiatedVarNamesfuncName を含まず、かつ funcName"arguments" でないなら、
            1. varEnv.CreateMutableBinding( funcName, false) を実行する。
            2. varEnv.InitializeBinding( funcName, undefined) を実行す る。
            3. funcNameinstantiatedVarNames に append する。
          3. FunctionDeclaration fnDecl が評価されるとき、 15.2.6 で与えられる FunctionDeclaration Evaluation algorithm の代わりに、次 の手順を実行する:
            1. fEnvrunning execution context の VariableEnvironment とする。
            2. bEnvrunning execution context の LexicalEnvironment とする。
            3. fObj を ! bEnv.GetBindingValue(funcName, false) とする。
            4. fEnv.SetMutableBinding( funcName, fObj, false) を 実行する。
            5. unused を返す。
    2. lexEnvNewDeclarativeEnvironment( varEnv) とする。
    3. NOTE: non-strict function は、 direct eval が eval code によって導入さ れる var scoped declaration が、既存の top-level lexically scoped declaration と conflict するかどうかを判定できるよう に、top-level lexical declaration のた めに別の Environment Record を用いる。 strict function ではこれは不要である。な ぜなら strict な direct eval は常に、すべ ての declaration を新しい Environment Record に配置するからである。
  33. calleeContext の LexicalEnvironment を lexEnv に設定する。
  34. lexDeclarationscodeLexicallyScopedDeclarations とする。
  35. lexDeclarations の各要素 lexDecl につい て、次を行う
    1. NOTE: lexical に宣言された名前は、 function/generator declaration、仮引数、 または var 名と同じにはなり得ない。lexical に宣言された名前は、ここではインスタンス化の みが行われ、初期化は行われない。
    2. lexDeclBoundNames の各要素 dn につ いて、次を行う
      1. lexDeclIsConstantDeclarationtrue なら、
        1. lexEnv.CreateImmutableBinding( dn, true) を実行する。
      2. Else,
        1. lexEnv.CreateMutableBinding(dn, false) を実行する。
  36. privateEnvcalleeContext の PrivateEnvironment とする。
  37. functionsToInitialize の各 Parse Node fnDecl について、次を行う
    1. fnfnDeclBoundNames の唯一の要 素とする。
    2. folexEnv および privateEnv を引数 とする fnDeclInstantiateFunctionObject とする。
    3. varEnv.SetMutableBinding(fn, fo, false) を実行する。
  38. unused を返す。

10.3 組込み関数オブジェクト

組込み関数オブジェクトは通常オブジェクトである; それは 10.1 に定められた通常オブジェクトに対する要件を満たさなければ ならない。

すべての通常オブジェクトに要求される内部スロット (10.1 を参照)に加えて、組込み関数オブジェクトは次の内部スロッ トも持たなければならない:

  • [[Realm]]: 関数が作成された realm を表す Realm Record
  • [[InitialName]]: 関数の初期名である String。 20.2.3.5 により使用される。
  • [[Async]]: 関数が BuiltinCallOrConstruct にお いて async な関数呼出しおよび構築の振る舞いを持つかど うかを示す Boolean。

別段の指定がない限り、組込み関数オブジェクトの [[Prototype]] 内部スロットの初期値は %Function.prototype% である。

組込み関数オブジェクトは、 10.3.1 の定義に適合する [[Call]] 内部メソッドを持たなければなら ない。

組込み関数オブジェクトは、それが “constructor” と 記述されている場合、またはこの仕様内の何らかのアルゴリズ ムがその [[Construct]] 内部メソッドを明示的に設定する場 合に限り、[[Construct]] 内部メソッドを持つ。そのような [[Construct]] 内部メソッドは、 10.3.2 の定義に適合しなければならない。

実装は、この仕様で定義されていない追加の組込み関数オブ ジェクトを提供してよい。

10.3.1 [[Call]] ( thisArgument, argumentsList )

The [[Call]] internal method of a built-in function object func takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. BuiltinCallOrConstruct(func, thisArgument, argumentsList, undefined) を返す。

10.3.2 [[Construct]] ( argumentsList, newTarget )

The [[Construct]] internal method of a built-in function object func (when the method is present) takes arguments argumentsList (a List of ECMAScript language values) and newTarget (a constructor) and returns either a normal completion containing an Object or a throw completion. It performs the following steps when called:

  1. result を ? BuiltinCallOrConstruct(func, uninitialized, argumentsList, newTarget) と する。
  2. Assert: result は Object である。
  3. result を返す。

10.3.3 BuiltinCallOrConstruct ( func, thisArgument, argumentsList, newTarget )

The abstract operation BuiltinCallOrConstruct takes arguments func (a built-in function object), thisArgument (an ECMAScript language value or uninitialized), argumentsList (a List of ECMAScript language values), and newTarget (a constructor or undefined) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. callerContextrunning execution context とする。
  2. callerContext がまだ suspend されていなけれ ば、callerContext を suspend する。
  3. calleeContext を新しい execution context とする。
  4. calleeContext の Function を func に設定す る。
  5. calleeRealmfunc.[[Realm]] とする。
  6. calleeContextRealmcalleeRealm に 設定する。
  7. calleeContext の ScriptOrModule を null に設定する。
  8. calleeContext に対して必要な implementation-defined な初期化を実行する。
  9. calleeContextexecution context stack に push する; calleeContext はいま running execution context である。
  10. func.[[Async]]true なら、
    1. promiseCapability を ! NewPromiseCapability(%Promise%) とする。
    2. resultsClosure を、引数を持たず、functhisArgumentargumentsList、および newTarget を capture し、呼び出されたとき 次の手順を実行する新しい Abstract Closure と する:
      1. result を、func の仕様に適合する方法で func評価した結果である Completion Record とする。 thisArgumentuninitialized なら、 this 値は uninitialized である; そうでな ければ thisArgumentthis 値を与え る。argumentsList が名前付き引数を与え る。newTarget が NewTarget 値を与える。
      2. NOTE: func がこの文書で定義されている場合、 “func の仕様” とは、algorithm step ま たはその他の手段により指定されたその振る舞い である。
      3. Completion(result) を返す。
    3. AsyncFunctionStart(promiseCapability, resultsClosure) を実行する。
    4. calleeContextexecution context stack から取り除き、callerContextrunning execution context として復元する。
    5. promiseCapability.[[Promise]] を返す。
  11. result を、func の仕様に適合する方法で func評価した結果である Completion Record とする。thisArgumentuninitialized なら、this 値は uninitialized である; そう でなければ thisArgumentthis 値を与え る。argumentsList が名前付き引数を与える。 newTarget が NewTarget 値を与える。
  12. NOTE: func がこの文書で定義されている場合、 “func の仕様” とは、algorithm step または その他の手段により指定されたその振る舞いである。
  13. calleeContextexecution context stack から取り除き、callerContextrunning execution context として復元する。
  14. result を返す。
Note

calleeContextexecution context stack から取り除かれるとき、それが suspend され、後で再開する ためにアクセス可能な Generator によって保持されている場 合には、破棄してはならない。

10.3.4 CreateBuiltinFunction ( behaviour, length, name, additionalInternalSlotsList [ , realm [ , prototype [ , prefix [ , async ] ] ] ] )

The abstract operation CreateBuiltinFunction takes arguments behaviour (an Abstract Closure, a set of algorithm steps, or some other definition of a function's behaviour provided in this specification), length (a non-negative integer or +∞), name (a property key or a Private Name), and additionalInternalSlotsList (a List of names of internal slots) and optional arguments realm (a Realm Record), prototype (an Object or null), prefix (a String), and async (a Boolean) and returns a built-in function object. additionalInternalSlotsList は、そのオブジェク トの一部として定義されなければならない追加内部スロットの 名前を含む。この操作は組込み関数オブジェクトを作成する。 It performs the following steps when called:

  1. realm が与えられていなければ、realmcurrent Realm Record に設定する。
  2. prototype が与えられていなければ、 prototyperealm.[[Intrinsics]].[[%Function.prototype%]] に設定する。
  3. async が与えられていなければ、asyncfalse に設定する。
  4. internalSlotsList を、これから作成される組 込み関数オブジェクトに 10.3 が要求するすべての内部スロットの名前を含む List とする。
  5. additionalInternalSlotsList の要素を internalSlotsList に append する。
  6. func を新しい組込み関数オブジェクトとする。こ の関数オブジェクトは、呼び出されると、 behaviour に記述された action を、与えられ た引数を behaviour により指定される対応する parameter の値として用いて実行する。新しい関 数オブジェクトは、その名前が internalSlotsList の要素である内部スロット と、[[InitialName]] internal slot を持つ。
  7. func.[[Async]]async に設定する。
  8. func.[[Prototype]]prototype に設定す る。
  9. func.[[Extensible]]true に設定する。
  10. func.[[Realm]]realm に設定する。
  11. func.[[InitialName]]null に設定する。
  12. SetFunctionLength(func, length) を実行す る。
  13. prefix が与えられていなければ、
    1. SetFunctionName(func, name) を実行す る。
  14. Else,
    1. SetFunctionName(func, name, prefix) を実行する。
  15. func を返す。

この仕様で定義される各組込み関数は、 CreateBuiltinFunction 抽象操作を呼び出すことによって 作成される。

10.4 組込み特殊オブジェクトの内部メソッドとスロット

この仕様は、数種類の組込み特殊オブジェクトを定義する。 これらのオブジェクトは、いくつかの特定状況を除いて、一般 に通常オブジェクトと類似した振る舞いをする。以下の特殊オ ブジェクトは、以下で明示的に別段の指定がある場合を除き、 通常オブジェクトの内部メソッドを用いる:

10.4.1 束縛関数特殊オブジェクト

束縛関数特殊オブジェクトは、別の関数オブジェクトを包む 特殊オブジェクトである。束縛関数特殊オブジェクトは呼出し 可能である([[Call]] 内部メソッドを持ち、[[Construct]] 内部メソッドを持つ場合もある)。束縛関数特殊オブジェクト を呼び出すと、通常はその包まれた関数の呼出しが結果として 生じる。

オブジェクトが 束縛関数特殊オブジェクト であるのは、その [[Call]] および(該当する場合) [[Construct]] 内部メソッドが次の実装を用い、かつ他の本質 的内部メソッドが 10.1 にある定義を用いる場合である。これらのメソッドは BoundFunctionCreate で設定される。

束縛関数特殊オブジェクトは、 Table 25 に列挙された ECMAScript 関数オブジェクトの内部スロット を持たない。代わりに、それらは [[Prototype]] および [[Extensible]] に加えて、 Table 26 に列挙された内部スロットを持つ。

Table 26: Internal Slots of Bound Function Exotic Objects
内部スロット 説明
[[BoundTargetFunction]] a callable Object 包まれている関数オブジェクト。
[[BoundThis]] an ECMAScript language value 包まれた関数を呼び出すときに、常に this 値 として渡される値。
[[BoundArguments]] a List of ECMAScript language values その要素が、包まれた関数へのあらゆる呼出しに おいて最初の引数として用いられる値の list。

10.4.1.1 [[Call]] ( thisArgument, argumentsList )

The [[Call]] internal method of a bound function exotic object func takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. targetfunc.[[BoundTargetFunction]] とす る。
  2. boundThisfunc.[[BoundThis]] とする。
  3. boundArgsfunc.[[BoundArguments]] とす る。
  4. argsboundArgsargumentsListlist-concatenation とする。
  5. Call(target, boundThis, args) を返 す。

10.4.1.2 [[Construct]] ( argumentsList, newTarget )

The [[Construct]] internal method of a bound function exotic object func takes arguments argumentsList (a List of ECMAScript language values) and newTarget (a constructor) and returns either a normal completion containing an Object or a throw completion. It performs the following steps when called:

  1. targetfunc.[[BoundTargetFunction]] とす る。
  2. Assert: IsConstructor(target) is true.
  3. boundArgsfunc.[[BoundArguments]] と する。
  4. argsboundArgsargumentsListlist-concatenation とする。
  5. SameValue(func, newTarget) が true なら、newTargettarget に設定する。
  6. Construct(target, args, newTarget) を返す。

10.4.1.3 BoundFunctionCreate ( targetFunction, boundThis, boundArgs )

The abstract operation BoundFunctionCreate takes arguments targetFunction (a function object), boundThis (an ECMAScript language value), and boundArgs (a List of ECMAScript language values) and returns either a normal completion containing a function object or a throw completion. これは、新しい束縛関数特殊オブジェクトの作成を規定 するために用いられる。 It performs the following steps when called:

  1. proto を ? targetFunction.[[GetPrototypeOf]]() とする。
  2. internalSlotsList を « [[Prototype]], [[Extensible]] » と Table 26 に列挙された内部スロットの list-concatenation とする。
  3. objMakeBasicObject(internalSlotsList) とする。
  4. obj.[[Prototype]]proto に設定する。
  5. obj.[[Call]]10.4.1.1 に規定されたとおりに設定する。
  6. IsConstructor(targetFunction) が true な ら、
    1. obj.[[Construct]]10.4.1.2 に規定されたとおりに設定する。
  7. obj.[[BoundTargetFunction]]targetFunction に設定する。
  8. obj.[[BoundThis]]boundThis に設定す る。
  9. obj.[[BoundArguments]]boundArgs に設 定する。
  10. obj を返す。

10.4.2 配列特殊オブジェクト

Array は、array index property key に特別な扱いを 与える特殊オブジェクトである( 6.1.7 を参照)。 property namearray index であるプロパティは element とも呼ばれる。すべての Array は、 non-configurable な "length" プロパティを持ち、そ の値は常に数学的に厳密に 232 未満である非負整 数 Number である。"length" プロパティの値は、名前が array index であるすべての own property の名前よりも 数値的に大きい; Array の own property が作成または変更 されるたびに、この不変条件を維持するため必要に応じて他の プロパティが調整される。具体的には、名前が array index である own property が追加されるたびに、必要に応じて "length" プロパティの値は、その array index の数値 に 1 を加えた値に変更される; また、"length" プロパ ティの値が変更されるたびに、その値が新しい length 以上で ある名前が array index のすべての own property は削除 される。この制約は Array の own property にのみ適用さ れ、その prototype から継承され得る "length" また は array index property の影響を受けない。

オブジェクトが Array 特殊オブジェクト (または単に Array)であるのは、その [[DefineOwnProperty]] 内部メソッドが次の実装を用い、かつ他の本質的内部メソッド が 10.1 にある定義を用いる場合である。これらのメソッドは ArrayCreate で設定される。

10.4.2.1 [[DefineOwnProperty]] ( propertyKey, desc )

The [[DefineOwnProperty]] internal method of an Array exotic object array takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. propertyKey"length" なら、 ? ArraySetLength(array, desc) を返す。
  2. propertyKeyarray index なら、
    1. lengthDescOrdinaryGetOwnProperty( array, "length") とする。
    2. Assert: lengthDescundefined では ない。
    3. Assert: IsDataDescriptor(lengthDesc) is true.
    4. Assert: lengthDesc.[[Configurable]] is false.
    5. lengthlengthDesc.[[Value]] とする。
    6. Assert: length は非負整数 Number である。
    7. index を ! ToUint32(propertyKey) とする。
    8. indexlength かつ lengthDesc.[[Writable]]false な ら、false を返す。
    9. succeeded を ! OrdinaryDefineOwnProperty(array, propertyKey, desc) とする。
    10. succeededfalse なら、false を 返す。
    11. indexlength なら、
      1. lengthDesc.[[Value]]index + 1𝔽 に設定する。
      2. succeeded を ! OrdinaryDefineOwnProperty(array, "length", lengthDesc) に設定する。
      3. Assert: succeeded is true.
    12. true を返す。
  3. OrdinaryDefineOwnProperty(array, propertyKey, desc) を返す。

10.4.2.2 ArrayCreate ( length [ , proto ] )

The abstract operation ArrayCreate takes argument length (a non-negative integer) and optional argument proto (an Object) and returns either a normal completion containing an Array exotic object or a throw completion. これは、新しい Array の作成を規定するために用い られる。 It performs the following steps when called:

  1. length > 232 - 1 なら、 RangeError 例外を送出する。
  2. proto が与えられていなければ、proto%Array.prototype% に設定する。
  3. arrayMakeBasicObject( « [[Prototype]], [[Extensible]] ») とす る。
  4. array.[[Prototype]]proto に設定す る。
  5. array.[[DefineOwnProperty]]10.4.2.1 に規定されたとおりに設定する。
  6. OrdinaryDefineOwnProperty(array, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) を実行する。
  7. array を返す。

10.4.2.3 ArraySpeciesCreate ( originalArray, length )

The abstract operation ArraySpeciesCreate takes arguments originalArray (an Object) and length (a non-negative integer) and returns either a normal completion containing an Object or a throw completion. これは、originalArray から導出された constructor function を用いて、新しい Array または 類似オブジェクトの作成を規定するために用いられる。それ は、constructor function が Array を返すことまでは強 制しない。 It performs the following steps when called:

  1. isArray を ? IsArray(originalArray) とす る。
  2. isArrayfalse なら、 ? ArrayCreate(length) を返す。
  3. constructor を ? Get(originalArray, "constructor") とする。
  4. IsConstructor(constructor) が true な ら、
    1. thisRealmcurrent Realm Record とす る。
    2. constructorRealm を ? GetFunctionRealm(constructor) とす る。
    3. thisRealmconstructorRealm が同 じ Realm Record でないなら、
      1. SameValue(constructor, constructorRealm.[[Intrinsics]].[[%Array%]]) が true なら、constructorundefined に設定する。
  5. constructor が Object なら、
    1. constructor を ? Get(constructor, %Symbol.species%) に設定する。
    2. constructornull なら、 constructorundefined に設定する。
  6. constructorundefined なら、 ? ArrayCreate(length) を返す。
  7. IsConstructor(constructor) が false な ら、TypeError 例外を送出する。
  8. Construct(constructor, « 𝔽(length) ») を返す。
Note

originalArray が、running execution contextrealm ではない realm に属する標準組込み Array constructor を用いて作成されていた場合、新し い Array は running execution contextrealm を 用いて作成される。これにより、現在 ArraySpeciesCreate を用いて定義されている Array.prototype メソッドについて、歴史的にそのよう な挙動を持っていた Web browser との互換性が維持され る。

10.4.2.4 ArraySetLength ( array, desc )

The abstract operation ArraySetLength takes arguments array (an Array) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. desc[[Value]] フィールドを持たないなら、
    1. OrdinaryDefineOwnProperty(array, "length", desc) を返す。
  2. newLenDescdesc の copy とする。
  3. newLen を ? ToUint32(desc.[[Value]]) とする。
  4. numberLen を ? ToNumber(desc.[[Value]]) とする。
  5. SameValueZero(newLen, numberLen) が false なら、RangeError 例外を送出す る。
  6. newLenDesc.[[Value]]newLen に設定す る。
  7. oldLenDescOrdinaryGetOwnProperty( array, "length") とする。
  8. Assert: oldLenDescundefined では ない。
  9. Assert: IsDataDescriptor(oldLenDesc) is true.
  10. Assert: oldLenDesc.[[Configurable]] is false.
  11. oldLenoldLenDesc.[[Value]] とする。
  12. newLenoldLen なら、
    1. OrdinaryDefineOwnProperty(array, "length", newLenDesc) を返す。
  13. oldLenDesc.[[Writable]]false な ら、false を返す。
  14. newLenDesc[[Writable]] フィールドを持 たないか、または newLenDesc.[[Writable]]true なら、
    1. newWritabletrue とする。
  15. Else,
    1. NOTE: いずれかの element を削除できない場 合に備えて、[[Writable]] 属性を false に設定するのは延期される。
    2. newWritablefalse とする。
    3. newLenDesc.[[Writable]]true に設 定する。
  16. succeeded を ! OrdinaryDefineOwnProperty(array, "length", newLenDesc) とする。
  17. succeededfalse なら、false を返 す。
  18. array の各 own property key propertyKey について、propertyKeyarray index であり、かつ ! ToUint32(propertyKey) ≥ newLen であ るものを、数値 index 降順で処理し、次を行う
    1. deleteSucceeded を ! array.[[Delete]](propertyKey) とす る。
    2. deleteSucceededfalse なら、
      1. newLenDesc.[[Value]] を ! ToUint32(propertyKey) + 1𝔽 に設定する。
      2. newWritablefalse なら、 newLenDesc.[[Writable]]false に設定する。
      3. OrdinaryDefineOwnProperty(array, "length", newLenDesc) を実行す る。
      4. false を返す。
  19. newWritablefalse なら、
    1. succeeded を ! OrdinaryDefineOwnProperty(array, "length", PropertyDescriptor { [[Writable]]: false }) に設定する。
    2. Assert: succeeded is true.
  20. true を返す。
Note

手順 3 および 4 において、desc.[[Value]] が object である場合、 その valueOf メソッドは 2 回呼び出される。これは、 この仕様の第 2 版以来、この効果を伴うものとして規定されて いる legacy な挙動である。

10.4.3 文字列特殊オブジェクト

String object は、String 値をカプセル化し、その String 値の個々の code unit 要素に対応する仮想的な整数 index 付き data property を公開する特殊オブジェクトであ る。String 特殊オブジェクトは、常に "length" とい う名前の data property を持ち、その値はカプセル化された String 値の長さである。code unit data property"length" プロパティの両方とも、書込み不可かつ configurable ではない。

オブジェクトが String 特殊オブジェクト (または単に String object)であるのは、その [[GetOwnProperty]][[DefineOwnProperty]][[OwnPropertyKeys]] 内部メソッドが次の実装を用い、かつ 他の本質的内部メソッドが 10.1 にある定義を用いる場合である。これらのメソッドは StringCreate において設定される。

String 特殊オブジェクトは通常オブジェクトと同じ内部ス ロットを持つ。さらに [[StringData]] 内部スロットを持 つ。

10.4.3.1 [[GetOwnProperty]] ( propertyKey )

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

  1. descOrdinaryGetOwnProperty(str, propertyKey) とする。
  2. descundefined でなければ、 desc を返す。
  3. StringGetOwnProperty(str, propertyKey) を返す。

10.4.3.2 [[DefineOwnProperty]] ( propertyKey, desc )

The [[DefineOwnProperty]] internal method of a String exotic object str takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. stringDescStringGetOwnProperty(str, propertyKey) とする。
  2. stringDescundefined でなければ、
    1. extensiblestr.[[Extensible]] とす る。
    2. IsCompatiblePropertyDescriptor( extensible, desc, stringDesc) を返 す。
  3. OrdinaryDefineOwnProperty(str, propertyKey, desc) を返す。

10.4.3.3 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of a String exotic object obj takes no arguments and returns a normal completion containing a List of property keys. It performs the following steps when called:

  1. keys を新しい空の List とする。
  2. strobj.[[StringData]] とする。
  3. Assert: str は String である。
  4. lenstr の長さとする。
  5. 0 ≤ i < len を満たす各整数 i につい て、昇順で、次を行う
    1. ToString(𝔽(i)) を keys に append する。
  6. obj の各 own property key propertyKey について、propertyKeyarray index で あり、かつ ! ToIntegerOrInfinity( propertyKey) ≥ len であるものを、数値 index 昇順で処理し、次を行う
    1. propertyKeykeys に append する。
  7. obj の各 own property key propertyKey について、propertyKey が String であり、 かつ array index ではないものを、プロパティ 作成時刻の昇順で処理し、次を行う
    1. propertyKeykeys に append する。
  8. obj の各 own property key propertyKey について、propertyKey が Symbol である ものを、プロパティ作成時刻の昇順で処理し、次を 行う
    1. propertyKeykeys に append する。
  9. keys を返す。

10.4.3.4 StringCreate ( value, prototype )

The abstract operation StringCreate takes arguments value (a String) and prototype (an Object) and returns a String exotic object. これは、新しい String 特殊オブジェクトの作成を 規定するために用いられる。 It performs the following steps when called:

  1. strMakeBasicObject( « [[Prototype]], [[Extensible]], [[StringData]] ») とする。
  2. str.[[Prototype]]prototype に設定す る。
  3. str.[[StringData]]value に設定する。
  4. str.[[GetOwnProperty]]10.4.3.1 に規定されたとおりに設定する。
  5. str.[[DefineOwnProperty]]10.4.3.2 に規定されたとおりに設定する。
  6. str.[[OwnPropertyKeys]]10.4.3.3 に規定されたとおりに設定する。
  7. lengthvalue の長さとする。
  8. DefinePropertyOrThrow(str, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }) を実行する。
  9. str を返す。

10.4.3.5 StringGetOwnProperty ( str, propertyKey )

The abstract operation StringGetOwnProperty takes arguments str (an Object that has a [[StringData]] internal slot) and propertyKey (a property key) and returns a Property Descriptor or undefined. It performs the following steps when called:

  1. propertyKey が String でなければ、 undefined を返す。
  2. indexCanonicalNumericIndexString(propertyKey) とする。
  3. index が整数 Number でなければ、 undefined を返す。
  4. index-0𝔽 であるか、また は index < -0𝔽 なら、 undefined を返す。
  5. stringDatastr.[[StringData]] とす る。
  6. Assert: stringData は String である。
  7. lenstringData の長さとする。
  8. (index) ≥ len なら、undefined を返 す。
  9. resultStr を、(index) から (index) + 1 までの stringDatasubstring とする。
  10. PropertyDescriptor { [[Value]]: resultStr, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: false } を返す。

10.4.4 Arguments 特殊オブジェクト

ほとんどの ECMAScript 関数は、そのコードから利用可能 な arguments object を作成する。関数定義の特性に応じ て、その arguments object は通常オブジェクトまたは arguments 特殊オブジェクトのいずれかである。 arguments 特殊オブジェクトは、その array index property が、対応する ECMAScript 関数の呼出しにおける 仮引数束縛へ対応付けられる特殊オブジェクトである。

オブジェクトが arguments 特殊オブジェクト であるのは、その内部メソッドが次の実装を用い、ここで指定 されていないものは 10.1 にある定義を用いる場合である。これらのメソッドは CreateMappedArgumentsObject において設定される。

Note 1

CreateUnmappedArgumentsObject はこの節に含められ ているが、それが作成するのは通常オブジェクトであり、 arguments 特殊オブジェクトではない。

arguments 特殊オブジェクトは通常オブジェクトと同 じ内部スロットを持つ。さらに [[ParameterMap]] 内部スロ ットを持つ。通常の arguments object も [[ParameterMap]] 内部スロットを持つが、その値は常に undefined である。通常の arguments object におい て [[ParameterMap]] 内部スロットは、 Object.prototype.toString20.1.3.6) がそれらをそのようなものとして識別するためにのみ用いられ る。

Note 2

対応する関数オブジェクトの仮引数の数より小さい数値名を 持つ arguments 特殊オブジェクトの整数 index 付き data property は、初期状態では関数の execution context における対応する引数束縛と値を共有する。これ は、そのプロパティを変更すると対応する引数束縛の値も変わ り、逆もまた同様であることを意味する。この対応関係は、そ のようなプロパティが削除されてから再定義された場合、また はそのプロパティが accessor property に変更された場合 に壊れる。arguments object が通常オブジェクトである場 合、そのプロパティの値は関数に渡された引数の単なる copy であり、プロパティ値と仮引数値の間に動的な連結は存在しな い。

Note 3

ParameterMap object とその property 値は、 arguments object と引数束縛との対応を規定するための仕 組みとして用いられる。ParameterMap object と、そのプ ロパティの値であるオブジェクトは、ECMAScript code から 直接観測可能ではない。ECMAScript 実装は、指定された意味 論を実装するために、そのようなオブジェクトを実際に作成し たり使用したりする必要はない。

Note 4

通常の arguments object は、"callee" という 名前の non-configurable な accessor property を定 義し、そのアクセス時には TypeError 例外を送出する。 "callee" プロパティは、arguments 特殊オブジェクト においてはより具体的な意味を持つ。arguments 特殊オブ ジェクトは、non-strict function のある種のクラスに対 してのみ作成される。通常版におけるこのプロパティの定義 は、適合する ECMAScript 実装によってこれが他の方法で定 義されないことを保証するために存在する。

Note 5

ECMAScript 実装の arguments 特殊オブジェクトは、 歴史的に "caller" という名前の accessor property を含んでいた。ECMAScript 2017 より前、この仕様は通常 の arguments object に throwing な "caller" プロパティを定義していた。実装はもはやこの拡張を含まない ため、ECMAScript 2017 では throwing な "caller" accessor の要件が削除された。

10.4.4.1 [[GetOwnProperty]] ( propertyKey )

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

  1. descOrdinaryGetOwnProperty(args, propertyKey) とする。
  2. descundefined なら、undefined を 返す。
  3. mapargs.[[ParameterMap]] とする。
  4. isMapped を ! HasOwnProperty(map, propertyKey) とする。
  5. isMappedtrue なら、
    1. desc.[[Value]] を ! Get(map, propertyKey) に設定する。
  6. desc を返す。

10.4.4.2 [[DefineOwnProperty]] ( propertyKey, desc )

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

  1. mapargs.[[ParameterMap]] とする。
  2. isMapped を ! HasOwnProperty(map, propertyKey) とする。
  3. newArgDescdesc とする。
  4. isMappedtrue かつ IsDataDescriptor(desc) が true なら、
    1. desc[[Value]] フィールドを持たず、 desc[[Writable]] フィールドを持ち、 かつ desc.[[Writable]]false な ら、
      1. newArgDescdesc の copy に設定 する。
      2. newArgDesc.[[Value]] を ! Get(map, propertyKey) に設定する。
  5. allowed を ! OrdinaryDefineOwnProperty(args, propertyKey, newArgDesc) とする。
  6. allowedfalse なら、false を返 す。
  7. isMappedtrue なら、
    1. IsAccessorDescriptor(desc) が true な ら、
      1. map.[[Delete]](propertyKey) を実 行する。
    2. Else,
      1. desc[[Value]] フィールドを持つな ら、
        1. Assert: 次の Set は成功する。なぜなら arguments object によって対応付け られる仮引数は常に書込み可能だからであ る。
        2. Set(map, propertyKey, desc.[[Value]], false) を実行す る。
      2. desc[[Writable]] フィールドを持 ち、かつ desc.[[Writable]]false なら、
        1. map.[[Delete]](propertyKey) を 実行する。
  8. true を返す。

10.4.4.3 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of an arguments exotic object args takes arguments propertyKey (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. mapargs.[[ParameterMap]] とする。
  2. isMapped を ! HasOwnProperty(map, propertyKey) とする。
  3. isMappedfalse なら、 ? OrdinaryGet(args, propertyKey, receiver) を返す。
  4. Assert: mappropertyKey に対する仮 引数対応付けを含む。
  5. Get(map, propertyKey) を返す。

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

The [[Set]] internal method of an arguments exotic object args takes arguments propertyKey (a property key), value (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. SameValue(args, receiver) が false な ら、
    1. isMappedfalse とする。
  2. Else,
    1. mapargs.[[ParameterMap]] とする。
    2. isMapped を ! HasOwnProperty(map, propertyKey) とする。
  3. isMappedtrue なら、
    1. Assert: 次の Set は成功する。なぜなら arguments object によって対応付けられ る仮引数は常に書込み可能だからである。
    2. Set(map, propertyKey, value, false) を実行する。
  4. OrdinarySet(args, propertyKey, value, receiver) を返す。

10.4.4.5 [[Delete]] ( propertyKey )

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

  1. mapargs.[[ParameterMap]] とする。
  2. isMapped を ! HasOwnProperty(map, propertyKey) とする。
  3. result を ? OrdinaryDelete(args, propertyKey) とする。
  4. resulttrue かつ isMappedtrue なら、
    1. map.[[Delete]](propertyKey) を実行す る。
  5. result を返す。

10.4.4.6 CreateUnmappedArgumentsObject ( argumentsList )

The abstract operation CreateUnmappedArgumentsObject takes argument argumentsList (a List of ECMAScript language values) and returns an ordinary object. It performs the following steps when called:

  1. lenargumentsList の要素数とする。
  2. objOrdinaryObjectCreate(%Object.prototype%, « [[ParameterMap]] ») とする。
  3. obj.[[ParameterMap]]undefined に設 定する。
  4. DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(len), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }) を実行する。
  5. index を 0 とする。
  6. index < len の間、繰り返す
    1. valargumentsList[index] とす る。
    2. CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), val) を実行す る。
    3. indexindex + 1 に設定する。
  7. DefinePropertyOrThrow(obj, %Symbol.iterator%, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }) を実行する。
  8. DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Get]]: %ThrowTypeError%, [[Set]]: %ThrowTypeError%, [[Enumerable]]: false, [[Configurable]]: false }) を実行する。
  9. obj を返す。

10.4.4.7 CreateMappedArgumentsObject ( func, formals, argumentsList, env )

The abstract operation CreateMappedArgumentsObject takes arguments func (an ECMAScript function 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 は rest parameter、 binding pattern、またはいかなる initializer も含まない。重複識別子を含んでもよい。
  2. lenargumentsList の要素数とする。
  3. objMakeBasicObject( « [[Prototype]], [[Extensible]], [[ParameterMap]] ») とする。
  4. obj.[[GetOwnProperty]]10.4.4.1 に規定されたとおりに設定する。
  5. obj.[[DefineOwnProperty]]10.4.4.2 に規定されたとおりに設定する。
  6. obj.[[Get]]10.4.4.3 に規定されたとおりに設定する。
  7. obj.[[Set]]10.4.4.4 に規定されたとおりに設定する。
  8. obj.[[Delete]]10.4.4.5 に規定されたとおりに設定する。
  9. obj.[[Prototype]]%Object.prototype% に設定する。
  10. mapOrdinaryObjectCreate(null) とす る。
  11. obj.[[ParameterMap]]map に設定す る。
  12. parameterNamesformalsBoundNames とする。
  13. numberOfParametersparameterNames の要素数とする。
  14. index を 0 とする。
  15. index < len の間、繰り返す
    1. valargumentsList[index] とす る。
    2. CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), val) を実行す る。
    3. indexindex + 1 に設定する。
  16. DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(len), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }) を実行する。
  17. mappedNames を新しい空の List とする。
  18. indexnumberOfParameters - 1 に設定 する。
  19. index ≥ 0 の間、繰り返す
    1. nameparameterNames[index] とす る。
    2. mappedNamesname を含まないなら、
      1. namemappedNames に append す る。
      2. index < len なら、
        1. getterMakeArgGetter(name, env) とする。
        2. setterMakeArgSetter(name, env) とする。
        3. map.[[DefineOwnProperty]]( ! ToString(𝔽(index)), PropertyDescriptor { [[Set]]: setter, [[Get]]: getter, [[Enumerable]]: false, [[Configurable]]: true }) を実行する。
    3. indexindex - 1 に設定する。
  20. DefinePropertyOrThrow(obj, %Symbol.iterator%, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }) を実行する。
  21. DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Value]]: func, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }) を実行する。
  22. 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. これは、実行されると env において name に束 縛された値を返す built-in function object を作成す る。 It performs the following steps when called:

  1. getterClosure を、引数を持たず、nameenv を capture し、呼び出されたとき 次の手順を実行する新しい Abstract Closure とする:
    1. NormalCompletion( ! env.GetBindingValue(name, false)) を返す。
  2. getterCreateBuiltinFunction( getterClosure, 0, "", « ») とする。
  3. NOTE: getter は ECMAScript code から直 接アクセス可能になることはない。
  4. 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. これは、実行されると env において name に束 縛された値を設定する built-in function object を作成 する。 It performs the following steps when called:

  1. setterClosure を、(value) を引数とし、 nameenv を capture し、呼び出された とき次の手順を実行する新しい Abstract Closure とする:
    1. NormalCompletion( ! env.SetMutableBinding(name, value, false)) を返す。
  2. setterCreateBuiltinFunction( setterClosure, 1, "", « ») とす る。
  3. NOTE: setter は ECMAScript code から直 接アクセス可能になることはない。
  4. setter を返す。

10.4.5 TypedArray 特殊オブジェクト

TypedArray は、canonical numeric string であ る property key に特別な処理を行う特殊オブジェクトであ り、そのうち範囲内の整数 index である部分集合を用いて均 一な型の element を index し、残りが prototype chain の探索を生じさせることなく存在しないという不変条件 を強制する。

Note

任意の Number n に対する ToString(n) は canonical numeric string であるため、実装は実際に string 変換を行うことなく、TypedArray に対する property key として Number を扱ってよい。

TypedArray は通常オブジェクトと同じ内部スロットを持 ち、さらに [[ViewedArrayBuffer]][[TypedArrayName]][[ContentType]][[ByteLength]][[ByteOffset]]、および [[ArrayLength]] 内部スロットを持つ。

オブジェクトが TypedArray であるのは、その [[PreventExtensions]][[GetOwnProperty]][[HasProperty]][[DefineOwnProperty]][[Get]][[Set]][[Delete]]、および [[OwnPropertyKeys]] 内部メソッド がこの節の定義を用い、かつ他の本質的内部メソッドが 10.1 にある定義を用いる場合である。これらのメソッドは TypedArrayCreate によって設定される。

10.4.5.1 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of a TypedArray obj takes no arguments and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. NOTE: 6.1.7.3 に規定された拡張可能性関連の不変条件は、基底 buffer の resize によって整数 index 名の property が増える(または減ってから再び増え る)可能性があるとき、obj に対してこのメソ ッドが true を返すことを許さない。
  2. IsTypedArrayFixedLength(obj) が false なら、false を返す。
  3. OrdinaryPreventExtensions(obj) を返す。

10.4.5.2 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of a TypedArray obj takes argument propertyKey (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

  1. propertyKey が String なら、
    1. numericIndexCanonicalNumericIndexString(propertyKey) とする。
    2. numericIndexundefined でなけれ ば、
      1. valueTypedArrayGetElement(obj, numericIndex) とする。
      2. valueundefined なら、 undefined を返す。
      3. PropertyDescriptor { [[Value]]: value, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true } を返す。
  2. OrdinaryGetOwnProperty(obj, propertyKey) を返す。

10.4.5.3 [[HasProperty]] ( propertyKey )

The [[HasProperty]] internal method of a TypedArray obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. propertyKey が String なら、
    1. numericIndexCanonicalNumericIndexString(propertyKey) とする。
    2. numericIndexundefined でなけれ ば、 IsValidIntegerIndex(obj, numericIndex) を返す。
  2. OrdinaryHasProperty(obj, propertyKey) を返す。

10.4.5.4 [[DefineOwnProperty]] ( propertyKey, desc )

The [[DefineOwnProperty]] internal method of a TypedArray obj takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. propertyKey が String なら、
    1. numericIndexCanonicalNumericIndexString(propertyKey) とする。
    2. numericIndexundefined でなけれ ば、
      1. IsValidIntegerIndex(obj, numericIndex) が false なら、 false を返す。
      2. desc[[Configurable]] フィールド を持ち、かつ desc.[[Configurable]]false なら、false を返す。
      3. desc[[Enumerable]] フィールドを持 ち、かつ desc.[[Enumerable]]false なら、false を返す。
      4. IsAccessorDescriptor(desc) が true なら、false を返す。
      5. desc[[Writable]] フィールドを持 ち、かつ desc.[[Writable]]false なら、false を返す。
      6. desc[[Value]] フィールドを持つな ら、? TypedArraySetElement(obj, numericIndex, desc.[[Value]]) を 実行する。
      7. true を返す。
  2. OrdinaryDefineOwnProperty(obj, propertyKey, desc) を返す。

10.4.5.5 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of a TypedArray obj takes arguments propertyKey (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. propertyKey が String なら、
    1. numericIndexCanonicalNumericIndexString(propertyKey) とする。
    2. numericIndexundefined でなけれ ば、
      1. TypedArrayGetElement(obj, numericIndex) を返す。
  2. OrdinaryGet(obj, propertyKey, receiver) を返す。

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

The [[Set]] internal method of a TypedArray obj takes arguments propertyKey (a property key), value (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. propertyKey が String なら、
    1. numericIndexCanonicalNumericIndexString(propertyKey) とする。
    2. numericIndexundefined でなけれ ば、
      1. SameValue(obj, receiver) が true なら、
        1. TypedArraySetElement(obj, numericIndex, value) を実行する。
        2. true を返す。
      2. IsValidIntegerIndex(obj, numericIndex) が false なら、true を返す。
  2. OrdinarySet(obj, propertyKey, value, receiver) を返す。

10.4.5.7 [[Delete]] ( propertyKey )

The [[Delete]] internal method of a TypedArray obj takes argument propertyKey (a property key) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. propertyKey が String なら、
    1. numericIndexCanonicalNumericIndexString(propertyKey) とする。
    2. numericIndexundefined でなけれ ば、
      1. IsValidIntegerIndex(obj, numericIndex) が false なら、true を返す。
      2. false を返す。
  2. OrdinaryDelete(obj, propertyKey) を返 す。

10.4.5.8 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of a TypedArray obj takes no arguments and returns a normal completion containing a List of property keys. It performs the following steps when called:

  1. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, seq-cst) とする。
  2. keys を新しい空の List とする。
  3. IsTypedArrayOutOfBounds(taRecord) が false なら、
    1. lengthTypedArrayLength(taRecord) とする。
    2. 0 ≤ i < length を満たす各整数 i に ついて、昇順で、次を行う
      1. ToString(𝔽(i)) を keys に append する。
  4. obj の各 own property key propertyKey について、propertyKey が String であり、 かつ integer index ではないものを、プロパテ ィ作成時刻の昇順で処理し、次を行う
    1. propertyKeykeys に append する。
  5. obj の各 own property key propertyKey について、propertyKey が Symbol であるも のを、プロパティ作成時刻の昇順で処理し、次を行 う
    1. propertyKeykeys に append す る。
  6. keys を返す。

10.4.5.9 TypedArray With Buffer Witness Record

TypedArray With Buffer Witness Record は、TypedArray と、その view された buffer の byte length の cache 値をあわせてカプセル化するために用いら れる Record 値である。これは、view された buffer が growable SharedArrayBuffer であるとき、byte length data block に対する ReadSharedMemory event が 1 回 だけになることを助けるために用いられる。

TypedArray With Buffer Witness Record は Table 27 に列挙されたフィールドを持つ。

Table 27: TypedArray With Buffer Witness Record Fields
フィールド名 意味
[[Object]] a TypedArray その buffer の byte length が読み込まれ る TypedArray
[[CachedBufferByteLength]] a non-negative integer or detached この Record が作成された時点における、オ ブジェクトの [[ViewedArrayBuffer]] の byte length。

10.4.5.10 MakeTypedArrayWithBufferWitnessRecord ( obj, order )

The abstract operation MakeTypedArrayWithBufferWitnessRecord takes arguments obj (a TypedArray) and order (seq-cst or unordered) and returns a TypedArray With Buffer Witness Record. It performs the following steps when called:

  1. bufferobj.[[ViewedArrayBuffer]] とす る。
  2. IsDetachedBuffer(buffer) が true な ら、
    1. byteLengthdetached とする。
  3. Else,
    1. byteLengthArrayBufferByteLength( buffer, order) とする。
  4. TypedArray With Buffer Witness Record { [[Object]]: obj, [[CachedBufferByteLength]]: byteLength } を返す。

10.4.5.11 TypedArrayCreate ( prototype )

The abstract operation TypedArrayCreate takes argument prototype (an Object) and returns a TypedArray. これは、新しい TypedArray の作成を規定するため に用いられる。 It performs the following steps when called:

  1. internalSlotsList を « [[Prototype]], [[Extensible]], [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] » とする。
  2. typedArrayMakeBasicObject(internalSlotsList) とす る。
  3. typedArray.[[PreventExtensions]]10.4.5.1 に規定されたとおりに設定する。
  4. typedArray.[[GetOwnProperty]]10.4.5.2 に規定されたとおりに設定する。
  5. typedArray.[[HasProperty]]10.4.5.3 に規定されたとおりに設定する。
  6. typedArray.[[DefineOwnProperty]]10.4.5.4 に規定されたとおりに設定する。
  7. typedArray.[[Get]]10.4.5.5 に規定されたとおりに設定する。
  8. typedArray.[[Set]]10.4.5.6 に規定されたとおりに設定する。
  9. typedArray.[[Delete]]10.4.5.7 に規定されたとおりに設定する。
  10. typedArray.[[OwnPropertyKeys]]10.4.5.8 に規定されたとおりに設定する。
  11. typedArray.[[Prototype]]prototype に 設定する。
  12. typedArray を返す。

10.4.5.12 TypedArrayByteLength ( taRecord )

The abstract operation TypedArrayByteLength takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a non-negative integer. It performs the following steps when called:

  1. Assert: IsTypedArrayOutOfBounds(taRecord) is false.
  2. objtaRecord.[[Object]] とする。
  3. obj.[[ByteLength]]auto でなけれ ば、obj.[[ByteLength]] を返す。
  4. lengthTypedArrayLength(taRecord) とする。
  5. elementSizeTypedArrayElementSize(obj) とする。
  6. NOTE: 返される byte length は、基底 buffer が非整数倍に resize されている場合でも、常 に elementSize の整数倍である。
  7. length × elementSize を返す。

10.4.5.13 TypedArrayLength ( taRecord )

The abstract operation TypedArrayLength takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a non-negative integer. It performs the following steps when called:

  1. Assert: IsTypedArrayOutOfBounds(taRecord) is false.
  2. objtaRecord.[[Object]] とする。
  3. obj.[[ArrayLength]]auto でなけれ ば、obj.[[ArrayLength]] を返す。
  4. Assert: IsFixedLengthArrayBuffer( obj.[[ViewedArrayBuffer]]) is false.
  5. byteOffsetobj.[[ByteOffset]] とす る。
  6. elementSizeTypedArrayElementSize(obj) とする。
  7. byteLengthtaRecord.[[CachedBufferByteLength]] とす る。
  8. Assert: byteLengthdetached ではな い。
  9. floor((byteLength - byteOffset) / elementSize) を返す。

10.4.5.14 IsTypedArrayOutOfBounds ( taRecord )

The abstract operation IsTypedArrayOutOfBounds takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a Boolean. これは、オブジェクトの数値プロパティのいずれかが、 基底 buffer の範囲内に含まれない index にある値を参 照しているかどうかを検査する。 It performs the following steps when called:

  1. objtaRecord.[[Object]] とする。
  2. bufferByteLengthtaRecord.[[CachedBufferByteLength]] とす る。
  3. IsDetachedBuffer(obj.[[ViewedArrayBuffer]]) が true なら、
    1. Assert: bufferByteLengthdetached である。
    2. true を返す。
  4. Assert: bufferByteLength は非負整数であ る。
  5. byteOffsetStartobj.[[ByteOffset]] とする。
  6. obj.[[ArrayLength]]auto なら、
    1. byteOffsetEndbufferByteLength とする。
  7. Else,
    1. elementSizeTypedArrayElementSize(obj) とする。
    2. arrayByteLengthobj.[[ArrayLength]] × elementSize とする。
    3. byteOffsetEndbyteOffsetStart + arrayByteLength とする。
  8. NOTE: [[ByteOffset]]bufferByteLength である長さ 0 の TypedArray は、範囲外とは みなされない。
  9. byteOffsetStart > bufferByteLength または byteOffsetEnd > bufferByteLength なら、true を返す。
  10. false を返す。

10.4.5.15 IsTypedArrayFixedLength ( obj )

The abstract operation IsTypedArrayFixedLength takes argument obj (a TypedArray) and returns a Boolean. It performs the following steps when called:

  1. obj.[[ArrayLength]]auto なら、 false を返す。
  2. bufferobj.[[ViewedArrayBuffer]] とする。
  3. IsFixedLengthArrayBuffer(buffer) が false かつ IsSharedArrayBuffer(buffer) が false なら、false を返す。
  4. true を返す。

10.4.5.16 IsValidIntegerIndex ( obj, index )

The abstract operation IsValidIntegerIndex takes arguments obj (a TypedArray) and index (a Number) and returns a Boolean. It performs the following steps when called:

  1. IsDetachedBuffer(obj.[[ViewedArrayBuffer]]) が true なら、false を返す。
  2. index が整数 Number でなければ、false を返す。
  3. index-0𝔽 であるか、また は index < -0𝔽 なら、 false を返す。
  4. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, unordered) とする。
  5. NOTE: obj の backing buffer が growable SharedArrayBuffer である場合、bounds checking は synchronizing operation では ない。
  6. IsTypedArrayOutOfBounds(taRecord) が true なら、false を返す。
  7. lengthTypedArrayLength(taRecord) とする。
  8. (index) ≥ length なら、false を返 す。
  9. true を返す。

10.4.5.17 TypedArrayGetElement ( obj, index )

The abstract operation TypedArrayGetElement takes arguments obj (a TypedArray) and index (a Number) and returns a Number, a BigInt, or undefined. It performs the following steps when called:

  1. IsValidIntegerIndex(obj, index) が false なら、undefined を返す。
  2. offsetobj.[[ByteOffset]] とする。
  3. elementSizeTypedArrayElementSize(obj) とする。
  4. byteIndexInBuffer を ((index) × elementSize) + offset とする。
  5. elementTypeTypedArrayElementType(obj) とする。
  6. GetValueFromBuffer(obj.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, true, unordered) を返す。

10.4.5.18 TypedArraySetElement ( obj, index, value )

The abstract operation TypedArraySetElement takes arguments obj (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. obj.[[ContentType]]bigint なら、 numValue を ? ToBigInt(value) とする。
  2. Else, numValue を ? ToNumber(value) とす る。
  3. IsValidIntegerIndex(obj, index) が true なら、
    1. offsetobj.[[ByteOffset]] とする。
    2. elementSizeTypedArrayElementSize(obj) とする。
    3. byteIndexInBuffer を ((index) × elementSize) + offset とする。
    4. elementTypeTypedArrayElementType(obj) とする。
    5. SetValueInBuffer(obj.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered) を実行す る。
  4. unused を返す。
Note

この操作は常に成功したように見えるが、TypedArray の終端を越えて書き込もうとした場合、または detached ArrayBuffer に裏付けられた TypedArray に書き込もう とした場合には効果を持たない。

10.4.5.19 IsArrayBufferViewOutOfBounds ( obj )

The abstract operation IsArrayBufferViewOutOfBounds takes argument obj (a TypedArray or a DataView) and returns a Boolean. これは、TypedArray の数値プロパティのいずれか、 または DataView object のメソッドのいずれかが、基底 data block の範囲内に含まれない index にある値を参照 し得るかどうかを検査する。この抽象操作は、上流仕様の便宜 のために存在する。 It performs the following steps when called:

  1. obj[[DataView]] internal slot を持つ なら、
    1. viewRecordMakeDataViewWithBufferWitnessRecord( obj, seq-cst) とする。
    2. IsViewOutOfBounds(viewRecord) を返す。
  2. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, seq-cst) とする。
  3. IsTypedArrayOutOfBounds(taRecord) を返す。

10.4.6 モジュール名前空間特殊オブジェクト

module namespace 特殊オブジェクトは、ECMAScript Module から export された束縛を公開する特殊オブジェ クトである(16.2.3 を参照)。module namespace 特殊オブジェクトの String key 付き own property と、Module によって export される束縛名との間には 1 対 1 の対応が存在する。export される束縛には、export * export item を用いて間接 的に export された束縛も含まれる。各 String 値の own property key は、対応する export 束縛名の StringValue である。これらが module namespace 特殊オ ブジェクトの唯一の String key 付き property である。 そのような各 property は { [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false } という属性を持つ。module namespace 特殊オ ブジェクトは拡張可能ではない。

オブジェクトが module namespace 特殊オブジェクト であるのは、その [[GetPrototypeOf]][[SetPrototypeOf]][[IsExtensible]][[PreventExtensions]][[GetOwnProperty]][[DefineOwnProperty]][[HasProperty]][[Get]][[Set]][[Delete]]、および [[OwnPropertyKeys]] 内部メソッドがこの節の定義を用い、かつ他の本質的内部メソ ッドが 10.1 にある定義を用いる場合である。これらのメソッドは ModuleNamespaceCreate によって設定される。

module namespace 特殊オブジェクトは、 Table 28 で定義された内部スロットを持つ。

Table 28: Internal Slots of Module Namespace Exotic Objects
内部スロット 説明
[[Module]] a Module Record この namespace が公開する export を持つ Module Record
[[Exports]] a List of Strings このオブジェクトの own property として公 開される export 名の String 値を要素とす る List。list は code unit の辞書順に従 って整列される。

10.4.6.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of a module namespace exotic object takes no arguments and returns a normal completion containing null. It performs the following steps when called:

  1. null を返す。

10.4.6.2 [[SetPrototypeOf]] ( proto )

The [[SetPrototypeOf]] internal method of a module namespace exotic object obj takes argument proto (an Object or null) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. SetImmutablePrototype(obj, proto) を返 す。

10.4.6.3 [[IsExtensible]] ( )

The [[IsExtensible]] internal method of a module namespace exotic object takes no arguments and returns a normal completion containing false. It performs the following steps when called:

  1. false を返す。

10.4.6.4 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of a module namespace exotic object takes no arguments and returns a normal completion containing true. It performs the following steps when called:

  1. true を返す。

10.4.6.5 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of a module namespace exotic object obj takes argument propertyKey (a property key) and returns either a normal completion containing either a Property Descriptor or undefined, or a throw completion. It performs the following steps when called:

  1. propertyKey が Symbol なら、 OrdinaryGetOwnProperty(obj, propertyKey) を返す。
  2. exportsobj.[[Exports]] とする。
  3. exportspropertyKey を含まないなら、 undefined を返す。
  4. value を ? obj.[[Get]](propertyKey, obj) とする。
  5. PropertyDescriptor { [[Value]]: value, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false } を返す。

10.4.6.6 [[DefineOwnProperty]] ( propertyKey, desc )

The [[DefineOwnProperty]] internal method of a module namespace exotic object obj takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. propertyKey が Symbol なら、 ! OrdinaryDefineOwnProperty(obj, propertyKey, desc) を返す。
  2. current を ? obj.[[GetOwnProperty]]( propertyKey) とする。
  3. currentundefined なら、false を返す。
  4. desc[[Configurable]] フィールドを持ち、 かつ desc.[[Configurable]]true な ら、false を返す。
  5. desc[[Enumerable]] フィールドを持ち、 かつ desc.[[Enumerable]]false な ら、false を返す。
  6. IsAccessorDescriptor(desc) が true な ら、false を返す。
  7. desc[[Writable]] フィールドを持ち、 かつ desc.[[Writable]]false なら、 false を返す。
  8. desc[[Value]] フィールドを持つなら、 SameValue(desc.[[Value]], current.[[Value]]) を返す。
  9. true を返す。

10.4.6.7 [[HasProperty]] ( propertyKey )

The [[HasProperty]] internal method of a module namespace exotic object obj takes argument propertyKey (a property key) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. propertyKey が Symbol なら、 ! OrdinaryHasProperty(obj, propertyKey) を返す。
  2. exportsobj.[[Exports]] とする。
  3. exportspropertyKey を含むなら、 true を返す。
  4. false を返す。

10.4.6.8 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of a module namespace exotic object obj takes arguments propertyKey (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. propertyKey が Symbol なら、
    1. OrdinaryGet(obj, propertyKey, receiver) を返す。
  2. exportsobj.[[Exports]] とする。
  3. exportspropertyKey を含まないなら、 undefined を返す。
  4. moduleobj.[[Module]] とする。
  5. bindingmodule.ResolveExport( propertyKey) とする。
  6. Assert: bindingResolvedBinding Record である。
  7. targetModulebinding.[[Module]] とす る。
  8. Assert: targetModuleundefined では ない。
  9. binding.[[BindingName]]namespace な ら、
    1. GetModuleNamespace(targetModule) を返 す。
  10. targetEnvtargetModule.[[Environment]] とする。
  11. targetEnvempty なら、 ReferenceError 例外を送出する。
  12. targetEnv.GetBindingValue( binding.[[BindingName]], true) を返す。
Note

ResolveExport は副作用を持たない。この操作が特定の exportNameresolveSet の組を引数として呼び出さ れるたびに、同じ結果を返さなければならない。実装は、各 module namespace 特殊オブジェクト[[Exports]] に対 する ResolveExport の結果を事前計算または cache す ることを選んでもよい。

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

The [[Set]] internal method of a module namespace exotic object takes arguments propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns a normal completion containing false. It performs the following steps when called:

  1. false を返す。

10.4.6.10 [[Delete]] ( propertyKey )

The [[Delete]] internal method of a module namespace exotic object obj takes argument propertyKey (a property key) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. propertyKey が Symbol なら、
    1. OrdinaryDelete(obj, propertyKey) を返 す。
  2. exportsobj.[[Exports]] とする。
  3. exportspropertyKey を含むなら、 false を返す。
  4. true を返す。

10.4.6.11 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of a module namespace exotic object obj takes no arguments and returns a normal completion containing a List of property keys. It performs the following steps when called:

  1. exportsobj.[[Exports]] とする。
  2. symbolKeysOrdinaryOwnPropertyKeys(obj) とする。
  3. exportssymbolKeyslist-concatenation を返す。

10.4.6.12 ModuleNamespaceCreate ( module, exports )

The abstract operation ModuleNamespaceCreate takes arguments module (a Module Record) and exports (a List of Strings) and returns a module namespace exotic object. これは、新しい module namespace 特殊オブジェ クトの作成を規定するために用いられる。 It performs the following steps when called:

  1. Assert: module.[[Namespace]] is empty.
  2. internalSlotsListTable 28 に列挙された内部スロットとする。
  3. namespaceMakeBasicObject(internalSlotsList) とす る。
  4. namespace の本質的内部メソッドを 10.4.6 に規定された定義に設定する。
  5. namespace.[[Module]]module に設定す る。
  6. sortedExports を、exports の要素を code unit の辞書順に整列した List とする。
  7. namespace.[[Exports]]sortedExports に設定する。
  8. 28.3 の定義に対応する own property を namespace に作成する。
  9. module.[[Namespace]]namespace に設 定する。
  10. namespace を返す。

10.4.7 不変プロトタイプ特殊オブジェクト

不変プロトタイプ特殊オブジェクトは、一度初期化される と変更されない [[Prototype]] 内部スロットを持つ特殊オ ブジェクトである。

オブジェクトが 不変プロトタイプ特殊オブジェクト であるのは、その [[SetPrototypeOf]] 内部メソッドが次の 実装を用いる場合である。(そのほかの本質的内部メソッド は、対象となる具体的な不変プロトタイプ特殊オブジェクトに 応じて、任意の実装を用いてよい。)

Note

他の特殊オブジェクトと異なり、不変プロトタイプ特殊オ ブジェクトに対しては専用の作成抽象操作は提供されていな い。これは、それらが %Object.prototype% および host environment によってのみ使用され、host environment においては、関係するオブジェクトが他の点でも特殊であり得 るため、それら独自の専用作成操作を必要とするからである。

10.4.7.1 [[SetPrototypeOf]] ( proto )

The [[SetPrototypeOf]] internal method of an immutable prototype exotic object obj takes argument proto (an Object or null) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. SetImmutablePrototype(obj, proto) を返 す。

10.4.7.2 SetImmutablePrototype ( obj, proto )

The abstract operation SetImmutablePrototype takes arguments obj (an Object) and proto (an Object or null) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. current を ? obj.[[GetPrototypeOf]]() とする。
  2. SameValue(proto, current) が true なら、true を返す。
  3. false を返す。

10.5 Proxy オブジェクトの内部メソッドと内部スロット

Proxy オブジェクトは、その本質的内部メソッドが ECMAScript code を用いて部分的に実装される特殊オブジェ クトである。すべての Proxy オブジェクトは [[ProxyHandler]] と呼ばれる内部スロットを持つ。 [[ProxyHandler]] の値は、proxy の handler object と呼ばれる object、または null である。handler object のメソッド (Table 29 を参照)は、Proxy オブジェクトの 1 つ以上の内部メソッド の実装を補強するために用いられ得る。すべての Proxy オブ ジェクトはまた [[ProxyTarget]] と呼ばれる内部スロットを 持ち、その値は object または null のいずれかである。 この object は proxy の target object と呼ば れる。

オブジェクトが Proxy 特殊オブジェクト であるのは、その本質的内部メソッド(該当する場合、 [[Call]] および [[Construct]] を含む)がこの節の定義を 用いる場合である。これらの内部メソッドは ProxyCreate に おいて設定される。

Table 29: Proxy Handler Methods
内部メソッド handler メソッド
[[GetPrototypeOf]] getPrototypeOf
[[SetPrototypeOf]] setPrototypeOf
[[IsExtensible]] isExtensible
[[PreventExtensions]] preventExtensions
[[GetOwnProperty]] getOwnPropertyDescriptor
[[DefineOwnProperty]] defineProperty
[[HasProperty]] has
[[Get]] get
[[Set]] set
[[Delete]] deleteProperty
[[OwnPropertyKeys]] ownKeys
[[Call]] apply
[[Construct]] construct

handler メソッドが Proxy オブジェクトの内部メソッ ド実装を提供するために呼び出されるとき、その handler メソッドには proxy の target object が引数として渡され る。proxy の handler object は、必ずしもすべての本質 的内部メソッドに対応するメソッドを持つわけではない。 handler object が内部 trap に対応するメソッドを持たな い場合、proxy 上で内部メソッドを起動すると、proxy の target object 上の対応する内部メソッドの起動が結果とし て生じる。

Proxy オブジェクトの [[ProxyHandler]] および [[ProxyTarget]] 内部スロットは、オブジェクトが作成される とき常に初期化され、通常は変更できない。いくつかの Proxy オブジェクトは、その後 revoked されることを許す 方法で作成される。proxy が revoked されると、その [[ProxyHandler]] および [[ProxyTarget]] 内部スロットは null に設定され、それによりその Proxy オブジェクト上 の内部メソッドの以後の起動は TypeError 例外を送出す るようになる。

Proxy オブジェクトは、任意の ECMAScript code によ って内部メソッドの実装を提供することを許すため、 6.1.7.3 で定義された不変条件に違反する handler メソッドを持つ Proxy オブジェクトを定義することが可能である。 6.1.7.3 で定義された内部メソッド不変条件のいくつかは、本質的完全 性不変条件である。これらの不変条件は、この節で規定される Proxy オブジェクト内部メソッドによって明示的に強制され る。ECMAScript 実装は、起こり得るすべての不変条件違反の 存在下でも堅牢でなければならない。

以下のアルゴリズム記述において、obj は ECMAScript Proxy object、propertyKeyproperty key 値、value は任意の ECMAScript 言語 値、そして descProperty Descriptor record であると仮定する。

10.5.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing either an Object or null, or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "getPrototypeOf") とする。
  6. trapundefined なら、
    1. target.[[GetPrototypeOf]]() を返す。
  7. handlerProto を ? Call(trap, handler, « target ») とする。
  8. handlerProto が Object でなく、かつ handlerProtonull でもないなら、 TypeError 例外を送出する。
  9. extensibleTarget を ? IsExtensible(target) とする。
  10. extensibleTargettrue なら、 handlerProto を返す。
  11. targetProto を ? target.[[GetPrototypeOf]]() とする。
  12. SameValue(handlerProto, targetProto) が false なら、TypeError 例外を送出する。
  13. handlerProto を返す。
Note

Proxy object に対する [[GetPrototypeOf]] は次 の不変条件を強制する:

  • [[GetPrototypeOf]] の結果は Object または null のいずれかでなければならない。
  • target object が拡張可能でない場合、 Proxy object に適用された [[GetPrototypeOf]] は、Proxy object の target object に適用 された [[GetPrototypeOf]] と同じ値を返さ なければならない。

10.5.2 [[SetPrototypeOf]] ( proto )

The [[SetPrototypeOf]] internal method of a Proxy exotic object obj takes argument proto (an Object or null) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "setPrototypeOf") とする。
  6. trapundefined なら、
    1. target.[[SetPrototypeOf]](proto) を返す。
  7. booleanTrapResultToBoolean(? Call( trap, handler, « target, proto »)) とする。
  8. booleanTrapResultfalse なら、 false を返す。
  9. extensibleTarget を ? IsExtensible(target) とする。
  10. extensibleTargettrue なら、 true を返す。
  11. targetProto を ? target.[[GetPrototypeOf]]() とする。
  12. SameValue(proto, targetProto) が false なら、TypeError 例外を送出する。
  13. true を返す。
Note

Proxy object に対する [[SetPrototypeOf]] は次 の不変条件を強制する:

  • [[SetPrototypeOf]] の結果は Boolean 値であ る。
  • target object が拡張可能でない場合、引数の 値は target object に適用された [[GetPrototypeOf]] の結果と同じでなければな らない。

10.5.3 [[IsExtensible]] ( )

The [[IsExtensible]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "isExtensible") とする。
  6. trapundefined なら、
    1. IsExtensible(target) を返す。
  7. booleanTrapResultToBoolean(? Call( trap, handler, « target »)) とする。
  8. targetResult を ? IsExtensible(target) とする。
  9. booleanTrapResulttargetResult でない なら、TypeError 例外を送出する。
  10. booleanTrapResult を返す。
Note

Proxy object に対する [[IsExtensible]] は次 の不変条件を強制する:

  • [[IsExtensible]] の結果は Boolean 値であ る。
  • Proxy object に適用された [[IsExtensible]] は、同じ引数で Proxy object の target object に適用された [[IsExtensible]] と同 じ値を返さなければならない。

10.5.4 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "preventExtensions") とする。
  6. trapundefined なら、
    1. target.[[PreventExtensions]]() を返す。
  7. booleanTrapResultToBoolean(? Call( trap, handler, « target »)) とする。
  8. booleanTrapResulttrue なら、
    1. extensibleTarget を ? IsExtensible(target) とする。
    2. extensibleTargettrue なら、 TypeError 例外を送出する。
  9. booleanTrapResult を返す。
Note

Proxy object に対する [[PreventExtensions]] は次の不変条件を強制する:

  • [[PreventExtensions]] の結果は Boolean 値で ある。
  • Proxy object に適用された [[PreventExtensions]] は、Proxy object の target object に適用された [[IsExtensible]]false である場合にのみ true を返 す。

10.5.5 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of a Proxy exotic object obj takes argument propertyKey (a property key) and returns either a normal completion containing either a Property Descriptor or undefined, or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "getOwnPropertyDescriptor") とする。
  6. trapundefined なら、
    1. target.[[GetOwnProperty]](propertyKey) を返す。
  7. trapResultObj を ? Call(trap, handler, « target, propertyKey ») とする。
  8. trapResultObj が Object でなく、かつ undefined でもないなら、TypeError 例外 を送出する。
  9. targetDesc を ? target.[[GetOwnProperty]](propertyKey) とする。
  10. trapResultObjundefined なら、
    1. targetDescundefined なら、 undefined を返す。
    2. targetDesc.[[Configurable]]false な ら、TypeError 例外を送出する。
    3. extensibleTarget を ? IsExtensible(target) とする。
    4. extensibleTargetfalse なら、 TypeError 例外を送出する。
    5. undefined を返す。
  11. extensibleTarget を ? IsExtensible(target) とする。
  12. resultDesc を ? ToPropertyDescriptor(trapResultObj) とす る。
  13. CompletePropertyDescriptor(resultDesc) を実 行する。
  14. validIsCompatiblePropertyDescriptor( extensibleTarget, resultDesc, targetDesc) とする。
  15. validfalse なら、TypeError 例外 を送出する。
  16. resultDesc.[[Configurable]]false な ら、
    1. targetDescundefined または targetDesc.[[Configurable]]true なら、
      1. TypeError 例外を送出する。
    2. resultDesc[[Writable]] フィールドを持 ち、かつ resultDesc.[[Writable]]false なら、
      1. Assert: targetDesc[[Writable]] フィールドを持つ。
      2. targetDesc.[[Writable]]true な ら、TypeError 例外を送出する。
  17. resultDesc を返す。
Note

Proxy object に対する [[GetOwnProperty]] は 次の不変条件を強制する:

  • [[GetOwnProperty]] の結果は Property Descriptor または undefined のいずれか でなければならない。
  • property は、target object の non-configurable own property として存 在する場合、存在しないものとして報告されてはな らない。
  • property は、拡張可能でない target object の own property として存在する場合、存在し ないものとして報告されてはならない。
  • property は、target object の own property として存在せず、かつ target object が拡張可能でない場合、存在するものとして報告さ れてはならない。
  • property は、それが target object の non-configurable own property として存在 しない限り、non-configurable として報告さ れてはならない。
  • property は、それが target object の non-configurable かつ non-writable own property として存在しない限り、 non-configurable かつ non-writable の 両方として報告されてはならない。

10.5.6 [[DefineOwnProperty]] ( propertyKey, desc )

The [[DefineOwnProperty]] internal method of a Proxy exotic object obj takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "defineProperty") とする。
  6. trapundefined なら、
    1. target.[[DefineOwnProperty]](propertyKey, desc) を返す。
  7. descObjFromPropertyDescriptor(desc) と する。
  8. booleanTrapResultToBoolean(? Call( trap, handler, « target, propertyKey, descObj »)) とする。
  9. booleanTrapResultfalse なら、 false を返す。
  10. targetDesc を ? target.[[GetOwnProperty]](propertyKey) とする。
  11. extensibleTarget を ? IsExtensible(target) とする。
  12. desc[[Configurable]] フィールドを持ち、 かつ desc.[[Configurable]]false な ら、
    1. settingConfigFalsetrue とする。
  13. Else,
    1. settingConfigFalsefalse とする。
  14. targetDescundefined なら、
    1. extensibleTargetfalse なら、 TypeError 例外を送出する。
    2. settingConfigFalsetrue なら、 TypeError 例外を送出する。
  15. Else,
    1. IsCompatiblePropertyDescriptor( extensibleTarget, desc, targetDesc) が false なら、TypeError 例外を送出す る。
    2. settingConfigFalsetrue かつ targetDesc.[[Configurable]]true なら、TypeError 例外を送出する。
    3. IsDataDescriptor(targetDesc) が truetargetDesc.[[Configurable]]false、 かつ targetDesc.[[Writable]]true なら、
      1. desc[[Writable]] フィールドを持ち、 かつ desc.[[Writable]]false な ら、TypeError 例外を送出する。
  16. true を返す。
Note

Proxy object に対する [[DefineOwnProperty]] は次の不変条件を強制する:

  • [[DefineOwnProperty]] の結果は Boolean 値で ある。
  • target object が拡張可能でない場合、 property を追加することはできない。
  • target object に対応する non-configurable own property が存在しな い限り、property を non-configurable に することはできない。
  • target object に対応する non-configurable かつ non-writable own property が存在しない限り、 non-configurable property を non-writable にすることはできない。
  • property に対応する target object の property が存在する場合、その Property Descriptor[[DefineOwnProperty]] を用 いて target object に適用しても例外を送出 してはならない。

10.5.7 [[HasProperty]] ( propertyKey )

The [[HasProperty]] internal method of a Proxy exotic object obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "has") とする。
  6. trapundefined なら、
    1. target.[[HasProperty]](propertyKey) を返す。
  7. booleanTrapResultToBoolean(? Call( trap, handler, « target, propertyKey »)) とする。
  8. booleanTrapResultfalse なら、
    1. targetDesc を ? target.[[GetOwnProperty]](propertyKey) とする。
    2. targetDescundefined でなければ、
      1. targetDesc.[[Configurable]]false なら、TypeError 例外を送出する。
      2. extensibleTarget を ? IsExtensible(target) とする。
      3. extensibleTargetfalse なら、 TypeError 例外を送出する。
  9. booleanTrapResult を返す。
Note

Proxy object に対する [[HasProperty]] は次 の不変条件を強制する:

  • [[HasProperty]] の結果は Boolean 値である。
  • property は、target object の non-configurable own property として存 在する場合、存在しないものとして報告されてはな らない。
  • property は、target object の own property として存在し、かつ target object が拡張可能でない場合、存在しないものとして報告 されてはならない。

10.5.8 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of a Proxy exotic object obj takes arguments propertyKey (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. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "get") とする。
  6. trapundefined なら、
    1. target.[[Get]](propertyKey, receiver) を返す。
  7. trapResult を ? Call(trap, handler, « target, propertyKey, receiver ») とする。
  8. targetDesc を ? target.[[GetOwnProperty]](propertyKey) とする。
  9. targetDescundefined でなく、かつ targetDesc.[[Configurable]]false なら、
    1. IsDataDescriptor(targetDesc) が true かつ targetDesc.[[Writable]]false なら、
      1. SameValue(trapResult, targetDesc.[[Value]]) が false な ら、TypeError 例外を送出する。
    2. IsAccessorDescriptor(targetDesc) が true かつ targetDesc.[[Get]]undefined なら、
      1. trapResultundefined でなけれ ば、TypeError 例外を送出する。
  10. trapResult を返す。
Note

Proxy object に対する [[Get]] は次の不変条 件を強制する:

  • target object の property が non-writable かつ non-configurable な own data property である場合、property に対して報告される値は、対応する target object property の値と同じでなければならな い。
  • 対応する target object property が、 [[Get]] 属性として undefined を持つ non-configurable own accessor property である場合、property に対して報告される値 は undefined でなければならない。

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

The [[Set]] internal method of a Proxy exotic object obj takes arguments propertyKey (a property key), value (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. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "set") とする。
  6. trapundefined なら、
    1. target.[[Set]](propertyKey, value, receiver) を返す。
  7. booleanTrapResultToBoolean(? Call( trap, handler, « target, propertyKey, value, receiver »)) とする。
  8. booleanTrapResultfalse なら、 false を返す。
  9. targetDesc を ? target.[[GetOwnProperty]](propertyKey) とする。
  10. targetDescundefined でなく、かつ targetDesc.[[Configurable]]false なら、
    1. IsDataDescriptor(targetDesc) が true かつ targetDesc.[[Writable]]false なら、
      1. SameValue(value, targetDesc.[[Value]]) が false なら、TypeError 例外を送 出する。
    2. IsAccessorDescriptor(targetDesc) が true なら、
      1. targetDesc.[[Set]]undefined なら、TypeError 例外を送出する。
  11. true を返す。
Note

Proxy object に対する [[Set]] は次の不変条件 を強制する:

  • [[Set]] の結果は Boolean 値である。
  • 対応する target object property が non-writable かつ non-configurable な own data property である場合、その property の値を対応する target object property の値と異なるものに変更することはで きない。
  • 対応する target object property が、 [[Set]] 属性として undefined を持つ non-configurable own accessor property である場合、その property の値を設定するこ とはできない。

10.5.10 [[Delete]] ( propertyKey )

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

  1. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "deleteProperty") とする。
  6. trapundefined なら、
    1. target.[[Delete]](propertyKey) を返す。
  7. booleanTrapResultToBoolean(? Call( trap, handler, « target, propertyKey »)) とする。
  8. booleanTrapResultfalse なら、 false を返す。
  9. targetDesc を ? target.[[GetOwnProperty]](propertyKey) とする。
  10. targetDescundefined なら、true を返す。
  11. targetDesc.[[Configurable]]false な ら、TypeError 例外を送出する。
  12. extensibleTarget を ? IsExtensible(target) とする。
  13. extensibleTargetfalse なら、 TypeError 例外を送出する。
  14. true を返す。
Note

Proxy object に対する [[Delete]] は次の不変 条件を強制する:

  • [[Delete]] の結果は Boolean 値である。
  • property は、target object の non-configurable own property として存 在する場合、削除されたものとして報告されてはな らない。
  • property は、target object の own property として存在し、かつ target object が non-extensible である場合、削除されたも のとして報告されてはならない。

10.5.11 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing a List of property keys or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "ownKeys") とする。
  6. trapundefined なら、
    1. target.[[OwnPropertyKeys]]() を返す。
  7. trapResultArray を ? Call(trap, handler, « target ») とする。
  8. trapResult を ? CreateListFromArrayLike(trapResultArray, property-key) とする。
  9. trapResult に重複要素が含まれるなら、 TypeError 例外を送出する。
  10. extensibleTarget を ? IsExtensible(target) とする。
  11. targetKeys を ? target.[[OwnPropertyKeys]]() とする。
  12. Assert: targetKeysproperty keyList である。
  13. Assert: targetKeys は重複要素を含まない。
  14. targetConfigurableKeys を新しい空の List とする。
  15. targetNonconfigurableKeys を新しい空の List とする。
  16. targetKeys の各要素 key について、次を行う
    1. desc を ? target.[[GetOwnProperty]](key) とする。
    2. descundefined でなく、かつ desc.[[Configurable]]false なら、
      1. keytargetNonconfigurableKeys に append する。
    3. Else,
      1. keytargetConfigurableKeys に append する。
  17. extensibleTargettrue かつ targetNonconfigurableKeys が空なら、
    1. trapResult を返す。
  18. uncheckedResultKeys を、その要素が trapResult の要素である List とする。
  19. targetNonconfigurableKeys の各要素 key について、次を行う
    1. uncheckedResultKeyskey を含まなけ れば、TypeError 例外を送出する。
    2. uncheckedResultKeys から key を除去す る。
  20. extensibleTargettrue なら、 trapResult を返す。
  21. targetConfigurableKeys の各要素 key に ついて、次を行う
    1. uncheckedResultKeyskey を含まなけ れば、TypeError 例外を送出する。
    2. uncheckedResultKeys から key を除去す る。
  22. uncheckedResultKeys が空でなければ、 TypeError 例外を送出する。
  23. trapResult を返す。
Note

Proxy object に対する [[OwnPropertyKeys]] は 次の不変条件を強制する:

  • [[OwnPropertyKeys]] の結果は List である。
  • 返される List は重複要素を含まない。
  • 返される List の各要素は property key であ る。
  • 結果の List は、target object のすべての non-configurable own property の key を 含まなければならない。
  • target object が拡張可能でない場合、結果の List は target object の own property のすべての key を含み、かつそれ以外の値を含ん ではならない。

10.5.12 [[Call]] ( thisArgument, argumentsList )

The [[Call]] internal method of a Proxy exotic object obj takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. handlerobj.[[ProxyHandler]] とする。
  4. Assert: handler は Object である。
  5. trap を ? GetMethod(handler, "apply") とする。
  6. trapundefined なら、
    1. Call(target, thisArgument, argumentsList) を返す。
  7. argArrayCreateArrayFromList(argumentsList) とする。
  8. Call(trap, handler, « target, thisArgument, argArray ») を返す。
Note

Proxy 特殊オブジェクト[[Call]] 内部メソッドを持 つのは、その [[ProxyTarget]] 内部スロットの初期値が [[Call]] 内部メソッドを持つ object である場合に限られ る。

10.5.13 [[Construct]] ( argumentsList, newTarget )

The [[Construct]] internal method of a Proxy exotic object obj takes arguments argumentsList (a List of ECMAScript language values) and newTarget (a constructor) and returns either a normal completion containing an Object or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj) を実行する。
  2. targetobj.[[ProxyTarget]] とする。
  3. Assert: IsConstructor(target) is true.
  4. handlerobj.[[ProxyHandler]] とする。
  5. Assert: handler は Object である。
  6. trap を ? GetMethod(handler, "construct") とする。
  7. trapundefined なら、
    1. Construct(target, argumentsList, newTarget) を返す。
  8. argArrayCreateArrayFromList(argumentsList) とする。
  9. newObj を ? Call(trap, handler, « target, argArray, newTarget ») とす る。
  10. newObj が Object でなければ、 TypeError 例外を送出する。
  11. newObj を返す。
Note 1

Proxy 特殊オブジェクト[[Construct]] 内部メソッ ドを持つのは、その [[ProxyTarget]] 内部スロットの初期値 が [[Construct]] 内部メソッドを持つ object である場合 に限られる。

Note 2

Proxy object に対する [[Construct]] は次の不 変条件を強制する:

  • [[Construct]] の結果は Object でなければなら ない。

10.5.14 ValidateNonRevokedProxy ( proxy )

The abstract operation ValidateNonRevokedProxy takes argument proxy (a Proxy exotic object) and returns either a normal completion containing unused or a throw completion. これは、proxy が revoked されている場合に TypeError 例外を送出する。 It performs the following steps when called:

  1. proxy.[[ProxyTarget]]null なら、 TypeError 例外を送出する。
  2. Assert: proxy.[[ProxyHandler]]null ではない。
  3. unused を返す。

10.5.15 ProxyCreate ( target, handler )

The abstract operation ProxyCreate takes arguments target (an ECMAScript language value) and handler (an ECMAScript language value) and returns either a normal completion containing a Proxy exotic object or a throw completion. これは、新しい Proxy object の作成を規定する ために用いられる。 It performs the following steps when called:

  1. target が Object でなければ、 TypeError 例外を送出する。
  2. handler が Object でなければ、 TypeError 例外を送出する。
  3. proxyMakeBasicObject( « [[ProxyHandler]], [[ProxyTarget]] ») とする。
  4. proxy の本質的内部メソッドのうち [[Call]] および [[Construct]] を除くものを、 10.5 に規定された定義に設定する。
  5. IsCallable(target) が true なら、
    1. proxy.[[Call]]10.5.12 に規定されたとおりに設定する。
    2. IsConstructor(target) が true なら、
      1. proxy.[[Construct]]10.5.13 に規定されたとおりに設定する。
  6. proxy.[[ProxyTarget]]target に設定す る。
  7. proxy.[[ProxyHandler]]handler に設定 する。
  8. proxy を返す。