10 Ordinary ObjectsおよびExotic Objectsの振る舞い

10.1 Ordinary Object Internal Methods and Internal Slots

すべてのordinary objectsは、[[Prototype]]と呼ばれるinternal slotを持ちます。このinternal slotの値はnullまたはobjectのいずれかであり、inheritanceの実装に使用されます。propertyKeyという名前のpropertyがordinary object objには存在しないが、その[[Prototype]] object上には存在すると仮定します。propertyKey[[Prototype]] object上のdata propertyを参照する場合、objはget accessについてそれを継承し、propertyKeyobjのpropertyであるかのように振る舞います。propertyKey[[Prototype]] object上のwritable data propertyを参照する場合、obj上のpropertyKeyのset accessは、obj上にpropertyKeyという名前の新しいdata propertyを作成します。propertyKey[[Prototype]] object上のnon-writable data propertyを参照する場合、obj上のpropertyKeyのset accessは失敗します。propertyKey[[Prototype]] object上のaccessor propertyを参照する場合、そのaccessorはget accessとset accessの両方についてobjに継承されます。

すべてのordinary objectはBoolean値の[[Extensible]] internal slotを持ち、これは6.1.7.3で指定されるextensibility関連のinternal method invariantsを満たすために使用されます。すなわち、objectの[[Extensible]] internal slotの値がいったんfalseに設定されると、そのobjectにpropertiesを追加すること、そのobjectの[[Prototype]] internal slotの値を変更すること、またはその後[[Extensible]]の値をtrueへ変更することは、もはや不可能になります。

以下のalgorithm descriptionsでは、objordinary objectpropertyKeyproperty key値、valueは任意のECMAScript言語値propertyDescProperty Descriptor recordであると仮定します。

ordinary object internal methodは、同様の名前を持つabstract operationへ委譲します。そのようなabstract operationが別のinternal methodに依存する場合、その同様の名前を持つabstract operationを直接呼び出すのではなく、internal methodがobj上で呼び出されます。これらのsemanticsは、ordinary object internal methodsがexotic objectsに適用されたとき、exotic objectsのoverridden internal methodsが呼び出されることを保証します。

10.1.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of 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 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. そうでなく、SameValue(cursor, obj)がtrueなら、
      1. falseを返す。
    3. そうでなければ、
      1. cursor.[[GetPrototypeOf]]10.1.1で定義されるordinary object internal methodでないなら、donetrueに設定する。
      2. そうでなければ、cursorcursor.[[Prototype]]に設定する。
  8. obj.[[Prototype]]protoに設定する。
  9. trueを返す。
Note

ステップ7のloopは、[[GetPrototypeOf]]および[[SetPrototypeOf]]についてordinary object definitionsを使用するobjectsのみを含む任意のprototype chainにcyclesが存在しないことを保証します。

10.1.3 [[IsExtensible]] ( )

The [[IsExtensible]] internal method of 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 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 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. propertyDescを、fieldsを持たない新しく作成されたProperty Descriptorとする。
  3. ownPropertyを、keyがpropertyKeyであるobjのown propertyとする。
  4. ownPropertydata propertyなら、
    1. propertyDesc.[[Value]]ownProperty[[Value]]属性の値に設定する。
    2. propertyDesc.[[Writable]]ownProperty[[Writable]]属性の値に設定する。
  5. そうでなければ、
    1. Assert: ownPropertyaccessor propertyである。
    2. propertyDesc.[[Get]]ownProperty[[Get]]属性の値に設定する。
    3. propertyDesc.[[Set]]ownProperty[[Set]]属性の値に設定する。
  6. propertyDesc.[[Enumerable]]ownProperty[[Enumerable]]属性の値に設定する。
  7. propertyDesc.[[Configurable]]ownProperty[[Configurable]]属性の値に設定する。
  8. propertyDescを返す。

10.1.6 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

The [[DefineOwnProperty]] internal method of ordinary object obj takes arguments propertyKey (a property key) and propertyDesc (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, propertyDesc)を返す。

10.1.6.1 OrdinaryDefineOwnProperty ( obj, propertyKey, propertyDesc )

The abstract operation OrdinaryDefineOwnProperty takes arguments obj (an Object), propertyKey (a property key), and propertyDesc (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, propertyDesc, current)を返す。

10.1.6.2 IsCompatiblePropertyDescriptor ( extensible, propertyDesc, current )

The abstract operation IsCompatiblePropertyDescriptor takes arguments extensible (a Boolean), propertyDesc (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, propertyDesc, current)を返す。

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

The abstract operation ValidateAndApplyPropertyDescriptor takes arguments obj (an Object or undefined), propertyKey (a property key), extensible (a Boolean), propertyDesc (a Property Descriptor), and current (a Property Descriptor or undefined) and returns a Boolean. これは、invariantsを維持しつつ、指定されたextensibilityおよび現在のproperty currentを持つobjectのpropertyとしてpropertyDescを適用できる場合に限りtrueを返します。そのような適用が可能であり、objundefinedでない場合、propertyKeyという名前のpropertyについてそれが実行されます(必要であれば作成されます)。 It performs the following steps when called:

  1. Assert: propertyKeyproperty keyである。
  2. currentundefinedなら、
    1. extensiblefalseなら、falseを返す。
    2. objundefinedなら、trueを返す。
    3. IsAccessorDescriptor(propertyDesc)がtrueなら、
      1. object objpropertyKeyという名前のown accessor propertyを作成する。その[[Get]][[Set]][[Enumerable]]、および[[Configurable]]属性は、propertyDescが対応するfieldを持つ場合はpropertyDesc内の対応するfieldの値に、そうでない場合はその属性のdefault valueに設定される。
    4. そうでなければ、
      1. object objpropertyKeyという名前のown data propertyを作成する。その[[Value]][[Writable]][[Enumerable]]、および[[Configurable]]属性は、propertyDescが対応するfieldを持つ場合はpropertyDesc内の対応するfieldの値に、そうでない場合はその属性のdefault valueに設定される。
    5. trueを返す。
  3. Assert: currentfully populated Property Descriptorである。
  4. propertyDescがfieldsをまったく持たないなら、trueを返す。
  5. current.[[Configurable]]falseなら、
    1. propertyDesc[[Configurable]] fieldを持ち、propertyDesc.[[Configurable]]trueなら、falseを返す。
    2. propertyDesc[[Enumerable]] fieldを持ち、propertyDesc.[[Enumerable]]current.[[Enumerable]]でないなら、falseを返す。
    3. IsGenericDescriptor(propertyDesc)がfalseであり、かつIsAccessorDescriptor(propertyDesc)がIsAccessorDescriptor(current)でないなら、falseを返す。
    4. IsAccessorDescriptor(current)がtrueなら、
      1. propertyDesc[[Get]] fieldを持ち、SameValue(propertyDesc.[[Get]], current.[[Get]])がfalseなら、falseを返す。
      2. propertyDesc[[Set]] fieldを持ち、SameValue(propertyDesc.[[Set]], current.[[Set]])がfalseなら、falseを返す。
    5. そうでなく、current.[[Writable]]falseなら、
      1. propertyDesc[[Writable]] fieldを持ち、propertyDesc.[[Writable]]trueなら、falseを返す。
      2. NOTE: SameValueNaN valuesに対してtrueを返しますが、それらは他の手段によって区別可能な場合があります。ここで返すことにより、objの既存propertyが変更されないことが保証されます。
      3. propertyDesc[[Value]] fieldを持つなら、SameValue(propertyDesc.[[Value]], current.[[Value]])を返す。
  6. objundefinedでないなら、
    1. IsDataDescriptor(current)がtrueであり、かつIsAccessorDescriptor(propertyDesc)がtrueなら、
      1. propertyDesc[[Configurable]] fieldを持つなら、configurablepropertyDesc.[[Configurable]]とする;そうでなければ、configurablecurrent.[[Configurable]]とする。
      2. propertyDesc[[Enumerable]] fieldを持つなら、enumerablepropertyDesc.[[Enumerable]]とする;そうでなければ、enumerablecurrent.[[Enumerable]]とする。
      3. object objpropertyKeyという名前のpropertyをaccessor propertyで置き換える。その[[Configurable]]および[[Enumerable]]属性はそれぞれconfigurableおよびenumerableに設定され、その[[Get]]および[[Set]]属性は、propertyDescが対応するfieldを持つ場合はpropertyDesc内の対応するfieldの値に、そうでない場合はその属性のdefault valueに設定される。
    2. そうでなく、IsAccessorDescriptor(current)がtrueであり、かつIsDataDescriptor(propertyDesc)がtrueなら、
      1. propertyDesc[[Configurable]] fieldを持つなら、configurablepropertyDesc.[[Configurable]]とする;そうでなければ、configurablecurrent.[[Configurable]]とする。
      2. propertyDesc[[Enumerable]] fieldを持つなら、enumerablepropertyDesc.[[Enumerable]]とする;そうでなければ、enumerablecurrent.[[Enumerable]]とする。
      3. object objpropertyKeyという名前のpropertyをdata propertyで置き換える。その[[Configurable]]および[[Enumerable]]属性はそれぞれconfigurableおよびenumerableに設定され、その[[Value]]および[[Writable]]属性は、propertyDescが対応するfieldを持つ場合はpropertyDesc内の対応するfieldの値に、そうでない場合はその属性のdefault valueに設定される。
    3. そうでなければ、
      1. propertyDescの各field name fieldNameについて、object objpropertyKeyという名前のpropertyのfieldNameという名前の属性を、propertyDescfieldName fieldの値に設定する。
  7. trueを返す。

10.1.7 [[HasProperty]] ( propertyKey )

The [[HasProperty]] internal method of 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 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. propertyDescを ? obj.[[GetOwnProperty]](propertyKey) とする。
  2. propertyDescundefinedなら、
    1. parentを ? obj.[[GetPrototypeOf]]() とする。
    2. parentnullなら、undefinedを返す。
    3. parent.[[Get]](propertyKey, receiver)を返す。
  3. IsDataDescriptor(propertyDesc)がtrueなら、propertyDesc.[[Value]]を返す。
  4. Assert: IsAccessorDescriptor(propertyDesc)はtrueである。
  5. getterpropertyDesc.[[Get]]とする。
  6. getterundefinedなら、undefinedを返す。
  7. Call(getter, receiver)を返す。

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

The [[Set]] internal method of 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. existingDescを ? receiver.[[GetOwnProperty]](propertyKey) とする。
    4. existingDescundefinedなら、
      1. Assert: receiverは現在property propertyKeyを持たない。
      2. CreateDataProperty(receiver, propertyKey, value)を返す。
    5. IsAccessorDescriptor(existingDesc)がtrueなら、falseを返す。
    6. existingDesc.[[Writable]]falseなら、falseを返す。
    7. valueDescをPropertyDescriptor { [[Value]]: value }とする。
    8. receiver.[[DefineOwnProperty]](propertyKey, valueDesc)を返す。
  3. Assert: IsAccessorDescriptor(ownDesc)はtrueである。
  4. setterownDesc.[[Set]]とする。
  5. setterundefinedなら、falseを返す。
  6. Call(setter, receiver, « value »)を実行する。
  7. trueを返す。

10.1.10 [[Delete]] ( propertyKey )

The [[Delete]] internal method of 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. propertyDescを ? obj.[[GetOwnProperty]](propertyKey) とする。
  2. propertyDescundefinedなら、trueを返す。
  3. propertyDesc.[[Configurable]]trueなら、
    1. objからpropertyKeyという名前のown propertyを削除する。
    2. trueを返す。
  4. falseを返す。

