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についてそれを継承し、propertyKey がobj の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では、obj はordinary object 、propertyKey はproperty key 値、value は任意のECMAScript言語値 、propertyDesc はProperty 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:
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:
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:
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:
current をobj .[[Prototype]] とする。SameValue (proto , current )がtrue なら、true を返す。extensible をobj .[[Extensible]] とする。extensible がfalse なら、false を返す。cursor をproto とする。done をfalse とする。done がfalse である間、繰り返すcursor がnull なら、done をtrue に設定する。そうでなく、SameValue (cursor , obj )がtrue なら、false を返す。 そうでなければ、cursor .[[GetPrototypeOf]] が10.1.1 で定義されるordinary object internal methodでないなら、done をtrue に設定する。そうでなければ、cursor をcursor .[[Prototype]] に設定する。 obj .[[Prototype]] をproto に設定する。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:
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:
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:
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:
obj .[[Extensible]] をfalse に設定する。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:
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:
obj がkey propertyKey を持つown propertyを持たないなら、undefined を返す。propertyDesc を、fieldsを持たない新しく作成されたProperty Descriptor とする。ownProperty を、keyがpropertyKey であるobj のown propertyとする。ownProperty がdata property なら、propertyDesc .[[Value]] をownProperty の[[Value]] 属性の値に設定する。propertyDesc .[[Writable]] をownProperty の[[Writable]] 属性の値に設定する。そうでなければ、Assert : ownProperty はaccessor property である。propertyDesc .[[Get]] をownProperty の[[Get]] 属性の値に設定する。propertyDesc .[[Set]] をownProperty の[[Set]] 属性の値に設定する。 propertyDesc .[[Enumerable]] をownProperty の[[Enumerable]] 属性の値に設定する。propertyDesc .[[Configurable]] をownProperty の[[Configurable]] 属性の値に設定する。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:
? 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:
current を ? obj .[[GetOwnProperty]] (propertyKey ) とする。extensible を ? IsExtensible (obj ) とする。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:
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 を返します。そのような適用が可能であり、obj がundefined でない場合、propertyKey という名前のpropertyについてそれが実行されます(必要であれば作成されます)。 It performs the following steps when called:
Assert : propertyKey はproperty key である。current がundefined なら、extensible がfalse なら、false を返す。obj がundefined なら、true を返す。IsAccessorDescriptor (propertyDesc )がtrue なら、object obj のpropertyKey という名前のown accessor property を作成する。その[[Get]] 、[[Set]] 、[[Enumerable]] 、および[[Configurable]] 属性は、propertyDesc が対応するfieldを持つ場合はpropertyDesc 内の対応するfieldの値に、そうでない場合はその属性のdefault value に設定される。 そうでなければ、object obj のpropertyKey という名前のown data property を作成する。その[[Value]] 、[[Writable]] 、[[Enumerable]] 、および[[Configurable]] 属性は、propertyDesc が対応するfieldを持つ場合はpropertyDesc 内の対応するfieldの値に、そうでない場合はその属性のdefault value に設定される。 true を返す。Assert : current はfully populated Property Descriptor である。propertyDesc がfieldsをまったく持たないなら、true を返す。current .[[Configurable]] がfalse なら、propertyDesc が[[Configurable]] fieldを持ち、propertyDesc .[[Configurable]] がtrue なら、false を返す。propertyDesc が[[Enumerable]] fieldを持ち、propertyDesc .[[Enumerable]] がcurrent .[[Enumerable]] でないなら、false を返す。IsGenericDescriptor (propertyDesc )がfalse であり、かつIsAccessorDescriptor (propertyDesc )がIsAccessorDescriptor (current )でないなら、false を返す。IsAccessorDescriptor (current )がtrue なら、propertyDesc が[[Get]] fieldを持ち、SameValue (propertyDesc .[[Get]] , current .[[Get]] )がfalse なら、false を返す。propertyDesc が[[Set]] fieldを持ち、SameValue (propertyDesc .[[Set]] , current .[[Set]] )がfalse なら、false を返す。そうでなく、current .[[Writable]] がfalse なら、propertyDesc が[[Writable]] fieldを持ち、propertyDesc .[[Writable]] がtrue なら、false を返す。NOTE : SameValue はNaN valuesに対してtrue を返しますが、それらは他の手段によって区別可能な場合があります。ここで返すことにより、obj の既存propertyが変更されないことが保証されます。propertyDesc が[[Value]] fieldを持つなら、SameValue (propertyDesc .[[Value]] , current .[[Value]] )を返す。 obj がundefined でないなら、IsDataDescriptor (current )がtrue であり、かつIsAccessorDescriptor (propertyDesc )がtrue なら、propertyDesc が[[Configurable]] fieldを持つなら、configurable をpropertyDesc .[[Configurable]] とする;そうでなければ、configurable をcurrent .[[Configurable]] とする。propertyDesc が[[Enumerable]] fieldを持つなら、enumerable をpropertyDesc .[[Enumerable]] とする;そうでなければ、enumerable をcurrent .[[Enumerable]] とする。object obj のpropertyKey という名前のpropertyをaccessor property で置き換える。その[[Configurable]] および[[Enumerable]] 属性はそれぞれconfigurable およびenumerable に設定され、その[[Get]] および[[Set]] 属性は、propertyDesc が対応するfieldを持つ場合はpropertyDesc 内の対応するfieldの値に、そうでない場合はその属性のdefault value に設定される。 そうでなく、IsAccessorDescriptor (current )がtrue であり、かつIsDataDescriptor (propertyDesc )がtrue なら、propertyDesc が[[Configurable]] fieldを持つなら、configurable をpropertyDesc .[[Configurable]] とする;そうでなければ、configurable をcurrent .[[Configurable]] とする。propertyDesc が[[Enumerable]] fieldを持つなら、enumerable をpropertyDesc .[[Enumerable]] とする;そうでなければ、enumerable をcurrent .[[Enumerable]] とする。object obj のpropertyKey という名前のpropertyをdata property で置き換える。その[[Configurable]] および[[Enumerable]] 属性はそれぞれconfigurable およびenumerable に設定され、その[[Value]] および[[Writable]] 属性は、propertyDesc が対応するfieldを持つ場合はpropertyDesc 内の対応するfieldの値に、そうでない場合はその属性のdefault value に設定される。 そうでなければ、propertyDesc の各field name fieldName について、object obj のpropertyKey という名前のpropertyのfieldName という名前の属性を、propertyDesc のfieldName fieldの値に設定する。 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:
? 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:
hasOwn を ? obj .[[GetOwnProperty]] (propertyKey ) とする。hasOwn がundefined でないなら、true を返す。parent を ? obj .[[GetPrototypeOf]] () とする。parent がnull でないなら、? parent .[[HasProperty]] (propertyKey ) を返す。 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:
? 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:
propertyDesc を ? obj .[[GetOwnProperty]] (propertyKey ) とする。propertyDesc がundefined なら、parent を ? obj .[[GetPrototypeOf]] () とする。parent がnull なら、undefined を返す。? parent .[[Get]] (propertyKey , receiver ) を返す。 IsDataDescriptor (propertyDesc )がtrue なら、propertyDesc .[[Value]] を返す。Assert : IsAccessorDescriptor (propertyDesc )はtrue である。getter をpropertyDesc .[[Get]] とする。getter がundefined なら、undefined を返す。? 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:
? 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:
ownDesc を ? obj .[[GetOwnProperty]] (propertyKey ) とする。? 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:
ownDesc がundefined なら、parent を ? obj .[[GetPrototypeOf]] () とする。parent がnull でないなら、? parent .[[Set]] (propertyKey , value , receiver ) を返す。ownDesc をPropertyDescriptor { [[Value]] : undefined , [[Writable]] : true , [[Enumerable]] : true , [[Configurable]] : true }に設定する。IsDataDescriptor (ownDesc )がtrue なら、ownDesc .[[Writable]] がfalse なら、false を返す。receiver がObjectでないなら、false を返す。existingDesc を ? receiver .[[GetOwnProperty]] (propertyKey ) とする。existingDesc がundefined なら、Assert : receiver は現在property propertyKey を持たない。? CreateDataProperty (receiver , propertyKey , value )を返す。 IsAccessorDescriptor (existingDesc )がtrue なら、false を返す。existingDesc .[[Writable]] がfalse なら、false を返す。valueDesc をPropertyDescriptor { [[Value]] : value }とする。? receiver .[[DefineOwnProperty]] (propertyKey , valueDesc ) を返す。 Assert : IsAccessorDescriptor (ownDesc )はtrue である。setter をownDesc .[[Set]] とする。setter がundefined なら、false を返す。? Call (setter , receiver , « value »)を実行する。 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:
? 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:
propertyDesc を ? obj .[[GetOwnProperty]] (propertyKey ) とする。propertyDesc がundefined なら、true を返す。propertyDesc .[[Configurable]] がtrue なら、obj からpropertyKey という名前のown propertyを削除する。true を返す。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:
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:
keys を新しい空のList とする。array index であるようなobj の各own property key propertyKey について、ascending numeric index orderで、以下を行うpropertyKey をkeys へappendする。Stringであり、array index でないようなobj の各own property key propertyKey について、property creationのascending chronological orderで、以下を行うpropertyKey をkeys へappendする。 Symbolであるようなobj の各own property key propertyKey について、property creationのascending chronological orderで、以下を行うpropertyKey をkeys へappendする。 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:
internalSlotsList を« [[Prototype]] , [[Extensible]] »とする。additionalInternalSlotsList が存在するなら、internalSlotsList をinternalSlotsList とadditionalInternalSlotsList のlist-concatenation に設定する。obj をMakeBasicObject (internalSlotsList )とする。obj .[[Prototype]] をproto に設定する。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:
Assert : intrinsicDefaultProto はこの仕様におけるintrinsic objectの名前である。対応するobjectは、objectの[[Prototype]] 値として使用されることを意図したintrinsicでなければならない。proto を ? GetPrototypeFromConstructor (ctor , intrinsicDefaultProto ) とする。internalSlotsList が存在するなら、slots をinternalSlotsList とする。そうでなければ、slots を新しい空のList とする。 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:
Assert : intrinsicDefaultProto はこの仕様におけるintrinsic objectの名前である。対応するobjectは、objectの[[Prototype]] 値として使用されることを意図したintrinsicでなければならない。proto を ? Get (ctor , "prototype" ) とする。proto がObjectでないなら、realm を ? GetFunctionRealm (ctor ) とする。proto をintrinsicDefaultProto という名前のrealm のintrinsic objectに設定する。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:
obj がObjectでないなら、TypeError 例外をthrowする。obj がinternalSlot internal slotを持たないなら、TypeError 例外をthrowする。unused を返す。
10.2 ECMAScript関数オブジェクト
ECMAScript function objects は、lexical environmentで閉じ込められたparameterized ECMAScript codeをカプセル化し、そのコードの動的評価をサポートします。ECMAScript function object はordinary object であり、他のordinary objects と同じinternal slotsおよび同じinternal methodsを持ちます。ECMAScript function object のコードは、strict mode code (11.2.2 )またはnon-strict code のいずれかであり得ます。コードがstrict mode code であるECMAScript function object はstrict function と呼ばれます。コードがstrict mode code でないものはnon-strict function と呼ばれます。
[[Extensible]] および[[Prototype]] に加えて、ECMAScript function objects はTable 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 またはnull のthis 値がglobal object への参照として解釈され、その他のthis 値はまずToObject に渡されることを意味します。
[[Strict]]
Boolean
これがstrict function である場合はtrue 、non-strict function である場合はfalse 。
[[HomeObject]]
Objectまたはundefined
functionがsuperを使用する場合、これは、その[[GetPrototypeOf]] がsuper property lookupsを開始するobjectを提供するobjectです。
[[SourceText]]
Unicode code pointsのsequence
functionを定義するsource text 。
[[Fields]]
ClassFieldDefinition Records のList
functionがclassである場合、これはclassのnon-static fieldsおよび対応するinitializersを表すRecords のlistです。
[[PrivateMethods]]
PrivateElements のList
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:
callerContext をrunning execution context とする。calleeContext をPrepareForOrdinaryCall (func , undefined )とする。Assert : calleeContext は現在running execution context である。func .[[IsClassConstructor]] がtrue なら、error を新しく作成されたTypeError objectとする。NOTE : error は、func に関連付けられたRealm Record を伴うcalleeContext 内で作成される。calleeContext をexecution context stack から削除し、callerContext をrunning execution context として復元する。error をthrowする。OrdinaryCallBindThis (func , calleeContext , thisArg )を実行する。result をCompletion (OrdinaryCallEvaluateBody (func , argList ))とする。calleeContext をexecution context stack から削除し、callerContext をrunning execution context として復元する。result がreturn completion なら、result .[[Value]] を返す。Assert : result はthrow completion である。? result を返す。
Note
ステップ7 でcalleeContext がexecution 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:
callerContext をrunning execution context とする。calleeContext を新しいECMAScript code execution context とする。calleeContext のFunctionをfunc に設定する。calleeRealm をfunc .[[Realm]] とする。calleeContext のRealm をcalleeRealm に設定する。calleeContext のScriptOrModuleをfunc .[[ScriptOrModule]] に設定する。localEnv をNewFunctionEnvironment (func , newTarget )とする。calleeContext のLexicalEnvironmentをlocalEnv に設定する。calleeContext のVariableEnvironmentをlocalEnv に設定する。calleeContext のPrivateEnvironmentをfunc .[[PrivateEnvironment]] に設定する。callerContext がまだsuspendedでないなら、callerContext をsuspendする。calleeContext をexecution context stack へpushする;calleeContext は現在running execution context である。NOTE : この時点以降に生成される任意のexception objectsはcalleeRealm に関連付けられる。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:
thisMode をfunc .[[ThisMode]] とする。thisMode がlexical なら、unused を返す。calleeRealm をfunc .[[Realm]] とする。localEnv をcalleeContext のLexicalEnvironmentとする。thisMode がstrict なら、thisValue をthisArg とする。そうでなければ、thisArg がundefined またはnull のいずれかなら、globalEnv をcalleeRealm .[[GlobalEnv]] とする。Assert : globalEnv はGlobal Environment Record である。thisValue をglobalEnv .[[GlobalThisValue]] とする。そうでなければ、thisValue を ! ToObject (thisArg ) とする。NOTE : ToObject はcalleeRealm を使用してwrapper objectsを生成する。 Assert : localEnv はFunction Environment Record である。Assert : 次のstepはabrupt completion を返すことはない。なぜならlocalEnv .[[ThisBindingStatus]] はinitialized でないからである。! BindThisValue (localEnv , thisValue )を実行する。 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
引数func およびargList を伴うFunctionBody のEvaluateFunctionBody を ? で返す。
ConciseBody : ExpressionBody
引数func およびargList を伴うConciseBody のEvaluateConciseBody を ? で返す。
GeneratorBody : FunctionBody
引数func およびargList を伴うGeneratorBody のEvaluateGeneratorBody を ? で返す。
AsyncGeneratorBody : FunctionBody
引数func およびargList を伴うAsyncGeneratorBody のEvaluateAsyncGeneratorBody を ? で返す。
AsyncFunctionBody : FunctionBody
引数func およびargList を伴うAsyncFunctionBody のEvaluateAsyncFunctionBody を ? で返す。
AsyncConciseBody : ExpressionBody
引数func およびargList を伴うAsyncConciseBody のEvaluateAsyncConciseBody を ? で返す。
Initializer :
=
AssignmentExpression
Assert : argList は空である。Assert : func .[[ClassFieldInitializerName]] はempty でない。IsAnonymousFunctionDefinition (AssignmentExpression )がtrue なら、value を、引数func .[[ClassFieldInitializerName]] を伴うInitializer のNamedEvaluation の ? 結果とする。そうでなければ、rhs をAssignmentExpression のEvaluation の ? 結果とする。value を ? GetValue (rhs ) とする。 ReturnCompletion (value )を返す。
Note
field initializersはfunction boundaryを構成しますが、FunctionDeclarationInstantiation の呼び出しには観測可能な効果がないため省略されます。
ClassStaticBlockBody : ClassStaticBlockStatementList
Assert : argList は空である。引数func を伴うClassStaticBlockBody のEvaluateClassStaticBlockBody を ? で返す。
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:
引数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:
callerContext をrunning execution context とする。kind をfunc .[[ConstructorKind]] とする。kind がbase なら、thisArg を ? OrdinaryCreateFromConstructor (newTarget , "%Object.prototype%" ) とする。calleeContext をPrepareForOrdinaryCall (func , newTarget )とする。Assert : calleeContext は現在running execution context である。kind がbase なら、OrdinaryCallBindThis (func , calleeContext , thisArg )を実行する。initializeResult をCompletion (InitializeInstanceElements (thisArg , func ))とする。initializeResult がabrupt completion なら、calleeContext をexecution context stack から削除し、callerContext をrunning execution context として復元する。? initializeResult を返す。 ctorEnv をcalleeContext のLexicalEnvironmentとする。result をCompletion (OrdinaryCallEvaluateBody (func , argList ))とする。calleeContext をexecution context stack から削除し、callerContext をrunning execution context として復元する。result がthrow completion なら、? result を返す。 Assert : result はreturn completion である。result .[[Value]] がObjectなら、result .[[Value]] を返す。kind がbase なら、thisArg を返す。result .[[Value]] がundefined でないなら、TypeError 例外をthrowする。thisBinding を ? ctorEnv .GetThisBinding () とする。Assert : thisBinding はObjectである。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:
internalSlotsList をTable 26 に列挙されるinternal slotsとする。func をOrdinaryObjectCreate (proto , internalSlotsList )とする。func .[[Call]] を10.2.1 で指定される定義に設定する。func .[[SourceText]] をsourceText に設定する。func .[[FormalParameters]] をparamList に設定する。func .[[ECMAScriptCode]] をbody に設定する。strict をIsStrict (body )とする。func .[[Strict]] をstrict に設定する。thisMode がlexical-this なら、func .[[ThisMode]] をlexical に設定する。そうでなく、strict がtrue なら、func .[[ThisMode]] をstrict に設定する。 そうでなければ、func .[[ThisMode]] をglobal に設定する。 func .[[IsClassConstructor]] をfalse に設定する。func .[[Environment]] をenvRecord に設定する。func .[[PrivateEnvironment]] をprivateEnv に設定する。func .[[ScriptOrModule]] をGetActiveScriptOrModule ()に設定する。func .[[Realm]] をcurrent Realm Record に設定する。func .[[HomeObject]] をundefined に設定する。func .[[Fields]] を新しい空のList に設定する。func .[[PrivateMethods]] を新しい空のList に設定する。func .[[ClassFieldInitializerName]] をempty に設定する。length をparamList のExpectedArgumentCount とする。SetFunctionLength (func , length )を実行する。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:
Assert : realm .[[Intrinsics]] .[[%ThrowTypeError% ]]は存在し、初期化済みである。thrower をrealm .[[Intrinsics]] .[[%ThrowTypeError% ]]とする。! DefinePropertyOrThrow (func , "caller" , PropertyDescriptor { [[Get]] : thrower , [[Set]] : thrower , [[Enumerable]] : false , [[Configurable]] : true })を実行する。 ! DefinePropertyOrThrow (func , "arguments" , PropertyDescriptor { [[Get]] : thrower , [[Set]] : thrower , [[Enumerable]] : false , [[Configurable]] : true })を実行する。 unused を返す。
10.2.4.1 %ThrowTypeError% ( )
このfunctionは%ThrowTypeError% intrinsic objectです。
これは、realm ごとに1回定義されるanonymous built-in function object です。
呼び出されたとき、次のstepsを実行します:
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 . これはfunc をconstructor へ変換します。 It performs the following steps when called:
func がECMAScript function object なら、Assert : IsConstructor (func )はfalse である。Assert : func はextensible objectであり、"prototype" own propertyを持たない。func .[[Construct]] を10.2.2 で指定される定義に設定する。そうでなければ、func .[[Construct]] を10.3.2 で指定される定義に設定する。 func .[[ConstructorKind]] をbase に設定する。writableProto が存在しないなら、writableProto をtrue に設定する。proto が存在しないなら、proto をOrdinaryObjectCreate (%Object.prototype% )に設定する。! DefinePropertyOrThrow (proto , "constructor" , PropertyDescriptor { [[Value]] : func , [[Writable]] : writableProto , [[Enumerable]] : false , [[Configurable]] : true })を実行する。 ! DefinePropertyOrThrow (func , "prototype" , PropertyDescriptor { [[Value]] : proto , [[Writable]] : writableProto , [[Enumerable]] : false , [[Configurable]] : false })を実行する。 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:
Assert : func .[[IsClassConstructor]] はfalse である。func .[[IsClassConstructor]] をtrue に設定する。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:
Assert : homeObj はordinary object である。func .[[HomeObject]] をhomeObj に設定する。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:
Assert : homeObj はordinaryかつextensible objectである。name がPrivate Name なら、PrivateElement { [[Key]] : name , [[Kind]] : method , [[Value]] : closure }を返す。propertyDesc をPropertyDescriptor { [[Value]] : closure , [[Writable]] : true , [[Enumerable]] : enumerable , [[Configurable]] : true }とする。? DefinePropertyOrThrow (homeObj , name , propertyDesc )を実行する。 NOTE : DefinePropertyOrThrow がabrupt completion を返すのは、name が"prototype" であるclass static methodを定義しようとする場合だけである。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:
Assert : func はextensible objectであり、"name" own propertyを持たない。name がSymbolなら、description をname .[[Description]] とする。description がundefined なら、name を空のStringに設定する。そうでなければ、name を"[" 、description 、および"]" のstring-concatenation に設定する。 そうでなく、name がPrivate Name なら、name をname .[[Description]] に設定する。 func が[[InitialName]] internal slotを持つなら、func .[[InitialName]] をname に設定する。prefix が存在するなら、prefixedName を、prefix 、code unit 0x0020 (SPACE)、およびname のstring-concatenation とする。func が[[InitialName]] internal slotを持つなら、NOTE : 次のstepの選択は、このAbstract Operationが呼び出されるたびに独立して行われる。func .[[InitialName]] をname またはprefixedName のいずれかのimplementation-defined choiceに設定する。name をprefixedName に設定する。! DefinePropertyOrThrow (func , "name" , PropertyDescriptor { [[Value]] : name , [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true })を実行する。 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:
Assert : func はextensible objectであり、"length" own propertyを持たない。! DefinePropertyOrThrow (func , "length" , PropertyDescriptor { [[Value]] : 𝔽 (length ), [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true })を実行する。 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を実行します:
実行中の実行コンテキストをcalleeContext とする。 func .[[ECMAScriptCode]] をcode とする。func .[[Strict]] をstrict とする。func .[[FormalParameters]] をformals とする。formals のBoundNames をparamNames とする。paramNames に重複するエントリがある場合、hasDuplicates をtrue とする。そうでなければ、hasDuplicates をfalse とする。formals のIsSimpleParameterList をsimpleParamList とする。formals のContainsExpression をhasParamExprs とする。code のVarDeclaredNames をvariableNames とする。code のVarScopedDeclarations をvariableDecls とする。code のLexicallyDeclaredNames をlexicalNames とする。funcNames を新しい空のList とする。funcsToInitialize を新しい空のList とする。variableDecls の各要素variableDecl について、List の逆順で、次を行う。variableDecl がVariableDeclaration 、ForBinding 、BindingIdentifier のいずれでもない場合、Assert : variableDecl は、FunctionDeclaration 、GeneratorDeclaration 、AsyncFunctionDeclaration 、またはAsyncGeneratorDeclaration のいずれかである。variableDecl のBoundNames の唯一の要素をfuncName とする。funcNames がfuncName を含まない場合、funcName をfuncNames の最初の要素として挿入する。NOTE : 同じ名前に対して複数の関数宣言がある場合、最後の宣言が使用される。variableDecl をfuncsToInitialize の最初の要素として挿入する。argumentsObjNeeded をtrue とする。func .[[ThisMode]] がlexical である場合、NOTE : アロー関数はargumentsオブジェクトを持たない。argumentsObjNeeded をfalse に設定する。そうでなく、paramNames が"arguments" を含む場合、argumentsObjNeeded をfalse に設定する。 そうでなく、hasParamExprs がfalse である場合、funcNames が"arguments" を含む、またはlexicalNames が"arguments" を含む場合、argumentsObjNeeded をfalse に設定する。 strict がtrue である、またはhasParamExprs がfalse である場合、NOTE : パラメータには単一のEnvironment Record だけが必要である。これは、strict modeコード内のevalへの呼び出しが、evalの外側で可視となる新しい束縛を作成できないためである。calleeContext のLexicalEnvironmentをenvRecord とする。そうでなければ、NOTE : 仮引数リスト内のdirect eval 呼び出しによって作成された束縛が、パラメータが宣言される環境の外側にあることを保証するため、別個のEnvironment Record が必要である。calleeContext のLexicalEnvironmentをcalleeEnv とする。NewDeclarativeEnvironment (calleeEnv )をenvRecord とする。Assert : calleeContext のVariableEnvironmentとcalleeEnv は同じEnvironment Record である。calleeContext のLexicalEnvironmentをenvRecord に設定する。 paramNames の各String paramName について、次を行う。! envRecord .HasBinding (paramName )をalreadyDeclared とする。 NOTE : Early error により、重複するパラメータ名は、パラメータ既定値またはrestパラメータを持たない非strict関数でのみ発生できることが保証される。alreadyDeclared がfalse である場合、! envRecord .CreateMutableBinding (paramName , false )を実行する。 hasDuplicates がtrue である場合、! envRecord .InitializeBinding (paramName , undefined )を実行する。 argumentsObjNeeded がtrue である場合、strict がtrue である、またはsimpleParamList がfalse である場合、CreateUnmappedArgumentsObject (argList )をargumentsObj とする。そうでなければ、NOTE : マップされたargumentsオブジェクトは、restパラメータ、パラメータ既定値初期化子、または分割代入パラメータを持たない非strict関数に対してのみ提供される。CreateMappedArgumentsObject (func , formals , argList , envRecord )をargumentsObj とする。 strict がtrue である場合、! envRecord .CreateImmutableBinding ("arguments" , false )を実行する。 NOTE : strict modeコードでは、この束縛に代入しようとすることがEarly error によって防止されるため、その可変性は観測できない。そうでなければ、! envRecord .CreateMutableBinding ("arguments" , false )を実行する。 ! envRecord .InitializeBinding ("arguments" , argumentsObj )を実行する。 paramNames と« "arguments" »のlist-concatenation をparamBindings とする。そうでなければ、paramNames をparamBindings とする。 CreateListIteratorRecord (argList )をiteratorRecord とする。hasDuplicates がtrue である場合、usedEnv をundefined とする。そうでなければ、envRecord をusedEnv とする。 NOTE : 次のステップはReturnCompletion を返すことができない。これは、式位置でそのようなcompletionが発生する唯一の方法はYieldExpression の使用によるものであり、これは15.5.1 および15.6.1 のEarly Error規則により、パラメータリストでは禁止されているためである。iteratorRecord およびusedEnv を引数として、formals のIteratorBindingInitialization を実行する。hasParamExprs がfalse である場合、NOTE : パラメータとトップレベルのvarには単一のEnvironment Record だけが必要である。List paramBindings のコピーをinstantiatedVariableNames とする。variableNames の各要素name について、次を行う。instantiatedVariableNames がname を含まない場合、name をinstantiatedVariableNames に追加する。! envRecord .CreateMutableBinding (name , false )を実行する。 ! envRecord .InitializeBinding (name , undefined )を実行する。 envRecord をvariableEnv とする。そうでなければ、NOTE : 仮引数リスト内の式によって作成されたクロージャが、関数本体内の宣言を可視にしないことを保証するため、別個のEnvironment Record が必要である。NewDeclarativeEnvironment (envRecord )をvariableEnv とする。calleeContext のVariableEnvironmentをvariableEnv に設定する。instantiatedVariableNames を新しい空のList とする。variableNames の各要素name について、次を行う。instantiatedVariableNames がname を含まない場合、name をinstantiatedVariableNames に追加する。! variableEnv .CreateMutableBinding (name , false )を実行する。 paramBindings がname を含まない、またはfuncNames がname を含む場合、initialValue をundefined とする。そうでなければ、! envRecord .GetBindingValue (name , false )をinitialValue とする。 ! variableEnv .InitializeBinding (name , initialValue )を実行する。 NOTE : 仮引数と同じ名前を持つvarは、最初は対応する初期化済みパラメータと同じ値を持つ。 strict がtrue である場合、variableEnv をlexicalEnv とする。そうでなければ、ホスト がWebブラウザである、またはその他の形でBlock-Level Function Declarations Web Legacy Compatibility Semantics をサポートする場合、code Contains x がtrue であるような任意のBlock 、CaseClause 、またはDefaultClause x のStatementList に直接含まれる各FunctionDeclaration funcDecl について、次を行う。funcDecl のBindingIdentifier のStringValue をfuncName とする。FunctionDeclaration funcDecl を、funcName をBindingIdentifier として持つVariableStatement に置き換えても、func に対してEarly Errorsが発生せず、かつparamNames がfuncName を含まない場合、NOTE : funcName に対するvar束縛は、それがVarDeclaredName、仮引数の名前、または別のFunctionDeclaration のいずれでもない場合にのみ、ここでインスタンス化される。instantiatedVariableNames がfuncName を含まず、かつfuncName が"arguments" でない場合、! variableEnv .CreateMutableBinding (funcName , false )を実行する。 ! variableEnv .InitializeBinding (funcName , undefined )を実行する。 funcName をinstantiatedVariableNames に追加する。FunctionDeclaration funcDecl が評価されるとき、15.2.6 で提供されるFunctionDeclaration Evaluation アルゴリズムの代わりに、次のステップを実行する。実行中の実行コンテキストのVariableEnvironmentをfuncEnv とする。 実行中の実行コンテキストのLexicalEnvironmentをblockEnv とする。 ! blockEnv .GetBindingValue (funcName , false )をfuncObj とする。 ! funcEnv .SetMutableBinding (funcName , funcObj , false )を実行する。 unused を返す。NewDeclarativeEnvironment (variableEnv )をlexicalEnv とする。NOTE : 非strict関数は、トップレベルのlexical宣言に別個のEnvironment Record を使用する。これにより、direct eval は、evalコードによって導入されたvar scoped宣言が、既存のトップレベルのlexically scoped宣言と競合するかどうかを判断できる。strict関数では、strict direct eval が常にすべての宣言を新しいEnvironment Record に配置するため、これは不要である。 calleeContext のLexicalEnvironmentをlexicalEnv に設定する。code のLexicallyScopedDeclarations をlexicalDecls とする。lexicalDecls の各要素lexicalDecl について、次を行う。NOTE : lexically declared nameは、関数/ジェネレータ宣言、仮引数、またはvar名と同じにすることはできない。Lexically declared nameはここでインスタンス化されるだけで、初期化はされない。lexicalDecl のBoundNames の各要素name について、次を行う。lexicalDecl のIsConstantDeclaration がtrue である場合、! lexicalEnv .CreateImmutableBinding (name , true )を実行する。 そうでなければ、! lexicalEnv .CreateMutableBinding (name , false )を実行する。 calleeContext のPrivateEnvironmentをprivateEnv とする。funcsToInitialize の各Parse Node funcDecl について、次を行う。funcDecl のBoundNames の唯一の要素をfuncName とする。lexicalEnv およびprivateEnv を引数として、funcDecl のInstantiateFunctionObject をfuncObj とする。! variableEnv .SetMutableBinding (funcName , funcObj , false )を実行する。 unused を返す。
10.3 Built-in Function Objects
built-in function object はordinary object です;10.1 に定められたordinary objects の要件を満たさなければなりません。
すべてのordinary object に要求されるinternal slots(10.1 を参照)に加えて、built-in function object は次のinternal slotsも持たなければなりません:
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:
? 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:
result を ? BuiltinCallOrConstruct (func , uninitialized , argList , newTarget ) とする。Assert : result はObjectである。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:
callerContext をrunning execution context とする。callerContext がまだsuspendedでないなら、callerContext をsuspendする。calleeContext を新しいexecution context とする。calleeContext のFunctionをfunc に設定する。calleeRealm をfunc .[[Realm]] とする。calleeContext のRealm をcalleeRealm に設定する。calleeContext のScriptOrModuleをnull に設定する。calleeContext の任意の必要なimplementation-defined initializationを実行する。calleeContext をexecution context stack へpushする;calleeContext は現在running execution context である。func .[[Async]] がtrue なら、promiseCapability を ! NewPromiseCapability (%Promise% ) とする。resultsClosure を、func 、thisArg 、argList 、およびnewTarget をcaptureし、呼び出されたときに次のstepsを実行する、parametersを持たない新しいAbstract Closure とする:result を、func の仕様に適合する方法でfunc を評価した結果 であるCompletion Record とする。thisArg がuninitialized である場合、this 値はuninitializedである;そうでなければthisArg がthis 値を提供する。argList はnamed parametersを提供する。newTarget はNewTarget値を提供する。NOTE : func がこの文書内で定義されている場合、“func の仕様”とは、algorithm stepsまたはその他の手段によってそれに対して指定されたbehaviourである。Completion (result )を返す。AsyncFunctionStart (promiseCapability , resultsClosure )を実行する。calleeContext をexecution context stack から削除し、callerContext をrunning execution context として復元する。promiseCapability .[[Promise]] を返す。result を、func の仕様に適合する方法でfunc を評価した結果 であるCompletion Record とする。thisArg がuninitialized である場合、this 値はuninitializedである;そうでなければthisArg がthis 値を提供する。argList はnamed parametersを提供する。newTarget はNewTarget値を提供する。NOTE : func がこの文書内で定義されている場合、“func の仕様”とは、algorithm stepsまたはその他の手段によってそれに対して指定されたbehaviourである。calleeContext をexecution context stack から削除し、callerContext をrunning execution context として復元する。? result を返す。
Note
calleeContext がexecution 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:
realm が存在しないなら、realm をcurrent Realm Record に設定する。proto が存在しないなら、proto をrealm .[[Intrinsics]] .[[%Function.prototype% ]]に設定する。async が存在しないなら、async をfalse に設定する。internalSlotsList を、10.3 がこれから作成されるbuilt-in function object に要求するすべてのinternal slotsの名前を含むList とする。additionalInternalSlotsList の要素をinternalSlotsList へappendする。func を、呼び出されたときに、提供されたargumentsをbehaviour によって指定される対応parametersの値として使用して、behaviour によって記述されるactionを実行する新しいbuilt-in function object とする。新しいfunction object は、internalSlotsList の要素を名前とするinternal slots、および[[InitialName]] internal slotを持つ。func .[[Async]] をasync に設定する。func .[[Prototype]] をproto に設定する。func .[[Extensible]] をtrue に設定する。func .[[Realm]] をrealm に設定する。func .[[InitialName]] をnull に設定する。SetFunctionLength (func , length )を実行する。prefix が存在しないなら、SetFunctionName (func , name )を実行する。そうでなければ、SetFunctionName (func , name , prefix )を実行する。 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:
target をfunc .[[BoundTargetFunction]] とする。boundThis をfunc .[[BoundThis]] とする。boundArgs をfunc .[[BoundArguments]] とする。args をboundArgs とargList のlist-concatenation とする。? 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:
target をfunc .[[BoundTargetFunction]] とする。Assert : IsConstructor (target )はtrue である。boundArgs をfunc .[[BoundArguments]] とする。args をboundArgs とargList のlist-concatenation とする。SameValue (func , newTarget )がtrue なら、newTarget をtarget に設定する。? 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:
proto を ? targetFunc .[[GetPrototypeOf]] () とする。internalSlotsList を、« [[Prototype]] , [[Extensible]] »とTable 27 に列挙されるinternal slotsのlist-concatenation とする。obj をMakeBasicObject (internalSlotsList )とする。obj .[[Prototype]] をproto に設定する。obj .[[Call]] を10.4.1.1 で指定されるように設定する。IsConstructor (targetFunc )がtrue なら、obj .[[Construct]] を10.4.1.2 で指定されるように設定する。obj .[[BoundTargetFunction]] をtargetFunc に設定する。obj .[[BoundThis]] をboundThis に設定する。obj .[[BoundArguments]] をboundArgs に設定する。obj を返す。
10.4.2 Array Exotic Objects
Arrayは、array index property keys を特別に扱うexotic object です(6.1.7 を参照)。property name がarray 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:
propertyKey が"length" なら、? ArraySetLength (array , propertyDesc )を返す。propertyKey がarray index なら、lengthDesc をOrdinaryGetOwnProperty (array , "length" )とする。Assert : lengthDesc はundefined でない。Assert : IsDataDescriptor (lengthDesc )はtrue である。Assert : lengthDesc .[[Configurable]] はfalse である。length をlengthDesc .[[Value]] とする。Assert : length は非負整数のNumberである。index を ! ToUint32 (propertyKey ) とする。index ≥ length かつlengthDesc .[[Writable]] がfalse なら、false を返す。succeeded を ! OrdinaryDefineOwnProperty (array , propertyKey , propertyDesc ) とする。succeeded がfalse なら、false を返す。index ≥ length なら、lengthDesc .[[Value]] をindex + 1 𝔽 に設定する。succeeded を ! OrdinaryDefineOwnProperty (array , "length" , lengthDesc ) に設定する。Assert : succeeded はtrue である。true を返す。? 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:
length > 232 - 1なら、RangeError 例外をthrowする。proto が存在しないなら、proto を%Array.prototype% に設定する。array をMakeBasicObject (« [[Prototype]] , [[Extensible]] »)とする。array .[[Prototype]] をproto に設定する。array .[[DefineOwnProperty]] を10.4.2.1 で指定されるように設定する。! OrdinaryDefineOwnProperty (array , "length" , PropertyDescriptor { [[Value]] : 𝔽 (length ), [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : false })を実行する。 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:
isArray を ? IsArray (originalArray ) とする。isArray がfalse なら、? ArrayCreate (length )を返す。ctor を ? Get (originalArray , "constructor" ) とする。IsConstructor (ctor )がtrue なら、thisRealm をcurrent Realm Record とする。ctorRealm を ? GetFunctionRealm (ctor ) とする。thisRealm とctorRealm が同じRealm Record でないなら、SameValue (ctor , ctorRealm .[[Intrinsics]] .[[%Array% ]])がtrue なら、ctor をundefined に設定する。ctor がObjectなら、ctor を ? Get (ctor , %Symbol.species% ) に設定する。ctor がnull なら、ctor をundefined に設定する。ctor がundefined なら、? ArrayCreate (length )を返す。IsConstructor (ctor )がfalse なら、TypeError 例外をthrowする。? Construct (ctor , « 𝔽 (length ) »)を返す。
Note
originalArray がrunning execution context のrealm ではないrealm のstandard built-in Array constructor を使用して作成された場合、新しいArrayはrunning execution context のrealm を使用して作成されます。これは、現在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:
propertyDesc が[[Value]] fieldを持たないなら、! OrdinaryDefineOwnProperty (array , "length" , propertyDesc )を返す。 newLengthDesc をpropertyDesc のcopyとする。newLength を ? ToUint32 (propertyDesc .[[Value]] ) とする。numberLength を ? ToNumber (propertyDesc .[[Value]] ) とする。SameValueZero (newLength , numberLength )がfalse なら、RangeError 例外をthrowする。newLengthDesc .[[Value]] をnewLength に設定する。oldLengthDesc をOrdinaryGetOwnProperty (array , "length" )とする。Assert : oldLengthDesc はundefined でない。Assert : IsDataDescriptor (oldLengthDesc )はtrue である。Assert : oldLengthDesc .[[Configurable]] はfalse である。oldLength をoldLengthDesc .[[Value]] とする。newLength ≥ oldLength なら、! OrdinaryDefineOwnProperty (array , "length" , newLengthDesc )を返す。 oldLengthDesc .[[Writable]] がfalse なら、false を返す。newLengthDesc が[[Writable]] fieldを持たない、またはnewLengthDesc .[[Writable]] がtrue なら、newWritable をtrue とする。そうでなければ、NOTE : 任意のelementsを削除できない場合に備えて、[[Writable]] 属性をfalse に設定することはdeferされる。newWritable をfalse とする。newLengthDesc .[[Writable]] をtrue に設定する。 succeeded を ! OrdinaryDefineOwnProperty (array , "length" , newLengthDesc ) とする。succeeded がfalse なら、false を返す。array index であり、! ToUint32 (propertyKey ) ≥ newLength であるようなarray の各own property key propertyKey について、descending numeric index orderで、以下を行うdeleteSucceeded を ! array .[[Delete]] (propertyKey ) とする。deleteSucceeded がfalse なら、newLengthDesc .[[Value]] を ! ToUint32 (propertyKey ) + 1 𝔽 に設定する。newWritable がfalse なら、newLengthDesc .[[Writable]] をfalse に設定する。! OrdinaryDefineOwnProperty (array , "length" , newLengthDesc )を実行する。 false を返す。newWritable がfalse なら、succeeded を ! OrdinaryDefineOwnProperty (array , "length" , PropertyDescriptor { [[Writable]] : false }) に設定する。Assert : succeeded はtrue である。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 objects はordinary 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:
propertyDesc をOrdinaryGetOwnProperty (string , propertyKey )とする。propertyDesc がundefined でないなら、propertyDesc を返す。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:
stringDesc をStringGetOwnProperty (string , propertyKey )とする。stringDesc がundefined でないなら、extensible をstring .[[Extensible]] とする。IsCompatiblePropertyDescriptor (extensible , propertyDesc , stringDesc )を返す。! 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:
keys を新しい空のList とする。string をobj .[[StringData]] とする。Assert : string はStringである。length をstring のlengthとする。0 ≤ i < length である各integer i について、昇順で、以下を行う! ToString (𝔽 (i ))をkeys へappendする。 array index であり、! ToIntegerOrInfinity (propertyKey ) ≥ length であるようなobj の各own property key propertyKey について、ascending numeric index orderで、以下を行うpropertyKey をkeys へappendする。Stringであり、array index でないようなobj の各own property key propertyKey について、property creationのascending chronological orderで、以下を行うpropertyKey をkeys へappendする。 Symbolであるようなobj の各own property key propertyKey について、property creationのascending chronological orderで、以下を行うpropertyKey をkeys へappendする。 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:
string をMakeBasicObject (« [[Prototype]] , [[Extensible]] , [[StringData]] »)とする。string .[[Prototype]] をproto に設定する。string .[[StringData]] をvalue に設定する。string .[[GetOwnProperty]] を10.4.3.1 で指定されるように設定する。string .[[DefineOwnProperty]] を10.4.3.2 で指定されるように設定する。string .[[OwnPropertyKeys]] を10.4.3.3 で指定されるように設定する。length をvalue のlengthとする。! DefinePropertyOrThrow (string , "length" , PropertyDescriptor { [[Value]] : 𝔽 (length ), [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false })を実行する。 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:
propertyKey がStringでないなら、undefined を返す。numericIndex をCanonicalNumericIndexString (propertyKey )とする。numericIndex がintegral Number でないなら、undefined を返す。numericIndex が-0 𝔽 またはnumericIndex < -0 𝔽 なら、undefined を返す。stringData をstring .[[StringData]] とする。Assert : stringData はStringである。length をstringData のlengthとする。ℝ (numericIndex ) ≥ length なら、undefined を返す。resultString をℝ (numericIndex )からℝ (numericIndex ) + 1までのstringData のsubstring とする。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
Arguments exotic objects はordinary objects と同じinternal slotsを持ちます。また、[[ParameterMap]] internal slotも持ちます。Ordinary arguments objectsも[[ParameterMap]] internal slotを持ち、その値は常にundefined です。ordinary argument objectsについては、[[ParameterMap]] internal slotはObject.prototype.toString(20.1.3.6 )がそれらをそのようなものとして識別するためにのみ使用されます。
Note 2
numeric name valuesが対応するfunction object のformal parametersの数より小さいarguments exotic object のinteger-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:
propertyDesc をOrdinaryGetOwnProperty (args , propertyKey )とする。propertyDesc がundefined なら、undefined を返す。map をargs .[[ParameterMap]] とする。isMapped を ! HasOwnProperty (map , propertyKey ) とする。isMapped がtrue なら、propertyDesc .[[Value]] を ! Get (map , propertyKey ) に設定する。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:
map をargs .[[ParameterMap]] とする。isMapped を ! HasOwnProperty (map , propertyKey ) とする。newArgDesc をpropertyDesc とする。isMapped がtrue であり、かつIsDataDescriptor (propertyDesc )がtrue なら、propertyDesc が[[Value]] fieldを持たず、propertyDesc が[[Writable]] fieldを持ち、かつpropertyDesc .[[Writable]] がfalse なら、newArgDesc をpropertyDesc のcopyに設定する。newArgDesc .[[Value]] を ! Get (map , propertyKey ) に設定する。allowed を ! OrdinaryDefineOwnProperty (args , propertyKey , newArgDesc ) とする。allowed がfalse なら、false を返す。isMapped がtrue なら、IsAccessorDescriptor (propertyDesc )がtrue なら、! map .[[Delete]] (propertyKey )を実行する。 そうでなければ、propertyDesc が[[Value]] fieldを持つなら、Assert : formal parameters mapped by arguments objectsは常にwritableであるため、次のSetは成功する。! Set (map , propertyKey , propertyDesc .[[Value]] , false )を実行する。 propertyDesc が[[Writable]] fieldを持ち、propertyDesc .[[Writable]] がfalse なら、! map .[[Delete]] (propertyKey )を実行する。 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:
map をargs .[[ParameterMap]] とする。isMapped を ! HasOwnProperty (map , propertyKey ) とする。isMapped がfalse なら、? OrdinaryGet (args , propertyKey , receiver )を返す。Assert : map はpropertyKey に対するformal parameter mappingを含む。! 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:
SameValue (args , receiver )がfalse なら、isMapped をfalse とする。そうでなければ、map をargs .[[ParameterMap]] とする。isMapped を ! HasOwnProperty (map , propertyKey ) とする。 isMapped がtrue なら、Assert : formal parameters mapped by arguments objectsは常にwritableであるため、次のSetは成功する。! Set (map , propertyKey , value , false )を実行する。 ? 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:
map をargs .[[ParameterMap]] とする。isMapped を ! HasOwnProperty (map , propertyKey ) とする。result を ? OrdinaryDelete (args , propertyKey ) とする。result がtrue かつisMapped がtrue なら、! map .[[Delete]] (propertyKey )を実行する。 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:
length をargList 内の要素数とする。obj をOrdinaryObjectCreate (%Object.prototype% , « [[ParameterMap]] »)とする。obj .[[ParameterMap]] をundefined に設定する。! DefinePropertyOrThrow (obj , "length" , PropertyDescriptor { [[Value]] : 𝔽 (length ), [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true })を実行する。 index を0とする。index < length である間、繰り返すvalue をargList [index ]とする。! CreateDataPropertyOrThrow (obj , ! ToString (𝔽 (index )), value )を実行する。 index をindex + 1に設定する。! DefinePropertyOrThrow (obj , %Symbol.iterator% , PropertyDescriptor { [[Value]] : %Array.prototype.values%, [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true })を実行する。 ! DefinePropertyOrThrow (obj , "callee" , PropertyDescriptor { [[Get]] : %ThrowTypeError% , [[Set]] : %ThrowTypeError% , [[Enumerable]] : false , [[Configurable]] : false })を実行する。 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:
Assert : formals はrest parameter、任意のbinding patterns、または任意のinitializersを含まない。duplicate identifiersを含む場合がある。length をargList 内の要素数とする。obj をMakeBasicObject (« [[Prototype]] , [[Extensible]] , [[ParameterMap]] »)とする。obj .[[GetOwnProperty]] を10.4.4.1 で指定されるように設定する。obj .[[DefineOwnProperty]] を10.4.4.2 で指定されるように設定する。obj .[[Get]] を10.4.4.3 で指定されるように設定する。obj .[[Set]] を10.4.4.4 で指定されるように設定する。obj .[[Delete]] を10.4.4.5 で指定されるように設定する。obj .[[Prototype]] を%Object.prototype% に設定する。map をOrdinaryObjectCreate (null )とする。obj .[[ParameterMap]] をmap に設定する。paramNames をformals のBoundNames とする。paramCount をparamNames 内の要素数とする。index を0とする。index < length である間、繰り返すvalue をargList [index ]とする。! CreateDataPropertyOrThrow (obj , ! ToString (𝔽 (index )), value )を実行する。 index をindex + 1に設定する。! DefinePropertyOrThrow (obj , "length" , PropertyDescriptor { [[Value]] : 𝔽 (length ), [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true })を実行する。 mappedNames を新しい空のList とする。index をparamCount - 1に設定する。index ≥ 0である間、繰り返すname をparamNames [index ]とする。mappedNames がname を含まないなら、name をmappedNames へappendする。index < length なら、getter をMakeArgGetter (name , envRecord )とする。setter をMakeArgSetter (name , envRecord )とする。! map .[[DefineOwnProperty]] (! ToString (𝔽 (index )), PropertyDescriptor { [[Set]] : setter , [[Get]] : getter , [[Enumerable]] : false , [[Configurable]] : true })を実行する。 index をindex - 1に設定する。! DefinePropertyOrThrow (obj , %Symbol.iterator% , PropertyDescriptor { [[Value]] : %Array.prototype.values%, [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true })を実行する。 ! DefinePropertyOrThrow (obj , "callee" , PropertyDescriptor { [[Value]] : func , [[Writable]] : true , [[Enumerable]] : false , [[Configurable]] : true })を実行する。 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:
getterClosure を、name およびenvRecord をcaptureし、呼び出されたときに次のstepsを実行する、parametersを持たない新しいAbstract Closure とする:NormalCompletion (! envRecord .GetBindingValue (name , false ))を返す。getter をCreateBuiltinFunction (getterClosure , 0, "" , « »)とする。NOTE : getter はECMAScriptコードから直接アクセス可能になることは決してない。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:
setterClosure を、name およびenvRecord をcaptureし、呼び出されたときに次のstepsを実行するparameters (value )を持つ新しいAbstract Closure とする:NormalCompletion (! envRecord .SetMutableBinding (name , value , false ))を返す。setter をCreateBuiltinFunction (setterClosure , 1, "" , « »)とする。NOTE : setter はECMAScriptコードから直接アクセス可能になることは決してない。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をTypedArrays のproperty keys として扱ってよいです。
TypedArrays はordinary 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:
NOTE : 6.1.7.3 で指定されるextensibility-related invariantsは、obj がpropertiesを得る(または失ってから再び得る)可能性があるとき、このmethodがtrue を返すことを許可しない。これは、そのunderlying bufferがresizeされるとき、integer index namesを持つpropertiesについて発生する場合がある。IsTypedArrayFixedLength (obj )がfalse なら、false を返す。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:
propertyKey がStringなら、numericIndex をCanonicalNumericIndexString (propertyKey )とする。numericIndex がundefined でないなら、value をTypedArrayGetElement (obj , numericIndex )とする。value がundefined なら、undefined を返す。PropertyDescriptor { [[Value]] : value , [[Writable]] : true , [[Enumerable]] : true , [[Configurable]] : true }を返す。 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:
propertyKey がStringなら、numericIndex をCanonicalNumericIndexString (propertyKey )とする。numericIndex がundefined でないなら、IsValidIntegerIndex (obj , numericIndex )を返す。? 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:
propertyKey がStringなら、numericIndex をCanonicalNumericIndexString (propertyKey )とする。numericIndex がundefined でないなら、IsValidIntegerIndex (obj , numericIndex )がfalse なら、false を返す。propertyDesc が[[Configurable]] fieldを持ち、propertyDesc .[[Configurable]] がfalse なら、false を返す。propertyDesc が[[Enumerable]] fieldを持ち、propertyDesc .[[Enumerable]] がfalse なら、false を返す。IsAccessorDescriptor (propertyDesc )がtrue なら、false を返す。propertyDesc が[[Writable]] fieldを持ち、propertyDesc .[[Writable]] がfalse なら、false を返す。propertyDesc が[[Value]] fieldを持つなら、? TypedArraySetElement (obj , numericIndex , propertyDesc .[[Value]] )を実行する。true を返す。! 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:
propertyKey がStringなら、numericIndex をCanonicalNumericIndexString (propertyKey )とする。numericIndex がundefined でないなら、TypedArrayGetElement (obj , numericIndex )を返す。? 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:
propertyKey がStringなら、numericIndex をCanonicalNumericIndexString (propertyKey )とする。numericIndex がundefined でないなら、SameValue (obj , receiver )がtrue なら、? TypedArraySetElement (obj , numericIndex , value )を実行する。 true を返す。IsValidIntegerIndex (obj , numericIndex )がfalse なら、true を返す。? 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:
propertyKey がStringなら、numericIndex をCanonicalNumericIndexString (propertyKey )とする。numericIndex がundefined でないなら、IsValidIntegerIndex (obj , numericIndex )がfalse なら、true を返す。false を返す。! 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:
taRecord をMakeTypedArrayWithBufferWitnessRecord (obj , seq-cst )とする。keys を新しい空のList とする。IsTypedArrayOutOfBounds (taRecord )がfalse なら、length をTypedArrayLength (taRecord )とする。0 ≤ i < length である各integer i について、昇順で、以下を行う! ToString (𝔽 (i ))をkeys へappendする。 Stringであり、integer index でないようなobj の各own property key propertyKey について、property creationのascending chronological orderで、以下を行うpropertyKey をkeys へappendする。 Symbolであるようなobj の各own property key propertyKey について、property creationのascending chronological orderで、以下を行うpropertyKey をkeys へappendする。 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:
buffer をobj .[[ViewedArrayBuffer]] とする。IsDetachedBuffer (buffer )がtrue なら、byteLength をdetached とする。そうでなければ、byteLength をArrayBufferByteLength (buffer , order )とする。 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:
internalSlotsList を« [[Prototype]] , [[Extensible]] , [[ViewedArrayBuffer]] , [[TypedArrayName]] , [[ContentType]] , [[ByteLength]] , [[ByteOffset]] , [[ArrayLength]] »とする。ta をMakeBasicObject (internalSlotsList )とする。ta .[[PreventExtensions]] を10.4.5.1 で指定されるように設定する。ta .[[GetOwnProperty]] を10.4.5.2 で指定されるように設定する。ta .[[HasProperty]] を10.4.5.3 で指定されるように設定する。ta .[[DefineOwnProperty]] を10.4.5.4 で指定されるように設定する。ta .[[Get]] を10.4.5.5 で指定されるように設定する。ta .[[Set]] を10.4.5.6 で指定されるように設定する。ta .[[Delete]] を10.4.5.7 で指定されるように設定する。ta .[[OwnPropertyKeys]] を10.4.5.8 で指定されるように設定する。ta .[[Prototype]] をproto に設定する。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:
Assert : IsTypedArrayOutOfBounds (taRecord )はfalse である。obj をtaRecord .[[Object]] とする。obj .[[ByteLength]] がauto でないなら、obj .[[ByteLength]] を返す。length をTypedArrayLength (taRecord )とする。elementSize をTypedArrayElementSize (obj )とする。NOTE : underlying bufferが非整数倍にresizeされている場合でも、返されるbyte lengthは常にelementSize の整数倍である。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:
Assert : IsTypedArrayOutOfBounds (taRecord )はfalse である。obj をtaRecord .[[Object]] とする。obj .[[ArrayLength]] がauto でないなら、obj .[[ArrayLength]] を返す。Assert : IsFixedLengthArrayBuffer (obj .[[ViewedArrayBuffer]] )はfalse である。byteOffset をobj .[[ByteOffset]] とする。elementSize をTypedArrayElementSize (obj )とする。byteLength をtaRecord .[[CachedBufferByteLength]] とする。Assert : byteLength はdetached でない。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:
obj をtaRecord .[[Object]] とする。bufferByteLength をtaRecord .[[CachedBufferByteLength]] とする。IsDetachedBuffer (obj .[[ViewedArrayBuffer]] )がtrue なら、Assert : bufferByteLength はdetached である。true を返す。Assert : bufferByteLength は非負整数である。byteOffsetStart をobj .[[ByteOffset]] とする。obj .[[ArrayLength]] がauto なら、byteOffsetEnd をbufferByteLength とする。そうでなければ、elementSize をTypedArrayElementSize (obj )とする。arrayByteLength をobj .[[ArrayLength]] × elementSize とする。byteOffsetEnd をbyteOffsetStart + arrayByteLength とする。 NOTE : [[ByteOffset]] がbufferByteLength である0-length TypedArray はout-of-boundsとはみなされない。byteOffsetStart > bufferByteLength またはbyteOffsetEnd > bufferByteLength なら、true を返す。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:
obj .[[ArrayLength]] がauto なら、false を返す。buffer をobj .[[ViewedArrayBuffer]] とする。IsFixedLengthArrayBuffer (buffer )がfalse かつIsSharedArrayBuffer (buffer )がfalse なら、false を返す。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:
IsDetachedBuffer (obj .[[ViewedArrayBuffer]] )がtrue なら、false を返す。index がintegral Number でないなら、false を返す。index が-0 𝔽 またはindex < -0 𝔽 なら、false を返す。taRecord をMakeTypedArrayWithBufferWitnessRecord (obj , unordered )とする。NOTE : obj のbacking bufferがgrowable SharedArrayBuffer である場合、Bounds checkingはsynchronizing operationではない。IsTypedArrayOutOfBounds (taRecord )がtrue なら、false を返す。length をTypedArrayLength (taRecord )とする。ℝ (index ) ≥ length なら、false を返す。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:
IsValidIntegerIndex (obj , index )がfalse なら、undefined を返す。offset をobj .[[ByteOffset]] とする。elementSize をTypedArrayElementSize (obj )とする。byteIndexInBuffer を(ℝ (index ) × elementSize ) + offset とする。elementType をTypedArrayElementType (obj )とする。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:
obj .[[ContentType]] がbigint なら、number を ? ToBigInt (value ) とする。そうでなければ、number を ? ToNumber (value ) とする。 IsValidIntegerIndex (obj , index )がtrue なら、offset をobj .[[ByteOffset]] とする。elementSize をTypedArrayElementSize (obj )とする。byteIndexInBuffer を(ℝ (index ) × elementSize ) + offset とする。elementType をTypedArrayElementType (obj )とする。SetValueInBuffer (obj .[[ViewedArrayBuffer]] , byteIndexInBuffer , elementType , number , true , unordered )を実行する。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:
obj が[[DataView]] internal slotを持つなら、viewRecord をMakeDataViewWithBufferWitnessRecord (obj , seq-cst )とする。IsViewOutOfBounds (viewRecord )を返す。taRecord をMakeTypedArrayWithBufferWitnessRecord (obj , seq-cst )とする。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
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:
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:
! 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:
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:
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:
propertyKey がSymbolなら、OrdinaryGetOwnProperty (obj , propertyKey )を返す。exports をobj .[[Exports]] とする。exports がpropertyKey を含まないなら、undefined を返す。value を ? obj .[[Get]] (propertyKey , obj ) とする。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:
propertyKey がSymbolなら、! OrdinaryDefineOwnProperty (obj , propertyKey , propertyDesc )を返す。current を ? obj .[[GetOwnProperty]] (propertyKey ) とする。current がundefined なら、false を返す。propertyDesc が[[Configurable]] fieldを持ち、propertyDesc .[[Configurable]] がtrue なら、false を返す。propertyDesc が[[Enumerable]] fieldを持ち、propertyDesc .[[Enumerable]] がfalse なら、false を返す。IsAccessorDescriptor (propertyDesc )がtrue なら、false を返す。propertyDesc が[[Writable]] fieldを持ち、propertyDesc .[[Writable]] がfalse なら、false を返す。propertyDesc が[[Value]] fieldを持つなら、SameValue (propertyDesc .[[Value]] , current .[[Value]] )を返す。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:
propertyKey がSymbolなら、! OrdinaryHasProperty (obj , propertyKey )を返す。exports をobj .[[Exports]] とする。exports がpropertyKey を含むなら、true を返す。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:
propertyKey がSymbolなら、! OrdinaryGet (obj , propertyKey , receiver )を返す。 exports をobj .[[Exports]] とする。exports がpropertyKey を含まないなら、undefined を返す。module をobj .[[Module]] とする。binding をmodule .ResolveExport (propertyKey )とする。Assert : binding はResolvedBinding Record である。targetModule をbinding .[[Module]] とする。Assert : targetModule はundefined でない。binding .[[BindingName]] がnamespace なら、GetModuleNamespace (targetModule )を返す。targetEnv をtargetModule .[[Environment]] とする。targetEnv がempty なら、ReferenceError 例外をthrowする。? targetEnv .GetBindingValue (binding .[[BindingName]] , true )を返す。
Note
ResolveExport はside-effect freeです。このoperationが特定のexportName 、resolveSet 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:
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:
propertyKey がSymbolなら、! OrdinaryDelete (obj , propertyKey )を返す。 exports をobj .[[Exports]] とする。exports がpropertyKey を含むなら、false を返す。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:
exports をobj .[[Exports]] とする。symbolKeys をOrdinaryOwnPropertyKeys (obj )とする。exports とsymbolKeys のlist-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:
Assert : module .[[Namespace]] はempty である。internalSlotsList をTable 29 に列挙されるinternal slotsとする。namespace をMakeBasicObject (internalSlotsList )とする。namespace のessential internal methodsを10.4.6 で指定される定義に設定する。namespace .[[Module]] をmodule に設定する。sortedExports を、exports の要素をlexicographic code unit order に従ってsortした要素を持つList とする。namespace .[[Exports]] をsortedExports に設定する。28.3 の定義に対応するnamespace のown propertiesを作成する。module .[[Namespace]] をnamespace に設定する。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:
? 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:
current を ? obj .[[GetPrototypeOf]] () とする。SameValue (proto , current )がtrue なら、true を返す。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、propertyKey はproperty key 値、value は任意のECMAScript language value、propertyDesc はProperty 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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "getPrototypeOf" ) とする。trap がundefined なら、? target .[[GetPrototypeOf]] () を返す。 handlerProto を ? Call (trap , handler , « target ») とする。handlerProto がObjectでなく、かつhandlerProto がnull でないなら、TypeError 例外をthrowする。extensibleTarget を ? IsExtensible (target ) とする。extensibleTarget がtrue なら、handlerProto を返す。targetProto を ? target .[[GetPrototypeOf]] () とする。SameValue (handlerProto , targetProto )がfalse なら、TypeError 例外をthrowする。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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "setPrototypeOf" ) とする。trap がundefined なら、? target .[[SetPrototypeOf]] (proto ) を返す。 boolTrapResult をToBoolean (? Call (trap , handler , « target , proto »))とする。boolTrapResult がfalse なら、false を返す。extensibleTarget を ? IsExtensible (target ) とする。extensibleTarget がtrue なら、true を返す。targetProto を ? target .[[GetPrototypeOf]] () とする。SameValue (proto , targetProto )がfalse なら、TypeError 例外をthrowする。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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "isExtensible" ) とする。trap がundefined なら、? IsExtensible (target )を返す。 boolTrapResult をToBoolean (? Call (trap , handler , « target »))とする。targetResult を ? IsExtensible (target ) とする。boolTrapResult がtargetResult でないなら、TypeError 例外をthrowする。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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "preventExtensions" ) とする。trap がundefined なら、? target .[[PreventExtensions]] () を返す。 boolTrapResult をToBoolean (? Call (trap , handler , « target »))とする。boolTrapResult がtrue なら、extensibleTarget を ? IsExtensible (target ) とする。extensibleTarget がtrue なら、TypeError 例外をthrowする。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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "getOwnPropertyDescriptor" ) とする。trap がundefined なら、? target .[[GetOwnProperty]] (propertyKey ) を返す。 trapResultObj を ? Call (trap , handler , « target , propertyKey ») とする。trapResultObj がObjectでなく、かつtrapResultObj がundefined でないなら、TypeError 例外をthrowする。targetDesc を ? target .[[GetOwnProperty]] (propertyKey ) とする。trapResultObj がundefined なら、targetDesc がundefined なら、undefined を返す。targetDesc .[[Configurable]] がfalse なら、TypeError 例外をthrowする。extensibleTarget を ? IsExtensible (target ) とする。extensibleTarget がfalse なら、TypeError 例外をthrowする。undefined を返す。extensibleTarget を ? IsExtensible (target ) とする。resultDesc を ? ToPropertyDescriptor (trapResultObj ) とする。CompletePropertyDescriptor (resultDesc )を実行する。valid をIsCompatiblePropertyDescriptor (extensibleTarget , resultDesc , targetDesc )とする。valid がfalse なら、TypeError 例外をthrowする。resultDesc .[[Configurable]] がfalse なら、targetDesc がundefined またはtargetDesc .[[Configurable]] がtrue なら、TypeError 例外をthrowする。resultDesc が[[Writable]] fieldを持ち、resultDesc .[[Writable]] がfalse なら、Assert : targetDesc は[[Writable]] fieldを持つ。targetDesc .[[Writable]] がtrue なら、TypeError 例外をthrowする。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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "defineProperty" ) とする。trap がundefined なら、? target .[[DefineOwnProperty]] (propertyKey , propertyDesc ) を返す。 propertyDescObj をFromPropertyDescriptor (propertyDesc )とする。boolTrapResult をToBoolean (? Call (trap , handler , « target , propertyKey , propertyDescObj »))とする。boolTrapResult がfalse なら、false を返す。targetDesc を ? target .[[GetOwnProperty]] (propertyKey ) とする。extensibleTarget を ? IsExtensible (target ) とする。propertyDesc が[[Configurable]] fieldを持ち、propertyDesc .[[Configurable]] がfalse なら、settingConfigFalse をtrue とする。そうでなければ、settingConfigFalse をfalse とする。 targetDesc がundefined なら、extensibleTarget がfalse なら、TypeError 例外をthrowする。settingConfigFalse がtrue なら、TypeError 例外をthrowする。そうでなければ、IsCompatiblePropertyDescriptor (extensibleTarget , propertyDesc , targetDesc )がfalse なら、TypeError 例外をthrowする。settingConfigFalse がtrue かつtargetDesc .[[Configurable]] がtrue なら、TypeError 例外をthrowする。IsDataDescriptor (targetDesc )がtrue 、targetDesc .[[Configurable]] がfalse 、かつtargetDesc .[[Writable]] がtrue なら、propertyDesc が[[Writable]] fieldを持ち、propertyDesc .[[Writable]] がfalse なら、TypeError 例外をthrowする。 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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "has" ) とする。trap がundefined なら、? target .[[HasProperty]] (propertyKey ) を返す。 boolTrapResult をToBoolean (? Call (trap , handler , « target , propertyKey »))とする。boolTrapResult がfalse なら、targetDesc を ? target .[[GetOwnProperty]] (propertyKey ) とする。targetDesc がundefined でないなら、targetDesc .[[Configurable]] がfalse なら、TypeError 例外をthrowする。extensibleTarget を ? IsExtensible (target ) とする。extensibleTarget がfalse なら、TypeError 例外をthrowする。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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "get" ) とする。trap がundefined なら、? target .[[Get]] (propertyKey , receiver ) を返す。 trapResult を ? Call (trap , handler , « target , propertyKey , receiver ») とする。targetDesc を ? target .[[GetOwnProperty]] (propertyKey ) とする。targetDesc がundefined でなく、かつtargetDesc .[[Configurable]] がfalse なら、IsDataDescriptor (targetDesc )がtrue であり、かつtargetDesc .[[Writable]] がfalse なら、SameValue (trapResult , targetDesc .[[Value]] )がfalse なら、TypeError 例外をthrowする。IsAccessorDescriptor (targetDesc )がtrue であり、かつtargetDesc .[[Get]] がundefined なら、trapResult がundefined でないなら、TypeError 例外をthrowする。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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "set" ) とする。trap がundefined なら、? target .[[Set]] (propertyKey , value , receiver ) を返す。 boolTrapResult をToBoolean (? Call (trap , handler , « target , propertyKey , value , receiver »))とする。boolTrapResult がfalse なら、false を返す。targetDesc を ? target .[[GetOwnProperty]] (propertyKey ) とする。targetDesc がundefined でなく、かつtargetDesc .[[Configurable]] がfalse なら、IsDataDescriptor (targetDesc )がtrue であり、かつtargetDesc .[[Writable]] がfalse なら、SameValue (value , targetDesc .[[Value]] )がfalse なら、TypeError 例外をthrowする。IsAccessorDescriptor (targetDesc )がtrue なら、targetDesc .[[Set]] がundefined なら、TypeError 例外をthrowする。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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "deleteProperty" ) とする。trap がundefined なら、? target .[[Delete]] (propertyKey ) を返す。 boolTrapResult をToBoolean (? Call (trap , handler , « target , propertyKey »))とする。boolTrapResult がfalse なら、false を返す。targetDesc を ? target .[[GetOwnProperty]] (propertyKey ) とする。targetDesc がundefined なら、true を返す。targetDesc .[[Configurable]] がfalse なら、TypeError 例外をthrowする。extensibleTarget を ? IsExtensible (target ) とする。extensibleTarget がfalse なら、TypeError 例外をthrowする。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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "ownKeys" ) とする。trap がundefined なら、? target .[[OwnPropertyKeys]] () を返す。 trapResultArray を ? Call (trap , handler , « target ») とする。trapResult を ? CreateListFromArrayLike (trapResultArray , property-key ) とする。trapResult が重複entriesを含むなら、TypeError 例外をthrowする。extensibleTarget を ? IsExtensible (target ) とする。targetKeys を ? target .[[OwnPropertyKeys]] () とする。Assert : targetKeys はproperty keys のList である。Assert : targetKeys は重複entriesを含まない。targetConfigurableKeys を新しい空のList とする。targetNonconfigurableKeys を新しい空のList とする。targetKeys の各要素key について、以下を行うpropertyDesc を ? target .[[GetOwnProperty]] (key ) とする。propertyDesc がundefined でなく、かつpropertyDesc .[[Configurable]] がfalse なら、key をtargetNonconfigurableKeys へappendする。そうでなければ、key をtargetConfigurableKeys へappendする。 extensibleTarget がtrue であり、かつtargetNonconfigurableKeys が空なら、trapResult を返す。uncheckedResultKeys を、要素がtrapResult の要素であるList とする。targetNonconfigurableKeys の各要素key について、以下を行うuncheckedResultKeys がkey を含まないなら、TypeError 例外をthrowする。key をuncheckedResultKeys から削除する。extensibleTarget がtrue なら、trapResult を返す。targetConfigurableKeys の各要素key について、以下を行うuncheckedResultKeys がkey を含まないなら、TypeError 例外をthrowする。key をuncheckedResultKeys から削除する。uncheckedResultKeys が空でないなら、TypeError 例外をthrowする。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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "apply" ) とする。trap がundefined なら、? Call (target , thisArg , argList )を返す。 argArray をCreateArrayFromList (argList )とする。? 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:
? ValidateNonRevokedProxy (obj )を実行する。 target をobj .[[ProxyTarget]] とする。Assert : IsConstructor (target )はtrue である。handler をobj .[[ProxyHandler]] とする。Assert : handler はObjectである。trap を ? GetMethod (handler , "construct" ) とする。trap がundefined なら、? Construct (target , argList , newTarget )を返す。 argArray をCreateArrayFromList (argList )とする。newObj を ? Call (trap , handler , « target , argArray , newTarget ») とする。newObj がObjectでないなら、TypeError 例外をthrowする。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:
proxy .[[ProxyTarget]] がnull なら、TypeError 例外をthrowする。Assert : proxy .[[ProxyHandler]] はnull でない。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:
target がObjectでないなら、TypeError 例外をthrowする。handler がObjectでないなら、TypeError 例外をthrowする。proxy をMakeBasicObject (« [[ProxyHandler]] , [[ProxyTarget]] »)とする。, [[Call]] および[[Construct]] を除き、proxy のessential internal methodsを10.5 で指定される定義に設定する。 IsCallable (target )がtrue なら、proxy .[[Call]] を10.5.12 で指定されるように設定する。IsConstructor (target )がtrue なら、proxy .[[Construct]] を10.5.13 で指定されるように設定する。proxy .[[ProxyTarget]] をtarget に設定する。proxy .[[ProxyHandler]] をhandler に設定する。proxy を返す。