10.1.11 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of 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. array indexであるようなobjの各own property key propertyKeyについて、ascending numeric index orderで、以下を行う
    1. propertyKeykeysへappendする。
  3. Stringであり、array indexでないようなobjの各own property key propertyKeyについて、property creationのascending chronological orderで、以下を行う
    1. propertyKeykeysへappendする。
  4. Symbolであるようなobjの各own property key propertyKeyについて、property creationのascending chronological orderで、以下を行う
    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. これは、新しいordinary objectsのruntime creationを指定するために使用されます。additionalInternalSlotsListは、[[Prototype]]および[[Extensible]]を超えて、objectの一部として定義されなければならない追加internal slotsの名前を含みます。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を呼び出す以上のことはほとんどしませんが、その使用はordinary objectを作成する意図を伝え、exotic objectを作成する意図ではないことを伝えます。したがって、この仕様内では、その結果がnon-ordinaryになるような方法でobjectのinternal methodsを後で変更するalgorithmからは呼び出されません。exotic objectsを作成するoperationsはMakeBasicObjectを直接invokeします。

10.1.13 OrdinaryCreateFromConstructor ( ctor, intrinsicDefaultProto [ , internalSlotsList ] )

The abstract operation OrdinaryCreateFromConstructor takes arguments ctor (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. これは、存在する場合にはconstructor"prototype" propertyから[[Prototype]]値を取得したordinary objectを作成します。そうでない場合、intrinsicDefaultProtoによって名付けられたintrinsicが[[Prototype]]に使用されます。internalSlotsListは、objectの一部として定義されなければならない追加internal slotsの名前を含みます。internalSlotsListが提供されない場合、新しい空のListが使用されます。 It performs the following steps when called:

  1. Assert: intrinsicDefaultProtoはこの仕様におけるintrinsic objectの名前である。対応するobjectは、objectの[[Prototype]]値として使用されることを意図したintrinsicでなければならない。
  2. protoを ? GetPrototypeFromConstructor(ctor, intrinsicDefaultProto) とする。
  3. internalSlotsListが存在するなら、slotsinternalSlotsListとする。
  4. そうでなければ、slotsを新しい空のListとする。
  5. OrdinaryObjectCreate(proto, slots)を返す。

10.1.14 GetPrototypeFromConstructor ( ctor, intrinsicDefaultProto )

The abstract operation GetPrototypeFromConstructor takes arguments ctor (a function object) and intrinsicDefaultProto (a String) and returns either a normal completion containing an Object or a throw completion. これは、特定のconstructorに対応するobjectを作成するために使用すべき[[Prototype]]値を決定します。その値は、存在する場合にはconstructor"prototype" propertyから取得されます。そうでない場合、intrinsicDefaultProtoによって名付けられたintrinsicが[[Prototype]]に使用されます。 It performs the following steps when called:

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

ctor[[Prototype]]値を供給しない場合、使用されるdefault valueはrunning execution contextからではなく、ctor functionの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を持つ場合を除き、例外をthrowします。 It performs the following steps when called:

  1. objがObjectでないなら、TypeError例外をthrowする。
  2. objinternalSlot internal slotを持たないなら、TypeError例外をthrowする。
  3. unusedを返す。

10.2 ECMAScript関数オブジェクト

ECMAScript function objectsは、lexical environmentで閉じ込められたparameterized ECMAScript codeをカプセル化し、そのコードの動的評価をサポートします。ECMAScript function objectordinary objectであり、他のordinary objectsと同じinternal slotsおよび同じinternal methodsを持ちます。ECMAScript function objectのコードは、strict mode code11.2.2)またはnon-strict codeのいずれかであり得ます。コードがstrict mode codeであるECMAScript function objectstrict functionと呼ばれます。コードがstrict mode codeでないものはnon-strict functionと呼ばれます。

[[Extensible]]および[[Prototype]]に加えて、ECMAScript function objectsTable 26に列挙されるinternal slotsも持ちます。

Table 26: Internal Slots of ECMAScript Function Objects
Internal Slot 説明
[[Environment]] Environment Record functionがclosed overされたEnvironment Record。functionのコードを評価するときにouter environmentとして使用されます。
[[PrivateEnvironment]] PrivateEnvironment Recordまたはnull functionがclosed overされたPrivate NamesのためのPrivateEnvironment Record。このfunctionが構文上class内に含まれていない場合はnull。functionのコードを評価するとき、inner classesのouter PrivateEnvironmentとして使用されます。
[[FormalParameters]] Parse Node functionのformal parameter listを定義するsource textのroot parse node。
[[ECMAScriptCode]] Parse Node functionのbodyを定義するsource textのroot parse node。
[[ConstructorKind]] baseまたはderived functionがderived class constructorであるかどうか。
[[Realm]] Realm Record functionが作成されたrealmであり、functionの評価時にアクセスされる任意のintrinsic objectsを提供するもの。
[[ScriptOrModule]] Script RecordまたはModule Record functionが作成されたscriptまたはmodule。
[[ThisMode]] lexical, strict, or global functionのformal parametersおよびcode body内でthis参照がどのように解釈されるかを定義します。lexicalは、thisが字句的に囲むfunctionのthis値を参照することを意味します。strictは、functionの呼び出しによって提供されたthis値がそのまま使用されることを意味します。globalは、undefinedまたはnullthis値がglobal objectへの参照として解釈され、その他のthis値はまずToObjectに渡されることを意味します。
[[Strict]] Boolean これがstrict functionである場合はtruenon-strict functionである場合はfalse
[[HomeObject]] Objectまたはundefined functionがsuperを使用する場合、これは、その[[GetPrototypeOf]]super property lookupsを開始するobjectを提供するobjectです。
[[SourceText]] Unicode code pointsのsequence functionを定義するsource text
[[Fields]] ClassFieldDefinition RecordsList functionがclassである場合、これはclassのnon-static fieldsおよび対応するinitializersを表すRecordsのlistです。
[[PrivateMethods]] PrivateElementsList functionがclassである場合、これはclassのnon-static private methodsおよびaccessorsを表すlistです。
[[ClassFieldInitializerName]] String、Symbol、Private Name、またはempty functionがclass fieldのinitializerとして作成された場合、そのfieldのNamedEvaluationに使用する名前;それ以外の場合はempty
[[IsClassConstructor]] Boolean functionがclass constructorであるかどうかを示します。(trueの場合、functionの[[Call]]を呼び出すと直ちにTypeError例外がthrowされます。)

すべてのECMAScript function objectsは、ここで定義される[[Call]] internal methodを持ちます。constructorでもあるECMAScript functionsは、さらに[[Construct]] internal methodを持ちます。

10.2.1 [[Call]] ( thisArg, argList )

The [[Call]] internal method of ECMAScript function object func takes arguments thisArg (an ECMAScript language value) and argList (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: errorは、funcに関連付けられたRealm Recordを伴うcalleeContext内で作成される。
    3. calleeContextexecution context stackから削除し、callerContextrunning execution contextとして復元する。
    4. errorをthrowする。
  5. OrdinaryCallBindThis(func, calleeContext, thisArg)を実行する。
  6. resultCompletion(OrdinaryCallEvaluateBody(func, argList))とする。
  7. calleeContextexecution context stackから削除し、callerContextrunning execution contextとして復元する。
  8. resultreturn completionなら、result.[[Value]]を返す。
  9. Assert: resultthrow completionである。
  10. resultを返す。
Note

ステップ7calleeContextexecution context stackから削除されるとき、それがsuspendedであり、accessible Generatorによる後続のresumptionのために保持されている場合、破棄してはなりません。

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がまだsuspendedでないなら、callerContextをsuspendする。
  12. calleeContextexecution context stackへpushする;calleeContextは現在running execution contextである。
  13. NOTE: この時点以降に生成される任意のexception objectsはcalleeRealmに関連付けられる。
  14. calleeContextを返す。

10.2.1.2 OrdinaryCallBindThis ( func, calleeContext, thisArg )

The abstract operation OrdinaryCallBindThis takes arguments func (an ECMAScript function object), calleeContext (an execution context), and thisArg (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. thisValuethisArgとする。
  6. そうでなければ、
    1. thisArgundefinedまたはnullのいずれかなら、
      1. globalEnvcalleeRealm.[[GlobalEnv]]とする。
      2. Assert: globalEnvGlobal Environment Recordである。
      3. thisValueglobalEnv.[[GlobalThisValue]]とする。
    2. そうでなければ、
      1. thisValueを ! ToObject(thisArg) とする。
      2. NOTE: ToObjectcalleeRealmを使用してwrapper objectsを生成する。
  7. Assert: localEnvFunction Environment Recordである。
  8. Assert: 次のstepは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 argList (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およびargListを伴うFunctionBodyEvaluateFunctionBodyを ? で返す。
ConciseBody : ExpressionBody
  1. 引数funcおよびargListを伴うConciseBodyEvaluateConciseBodyを ? で返す。
GeneratorBody : FunctionBody
  1. 引数funcおよびargListを伴うGeneratorBodyEvaluateGeneratorBodyを ? で返す。
AsyncGeneratorBody : FunctionBody
  1. 引数funcおよびargListを伴うAsyncGeneratorBodyEvaluateAsyncGeneratorBodyを ? で返す。
AsyncFunctionBody : FunctionBody
  1. 引数funcおよびargListを伴うAsyncFunctionBodyEvaluateAsyncFunctionBodyを ? で返す。
AsyncConciseBody : ExpressionBody
  1. 引数funcおよびargListを伴うAsyncConciseBodyEvaluateAsyncConciseBodyを ? で返す。
Initializer : = AssignmentExpression
  1. Assert: argListは空である。
  2. Assert: func.[[ClassFieldInitializerName]]emptyでない。
  3. IsAnonymousFunctionDefinition(AssignmentExpression)がtrueなら、
    1. valueを、引数func.[[ClassFieldInitializerName]]を伴うInitializerNamedEvaluationの ? 結果とする。
  4. そうでなければ、
    1. rhsAssignmentExpressionEvaluationの ? 結果とする。
    2. valueを ? GetValue(rhs) とする。
  5. ReturnCompletion(value)を返す。
Note

field initializersはfunction boundaryを構成しますが、FunctionDeclarationInstantiationの呼び出しには観測可能な効果がないため省略されます。

ClassStaticBlockBody : ClassStaticBlockStatementList
  1. Assert: argListは空である。
  2. 引数funcを伴うClassStaticBlockBodyEvaluateClassStaticBlockBodyを ? で返す。

10.2.1.4 OrdinaryCallEvaluateBody ( func, argList )

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

  1. 引数funcおよびargListを伴うfunc.[[ECMAScriptCode]]EvaluateBodyを ? で返す。

10.2.2 [[Construct]] ( argList, newTarget )

The [[Construct]] internal method of ECMAScript function object func takes arguments argList (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. thisArgを ? OrdinaryCreateFromConstructor(newTarget, "%Object.prototype%") とする。
  4. calleeContextPrepareForOrdinaryCall(func, newTarget)とする。
  5. Assert: calleeContextは現在running execution contextである。
  6. kindbaseなら、
    1. OrdinaryCallBindThis(func, calleeContext, thisArg)を実行する。
    2. initializeResultCompletion(InitializeInstanceElements(thisArg, func))とする。
    3. initializeResultabrupt completionなら、
      1. calleeContextexecution context stackから削除し、callerContextrunning execution contextとして復元する。
      2. initializeResultを返す。
  7. ctorEnvcalleeContextのLexicalEnvironmentとする。
  8. resultCompletion(OrdinaryCallEvaluateBody(func, argList))とする。
  9. calleeContextexecution context stackから削除し、callerContextrunning execution contextとして復元する。
  10. resultthrow completionなら、
    1. resultを返す。
  11. Assert: resultreturn completionである。
  12. result.[[Value]]がObjectなら、result.[[Value]]を返す。
  13. kindbaseなら、thisArgを返す。
  14. result.[[Value]]undefinedでないなら、TypeError例外をthrowする。
  15. thisBindingを ? ctorEnv.GetThisBinding() とする。
  16. Assert: thisBindingはObjectである。
  17. thisBindingを返す。

10.2.3 OrdinaryFunctionCreate ( proto, sourceText, paramList, body, thisMode, envRecord, privateEnv )

The abstract operation OrdinaryFunctionCreate takes arguments proto (an Object), sourceText (a sequence of Unicode code points), paramList (a Parse Node), body (a Parse Node), thisMode (lexical-this or non-lexical-this), envRecord (an Environment Record), and privateEnv (a PrivateEnvironment Record or null) and returns an ECMAScript function object. これは、デフォルトの[[Call]] internal methodを持ち、[[Construct]] internal methodを持たない新しいfunctionのruntime creationを指定するために使用されます(ただし、後でMakeConstructorなどのoperationによって追加される場合があります)。sourceTextは、作成されるfunctionのsyntactic definitionのsource textです。 It performs the following steps when called:

  1. internalSlotsListTable 26に列挙されるinternal slotsとする。
  2. funcOrdinaryObjectCreate(proto, internalSlotsList)とする。
  3. func.[[Call]]10.2.1で指定される定義に設定する。
  4. func.[[SourceText]]sourceTextに設定する。
  5. func.[[FormalParameters]]paramListに設定する。
  6. func.[[ECMAScriptCode]]bodyに設定する。
  7. strictIsStrict(body)とする。
  8. func.[[Strict]]strictに設定する。
  9. thisModelexical-thisなら、func.[[ThisMode]]lexicalに設定する。
  10. そうでなく、stricttrueなら、func.[[ThisMode]]strictに設定する。
  11. そうでなければ、func.[[ThisMode]]globalに設定する。
  12. func.[[IsClassConstructor]]falseに設定する。
  13. func.[[Environment]]envRecordに設定する。
  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. lengthparamListExpectedArgumentCountとする。
  22. SetFunctionLength(func, length)を実行する。
  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% ( )

このfunctionは%ThrowTypeError% intrinsic objectです。

これは、realmごとに1回定義されるanonymous built-in function objectです。

呼び出されたとき、次のstepsを実行します:

  1. TypeError例外をthrowする。

このfunctionの[[Extensible]] internal slotの値はfalseです。

このfunctionの"length" propertyは、attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }を持ちます。

このfunctionの"name" propertyは、attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }を持ちます。

10.2.5 MakeConstructor ( func [ , writableProto [ , proto ] ] )

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

  1. funcがECMAScript function objectなら、
    1. Assert: IsConstructor(func)はfalseである。
    2. Assert: funcはextensible objectであり、"prototype" own propertyを持たない。
    3. func.[[Construct]]10.2.2で指定される定義に設定する。
  2. そうでなければ、
    1. func.[[Construct]]10.3.2で指定される定義に設定する。
  3. func.[[ConstructorKind]]baseに設定する。
  4. writableProtoが存在しないなら、writablePrototrueに設定する。
  5. protoが存在しないなら、
    1. protoOrdinaryObjectCreate(%Object.prototype%)に設定する。
    2. DefinePropertyOrThrow(proto, "constructor", PropertyDescriptor { [[Value]]: func, [[Writable]]: writableProto, [[Enumerable]]: false, [[Configurable]]: true })を実行する。
  6. DefinePropertyOrThrow(func, "prototype", PropertyDescriptor { [[Value]]: proto, [[Writable]]: writableProto, [[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]]falseである。
  2. func.[[IsClassConstructor]]trueに設定する。
  3. unusedを返す。

10.2.7 MakeMethod ( func, homeObj )

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

  1. Assert: homeObjordinary objectである。
  2. func.[[HomeObject]]homeObjに設定する。
  3. unusedを返す。

10.2.8 DefineMethodProperty ( homeObj, name, closure, enumerable )

The abstract operation DefineMethodProperty takes arguments homeObj (an Object), name (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: homeObjはordinaryかつextensible objectである。
  2. namePrivate Nameなら、PrivateElement { [[Key]]: name, [[Kind]]: method, [[Value]]: closure }を返す。
  3. propertyDescをPropertyDescriptor { [[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true }とする。
  4. DefinePropertyOrThrow(homeObj, name, propertyDesc)を実行する。
  5. NOTE: DefinePropertyOrThrowabrupt completionを返すのは、name"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" propertyを追加します。 It performs the following steps when called:

  1. Assert: funcはextensible objectであり、"name" own propertyを持たない。
  2. nameがSymbolなら、
    1. descriptionname.[[Description]]とする。
    2. descriptionundefinedなら、nameを空のStringに設定する。
    3. そうでなければ、name"["description、および"]"string-concatenationに設定する。
  3. そうでなく、namePrivate Nameなら、
    1. namename.[[Description]]に設定する。
  4. func[[InitialName]] internal slotを持つなら、
    1. func.[[InitialName]]nameに設定する。
  5. prefixが存在するなら、
    1. prefixedNameを、prefix、code unit 0x0020 (SPACE)、およびnamestring-concatenationとする。
    2. func[[InitialName]] internal slotを持つなら、
      1. NOTE: 次のstepの選択は、このAbstract Operationが呼び出されるたびに独立して行われる。
      2. func.[[InitialName]]nameまたはprefixedNameのいずれかのimplementation-defined choiceに設定する。
    3. nameprefixedNameに設定する。
  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" propertyを追加します。 It performs the following steps when called:

  1. Assert: funcはextensible objectであり、"length" own propertyを持たない。
  2. DefinePropertyOrThrow(func, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true })を実行する。
  3. unusedを返す。

10.2.11 FunctionDeclarationInstantiation ( func, argList )

The abstract operation FunctionDeclarationInstantiation takes arguments func (an ECMAScript function object) and argList (a List of ECMAScript language values) and returns either a normal completion containing unused or a throw completion. funcは、execution contextが確立されている対象のfunction objectです。

Note

ECMAScript functionを評価するためにexecution contextが確立されると、新しいFunction Environment Recordが作成され、そのEnvironment Record内に各formal parameterのbindingsがinstantiateされます。function body内の各declarationもinstantiateされます。functionのformal parametersがdefault value initializersを含まない場合、body declarationsはparametersと同じEnvironment Record内でinstantiateされます。default value parameter initializersが存在する場合、body declarationsのために2番目のEnvironment Recordが作成されます。Formal parametersおよびfunctionsはFunctionDeclarationInstantiationの一部として初期化されます。他のすべてのbindingsはfunction bodyの評価中に初期化されます。

呼び出されたとき、次のstepsを実行します:

  1. 実行中の実行コンテキストをcalleeContextとする。
  2. func.[[ECMAScriptCode]]codeとする。
  3. func.[[Strict]]strictとする。
  4. func.[[FormalParameters]]formalsとする。
  5. formalsBoundNamesparamNamesとする。
  6. paramNamesに重複するエントリがある場合、hasDuplicatestrueとする。そうでなければ、hasDuplicatesfalseとする。
  7. formalsIsSimpleParameterListsimpleParamListとする。
  8. formalsContainsExpressionhasParamExprsとする。
  9. codeVarDeclaredNamesvariableNamesとする。
  10. codeVarScopedDeclarationsvariableDeclsとする。
  11. codeLexicallyDeclaredNameslexicalNamesとする。
  12. funcNamesを新しい空のListとする。
  13. funcsToInitializeを新しい空のListとする。
  14. variableDeclsの各要素variableDeclについて、Listの逆順で、次を行う。
    1. variableDeclVariableDeclarationForBindingBindingIdentifierのいずれでもない場合、
      1. Assert: variableDeclは、FunctionDeclarationGeneratorDeclarationAsyncFunctionDeclaration、またはAsyncGeneratorDeclarationのいずれかである。
      2. variableDeclBoundNamesの唯一の要素をfuncNameとする。
      3. funcNamesfuncNameを含まない場合、
        1. funcNamefuncNamesの最初の要素として挿入する。
        2. NOTE: 同じ名前に対して複数の関数宣言がある場合、最後の宣言が使用される。
        3. variableDeclfuncsToInitializeの最初の要素として挿入する。
  15. argumentsObjNeededtrueとする。
  16. func.[[ThisMode]]lexicalである場合、
    1. NOTE: アロー関数はargumentsオブジェクトを持たない。
    2. argumentsObjNeededfalseに設定する。
  17. そうでなく、paramNames"arguments"を含む場合、
    1. argumentsObjNeededfalseに設定する。
  18. そうでなく、hasParamExprsfalseである場合、
    1. funcNames"arguments"を含む、またはlexicalNames"arguments"を含む場合、
      1. argumentsObjNeededfalseに設定する。
  19. stricttrueである、またはhasParamExprsfalseである場合、
    1. NOTE: パラメータには単一のEnvironment Recordだけが必要である。これは、strict modeコード内のevalへの呼び出しが、evalの外側で可視となる新しい束縛を作成できないためである。
    2. calleeContextのLexicalEnvironmentをenvRecordとする。
  20. そうでなければ、
    1. NOTE: 仮引数リスト内のdirect eval呼び出しによって作成された束縛が、パラメータが宣言される環境の外側にあることを保証するため、別個のEnvironment Recordが必要である。
    2. calleeContextのLexicalEnvironmentをcalleeEnvとする。
    3. NewDeclarativeEnvironment(calleeEnv)をenvRecordとする。
    4. Assert: calleeContextのVariableEnvironmentとcalleeEnvは同じEnvironment Recordである。
    5. calleeContextのLexicalEnvironmentをenvRecordに設定する。
  21. paramNamesの各String paramNameについて、次を行う。
    1. envRecord.HasBinding(paramName)をalreadyDeclaredとする。
    2. NOTE: Early errorにより、重複するパラメータ名は、パラメータ既定値またはrestパラメータを持たない非strict関数でのみ発生できることが保証される。
    3. alreadyDeclaredfalseである場合、
      1. envRecord.CreateMutableBinding(paramName, false)を実行する。
      2. hasDuplicatestrueである場合、
        1. envRecord.InitializeBinding(paramName, undefined)を実行する。
  22. argumentsObjNeededtrueである場合、
    1. stricttrueである、またはsimpleParamListfalseである場合、
      1. CreateUnmappedArgumentsObject(argList)をargumentsObjとする。
    2. そうでなければ、
      1. NOTE: マップされたargumentsオブジェクトは、restパラメータ、パラメータ既定値初期化子、または分割代入パラメータを持たない非strict関数に対してのみ提供される。
      2. CreateMappedArgumentsObject(func, formals, argList, envRecord)をargumentsObjとする。
    3. stricttrueである場合、
      1. envRecord.CreateImmutableBinding("arguments", false)を実行する。
      2. NOTE: strict modeコードでは、この束縛に代入しようとすることがEarly errorによって防止されるため、その可変性は観測できない。
    4. そうでなければ、
      1. envRecord.CreateMutableBinding("arguments", false)を実行する。
    5. envRecord.InitializeBinding("arguments", argumentsObj)を実行する。
    6. paramNamesと« "arguments" »のlist-concatenationparamBindingsとする。
  23. そうでなければ、
    1. paramNamesparamBindingsとする。
  24. CreateListIteratorRecord(argList)をiteratorRecordとする。
  25. hasDuplicatestrueである場合、
    1. usedEnvundefinedとする。
  26. そうでなければ、
    1. envRecordusedEnvとする。
  27. NOTE: 次のステップはReturnCompletionを返すことができない。これは、式位置でそのようなcompletionが発生する唯一の方法はYieldExpressionの使用によるものであり、これは15.5.1および15.6.1のEarly Error規則により、パラメータリストでは禁止されているためである。
  28. iteratorRecordおよびusedEnvを引数として、formalsIteratorBindingInitializationを実行する。
  29. hasParamExprsfalseである場合、
    1. NOTE: パラメータとトップレベルのvarには単一のEnvironment Recordだけが必要である。
    2. List paramBindingsのコピーをinstantiatedVariableNamesとする。
    3. variableNamesの各要素nameについて、次を行う。
      1. instantiatedVariableNamesnameを含まない場合、
        1. nameinstantiatedVariableNamesに追加する。
        2. envRecord.CreateMutableBinding(name, false)を実行する。
        3. envRecord.InitializeBinding(name, undefined)を実行する。
    4. envRecordvariableEnvとする。
  30. そうでなければ、
    1. NOTE: 仮引数リスト内の式によって作成されたクロージャが、関数本体内の宣言を可視にしないことを保証するため、別個のEnvironment Recordが必要である。
    2. NewDeclarativeEnvironment(envRecord)をvariableEnvとする。
    3. calleeContextのVariableEnvironmentをvariableEnvに設定する。
    4. instantiatedVariableNamesを新しい空のListとする。
    5. variableNamesの各要素nameについて、次を行う。
      1. instantiatedVariableNamesnameを含まない場合、
        1. nameinstantiatedVariableNamesに追加する。
        2. variableEnv.CreateMutableBinding(name, false)を実行する。
        3. paramBindingsnameを含まない、またはfuncNamesnameを含む場合、
          1. initialValueundefinedとする。
        4. そうでなければ、
          1. envRecord.GetBindingValue(name, false)をinitialValueとする。
        5. variableEnv.InitializeBinding(name, initialValue)を実行する。
        6. NOTE: 仮引数と同じ名前を持つvarは、最初は対応する初期化済みパラメータと同じ値を持つ。
  31. stricttrueである場合、
    1. variableEnvlexicalEnvとする。
  32. そうでなければ、
    1. ホストがWebブラウザである、またはその他の形でBlock-Level Function Declarations Web Legacy Compatibility Semanticsをサポートする場合、
      1. code Contains xtrueであるような任意のBlockCaseClause、またはDefaultClause xStatementListに直接含まれる各FunctionDeclaration funcDeclについて、次を行う。
        1. funcDeclBindingIdentifierStringValuefuncNameとする。
        2. FunctionDeclaration funcDeclを、funcNameBindingIdentifierとして持つVariableStatementに置き換えても、funcに対してEarly Errorsが発生せず、かつparamNamesfuncNameを含まない場合、
          1. NOTE: funcNameに対するvar束縛は、それがVarDeclaredName、仮引数の名前、または別のFunctionDeclarationのいずれでもない場合にのみ、ここでインスタンス化される。
          2. instantiatedVariableNamesfuncNameを含まず、かつfuncName"arguments"でない場合、
            1. variableEnv.CreateMutableBinding(funcName, false)を実行する。
            2. variableEnv.InitializeBinding(funcName, undefined)を実行する。
            3. funcNameinstantiatedVariableNamesに追加する。
          3. FunctionDeclaration funcDeclが評価されるとき、15.2.6で提供されるFunctionDeclaration Evaluationアルゴリズムの代わりに、次のステップを実行する。
            1. 実行中の実行コンテキストのVariableEnvironmentをfuncEnvとする。
            2. 実行中の実行コンテキストのLexicalEnvironmentをblockEnvとする。
            3. blockEnv.GetBindingValue(funcName, false)をfuncObjとする。
            4. funcEnv.SetMutableBinding(funcName, funcObj, false)を実行する。
            5. unusedを返す。
    2. NewDeclarativeEnvironment(variableEnv)をlexicalEnvとする。
    3. NOTE: 非strict関数は、トップレベルのlexical宣言に別個のEnvironment Recordを使用する。これにより、direct evalは、evalコードによって導入されたvar scoped宣言が、既存のトップレベルのlexically scoped宣言と競合するかどうかを判断できる。strict関数では、strict direct evalが常にすべての宣言を新しいEnvironment Recordに配置するため、これは不要である。
  33. calleeContextのLexicalEnvironmentをlexicalEnvに設定する。
  34. codeLexicallyScopedDeclarationslexicalDeclsとする。
  35. lexicalDeclsの各要素lexicalDeclについて、次を行う。
    1. NOTE: lexically declared nameは、関数/ジェネレータ宣言、仮引数、またはvar名と同じにすることはできない。Lexically declared nameはここでインスタンス化されるだけで、初期化はされない。
    2. lexicalDeclBoundNamesの各要素nameについて、次を行う。
      1. lexicalDeclIsConstantDeclarationtrueである場合、
        1. lexicalEnv.CreateImmutableBinding(name, true)を実行する。
      2. そうでなければ、
        1. lexicalEnv.CreateMutableBinding(name, false)を実行する。
  36. calleeContextのPrivateEnvironmentをprivateEnvとする。
  37. funcsToInitializeの各Parse Node funcDeclについて、次を行う。
    1. funcDeclBoundNamesの唯一の要素をfuncNameとする。
    2. lexicalEnvおよびprivateEnvを引数として、funcDeclInstantiateFunctionObjectfuncObjとする。
    3. variableEnv.SetMutableBinding(funcName, funcObj, false)を実行する。
  38. unusedを返す。

10.3 Built-in Function Objects

built-in function objectordinary objectです;10.1に定められたordinary objectsの要件を満たさなければなりません。

すべてのordinary objectに要求されるinternal slots(10.1を参照)に加えて、built-in function objectは次のinternal slotsも持たなければなりません:

  • [[Realm]]。functionが作成されたrealmを表すRealm Record
  • [[InitialName]]。functionの初期名であるString。20.2.3.5によって使用されます。
  • [[Async]]。そのfunctionがBuiltinCallOrConstructにおいてasync function callおよびconstruct behaviourを持つかどうかを示すBoolean。

built-in function object[[Prototype]] internal slotの初期値は、別途指定されない限り%Function.prototype%です。

built-in function objectは、10.3.1の定義に適合する[[Call]] internal methodを持たなければなりません。

built-in function objectは、それが“constructor”として記述されている場合、またはこの仕様内の何らかのalgorithmが明示的にその[[Construct]] internal methodを設定する場合に限り、[[Construct]] internal methodを持ちます。そのような[[Construct]] internal methodは、10.3.2の定義に適合しなければなりません。

実装は、この仕様で定義されていない追加のbuilt-in function objectsを提供してよいです。

10.3.1 [[Call]] ( thisArg, argList )

The [[Call]] internal method of built-in function object func takes arguments thisArg (an ECMAScript language value) and argList (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, thisArg, argList, undefined)を返す。

10.3.2 [[Construct]] ( argList, newTarget )

The [[Construct]] internal method of built-in function object func(methodが存在する場合) takes arguments argList (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, argList, newTarget) とする。
  2. Assert: resultはObjectである。
  3. resultを返す。

10.3.3 BuiltinCallOrConstruct ( func, thisArg, argList, newTarget )

The abstract operation BuiltinCallOrConstruct takes arguments func (a built-in function object), thisArg (an ECMAScript language value or uninitialized), argList (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がまだsuspendedでないなら、callerContextをsuspendする。
  3. calleeContextを新しいexecution contextとする。
  4. calleeContextのFunctionをfuncに設定する。
  5. calleeRealmfunc.[[Realm]]とする。
  6. calleeContextRealmcalleeRealmに設定する。
  7. calleeContextのScriptOrModuleをnullに設定する。
  8. calleeContextの任意の必要なimplementation-defined initializationを実行する。
  9. calleeContextexecution context stackへpushする;calleeContextは現在running execution contextである。
  10. func.[[Async]]trueなら、
    1. promiseCapabilityを ! NewPromiseCapability(%Promise%) とする。
    2. resultsClosureを、functhisArgargList、およびnewTargetをcaptureし、呼び出されたときに次のstepsを実行する、parametersを持たない新しいAbstract Closureとする:
      1. resultを、funcの仕様に適合する方法でfunc評価した結果であるCompletion Recordとする。thisArguninitializedである場合、this値はuninitializedである;そうでなければthisArgthis値を提供する。argListはnamed parametersを提供する。newTargetはNewTarget値を提供する。
      2. NOTE: funcがこの文書内で定義されている場合、“funcの仕様”とは、algorithm stepsまたはその他の手段によってそれに対して指定されたbehaviourである。
      3. Completion(result)を返す。
    3. AsyncFunctionStart(promiseCapability, resultsClosure)を実行する。
    4. calleeContextexecution context stackから削除し、callerContextrunning execution contextとして復元する。
    5. promiseCapability.[[Promise]]を返す。
  11. resultを、funcの仕様に適合する方法でfunc評価した結果であるCompletion Recordとする。thisArguninitializedである場合、this値はuninitializedである;そうでなければthisArgthis値を提供する。argListはnamed parametersを提供する。newTargetはNewTarget値を提供する。
  12. NOTE: funcがこの文書内で定義されている場合、“funcの仕様”とは、algorithm stepsまたはその他の手段によってそれに対して指定されたbehaviourである。
  13. calleeContextexecution context stackから削除し、callerContextrunning execution contextとして復元する。
  14. resultを返す。
Note

calleeContextexecution context stackから削除されるとき、それがsuspendedされ、accessible Generatorによる後続のresumptionのために保持されている場合、破棄してはなりません。

10.3.4 CreateBuiltinFunction ( behaviour, length, name, additionalInternalSlotsList [ , realm [ , proto [ , 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), proto (an Object or null), prefix (a String), and async (a Boolean) and returns a built-in function object. additionalInternalSlotsListは、objectの一部として定義されなければならない追加internal slotsの名前を含みます。このoperationはbuilt-in function objectを作成します。 It performs the following steps when called:

  1. realmが存在しないなら、realmcurrent Realm Recordに設定する。
  2. protoが存在しないなら、protorealm.[[Intrinsics]].[[%Function.prototype%]]に設定する。
  3. asyncが存在しないなら、asyncfalseに設定する。
  4. internalSlotsListを、10.3がこれから作成されるbuilt-in function objectに要求するすべてのinternal slotsの名前を含むListとする。
  5. additionalInternalSlotsListの要素をinternalSlotsListへappendする。
  6. funcを、呼び出されたときに、提供されたargumentsをbehaviourによって指定される対応parametersの値として使用して、behaviourによって記述されるactionを実行する新しいbuilt-in function objectとする。新しいfunction objectは、internalSlotsListの要素を名前とするinternal slots、および[[InitialName]] internal slotを持つ。
  7. func.[[Async]]asyncに設定する。
  8. func.[[Prototype]]protoに設定する。
  9. func.[[Extensible]]trueに設定する。
  10. func.[[Realm]]realmに設定する。
  11. func.[[InitialName]]nullに設定する。
  12. SetFunctionLength(func, length)を実行する。
  13. prefixが存在しないなら、
    1. SetFunctionName(func, name)を実行する。
  14. そうでなければ、
    1. SetFunctionName(func, name, prefix)を実行する。
  15. funcを返す。

この仕様で定義される各built-in functionは、CreateBuiltinFunction abstract operationを呼び出すことによって作成されます。

10.4 Built-in Exotic Object Internal Methods and Slots

この仕様は、いくつかの種類のbuilt-in exotic objectsを定義します。これらのobjectsは一般に、いくつかの特定の状況を除いてordinary objectsと同様に振る舞います。次のexotic objectsは、以下で明示的に別途指定される場合を除き、ordinary object internal methodsを使用します:

10.4.1 Bound Function Exotic Objects

bound function exotic objectは、別のfunction objectをwrapするexotic objectです。bound function exotic objectはcallableです([[Call]] internal methodを持ち、[[Construct]] internal methodを持つ場合があります)。bound function exotic objectを呼び出すと、一般にそのwrapped functionがcallされます。

objectは、その[[Call]]および(該当する場合)[[Construct]] internal methodsが次の実装を使用し、その他のessential internal methodsが10.1にある定義を使用する場合、bound function exotic objectです。これらのmethodsはBoundFunctionCreateでinstallされます。

Bound function exotic objectsは、Table 26に列挙されるECMAScript function objectsのinternal slotsを持ちません。代わりに、[[Prototype]]および[[Extensible]]に加えて、Table 27に列挙されるinternal slotsを持ちます。

Table 27: Internal Slots of Bound Function Exotic Objects
Internal Slot 説明
[[BoundTargetFunction]] callable Object wrapped function object
[[BoundThis]] ECMAScript言語値 wrapped functionを呼び出すときに常にthis値として渡される値。
[[BoundArguments]] ECMAScript言語値List その要素がwrapped functionへの任意のcallの最初のargumentsとして使用される値のlist。

10.4.1.1 [[Call]] ( thisArg, argList )

The [[Call]] internal method of bound function exotic object func takes arguments thisArg (an ECMAScript language value) and argList (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. argsboundArgsargListlist-concatenationとする。
  5. Call(target, boundThis, args)を返す。

10.4.1.2 [[Construct]] ( argList, newTarget )

The [[Construct]] internal method of bound function exotic object func takes arguments argList (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)はtrueである。
  3. boundArgsfunc.[[BoundArguments]]とする。
  4. argsboundArgsargListlist-concatenationとする。
  5. SameValue(func, newTarget)がtrueなら、newTargettargetに設定する。
  6. Construct(target, args, newTarget)を返す。

10.4.1.3 BoundFunctionCreate ( targetFunc, boundThis, boundArgs )

The abstract operation BoundFunctionCreate takes arguments targetFunc (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. これは、新しいbound function exotic objectsの作成を指定するために使用されます。 It performs the following steps when called:

  1. protoを ? targetFunc.[[GetPrototypeOf]]() とする。
  2. internalSlotsListを、« [[Prototype]], [[Extensible]] »とTable 27に列挙されるinternal slotsのlist-concatenationとする。
  3. objMakeBasicObject(internalSlotsList)とする。
  4. obj.[[Prototype]]protoに設定する。
  5. obj.[[Call]]10.4.1.1で指定されるように設定する。
  6. IsConstructor(targetFunc)がtrueなら、
    1. obj.[[Construct]]10.4.1.2で指定されるように設定する。
  7. obj.[[BoundTargetFunction]]targetFuncに設定する。
  8. obj.[[BoundThis]]boundThisに設定する。
  9. obj.[[BoundArguments]]boundArgsに設定する。
  10. objを返す。

10.4.2 Array Exotic Objects

Arrayは、array index property keysを特別に扱うexotic objectです(6.1.7を参照)。property namearray indexであるpropertyはelementとも呼ばれます。すべてのArrayは、non-configurableな"length" propertyを持ち、その値は常に、その数学的値が232未満である非負整数のNumberです。"length" propertyの値は、名前がarray indexであるすべてのown propertyの名前より数値的に大きいです;Arrayのown propertyが作成または変更されるたびに、このinvariantを維持するために必要に応じて他のpropertiesが調整されます。具体的には、名前がarray indexであるown propertyが追加されるたびに、"length" propertyの値は、必要なら、そのarray indexの数値に1を加えた値へ変更されます;また、"length" propertyの値が変更されるたびに、その値が新しいlength以上であるarray indexを名前に持つすべてのown propertyが削除されます。この制約はArrayのown propertiesにのみ適用され、そのprototypesから継承される可能性のある"length"またはarray index propertiesには影響されません。

objectは、その[[DefineOwnProperty]] internal methodが次の実装を使用し、その他のessential internal methodsが10.1にある定義を使用する場合、Array exotic object(または単にArray)です。これらのmethodsはArrayCreateでinstallされます。

10.4.2.1 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

The [[DefineOwnProperty]] internal method of Array exotic object array takes arguments propertyKey (a property key) and propertyDesc (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, propertyDesc)を返す。
  2. propertyKeyarray indexなら、
    1. lengthDescOrdinaryGetOwnProperty(array, "length")とする。
    2. Assert: lengthDescundefinedでない。
    3. Assert: IsDataDescriptor(lengthDesc)はtrueである。
    4. Assert: lengthDesc.[[Configurable]]falseである。
    5. lengthlengthDesc.[[Value]]とする。
    6. Assert: lengthは非負整数のNumberである。
    7. indexを ! ToUint32(propertyKey) とする。
    8. indexlengthかつlengthDesc.[[Writable]]falseなら、falseを返す。
    9. succeededを ! OrdinaryDefineOwnProperty(array, propertyKey, propertyDesc) とする。
    10. succeededfalseなら、falseを返す。
    11. indexlengthなら、
      1. lengthDesc.[[Value]]index + 1𝔽に設定する。
      2. succeededを ! OrdinaryDefineOwnProperty(array, "length", lengthDesc) に設定する。
      3. Assert: succeededtrueである。
    12. trueを返す。
  3. OrdinaryDefineOwnProperty(array, propertyKey, propertyDesc)を返す。

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. これは、新しいArraysの作成を指定するために使用されます。 It performs the following steps when called:

  1. length > 232 - 1なら、RangeError例外をthrowする。
  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または類似objectの作成を指定するために使用されます。constructor functionがArrayを返すことは強制しません。 It performs the following steps when called:

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

originalArrayrunning execution contextrealmではないrealmのstandard built-in Array constructorを使用して作成された場合、新しいArrayはrunning execution contextrealmを使用して作成されます。これは、現在ArraySpeciesCreateを使用して定義されるArray.prototype methodsについて、歴史的にそのbehaviourを持っていたWeb browsersとの互換性を維持します。

10.4.2.4 ArraySetLength ( array, propertyDesc )

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

  1. propertyDesc[[Value]] fieldを持たないなら、
    1. OrdinaryDefineOwnProperty(array, "length", propertyDesc)を返す。
  2. newLengthDescpropertyDescのcopyとする。
  3. newLengthを ? ToUint32(propertyDesc.[[Value]]) とする。
  4. numberLengthを ? ToNumber(propertyDesc.[[Value]]) とする。
  5. SameValueZero(newLength, numberLength)がfalseなら、RangeError例外をthrowする。
  6. newLengthDesc.[[Value]]newLengthに設定する。
  7. oldLengthDescOrdinaryGetOwnProperty(array, "length")とする。
  8. Assert: oldLengthDescundefinedでない。
  9. Assert: IsDataDescriptor(oldLengthDesc)はtrueである。
  10. Assert: oldLengthDesc.[[Configurable]]falseである。
  11. oldLengtholdLengthDesc.[[Value]]とする。
  12. newLengtholdLengthなら、
    1. OrdinaryDefineOwnProperty(array, "length", newLengthDesc)を返す。
  13. oldLengthDesc.[[Writable]]falseなら、falseを返す。
  14. newLengthDesc[[Writable]] fieldを持たない、またはnewLengthDesc.[[Writable]]trueなら、
    1. newWritabletrueとする。
  15. そうでなければ、
    1. NOTE: 任意のelementsを削除できない場合に備えて、[[Writable]]属性をfalseに設定することはdeferされる。
    2. newWritablefalseとする。
    3. newLengthDesc.[[Writable]]trueに設定する。
  16. succeededを ! OrdinaryDefineOwnProperty(array, "length", newLengthDesc) とする。
  17. succeededfalseなら、falseを返す。
  18. array indexであり、! ToUint32(propertyKey) ≥ newLengthであるようなarrayの各own property key propertyKeyについて、descending numeric index orderで、以下を行う
    1. deleteSucceededを ! array.[[Delete]](propertyKey) とする。
    2. deleteSucceededfalseなら、
      1. newLengthDesc.[[Value]]を ! ToUint32(propertyKey) + 1𝔽に設定する。
      2. newWritablefalseなら、newLengthDesc.[[Writable]]falseに設定する。
      3. OrdinaryDefineOwnProperty(array, "length", newLengthDesc)を実行する。
      4. falseを返す。
  19. newWritablefalseなら、
    1. succeededを ! OrdinaryDefineOwnProperty(array, "length", PropertyDescriptor { [[Writable]]: false }) に設定する。
    2. Assert: succeededtrueである。
  20. trueを返す。
Note

ステップ3および4において、propertyDesc.[[Value]]がobjectである場合、そのvalueOf methodは2回呼び出されます。これは、この仕様の第2からこのeffectを伴って指定されていたlegacy behaviourです。

10.4.3 String Exotic Objects

String objectは、String値をカプセル化し、String値の個々のcode unit elementsに対応するvirtual integer-indexed data propertiesを公開するexotic objectです。String exotic objectsは常に、カプセル化されたString値のlengthを値に持つ"length"という名前のdata propertyを持ちます。code unit data properties"length" propertyはいずれもnon-writableかつnon-configurableです。

objectは、その[[GetOwnProperty]][[DefineOwnProperty]]、および[[OwnPropertyKeys]] internal methodsが次の実装を使用し、その他のessential internal methodsが10.1にある定義を使用する場合、String exotic object(または単にString object)です。これらのmethodsはStringCreateでinstallされます。

String exotic objectsordinary objectsと同じinternal slotsを持ちます。また、[[StringData]] internal slotも持ちます。

10.4.3.1 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of String exotic object string 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. propertyDescOrdinaryGetOwnProperty(string, propertyKey)とする。
  2. propertyDescundefinedでないなら、propertyDescを返す。
  3. StringGetOwnProperty(string, propertyKey)を返す。

10.4.3.2 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

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

  1. stringDescStringGetOwnProperty(string, propertyKey)とする。
  2. stringDescundefinedでないなら、
    1. extensiblestring.[[Extensible]]とする。
    2. IsCompatiblePropertyDescriptor(extensible, propertyDesc, stringDesc)を返す。
  3. OrdinaryDefineOwnProperty(string, propertyKey, propertyDesc)を返す。

10.4.3.3 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of 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. stringobj.[[StringData]]とする。
  3. Assert: stringはStringである。
  4. lengthstringのlengthとする。
  5. 0 ≤ i < lengthである各integer iについて、昇順で、以下を行う
    1. ToString(𝔽(i))をkeysへappendする。
  6. array indexであり、! ToIntegerOrInfinity(propertyKey) ≥ lengthであるようなobjの各own property key propertyKeyについて、ascending numeric index orderで、以下を行う
    1. propertyKeykeysへappendする。
  7. Stringであり、array indexでないようなobjの各own property key propertyKeyについて、property creationのascending chronological orderで、以下を行う
    1. propertyKeykeysへappendする。
  8. Symbolであるようなobjの各own property key propertyKeyについて、property creationのascending chronological orderで、以下を行う
    1. propertyKeykeysへappendする。
  9. keysを返す。

10.4.3.4 StringCreate ( value, proto )

The abstract operation StringCreate takes arguments value (a String) and proto (an Object) and returns a String exotic object. これは、新しいString exotic objectsの作成を指定するために使用されます。 It performs the following steps when called:

  1. stringMakeBasicObject[[Prototype]], [[Extensible]], [[StringData]] »)とする。
  2. string.[[Prototype]]protoに設定する。
  3. string.[[StringData]]valueに設定する。
  4. string.[[GetOwnProperty]]10.4.3.1で指定されるように設定する。
  5. string.[[DefineOwnProperty]]10.4.3.2で指定されるように設定する。
  6. string.[[OwnPropertyKeys]]10.4.3.3で指定されるように設定する。
  7. lengthvalueのlengthとする。
  8. DefinePropertyOrThrow(string, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false })を実行する。
  9. stringを返す。

10.4.3.5 StringGetOwnProperty ( string, propertyKey )

The abstract operation StringGetOwnProperty takes arguments string (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. numericIndexCanonicalNumericIndexString(propertyKey)とする。
  3. numericIndexintegral Numberでないなら、undefinedを返す。
  4. numericIndex-0𝔽またはnumericIndex < -0𝔽なら、undefinedを返す。
  5. stringDatastring.[[StringData]]とする。
  6. Assert: stringDataはStringである。
  7. lengthstringDataのlengthとする。
  8. (numericIndex) ≥ lengthなら、undefinedを返す。
  9. resultString(numericIndex)から(numericIndex) + 1までのstringDatasubstringとする。
  10. PropertyDescriptor { [[Value]]: resultString, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: false }を返す。

10.4.4 Arguments Exotic Objects

ほとんどのECMAScript functionsは、そのコードからarguments objectを利用可能にします。function definitionの特性に応じて、そのarguments objectはordinary objectまたはarguments exotic objectのいずれかです。arguments exotic objectは、array index propertiesが、その関連ECMAScript functionの呼び出しのformal parameters bindingsへmapするexotic objectです。

objectは、そのinternal methodsが次の実装を使用し、ここで指定されていないものは10.1にある定義を使用する場合、arguments exotic objectです。これらのmethodsはCreateMappedArgumentsObjectでinstallされます。

Note 1

CreateUnmappedArgumentsObjectはこのclauseにgroup化されていますが、arguments exotic objectではなくordinary objectを作成します。

Arguments exotic objectsordinary objectsと同じinternal slotsを持ちます。また、[[ParameterMap]] internal slotも持ちます。Ordinary arguments objectsも[[ParameterMap]] internal slotを持ち、その値は常にundefinedです。ordinary argument objectsについては、[[ParameterMap]] internal slotはObject.prototype.toString20.1.3.6)がそれらをそのようなものとして識別するためにのみ使用されます。

Note 2

numeric name valuesが対応するfunction objectのformal parametersの数より小さいarguments exotic objectinteger-indexed data propertiesは、初期状態で、functionのexecution context内の対応するargument bindingsと値を共有します。これは、propertyを変更すると対応するargument bindingの値が変更され、その逆も成り立つことを意味します。この対応関係は、そのようなpropertyが削除されてから再定義された場合、またはそのpropertyがaccessor propertyへ変更された場合に破られます。arguments objectがordinary objectである場合、そのpropertiesの値は、単にfunctionへ渡されたargumentsのcopyであり、property valuesとformal parameter valuesの間に動的なlinkageはありません。

Note 3

ParameterMap objectおよびそのproperty valuesは、arguments objectとargument bindingsとの対応を指定するための装置として使用されます。ParameterMap objectおよびそのpropertiesの値であるobjectsは、ECMAScriptコードから直接観測可能ではありません。ECMAScript実装は、指定されたsemanticsを実装するために、そのようなobjectsを実際に作成または使用する必要はありません。

Note 4

Ordinary arguments objectsは、アクセス時にTypeError例外をthrowする、"callee"という名前のnon-configurable accessor propertyを定義します。"callee" propertyは、一部のclassのnon-strict functionsに対してのみ作成されるarguments exotic objectsについて、より具体的な意味を持ちます。ordinary variantにおけるこのpropertyの定義は、conforming ECMAScript implementationsによって他の方法で定義されないことを保証するために存在します。

Note 5

arguments exotic objectsのECMAScript実装は、歴史的に"caller"という名前のaccessor propertyを含んでいました。ECMAScript 2017より前、この仕様にはordinary arguments objects上のthrowing "caller" propertyの定義が含まれていました。実装はもはやこの拡張を含まないため、ECMAScript 2017はthrowing "caller" accessorの要件を削除しました。

10.4.4.1 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of 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. propertyDescOrdinaryGetOwnProperty(args, propertyKey)とする。
  2. propertyDescundefinedなら、undefinedを返す。
  3. mapargs.[[ParameterMap]]とする。
  4. isMappedを ! HasOwnProperty(map, propertyKey) とする。
  5. isMappedtrueなら、
    1. propertyDesc.[[Value]]を ! Get(map, propertyKey) に設定する。
  6. propertyDescを返す。

10.4.4.2 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

The [[DefineOwnProperty]] internal method of arguments exotic object args takes arguments propertyKey (a property key) and propertyDesc (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. newArgDescpropertyDescとする。
  4. isMappedtrueであり、かつIsDataDescriptor(propertyDesc)がtrueなら、
    1. propertyDesc[[Value]] fieldを持たず、propertyDesc[[Writable]] fieldを持ち、かつpropertyDesc.[[Writable]]falseなら、
      1. newArgDescpropertyDescのcopyに設定する。
      2. newArgDesc.[[Value]]を ! Get(map, propertyKey) に設定する。
  5. allowedを ! OrdinaryDefineOwnProperty(args, propertyKey, newArgDesc) とする。
  6. allowedfalseなら、falseを返す。
  7. isMappedtrueなら、
    1. IsAccessorDescriptor(propertyDesc)がtrueなら、
      1. map.[[Delete]](propertyKey)を実行する。
    2. そうでなければ、
      1. propertyDesc[[Value]] fieldを持つなら、
        1. Assert: formal parameters mapped by arguments objectsは常にwritableであるため、次のSetは成功する。
        2. Set(map, propertyKey, propertyDesc.[[Value]], false)を実行する。
      2. propertyDesc[[Writable]] fieldを持ち、propertyDesc.[[Writable]]falseなら、
        1. map.[[Delete]](propertyKey)を実行する。
  8. trueを返す。

10.4.4.3 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of 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に対するformal parameter mappingを含む。
  5. Get(map, propertyKey)を返す。

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

The [[Set]] internal method of 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. そうでなければ、
    1. mapargs.[[ParameterMap]]とする。
    2. isMappedを ! HasOwnProperty(map, propertyKey) とする。
  3. isMappedtrueなら、
    1. Assert: formal parameters mapped by arguments objectsは常にwritableであるため、次のSetは成功する。
    2. Set(map, propertyKey, value, false)を実行する。
  4. OrdinarySet(args, propertyKey, value, receiver)を返す。

10.4.4.5 [[Delete]] ( propertyKey )

The [[Delete]] internal method of 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 ( argList )

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

  1. lengthargList内の要素数とする。
  2. objOrdinaryObjectCreate(%Object.prototype%, « [[ParameterMap]] »)とする。
  3. obj.[[ParameterMap]]undefinedに設定する。
  4. DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true })を実行する。
  5. indexを0とする。
  6. index < lengthである間、繰り返す
    1. valueargList[index]とする。
    2. CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), value)を実行する。
    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, argList, envRecord )

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

  1. Assert: formalsはrest parameter、任意のbinding patterns、または任意のinitializersを含まない。duplicate identifiersを含む場合がある。
  2. lengthargList内の要素数とする。
  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. paramNamesformalsBoundNamesとする。
  13. paramCountparamNames内の要素数とする。
  14. indexを0とする。
  15. index < lengthである間、繰り返す
    1. valueargList[index]とする。
    2. CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), value)を実行する。
    3. indexindex + 1に設定する。
  16. DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true })を実行する。
  17. mappedNamesを新しい空のListとする。
  18. indexparamCount - 1に設定する。
  19. index ≥ 0である間、繰り返す
    1. nameparamNames[index]とする。
    2. mappedNamesnameを含まないなら、
      1. namemappedNamesへappendする。
      2. index < lengthなら、
        1. getterMakeArgGetter(name, envRecord)とする。
        2. setterMakeArgSetter(name, envRecord)とする。
        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, envRecord )

The abstract operation MakeArgGetter takes arguments name (a String) and envRecord (an Environment Record) and returns a function object. これは、実行されたときにenvRecord内でnameにbindされた値を返すbuilt-in function objectを作成します。 It performs the following steps when called:

  1. getterClosureを、nameおよびenvRecordをcaptureし、呼び出されたときに次のstepsを実行する、parametersを持たない新しいAbstract Closureとする:
    1. NormalCompletion(! envRecord.GetBindingValue(name, false))を返す。
  2. getterCreateBuiltinFunction(getterClosure, 0, "", « »)とする。
  3. NOTE: getterはECMAScriptコードから直接アクセス可能になることは決してない。
  4. getterを返す。

10.4.4.7.2 MakeArgSetter ( name, envRecord )

The abstract operation MakeArgSetter takes arguments name (a String) and envRecord (an Environment Record) and returns a function object. これは、実行されたときにenvRecord内でnameにbindされた値を設定するbuilt-in function objectを作成します。 It performs the following steps when called:

  1. setterClosureを、nameおよびenvRecordをcaptureし、呼び出されたときに次のstepsを実行するparameters (value)を持つ新しいAbstract Closureとする:
    1. NormalCompletion(! envRecord.SetMutableBinding(name, value, false))を返す。
  2. setterCreateBuiltinFunction(setterClosure, 1, "", « »)とする。
  3. NOTE: setterはECMAScriptコードから直接アクセス可能になることは決してない。
  4. setterを返す。

10.4.5 TypedArray Exotic Objects

TypedArrayは、canonical numeric stringsであるproperty keysを特別に処理するexotic objectです。in-bounds integer indicesであるsubsetを使用してuniform typeのelementsをindexし、残りはprototype chain traversalを発生させずに存在しないというinvariantを強制します。

Note

任意のNumber nについてToString(n)はcanonical numeric stringであるため、実装は、実際にstring conversionを実行せずに、NumbersをTypedArraysproperty keysとして扱ってよいです。

TypedArraysordinary objectsと同じinternal slotsを持ち、さらに[[ViewedArrayBuffer]][[TypedArrayName]][[ContentType]][[ByteLength]][[ByteOffset]]、および[[ArrayLength]] internal slotsを持ちます。

objectは、その[[PreventExtensions]][[GetOwnProperty]][[HasProperty]][[DefineOwnProperty]][[Get]][[Set]][[Delete]]、および[[OwnPropertyKeys]] internal methodsがこのsectionの定義を使用し、その他のessential internal methodsが10.1にある定義を使用する場合、TypedArrayです。これらのmethodsはTypedArrayCreateによってinstallされます。

10.4.5.1 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of 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で指定されるextensibility-related invariantsは、objがpropertiesを得る(または失ってから再び得る)可能性があるとき、このmethodがtrueを返すことを許可しない。これは、そのunderlying bufferがresizeされるとき、integer index namesを持つpropertiesについて発生する場合がある。
  2. IsTypedArrayFixedLength(obj)がfalseなら、falseを返す。
  3. OrdinaryPreventExtensions(obj)を返す。

10.4.5.2 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of 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 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, propertyDesc )

The [[DefineOwnProperty]] internal method of TypedArray obj takes arguments propertyKey (a property key) and propertyDesc (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. propertyDesc[[Configurable]] fieldを持ち、propertyDesc.[[Configurable]]falseなら、falseを返す。
      3. propertyDesc[[Enumerable]] fieldを持ち、propertyDesc.[[Enumerable]]falseなら、falseを返す。
      4. IsAccessorDescriptor(propertyDesc)がtrueなら、falseを返す。
      5. propertyDesc[[Writable]] fieldを持ち、propertyDesc.[[Writable]]falseなら、falseを返す。
      6. propertyDesc[[Value]] fieldを持つなら、? TypedArraySetElement(obj, numericIndex, propertyDesc.[[Value]])を実行する。
      7. trueを返す。
  2. OrdinaryDefineOwnProperty(obj, propertyKey, propertyDesc)を返す。

10.4.5.5 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of 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 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 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 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である各integer iについて、昇順で、以下を行う
      1. ToString(𝔽(i))をkeysへappendする。
  4. Stringであり、integer indexでないようなobjの各own property key propertyKeyについて、property creationのascending chronological orderで、以下を行う
    1. propertyKeykeysへappendする。
  5. Symbolであるようなobjの各own property key propertyKeyについて、property creationのascending chronological orderで、以下を行う
    1. propertyKeykeysへappendする。
  6. keysを返す。

10.4.5.9 TypedArray With Buffer Witness Records

TypedArray With Buffer Witness Recordは、TypedArrayを、viewed bufferのcached byte lengthとともにカプセル化するために使用されるRecord値です。viewed bufferがgrowable SharedArrayBufferであるとき、byte length data blockの単一のReadSharedMemory eventが存在することを保証する助けとして使用されます。

TypedArray With Buffer Witness Recordsは、Table 28に列挙されるフィールドを持ちます。

Table 28: TypedArray With Buffer Witness Record Fields
フィールド名 意味
[[Object]] TypedArray そのbufferのbyte lengthがloadされるTypedArray
[[CachedBufferByteLength]] 非負整数またはdetached Recordが作成されたときのobjectの[[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. そうでなければ、
    1. byteLengthArrayBufferByteLength(buffer, order)とする。
  4. TypedArray With Buffer Witness Record { [[Object]]: obj, [[CachedBufferByteLength]]: byteLength }を返す。

10.4.5.11 TypedArrayCreate ( proto )

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

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

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)はfalseである。
  2. objtaRecord.[[Object]]とする。
  3. obj.[[ByteLength]]autoでないなら、obj.[[ByteLength]]を返す。
  4. lengthTypedArrayLength(taRecord)とする。
  5. elementSizeTypedArrayElementSize(obj)とする。
  6. NOTE: underlying bufferが非整数倍にresizeされている場合でも、返されるbyte lengthは常に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)はfalseである。
  2. objtaRecord.[[Object]]とする。
  3. obj.[[ArrayLength]]autoでないなら、obj.[[ArrayLength]]を返す。
  4. Assert: IsFixedLengthArrayBuffer(obj.[[ViewedArrayBuffer]])は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. これは、objectのnumeric propertiesのいずれかがunderlying bufferのbounds内に含まれないindexにある値を参照するかどうかをcheckします。 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. そうでなければ、
    1. elementSizeTypedArrayElementSize(obj)とする。
    2. arrayByteLengthobj.[[ArrayLength]] × elementSizeとする。
    3. byteOffsetEndbyteOffsetStart + arrayByteLengthとする。
  8. NOTE: [[ByteOffset]]bufferByteLengthである0-length TypedArrayはout-of-boundsとはみなされない。
  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. indexintegral 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なら、numberを ? ToBigInt(value) とする。
  2. そうでなければ、numberを ? 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, number, true, unordered)を実行する。
  4. unusedを返す。
Note

このoperationは常に成功するように見えますが、TypedArrayの末尾を越えてwriteしようとする場合、またはdetached ArrayBufferによってbackされるTypedArrayへwriteしようとする場合、効果はありません。

10.4.5.19 IsArrayBufferViewOutOfBounds ( obj )

The abstract operation IsArrayBufferViewOutOfBounds takes argument obj (a TypedArray or a DataView) and returns a Boolean. これは、TypedArrayのnumeric propertiesのいずれか、またはDataView objectのmethodsが、underlying data blockのbounds内に含まれないindexにある値を参照できるかどうかをcheckします。このabstract operationは、upstream specificationsの便宜のために存在します。 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 Exotic Objects

module namespace exotic objectは、ECMAScript Moduleからexportされたbindingsを公開するexotic objectです(16.2.3を参照)。module namespace exotic objectのString-keyed own propertiesと、Moduleによってexportされたbinding namesの間には1対1の対応があります。exported bindingsには、export * export itemsを使用してindirectlyにexportされた任意のbindingsが含まれます。各String-valued own property keyは、対応するexported binding nameのStringValueです。これらはmodule namespace exotic objectの唯一のString-keyed propertiesです。そのような各propertyは、attributes { [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false }を持ちます。Module namespace exotic objectsはextensibleではありません。

objectは、その[[GetPrototypeOf]][[SetPrototypeOf]][[IsExtensible]][[PreventExtensions]][[GetOwnProperty]][[DefineOwnProperty]][[HasProperty]][[Get]][[Set]][[Delete]]、および[[OwnPropertyKeys]] internal methodsがこのsectionの定義を使用し、その他のessential internal methodsが10.1にある定義を使用する場合、module namespace exotic objectです。これらのmethodsはModuleNamespaceCreateによってinstallされます。

Module namespace exotic objectsは、Table 29で定義されるinternal slotsを持ちます。

Table 29: Internal Slots of Module Namespace Exotic Objects
Internal Slot 説明
[[Module]] Module Record このnamespaceが公開するexportsを持つModule Record
[[Exports]] StringsのList 要素が、このobjectのown propertiesとして公開されるexported namesのString値であるList。このlistはlexicographic code unit orderに従ってsortされます。

10.4.6.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of 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 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 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 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 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, propertyDesc )

The [[DefineOwnProperty]] internal method of module namespace exotic object obj takes arguments propertyKey (a property key) and propertyDesc (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, propertyDesc)を返す。
  2. currentを ? obj.[[GetOwnProperty]](propertyKey) とする。
  3. currentundefinedなら、falseを返す。
  4. propertyDesc[[Configurable]] fieldを持ち、propertyDesc.[[Configurable]]trueなら、falseを返す。
  5. propertyDesc[[Enumerable]] fieldを持ち、propertyDesc.[[Enumerable]]falseなら、falseを返す。
  6. IsAccessorDescriptor(propertyDesc)がtrueなら、falseを返す。
  7. propertyDesc[[Writable]] fieldを持ち、propertyDesc.[[Writable]]falseなら、falseを返す。
  8. propertyDesc[[Value]] fieldを持つなら、SameValue(propertyDesc.[[Value]], current.[[Value]])を返す。
  9. trueを返す。

10.4.6.7 [[HasProperty]] ( propertyKey )

The [[HasProperty]] internal method of 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 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例外をthrowする。
  12. targetEnv.GetBindingValue(binding.[[BindingName]], true)を返す。
Note

ResolveExportはside-effect freeです。このoperationが特定のexportNameresolveSet pairをargumentsとして呼び出されるたびに、同じ結果を返さなければなりません。実装は、各module namespace exotic object[[Exports]]についてResolveExportの結果をpre-computeまたはcacheすることを選択する場合があります。

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

The [[Set]] internal method of 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 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 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 exotic objectsの作成を指定するために使用されます。 It performs the following steps when called:

  1. Assert: module.[[Namespace]]emptyである。
  2. internalSlotsListTable 29に列挙されるinternal slotsとする。
  3. namespaceMakeBasicObject(internalSlotsList)とする。
  4. namespaceのessential internal methodsを10.4.6で指定される定義に設定する。
  5. namespace.[[Module]]moduleに設定する。
  6. sortedExportsを、exportsの要素をlexicographic code unit orderに従ってsortした要素を持つListとする。
  7. namespace.[[Exports]]sortedExportsに設定する。
  8. 28.3の定義に対応するnamespaceのown propertiesを作成する。
  9. module.[[Namespace]]namespaceに設定する。
  10. namespaceを返す。

10.4.7 Immutable Prototype Exotic Objects

immutable prototype exotic objectは、初期化されると変更されない[[Prototype]] internal slotを持つexotic objectです。

objectは、その[[SetPrototypeOf]] internal methodが次の実装を使用する場合、immutable prototype exotic objectです。(その他のessential internal methodsは、対象となる具体的なimmutable prototype exotic objectに応じて、任意の実装を使用できます。)

Note

他のexotic objectsとは異なり、immutable prototype exotic objectsには専用のcreation abstract operationは提供されていません。これは、それらが%Object.prototype%およびhost environmentsによってのみ使用され、host environmentsでは、関連objectsが他の方法でもpotentially exoticであるため、それら自身の専用creation operationを必要とするからです。

10.4.7.1 [[SetPrototypeOf]] ( proto )

The [[SetPrototypeOf]] internal method of 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 Object Internal Methods and Internal Slots

Proxy objectは、そのessential internal methodsが部分的にECMAScriptコードを使用して実装されるexotic objectです。すべてのProxy objectは[[ProxyHandler]]と呼ばれるinternal slotを持ちます。[[ProxyHandler]]の値は、proxyのhandler objectと呼ばれるobject、またはnullです。handler objectのmethods(Table 30を参照)は、Proxy objectの1つ以上のinternal methodsの実装を補強するために使用される場合があります。すべてのProxy objectは[[ProxyTarget]]と呼ばれるinternal slotも持ち、その値はobjectまたはnullのいずれかです。このobjectはproxyのtarget objectと呼ばれます。

objectは、そのessential internal methods(該当する場合は[[Call]]および[[Construct]]を含む)がこのsectionの定義を使用する場合、Proxy exotic objectです。これらのinternal methodsはProxyCreateでinstallされます。

Table 30: Proxy Handler Methods
Internal Method Handler Method
[[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 methodがProxy object internal methodの実装を提供するために呼び出されるとき、handler methodにはproxyのtarget objectがparameterとして渡されます。proxyのhandler objectは、すべてのessential internal methodに対応するmethodを必ずしも持つわけではありません。proxy上でinternal methodをinvokeすると、handler objectがinternal trapに対応するmethodを持たない場合、proxyのtarget object上で対応するinternal methodがinvokeされます。

Proxy objectの[[ProxyHandler]]および[[ProxyTarget]] internal slotsは、objectが作成されるときに常に初期化され、通常は変更できません。一部のProxy objectsは、後でrevokedできるような方法で作成されます。proxyがrevokedされると、その[[ProxyHandler]]および[[ProxyTarget]] internal slotsはnullに設定され、そのProxy object上で後続のinternal methodsのinvocationsがTypeError例外をthrowするようになります。

Proxy objectsはinternal methodsの実装を任意のECMAScriptコードによって提供することを許可するため、handler methodsが6.1.7.3で定義されるinvariantsに違反するProxy objectを定義することが可能です。6.1.7.3で定義されるinternal method invariantsの一部はessential integrity invariantsです。これらのinvariantsは、このsectionで指定されるProxy object internal methodsによって明示的に強制されます。ECMAScript実装は、あらゆる可能なinvariant violationsが存在する場合にも堅牢でなければなりません。

以下のalgorithm descriptionsでは、objはECMAScript Proxy object、propertyKeyproperty key値、valueは任意のECMAScript language value、propertyDescProperty Descriptor recordであると仮定します。

10.5.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of 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例外をthrowする。
  9. extensibleTargetを ? IsExtensible(target) とする。
  10. extensibleTargettrueなら、handlerProtoを返す。
  11. targetProtoを ? target.[[GetPrototypeOf]]() とする。
  12. SameValue(handlerProto, targetProto)がfalseなら、TypeError例外をthrowする。
  13. handlerProtoを返す。
Note

Proxy objectsに対する[[GetPrototypeOf]]は次のinvariantsを強制します:

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

10.5.2 [[SetPrototypeOf]] ( proto )

The [[SetPrototypeOf]] internal method of 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. boolTrapResultToBoolean(? Call(trap, handler, « target, proto »))とする。
  8. boolTrapResultfalseなら、falseを返す。
  9. extensibleTargetを ? IsExtensible(target) とする。
  10. extensibleTargettrueなら、trueを返す。
  11. targetProtoを ? target.[[GetPrototypeOf]]() とする。
  12. SameValue(proto, targetProto)がfalseなら、TypeError例外をthrowする。
  13. trueを返す。
Note

Proxy objectsに対する[[SetPrototypeOf]]は次のinvariantsを強制します:

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

10.5.3 [[IsExtensible]] ( )

The [[IsExtensible]] internal method of 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. boolTrapResultToBoolean(? Call(trap, handler, « target »))とする。
  8. targetResultを ? IsExtensible(target) とする。
  9. boolTrapResulttargetResultでないなら、TypeError例外をthrowする。
  10. boolTrapResultを返す。
Note

Proxy objectsに対する[[IsExtensible]]は次のinvariantsを強制します:

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

10.5.4 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of 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. boolTrapResultToBoolean(? Call(trap, handler, « target »))とする。
  8. boolTrapResulttrueなら、
    1. extensibleTargetを ? IsExtensible(target) とする。
    2. extensibleTargettrueなら、TypeError例外をthrowする。
  9. boolTrapResultを返す。
Note

Proxy objectsに対する[[PreventExtensions]]は次のinvariantsを強制します:

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

10.5.5 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of 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でなく、かつtrapResultObjundefinedでないなら、TypeError例外をthrowする。
  9. targetDescを ? target.[[GetOwnProperty]](propertyKey) とする。
  10. trapResultObjundefinedなら、
    1. targetDescundefinedなら、undefinedを返す。
    2. targetDesc.[[Configurable]]falseなら、TypeError例外をthrowする。
    3. extensibleTargetを ? IsExtensible(target) とする。
    4. extensibleTargetfalseなら、TypeError例外をthrowする。
    5. undefinedを返す。
  11. extensibleTargetを ? IsExtensible(target) とする。
  12. resultDescを ? ToPropertyDescriptor(trapResultObj) とする。
  13. CompletePropertyDescriptor(resultDesc)を実行する。
  14. validIsCompatiblePropertyDescriptor(extensibleTarget, resultDesc, targetDesc)とする。
  15. validfalseなら、TypeError例外をthrowする。
  16. resultDesc.[[Configurable]]falseなら、
    1. targetDescundefinedまたはtargetDesc.[[Configurable]]trueなら、
      1. TypeError例外をthrowする。
    2. resultDesc[[Writable]] fieldを持ち、resultDesc.[[Writable]]falseなら、
      1. Assert: targetDesc[[Writable]] fieldを持つ。
      2. targetDesc.[[Writable]]trueなら、TypeError例外をthrowする。
  17. resultDescを返す。
Note

Proxy objectsに対する[[GetOwnProperty]]は次のinvariantsを強制します:

  • [[GetOwnProperty]]の結果はProperty Descriptorまたはundefinedのいずれかでなければならない。
  • propertyがtarget objectのnon-configurable own propertyとして存在する場合、そのpropertyをnon-existentとして報告することはできない。
  • propertyがnon-extensible target objectのown propertyとして存在する場合、そのpropertyをnon-existentとして報告することはできない。
  • propertyがtarget objectのown propertyとして存在せず、かつtarget objectがextensibleでない場合、そのpropertyをexistentとして報告することはできない。
  • propertyがtarget objectのnon-configurable own propertyとして存在しない限り、そのpropertyをnon-configurableとして報告することはできない。
  • propertyがtarget objectのnon-configurable, non-writable own propertyとして存在しない限り、そのpropertyをnon-configurableかつnon-writableとして報告することはできない。

10.5.6 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

The [[DefineOwnProperty]] internal method of Proxy exotic object obj takes arguments propertyKey (a property key) and propertyDesc (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, propertyDesc)を返す。
  7. propertyDescObjFromPropertyDescriptor(propertyDesc)とする。
  8. boolTrapResultToBoolean(? Call(trap, handler, « target, propertyKey, propertyDescObj »))とする。
  9. boolTrapResultfalseなら、falseを返す。
  10. targetDescを ? target.[[GetOwnProperty]](propertyKey) とする。
  11. extensibleTargetを ? IsExtensible(target) とする。
  12. propertyDesc[[Configurable]] fieldを持ち、propertyDesc.[[Configurable]]falseなら、
    1. settingConfigFalsetrueとする。
  13. そうでなければ、
    1. settingConfigFalsefalseとする。
  14. targetDescundefinedなら、
    1. extensibleTargetfalseなら、TypeError例外をthrowする。
    2. settingConfigFalsetrueなら、TypeError例外をthrowする。
  15. そうでなければ、
    1. IsCompatiblePropertyDescriptor(extensibleTarget, propertyDesc, targetDesc)がfalseなら、TypeError例外をthrowする。
    2. settingConfigFalsetrueかつtargetDesc.[[Configurable]]trueなら、TypeError例外をthrowする。
    3. IsDataDescriptor(targetDesc)がtruetargetDesc.[[Configurable]]false、かつtargetDesc.[[Writable]]trueなら、
      1. propertyDesc[[Writable]] fieldを持ち、propertyDesc.[[Writable]]falseなら、TypeError例外をthrowする。
  16. trueを返す。
Note

Proxy objectsに対する[[DefineOwnProperty]]は次のinvariantsを強制します:

  • [[DefineOwnProperty]]の結果はBoolean値である。
  • target objectがextensibleでない場合、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のProperty Descriptor[[DefineOwnProperty]]を使用してtarget objectに適用しても例外はthrowされない。

10.5.7 [[HasProperty]] ( propertyKey )

The [[HasProperty]] internal method of 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. boolTrapResultToBoolean(? Call(trap, handler, « target, propertyKey »))とする。
  8. boolTrapResultfalseなら、
    1. targetDescを ? target.[[GetOwnProperty]](propertyKey) とする。
    2. targetDescundefinedでないなら、
      1. targetDesc.[[Configurable]]falseなら、TypeError例外をthrowする。
      2. extensibleTargetを ? IsExtensible(target) とする。
      3. extensibleTargetfalseなら、TypeError例外をthrowする。
  9. boolTrapResultを返す。
Note

Proxy objectsに対する[[HasProperty]]は次のinvariantsを強制します:

  • [[HasProperty]]の結果はBoolean値である。
  • propertyがtarget objectのnon-configurable own propertyとして存在する場合、そのpropertyをnon-existentとして報告することはできない。
  • propertyがtarget objectのown propertyとして存在し、かつtarget objectがextensibleでない場合、そのpropertyをnon-existentとして報告することはできない。

10.5.8 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of 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例外をthrowする。
    2. IsAccessorDescriptor(targetDesc)がtrueであり、かつtargetDesc.[[Get]]undefinedなら、
      1. trapResultundefinedでないなら、TypeError例外をthrowする。
  10. trapResultを返す。
Note

Proxy objectsに対する[[Get]]は次のinvariantsを強制します:

  • propertyについて報告される値は、target object propertyがnon-writable, non-configurable own data 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 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. boolTrapResultToBoolean(? Call(trap, handler, « target, propertyKey, value, receiver »))とする。
  8. boolTrapResultfalseなら、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例外をthrowする。
    2. IsAccessorDescriptor(targetDesc)がtrueなら、
      1. targetDesc.[[Set]]undefinedなら、TypeError例外をthrowする。
  11. trueを返す。
Note

Proxy objectsに対する[[Set]]は次のinvariantsを強制します:

  • [[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 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. boolTrapResultToBoolean(? Call(trap, handler, « target, propertyKey »))とする。
  8. boolTrapResultfalseなら、falseを返す。
  9. targetDescを ? target.[[GetOwnProperty]](propertyKey) とする。
  10. targetDescundefinedなら、trueを返す。
  11. targetDesc.[[Configurable]]falseなら、TypeError例外をthrowする。
  12. extensibleTargetを ? IsExtensible(target) とする。
  13. extensibleTargetfalseなら、TypeError例外をthrowする。
  14. trueを返す。
Note

Proxy objectsに対する[[Delete]]は次のinvariantsを強制します:

  • [[Delete]]の結果はBoolean値である。
  • propertyがtarget objectのnon-configurable own propertyとして存在する場合、そのpropertyをdeletedとして報告することはできない。
  • propertyがtarget objectのown propertyとして存在し、かつtarget objectがnon-extensibleである場合、そのpropertyをdeletedとして報告することはできない。

10.5.11 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of 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が重複entriesを含むなら、TypeError例外をthrowする。
  10. extensibleTargetを ? IsExtensible(target) とする。
  11. targetKeysを ? target.[[OwnPropertyKeys]]() とする。
  12. Assert: targetKeysproperty keysListである。
  13. Assert: targetKeysは重複entriesを含まない。
  14. targetConfigurableKeysを新しい空のListとする。
  15. targetNonconfigurableKeysを新しい空のListとする。
  16. targetKeysの各要素keyについて、以下を行う
    1. propertyDescを ? target.[[GetOwnProperty]](key) とする。
    2. propertyDescundefinedでなく、かつpropertyDesc.[[Configurable]]falseなら、
      1. keytargetNonconfigurableKeysへappendする。
    3. そうでなければ、
      1. keytargetConfigurableKeysへappendする。
  17. extensibleTargettrueであり、かつtargetNonconfigurableKeysが空なら、
    1. trapResultを返す。
  18. uncheckedResultKeysを、要素がtrapResultの要素であるListとする。
  19. targetNonconfigurableKeysの各要素keyについて、以下を行う
    1. uncheckedResultKeyskeyを含まないなら、TypeError例外をthrowする。
    2. keyuncheckedResultKeysから削除する。
  20. extensibleTargettrueなら、trapResultを返す。
  21. targetConfigurableKeysの各要素keyについて、以下を行う
    1. uncheckedResultKeyskeyを含まないなら、TypeError例外をthrowする。
    2. keyuncheckedResultKeysから削除する。
  22. uncheckedResultKeysが空でないなら、TypeError例外をthrowする。
  23. trapResultを返す。
Note

Proxy objectsに対する[[OwnPropertyKeys]]は次のinvariantsを強制します:

  • [[OwnPropertyKeys]]の結果はListである。
  • 返されるListは重複entriesを含まない。
  • 返されるListの各要素はproperty keyである。
  • result Listは、target objectのすべてのnon-configurable own propertiesのkeysを含まなければならない。
  • target objectがextensibleでない場合、result Listはtarget objectのown propertiesのすべてのkeysを含み、他の値を含んではならない。

10.5.12 [[Call]] ( thisArg, argList )

The [[Call]] internal method of Proxy exotic object obj takes arguments thisArg (an ECMAScript language value) and argList (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, thisArg, argList)を返す。
  7. argArrayCreateArrayFromList(argList)とする。
  8. Call(trap, handler, « target, thisArg, argArray »)を返す。
Note

Proxy exotic object[[Call]] internal methodを持つのは、その[[ProxyTarget]] internal slotの初期値が[[Call]] internal methodを持つobjectである場合のみです。

10.5.13 [[Construct]] ( argList, newTarget )

The [[Construct]] internal method of Proxy exotic object obj takes arguments argList (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)はtrueである。
  4. handlerobj.[[ProxyHandler]]とする。
  5. Assert: handlerはObjectである。
  6. trapを ? GetMethod(handler, "construct") とする。
  7. trapundefinedなら、
    1. Construct(target, argList, newTarget)を返す。
  8. argArrayCreateArrayFromList(argList)とする。
  9. newObjを ? Call(trap, handler, « target, argArray, newTarget ») とする。
  10. newObjがObjectでないなら、TypeError例外をthrowする。
  11. newObjを返す。
Note 1

Proxy exotic object[[Construct]] internal methodを持つのは、その[[ProxyTarget]] internal slotの初期値が[[Construct]] internal methodを持つobjectである場合のみです。

Note 2

Proxy objectsに対する[[Construct]]は次のinvariantsを強制します:

  • [[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例外をthrowします。 It performs the following steps when called:

  1. proxy.[[ProxyTarget]]nullなら、TypeError例外をthrowする。
  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 objectsの作成を指定するために使用されます。 It performs the following steps when called:

  1. targetがObjectでないなら、TypeError例外をthrowする。
  2. handlerがObjectでないなら、TypeError例外をthrowする。
  3. proxyMakeBasicObject[[ProxyHandler]], [[ProxyTarget]] »)とする。
  4. , [[Call]]および[[Construct]]を除き、proxyのessential internal methodsを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を返す。