10.1 通常オブジェクトの内部メソッドと内部スロット
すべての通常オブジェクトは [[Prototype]] と呼ばれる内部
スロットを持つ。この内部スロットの値は null またはオ
ブジェクトのいずれかであり、継承を実装するために用いられ
る。通常オブジェクト obj から propertyKey という名
前のプロパティが欠けているが、その [[Prototype]] オブジ
ェクト上には存在していると仮定する。propertyKey が
[[Prototype]] オブジェクト上のデータプロパティを参照す
る場合、obj は get アクセスについてそれを継承し、
propertyKey が obj のプロパティであるかのように振
る舞う。propertyKey が [[Prototype]] オブジェクト上
の書込み可能なデータプロパティを参照する場合、obj 上
の propertyKey への set アクセスは、obj 上に
propertyKey という名前の新たなデータプロパティを作成
する。propertyKey が [[Prototype]] オブジェクト上の
書込み不可なデータプロパティを参照する場合、obj 上の
propertyKey への set アクセスは失敗する。
propertyKey が [[Prototype]] オブジェクト上のアクセ
サプロパティを参照する場合、そのアクセサは get アクセス
と set アクセスの両方について obj に継承される。
すべての通常オブジェクトは Boolean 値の [[Extensible]]
内部スロットを持ち、これは 6.1.7.3 で
規定される拡張可能性関連の内部メソッド不変条件を満たすた
めに用いられる。すなわち、オブジェクトの [[Extensible]]
内部スロットの値がいったん false に設定されると、その
オブジェクトにプロパティを追加すること、オブジェクトの
[[Prototype]] 内部スロットの値を変更すること、またはその
後に [[Extensible]] の値を true に変更することは、も
はや不可能となる。
以下のアルゴリズム記述において、obj は通常オブジェク
ト、propertyKey は property key 値、value は任意
の ECMAScript 言語値 、そして desc は Property
Descriptor レコードであると仮定する。
各通常オブジェクト内部メソッドは、同様の名前を持つ抽象操
作へ委譲する。そのような抽象操作が別の内部メソッドに依存
する場合、その内部メソッドは、同様の名前を持つ抽象操作を
直接呼び出すのではなく obj に対して呼び出される。これ
らの意味論により、通常オブジェクト内部メソッドが特殊オブ
ジェクトに適用されたとき、それらの上書きされた内部メソッ
ドが呼び出されることが保証される。
10.1.1 [[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of an ordinary object obj takes no arguments and returns a normal completion containing either an Object or null . It performs the following steps when called:
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 an ordinary object obj takes argument proto (an Object or null ) and returns a normal completion containing a Boolean. It performs the following steps when called:
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 に設定する。Else if SameValue (cursor , obj ) が true なら、false を返す。 Else,cursor .[[GetPrototypeOf]] が 10.1.1 で定義された通常オブジェクト内部メソッドで
なければ、done を true に設定する。Else, cursor を cursor .[[Prototype]] に設定
する。 obj .[[Prototype]] を proto に設定する。true を返す。
Note
手順 7 のループは、[[GetPrototypeOf]]
と [[SetPrototypeOf]] に通常オブジェクト定義を用いるオ
ブジェクトのみを含む prototype chain に循環が生じないこ
とを保証する。
10.1.3 [[IsExtensible]] ( )
The [[IsExtensible]] internal method of an ordinary object obj takes no arguments and returns a normal completion containing a Boolean. It performs the following steps when called:
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 an 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 an ordinary object obj takes argument propertyKey (a property key ) and returns a normal completion containing either a Property Descriptor or undefined . It performs the following steps when called:
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 を返す。desc を、フィールドを持たない新しく作成された
Property Descriptor とする。ownProperty を、key が propertyKey である
obj の own property とする。ownProperty が data property なら、desc .[[Value]] を ownProperty の [[Value]]
属性の値に設定する。desc .[[Writable]] を ownProperty の
[[Writable]] 属性の値に設定する。Else,Assert : ownProperty は accessor property で
ある。desc .[[Get]] を ownProperty の [[Get]]
属性の値に設定する。desc .[[Set]] を ownProperty の [[Set]]
属性の値に設定する。 desc .[[Enumerable]] を ownProperty の
[[Enumerable]] 属性の値に設定する。desc .[[Configurable]] を ownProperty の
[[Configurable]] 属性の値に設定する。desc を返す。
10.1.6 [[DefineOwnProperty]] ( propertyKey , desc )
The [[DefineOwnProperty]] internal method of an ordinary object obj takes arguments propertyKey (a property key ) and desc (a Property Descriptor ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? OrdinaryDefineOwnProperty (obj , propertyKey ,
desc ) を返す。
10.1.6.1 OrdinaryDefineOwnProperty ( obj , propertyKey , desc )
The abstract operation OrdinaryDefineOwnProperty takes arguments obj (an Object), propertyKey (a property key ), and desc (a Property Descriptor ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
current を ? obj .[[GetOwnProperty]] (propertyKey ) とする。extensible を ? IsExtensible (obj ) とする。ValidateAndApplyPropertyDescriptor (obj ,
propertyKey , extensible , desc , current ) を
返す。
10.1.6.2 IsCompatiblePropertyDescriptor ( extensible , desc , current )
The abstract operation IsCompatiblePropertyDescriptor takes arguments extensible (a Boolean), desc (a Property Descriptor ), and current (a Property Descriptor or undefined ) and returns a Boolean. It performs the following steps when called:
ValidateAndApplyPropertyDescriptor (undefined ,
"" , extensible , desc , current ) を返す。
10.1.6.3 ValidateAndApplyPropertyDescriptor ( obj , propertyKey , extensible , desc , current )
The abstract operation ValidateAndApplyPropertyDescriptor takes arguments obj (an Object or undefined ), propertyKey (a property key ), extensible (a Boolean), desc (a Property Descriptor ), and current (a Property Descriptor or undefined ) and returns a Boolean. これは、desc が、指定された extensibility と現
在のプロパティ current を持つオブジェクトのプロパティと
して、不変条件 を保ちながら
適用できる場合に限り true を返す。そのような適用が可能
であり、かつ obj が undefined でない場合、それは
propertyKey という名前のプロパティ(必要であれば作成
される)に対して実行される。 It performs the following steps when called:
Assert : propertyKey は property key である。current が undefined なら、extensible が false なら、false を返す。obj が undefined なら、true を返す。IsAccessorDescriptor (desc ) が true なら、obj の propertyKey という名前の own
accessor property を作成し、その [[Get]] 、
[[Set]] 、[[Enumerable]] 、[[Configurable]]
属性を、desc がそのフィールドを持つ場合は
対応する値に、そうでなければその属性の
既定値 に設定する。Else,obj の propertyKey という名前の own data
property を作成し、その [[Value]] 、
[[Writable]] 、[[Enumerable]] 、
[[Configurable]] 属性を、desc がそのフィ
ールドを持つ場合は対応する値に、そうでなけれ
ばその属性の 既定値 に設定
する。 true を返す。Assert : current は fully populated な
Property Descriptor である。desc がいかなるフィールドも持たないなら、
true を返す。current .[[Configurable]] が false なら、desc が [[Configurable]] フィールドを持ち、
かつ desc .[[Configurable]] が true なら、
false を返す。desc が [[Enumerable]] フィールドを持ち、
かつ desc .[[Enumerable]] が
current .[[Enumerable]] と異なるなら、false
を返す。IsGenericDescriptor (desc ) が false であり、
かつ IsAccessorDescriptor (desc ) が
IsAccessorDescriptor (current ) と異なるなら、
false を返す。IsAccessorDescriptor (current ) が true なら、desc が [[Get]] フィールドを持ち、かつ
SameValue (desc .[[Get]] , current .[[Get]] )
が false なら、false を返す。desc が [[Set]] フィールドを持ち、かつ
SameValue (desc .[[Set]] , current .[[Set]] )
が false なら、false を返す。Else if current .[[Writable]] が false なら、desc が [[Writable]] フィールドを持ち、かつ
desc .[[Writable]] が true なら、false
を返す。NOTE : SameValue は NaN 値に対して true
を返すが、これは他の手段で区別できる場合があ
る。ここで返ることにより、obj の既存プロパ
ティが変更されないことが保証される。desc が [[Value]] フィールドを持つなら、
SameValue (desc .[[Value]] ,
current .[[Value]] ) を返す。 obj が undefined でないなら、IsDataDescriptor (current ) が true であり、
かつ IsAccessorDescriptor (desc ) が true
なら、desc が [[Configurable]] フィールドを持つ
なら、configurable を
desc .[[Configurable]] とする; そうでなけれ
ば configurable を
current .[[Configurable]] とする。desc が [[Enumerable]] フィールドを持つな
ら、enumerable を desc .[[Enumerable]] と
する; そうでなければ enumerable を
current .[[Enumerable]] とする。obj の propertyKey という名前のプロパ
ティを accessor property に置き換え、その
[[Configurable]] および [[Enumerable]] 属性
をそれぞれ configurable および
enumerable に設定し、[[Get]] および
[[Set]] 属性を、desc がそのフィールドを持
つ場合は対応する値に、そうでなければその属性
の 既定値 に設定する。Else if IsAccessorDescriptor (current ) が
true であり、かつ IsDataDescriptor (desc )
が true なら、desc が [[Configurable]] フィールドを持つ
なら、configurable を
desc .[[Configurable]] とする; そうでなけれ
ば configurable を
current .[[Configurable]] とする。desc が [[Enumerable]] フィールドを持つな
ら、enumerable を desc .[[Enumerable]] と
する; そうでなければ enumerable を
current .[[Enumerable]] とする。obj の propertyKey という名前のプロパ
ティを data property に置き換え、その
[[Configurable]] および [[Enumerable]] 属性
をそれぞれ configurable および
enumerable に設定し、[[Value]] および
[[Writable]] 属性を、desc がそのフィールド
を持つ場合は対応する値に、そうでなければその
属性の 既定値 に設定する。 Else,desc の各フィールド名 fieldName につい
て、obj の propertyKey という名前のプロ
パティの fieldName という属性を、
desc の fieldName フィールドの値に設定
する。 true を返す。
10.1.7 [[HasProperty]] ( propertyKey )
The [[HasProperty]] internal method of an ordinary object obj takes argument propertyKey (a property key ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? 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 an ordinary object obj takes arguments propertyKey (a property key ) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion . It performs the following steps when called:
? 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:
desc を ? obj .[[GetOwnProperty]] (propertyKey ) とする。desc が undefined なら、parent を ? obj .[[GetPrototypeOf]] () とする。parent が null なら、undefined を返す。? parent .[[Get]] (propertyKey , receiver ) を返す。 IsDataDescriptor (desc ) が true なら、
desc .[[Value]] を返す。Assert : IsAccessorDescriptor (desc ) is true .getter を desc .[[Get]] とする。getter が undefined なら、undefined を返す。? Call (getter , receiver ) を返す。
10.1.9 [[Set]] ( propertyKey , value , receiver )
The [[Set]] internal method of an ordinary object obj takes arguments propertyKey (a property key ), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? 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 を返
す。existingDescriptor を ? receiver .[[GetOwnProperty]] (propertyKey ) とする。existingDescriptor が undefined なら、Assert : receiver は現在 propertyKey という
プロパティを持たない。? CreateDataProperty (receiver , propertyKey ,
value ) を返す。 IsAccessorDescriptor (existingDescriptor ) が
true なら、false を返す。existingDescriptor .[[Writable]] が false な
ら、false を返す。valueDesc を PropertyDescriptor { [[Value]] :
value } とする。? receiver .[[DefineOwnProperty]] (propertyKey , valueDesc ) を返す。 Assert : IsAccessorDescriptor (ownDesc ) is true .setter を ownDesc .[[Set]] とする。setter が undefined なら、false を返す。? Call (setter , receiver , « value ») を実行す
る。 true を返す。
10.1.10 [[Delete]] ( propertyKey )
The [[Delete]] internal method of an ordinary object obj takes argument propertyKey (a property key ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? 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:
desc を ? obj .[[GetOwnProperty]] (propertyKey ) とする。desc が undefined なら、true を返す。desc .[[Configurable]] が true なら、obj から名前が propertyKey である own
property を除去する。true を返す。false を返す。
10.1.11 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of an ordinary object obj takes no arguments and returns a normal completion containing a List of property keys . It performs the following steps when called:
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 とする。obj の各 own property key propertyKey につい
て、propertyKey が array index であるものを、
数値 index 昇順で処理し、propertyKey を keys に append する。obj の各 own property key propertyKey につい
て、propertyKey が String であり、かつ
array index ではないものを、プロパティ作成時刻の
昇順で処理し、propertyKey を keys に append する。obj の各 own property key propertyKey につい
て、propertyKey が Symbol であるものを、プロ
パティ作成時刻の昇順で処理し、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. これは、新しい通常オブジェクトの実行時作成を規定する
ために用いられる。additionalInternalSlotsList は、
[[Prototype]] と [[Extensible]] に加えて、そのオブジェ
クトの一部として定義されなければならない追加内部スロット
の名前を含む。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 を呼び出す以
上のことはほとんど行わないが、その使用は特殊オブジェクト
ではなく通常オブジェクトを作成する意図を伝える。したがっ
て、この仕様では、その後にオブジェクトの内部メソッドを変
更して結果を非通常なものにするようなアルゴリズムからは呼
び出されない。特殊オブジェクトを作成する操作は
MakeBasicObject を直接呼び出す。
10.1.13 OrdinaryCreateFromConstructor ( constructor , intrinsicDefaultProto [ , internalSlotsList ] )
The abstract operation OrdinaryCreateFromConstructor takes arguments constructor (a function object ) and intrinsicDefaultProto (a String) and optional argument internalSlotsList (a List of names of internal slots) and returns either a normal completion containing an Object or a throw completion . これは、[[Prototype]] 値が constructor の
"prototype" プロパティから取得される通常オブジェクトを
作成する。存在しない場合は、intrinsicDefaultProto に
よって指定された intrinsic が [[Prototype]] に用いられ
る。internalSlotsList は、そのオブジェクトの一部とし
て定義されなければならない追加内部スロットの名前を含む。
internalSlotsList が与えられない場合、新しい空の
List が用いられる。 It performs the following steps when called:
Assert : intrinsicDefaultProto は、この仕様にお
ける intrinsic object の名前である。対応する
object は、オブジェクトの [[Prototype]] 値として
使用されることが意図された intrinsic でなければ
ならない。proto を ? GetPrototypeFromConstructor (
constructor , intrinsicDefaultProto ) とする。internalSlotsList が存在する場合、slotsList
を internalSlotsList とする。Else, slotsList を新しい空の List とする。 OrdinaryObjectCreate (proto , slotsList ) を返
す。
10.1.14 GetPrototypeFromConstructor ( constructor , intrinsicDefaultProto )
The abstract operation GetPrototypeFromConstructor takes arguments constructor (a function object ) and intrinsicDefaultProto (a String) and returns either a normal completion containing an Object or a throw completion . これは、特定の constructor に対応するオブジェクト
を作成する際に使用すべき [[Prototype]] 値を決定する。そ
の値は、存在する場合、constructor の "prototype"
プロパティから取得される。そうでなければ、
intrinsicDefaultProto によって指定された intrinsic
が [[Prototype]] に用いられる。 It performs the following steps when called:
Assert : intrinsicDefaultProto は、この仕様にお
ける intrinsic object の名前である。対応する
object は、オブジェクトの [[Prototype]] 値として
使用されることが意図された intrinsic でなければ
ならない。proto を ? Get (constructor , "prototype" ) と
する。proto が Object でないなら、realm を ? GetFunctionRealm (constructor )
とする。proto を realm の
intrinsicDefaultProto という名前の intrinsic
object に設定する。proto を返す。
Note
constructor が [[Prototype]] 値を提供しない場
合、用いられる既定値は、running execution context か
らではなく constructor 関数の realm から取得され
る。
10.1.15 RequireInternalSlot ( obj , internalSlot )
The abstract operation RequireInternalSlot takes arguments obj (an ECMAScript language value) and internalSlot (an internal slot name) and returns either a normal completion containing unused or a throw completion . これは、obj が Object であり、かつ与えられた
internal slot を持つのでない限り例外を送出する。 It performs the following steps when called:
obj が Object でなければ、TypeError 例外を送
出する。obj が internalSlot internal slot を持たなけ
れば、TypeError 例外を送出する。unused を返す。
10.2 ECMAScript 関数オブジェクト
ECMAScript 関数オブジェクトは、レキシカル環境を閉包
した、パラメータ化された ECMAScript コードをカプセル化
し、そのコードの動的評価をサポートする。ECMAScript 関数
オブジェクトは通常オブジェクトであり、他の通常オブジェク
トと同じ内部スロットおよび同じ内部メソッドを持つ。
ECMAScript 関数オブジェクトのコードは、strict mode
code (11.2.2 )
であっても non-strict code であってもよい。コードが
strict mode code である ECMAScript 関数オブジェクト
は、strict function
と呼ばれる。コードが strict mode code でないものは、
non-strict function
と呼ばれる。
[[Extensible]] と [[Prototype]] に加えて、
ECMAScript 関数オブジェクトは
Table 25
に列挙された内部スロットも持つ。
Table 25: Internal Slots of ECMAScript Function Objects
内部スロット
型
説明
[[Environment]]
an Environment Record
関数が閉包した Environment Record 。関数のコード
を評価する際に outer environment として用いら
れる。
[[PrivateEnvironment]]
a PrivateEnvironment Record or null
関数が閉包した Private Name のための
PrivateEnvironment Record 。この関数が構文上
class の内部に含まれていない場合は null 。
関数のコードを評価する際、内側の class に対する
outer PrivateEnvironment として用いられる。
[[FormalParameters]]
a Parse Node
関数の仮引数リストを定義する source text の
root parse node。
[[ECMAScriptCode]]
a Parse Node
関数本体を定義する source text の root parse
node。
[[ConstructorKind]]
base or derived
関数が derived class constructor であるかど
うか。
[[Realm]]
a Realm Record
関数が作成された realm であり、関数評価時にア
クセスされる任意の intrinsic object を提供す
る。
[[ScriptOrModule]]
a Script Record or a Module Record
関数が作成された script または module。
[[ThisMode]]
lexical , strict , or global
関数の仮引数およびコード本体内で this 参照
がどのように解釈されるかを定義する。lexical
は、this がレキシカルに外側の関数の this
値を参照することを意味する。strict は、
this 値が関数呼出しによって与えられたとおり
に正確に使われることを意味する。global は、
undefined または null の this 値が
global object への参照として解釈され、それ以
外の this 値はまず ToObject に渡されること
を意味する。
[[Strict]]
a Boolean
これが strict function であれば true 、
non-strict function であれば false 。
[[HomeObject]]
an Object or undefined
関数が super を使用する場合、これは
super プロパティ探索が開始されるオブジェク
トを [[GetPrototypeOf]] が提供する、そのオブ
ジェクトである。
[[SourceText]]
a sequence of Unicode code points
関数を定義する source text 。
[[Fields]]
a List of ClassFieldDefinition Records
関数が class である場合、これは class の非
static field と、それに対応する initializer
を表す Record の list である。
[[PrivateMethods]]
a List of PrivateElements
関数が class である場合、これは class の非
static private method および accessor を表
す list である。
[[ClassFieldInitializerName]]
a String, a Symbol, a Private Name , or empty
関数が class field の initializer として作
成された場合、その field の NamedEvaluation
に使用する名前; それ以外では empty 。
[[IsClassConstructor]]
a Boolean
関数が class constructor であるかどうかを示
す。(true の場合、その関数の [[Call]] を呼
び出すと直ちに TypeError 例外が送出され
る。)
すべての ECMAScript 関数オブジェクトは、ここで定義
される [[Call]] 内部メソッドを持つ。さらに constructor
でもある ECMAScript 関数は、[[Construct]] 内部メソッ
ドも持つ。
10.2.1 [[Call]] ( thisArgument , argumentsList )
The [[Call]] internal method of an ECMAScript function object func takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values ) and returns either a normal completion containing an ECMAScript language value or a throw completion . It performs the following steps when called:
callerContext を running execution context
とする。calleeContext を
PrepareForOrdinaryCall (func , undefined )
とする。Assert : calleeContext はいま running
execution context である。func .[[IsClassConstructor]] が true なら、error を新しく作成された TypeError
object とする。NOTE : error は calleeContext において
func に関連付けられた Realm Record を用い
て作成される。calleeContext を execution context
stack から取り除き、callerContext を
running execution context として復元する。error を送出する。OrdinaryCallBindThis (func , calleeContext ,
thisArgument ) を実行する。result を Completion (
OrdinaryCallEvaluateBody (func , argumentsList ))
とする。calleeContext
を execution context stack から取り除き、
callerContext を running execution
context として復元する。result が return completion なら、
result .[[Value]] を返す。Assert : result は throw completion であ
る。? result を返す。
Note
手順 7 において calleeContext が
execution context stack から取り除かれるとき、それ
が suspend され、後でアクセス可能な Generator による
再開のために保持されている場合には、破棄してはならな
い。
10.2.1.1 PrepareForOrdinaryCall ( func , newTarget )
The abstract operation PrepareForOrdinaryCall takes arguments func (an ECMAScript function object ) and newTarget (an Object or undefined ) and returns an execution context . It performs the following steps when called:
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 がまだ suspend されていなけ
れば、callerContext を suspend する。calleeContext を execution context
stack に push する; calleeContext はいま
running execution context である。NOTE : これ以降に生成されるいかなる exception
object も calleeRealm に関連付けられる。calleeContext を返す。
10.2.1.2 OrdinaryCallBindThis ( func , calleeContext , thisArgument )
The abstract operation OrdinaryCallBindThis takes arguments func (an ECMAScript function object ), calleeContext (an execution context ), and thisArgument (an ECMAScript language value) and returns unused . It performs the following steps when called:
thisMode を func .[[ThisMode]] とする。thisMode が lexical なら、unused を返す。calleeRealm を func .[[Realm]] とする。localEnv を calleeContext の
LexicalEnvironment とする。thisMode が strict なら、thisValue を thisArgument とする。Else,thisArgument が undefined または null
のいずれかなら、globalEnv を calleeRealm .[[GlobalEnv]]
とする。Assert : globalEnv は Global
Environment Record である。thisValue を
globalEnv .[[GlobalThisValue]] とする。Else,thisValue を ! ToObject (thisArgument )
とする。NOTE : ToObject は calleeRealm を用いて
wrapper object を生成する。 Assert : localEnv は Function Environment
Record である。Assert : 次の手順が 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 argumentsList (a List of ECMAScript language values ) and returns a return completion or a throw completion . It is defined piecewise over the following productions:
FunctionBody : FunctionStatementList
func および argumentsList を引数として
FunctionBody の EvaluateFunctionBody を
? 返す。
ConciseBody : ExpressionBody
func および argumentsList を引数として
ConciseBody の EvaluateConciseBody を
? 返す。
GeneratorBody : FunctionBody
func および argumentsList を引数として
GeneratorBody の EvaluateGeneratorBody を
? 返す。
AsyncGeneratorBody : FunctionBody
func および argumentsList を引数として
AsyncGeneratorBody の
EvaluateAsyncGeneratorBody を ? 返す。
AsyncFunctionBody : FunctionBody
func および argumentsList を引数として
AsyncFunctionBody の
EvaluateAsyncFunctionBody を ? 返す。
AsyncConciseBody : ExpressionBody
func および argumentsList を引数として
AsyncConciseBody の
EvaluateAsyncConciseBody を ? 返す。
Initializer :
=
AssignmentExpression
Assert : argumentsList は空である。Assert : func .[[ClassFieldInitializerName]] は
empty ではない。IsAnonymousFunctionDefinition (
AssignmentExpression ) が true なら、value を、func .[[ClassFieldInitializerName]]
を引数とする Initializer の
NamedEvaluation の ? とする。Else,rhs を AssignmentExpression の ?
Evaluation とする。value を ? GetValue (rhs ) とする。 ReturnCompletion (value ) を返す。
Note
field initializer は関数境界を構成するが、
FunctionDeclarationInstantiation を呼び出しても観測
可能な効果はないため、省略される。
ClassStaticBlockBody : ClassStaticBlockStatementList
Assert : argumentsList は空である。func を引数として ClassStaticBlockBody の
EvaluateClassStaticBlockBody を ? 返す。
10.2.1.4 OrdinaryCallEvaluateBody ( func , argumentsList )
The abstract operation OrdinaryCallEvaluateBody takes arguments func (an ECMAScript function object ) and argumentsList (a List of ECMAScript language values ) and returns a return completion or a throw completion . It performs the following steps when called:
func および argumentsList を引数として
func .[[ECMAScriptCode]] の EvaluateBody を
? 返す。
10.2.2 [[Construct]] ( argumentsList , newTarget )
The [[Construct]] internal method of an ECMAScript function object func takes arguments argumentsList (a List of ECMAScript language values ) and newTarget (a constructor ) and returns either a normal completion containing an Object or a throw completion . It performs the following steps when called:
callerContext を running execution context
とする。kind を func .[[ConstructorKind]] とする。kind が base なら、thisArgument を
? OrdinaryCreateFromConstructor (newTarget ,
"%Object.prototype%" ) とする。calleeContext を
PrepareForOrdinaryCall (func , newTarget ) とす
る。Assert : calleeContext はいま running
execution context である。kind が base なら、OrdinaryCallBindThis (func , calleeContext ,
thisArgument ) を実行する。initializeResult を Completion (
InitializeInstanceElements (thisArgument , func ))
とする。initializeResult が abrupt completion なら、calleeContext を execution context
stack から取り除き、callerContext を
running execution context として復元する。? initializeResult を返す。 constructorEnv を calleeContext の
LexicalEnvironment とする。result を Completion (
OrdinaryCallEvaluateBody (func , argumentsList ))
とする。calleeContext を execution context stack
から取り除き、callerContext を running
execution context として復元する。result が throw completion なら、? result を返す。 Assert : result は return completion であ
る。result .[[Value]] が Object なら、
result .[[Value]] を返す。kind が base なら、thisArgument を返す。result .[[Value]] が undefined でないなら、
TypeError 例外を送出する。thisBinding を ? constructorEnv .GetThisBinding ()
とする。Assert : thisBinding は Object である。thisBinding を返す。
10.2.3 OrdinaryFunctionCreate ( functionPrototype , sourceText , parameterList , body , thisMode , env , privateEnv )
The abstract operation OrdinaryFunctionCreate takes arguments functionPrototype (an Object), sourceText (a sequence of Unicode code points), parameterList (a Parse Node ), body (a Parse Node ), thisMode (lexical-this or non-lexical-this ), env (an Environment Record ), and privateEnv (a PrivateEnvironment Record or null ) and returns an ECMAScript function object . これは、既定の [[Call]] 内部メソッドを持ち、
[[Construct]] 内部メソッドを持たない(ただし
MakeConstructor のような操作によって後から追加される
場合はある)新しい関数の実行時作成を規定するために用いら
れる。sourceText は、作成される関数の構文定義の
source text である。 It performs the following steps when called:
internalSlotsList を
Table 25
に列挙された内部スロットとする。func を OrdinaryObjectCreate (
functionPrototype , internalSlotsList ) とす
る。func .[[Call]] を
10.2.1
で規定された定義に設定する。func .[[SourceText]] を sourceText に設定す
る。func .[[FormalParameters]] を parameterList
に設定する。func .[[ECMAScriptCode]] を body に設定する。strict を IsStrict (body ) とする。func .[[Strict]] を strict に設定する。thisMode が lexical-this なら、
func .[[ThisMode]] を lexical に設定する。Else if strict が true なら、
func .[[ThisMode]] を strict に設定する。 Else, func .[[ThisMode]] を global に設定す
る。 func .[[IsClassConstructor]] を false に設
定する。func .[[Environment]] を env に設定する。func .[[PrivateEnvironment]] を privateEnv
に設定する。func .[[ScriptOrModule]] を
GetActiveScriptOrModule () に設定する。func .[[Realm]] を current Realm Record に
設定する。func .[[HomeObject]] を undefined に設定す
る。func .[[Fields]] を新しい空の List に設定す
る。func .[[PrivateMethods]] を新しい空の List に
設定する。func .[[ClassFieldInitializerName]] を
empty に設定する。len を parameterList の
ExpectedArgumentCount とする。SetFunctionLength (func , len ) を実行する。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% ( )
この関数は %ThrowTypeError% intrinsic
object である。
これは、各 realm ごとに 1 度定義される匿名の
built-in function object である。
呼び出されると、次の手順を実行する:
TypeError 例外を送出する。
この関数の [[Extensible]] 内部スロットの値は
false である。
この関数の "length" プロパティは { [[Writable]] :
false , [[Enumerable]] : false , [[Configurable]] :
false } という属性を持つ。
この関数の "name" プロパティは { [[Writable]] :
false , [[Enumerable]] : false , [[Configurable]] :
false } という属性を持つ。
10.2.5 MakeConstructor ( func [ , writablePrototype [ , prototype ] ] )
The abstract operation MakeConstructor takes argument func (an ECMAScript function object or a built-in function object ) and optional arguments writablePrototype (a Boolean) and prototype (an Object) and returns unused . これは func を constructor に変換する。 It performs the following steps when called:
func が ECMAScript function object なら、Assert : IsConstructor (func ) is false .Assert : func は "prototype" own property
を持たない拡張可能オブジェクトである。func .[[Construct]] を
10.2.2
で規定された定義に設定する。Else,func .[[Construct]] を
10.3.2
で規定された定義に設定する。 func .[[ConstructorKind]] を base に設定する。writablePrototype が存在しないなら、
writablePrototype を true に設定する。prototype が存在しないなら、prototype を OrdinaryObjectCreate (
%Object.prototype% ) に設定する。! DefinePropertyOrThrow (prototype ,
"constructor" , PropertyDescriptor { [[Value]] :
func , [[Writable]] : writablePrototype ,
[[Enumerable]] : false , [[Configurable]] :
true }) を実行する。 ! DefinePropertyOrThrow (func , "prototype" ,
PropertyDescriptor { [[Value]] : prototype ,
[[Writable]] : writablePrototype ,
[[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]] is false .func .[[IsClassConstructor]] を true に設定す
る。unused を返す。
10.2.7 MakeMethod ( func , homeObject )
The abstract operation MakeMethod takes arguments func (an ECMAScript function object ) and homeObject (an Object) and returns unused . これは func を method として構成する。 It performs the following steps when called:
Assert : homeObject は通常オブジェクトである。func .[[HomeObject]] を homeObject に設定す
る。unused を返す。
10.2.8 DefineMethodProperty ( homeObject , key , closure , enumerable )
The abstract operation DefineMethodProperty takes arguments homeObject (an Object), key (a property key or Private Name ), closure (a function object ), and enumerable (a Boolean) and returns either a normal completion containing either a PrivateElement or unused , or an abrupt completion . It performs the following steps when called:
Assert : homeObject は通常かつ拡張可能なオブジェ
クトである。key が Private Name なら、
PrivateElement { [[Key]] : key , [[Kind]] :
method , [[Value]] : closure } を返す。desc を PropertyDescriptor { [[Value]] :
closure , [[Writable]] : true , [[Enumerable]] :
enumerable , [[Configurable]] : true } とす
る。? DefinePropertyOrThrow (homeObject , key ,
desc ) を実行する。 NOTE : DefinePropertyOrThrow が abrupt
completion を返すのは、key が "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" プロパティを追加する。 It performs the following steps when called:
Assert : func は "name" own property を持た
ない拡張可能オブジェクトである。name が Symbol なら、description を name .[[Description]] とす
る。description が undefined なら、name を
空の String に設定する。Else, name を "[" と description と
"]" の string-concatenation に設定す
る。 Else if name が Private Name なら、name を name .[[Description]] に設定す
る。 func が [[InitialName]] internal slot を持つ
なら、func .[[InitialName]] を name に設定する。prefix が存在するなら、name を prefix と code unit 0x0020
(SPACE) と name の string-concatenation
に設定する。func が [[InitialName]] internal slot を持
つなら、NOTE : 次の手順における選択は、この抽象操作が
呼び出されるたびに独立して行われる。任意で、func .[[InitialName]] を name に
設定する。 ! 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" プロパティを追加する。 It performs the following steps when called:
Assert : func は "length" own property を持
たない拡張可能オブジェクトである。! DefinePropertyOrThrow (func , "length" ,
PropertyDescriptor { [[Value]] : 𝔽 (length ),
[[Writable]] : false , [[Enumerable]] : false ,
[[Configurable]] : true }) を実行する。 unused を返す。
10.2.11 FunctionDeclarationInstantiation ( func , argumentsList )
The abstract operation FunctionDeclarationInstantiation takes arguments func (an ECMAScript function object ) and argumentsList (a List of ECMAScript language values ) and returns either a normal completion containing unused or a throw completion . func は execution context が確立される対象の
関数オブジェクトである。
Note
ECMAScript 関数を評価するための execution
context が確立されると、新しい Function Environment
Record が作成され、各仮引数に対する束縛がその
Environment Record においてインスタンス化される。関
数本体内の各宣言もインスタンス化される。関数の仮引数に
default value initializer が含まれない場合、本体の宣
言は仮引数と同じ Environment Record 内でインスタンス
化される。default value parameter initializer が
存在する場合、本体の宣言のために 2 つ目の
Environment Record が作成される。仮引数および関数は
FunctionDeclarationInstantiation の一部として初期
化される。他のすべての束縛は、関数本体の評価中に初期化
される。
呼び出されると、次の手順を実行する:
calleeContext を running execution context
とする。code を func .[[ECMAScriptCode]] とする。strict を func .[[Strict]] とする。formals を func .[[FormalParameters]] とす
る。parameterNames を formals の BoundNames
とする。parameterNames が重複する要素を持つなら、
hasDuplicates を true とする; そうでなけ
れば hasDuplicates を false とする。simpleParameterList を formals の
IsSimpleParameterList とする。hasParameterExpressions を formals の
ContainsExpression とする。varNames を code の VarDeclaredNames と
する。varDeclarations を code の
VarScopedDeclarations とする。lexicalNames を code の
LexicallyDeclaredNames とする。functionNames を新しい空の List とする。functionsToInitialize を新しい空の List とす
る。varDeclarations の各要素 varDecl につい
て、List の逆順で、次を行うvarDecl が VariableDeclaration でも
ForBinding でも BindingIdentifier でも
ないなら、Assert : varDecl は FunctionDeclaration 、
GeneratorDeclaration 、
AsyncFunctionDeclaration 、
AsyncGeneratorDeclaration のいずれか
である。fn を varDecl の BoundNames の唯一の
要素とする。functionNames が fn を含まないなら、fn を functionNames の先頭要素として
挿入する。NOTE : 同じ名前に対して複数の function
declaration がある場合、最後の宣言が用い
られる。varDecl を functionsToInitialize
の先頭要素として挿入する。argumentsObjectNeeded を true とする。func .[[ThisMode]] が lexical なら、NOTE : Arrow function は決して arguments
object を持たない。argumentsObjectNeeded を false に設定
する。Else if parameterNames が "arguments" を
含むなら、argumentsObjectNeeded を false に設定
する。 Else if hasParameterExpressions が false
なら、functionNames が "arguments" を含むか、
または lexicalNames が "arguments" を
含むなら、argumentsObjectNeeded を false に設
定する。 strict が true または
hasParameterExpressions が false なら、NOTE : strict mode code 内の eval 呼出し
は eval の外から見える新しい束縛を作成で
きないため、仮引数に対して必要な
Environment Record は 1 つだけである。env を calleeContext の
LexicalEnvironment とする。Else,NOTE : 仮引数リストにおける direct eval 呼
出しによって作成された束縛が、仮引数が宣言さ
れる環境の外側になることを保証するために、別
の Environment Record が必要である。calleeEnv を calleeContext の
LexicalEnvironment とする。env を NewDeclarativeEnvironment (
calleeEnv ) とする。Assert : calleeContext の
VariableEnvironment と calleeEnv は同
じ Environment Record である。calleeContext の LexicalEnvironment を
env に設定する。 parameterNames の各 String paramName に
ついて、次を行うalreadyDeclared を
! env .HasBinding (paramName ) とする。NOTE : early error により、重複仮引数名が
起こり得るのは、parameter default value
や rest parameter を持たない non-strict
function に限られる。alreadyDeclared が false なら、! env .CreateMutableBinding (paramName ,
false ) を実行する。 hasDuplicates が true なら、! env .InitializeBinding (paramName ,
undefined ) を実行する。 argumentsObjectNeeded が true なら、strict が true または
simpleParameterList が false なら、ao を
CreateUnmappedArgumentsObject (
argumentsList ) とする。Else,NOTE : mapped argument object は、rest
parameter、parameter default value
initializer、または destructured
parameter を持たない non-strict
function に対してのみ提供される。ao を CreateMappedArgumentsObject (
func , formals , argumentsList , env )
とする。 strict が true なら、! env .CreateImmutableBinding (
"arguments" , false ) を実行する。 NOTE : strict mode code では early
error によりこの束縛への代入の試みは防が
れるため、その可変性は観測不能である。Else,! env .CreateMutableBinding (
"arguments" , false ) を実行する。 ! env .InitializeBinding ("arguments" ,
ao ) を実行する。 parameterBindings を parameterNames と
« "arguments" » の
list-concatenation とする。Else,parameterBindings を parameterNames
とする。 iteratorRecord を
CreateListIteratorRecord (argumentsList ) とす
る。hasDuplicates が true なら、usedEnv を undefined とする。Else,usedEnv を env とする。 NOTE : 次の手順が ReturnCompletion を返すこと
はない。なぜなら、式位置でそのような completion
が生じる唯一の方法は YieldExpression の使用
によるが、これは
15.5.1
および
15.6.1
の early error 規則により parameter list
では禁止されているからである。iteratorRecord および usedEnv を引数とす
る formals の
IteratorBindingInitialization を ? 実行する。hasParameterExpressions が false なら、NOTE : 仮引数および top-level var に必要な
Environment Record は 1 つだけである。instantiatedVarNames を List
parameterBindings の copy とする。varNames の各要素 n について、次を行うinstantiatedVarNames が n を含まなけ
れば、n を instantiatedVarNames に
append する。! env .CreateMutableBinding (n ,
false ) を実行する。 ! env .InitializeBinding (n ,
undefined ) を実行する。 varEnv を env とする。Else,NOTE : 仮引数リスト内の式によって作成された
closure が、関数本体内の宣言を可視にしない
ことを保証するために、別の Environment
Record が必要である。varEnv を NewDeclarativeEnvironment (
env ) とする。calleeContext の VariableEnvironment
を varEnv に設定する。instantiatedVarNames を新しい空の List
とする。varNames の各要素 n について、次を行うinstantiatedVarNames が n を含まなけ
れば、n を instantiatedVarNames に
append する。! varEnv .CreateMutableBinding (n ,
false ) を実行する。 parameterBindings が n を含まない
か、または functionNames が n を
含むなら、initialValue を undefined とする。Else,initialValue を
! env .GetBindingValue (n , false )
とする。 ! varEnv .InitializeBinding (n ,
initialValue ) を実行する。 NOTE : 仮引数と同名の var は、初期状態で
対応する初期化済み仮引数と同じ値を持つ。 strict が true なら、lexEnv を varEnv とする。Else,ホスト
が web browser であるか、または
ブロックレベル Function Declaration の Web レガシー互換性意味論
をサポートするなら、code Contains x が true である
任意の Block 、CaseClause 、
DefaultClause x の StatementList
に直接含まれる各 FunctionDeclaration
fnDecl について、次を行うfuncName を fnDecl の
BindingIdentifier の StringValue と
する。FunctionDeclaration fnDecl を
funcName を BindingIdentifier と
する VariableStatement に置き換えて
も func に対していかなる early
error も生じず、かつ parameterNames
が funcName を含まないなら、NOTE : funcName に対する var 束縛
は、それが VarDeclaredName でも、仮
引数名でも、別の
FunctionDeclaration でもない場合に
限ってここでインスタンス化される。instantiatedVarNames が
funcName を含まず、かつ funcName
が "arguments" でないなら、! varEnv .CreateMutableBinding (
funcName , false ) を実行する。 ! varEnv .InitializeBinding (
funcName , undefined ) を実行す
る。 funcName を
instantiatedVarNames に append
する。FunctionDeclaration
fnDecl が評価されるとき、
15.2.6
で与えられる FunctionDeclaration
Evaluation algorithm の代わりに、次
の手順を実行する:fEnv を running execution
context の VariableEnvironment
とする。bEnv を running execution
context の LexicalEnvironment
とする。fObj を
! bEnv .GetBindingValue (funcName ,
false ) とする。! fEnv .SetMutableBinding (
funcName , fObj , false ) を
実行する。 unused を返す。 lexEnv を NewDeclarativeEnvironment (
varEnv ) とする。NOTE : non-strict function は、
direct eval が eval code によって導入さ
れる var scoped declaration が、既存の
top-level lexically scoped declaration
と conflict するかどうかを判定できるよう
に、top-level lexical declaration のた
めに別の Environment Record を用いる。
strict function ではこれは不要である。な
ぜなら strict な direct eval は常に、すべ
ての declaration を新しい Environment
Record に配置するからである。 calleeContext の LexicalEnvironment を
lexEnv に設定する。lexDeclarations を code の
LexicallyScopedDeclarations とする。lexDeclarations の各要素 lexDecl につい
て、次を行うNOTE : lexical に宣言された名前は、
function/generator declaration、仮引数、
または var 名と同じにはなり得ない。lexical
に宣言された名前は、ここではインスタンス化の
みが行われ、初期化は行われない。lexDecl の BoundNames の各要素 dn につ
いて、次を行うlexDecl の IsConstantDeclaration が
true なら、! lexEnv .CreateImmutableBinding (
dn , true ) を実行する。 Else,! lexEnv .CreateMutableBinding (dn ,
false ) を実行する。 privateEnv を calleeContext の
PrivateEnvironment とする。functionsToInitialize の各 Parse Node
fnDecl について、次を行うfn を fnDecl の BoundNames の唯一の要
素とする。fo を lexEnv および privateEnv を引数
とする fnDecl の InstantiateFunctionObject
とする。! varEnv .SetMutableBinding (fn , fo ,
false ) を実行する。 unused を返す。
10.3 組込み関数オブジェクト
組込み関数オブジェクトは通常オブジェクトである; それは
10.1
に定められた通常オブジェクトに対する要件を満たさなければ
ならない。
すべての通常オブジェクトに要求される内部スロット
(10.1
を参照)に加えて、組込み関数オブジェクトは次の内部スロッ
トも持たなければならない:
別段の指定がない限り、組込み関数オブジェクトの
[[Prototype]] 内部スロットの初期値は
%Function.prototype% である。
組込み関数オブジェクトは、
10.3.1
の定義に適合する [[Call]] 内部メソッドを持たなければなら
ない。
組込み関数オブジェクトは、それが “constructor ” と
記述されている場合、またはこの仕様内の何らかのアルゴリズ
ムがその [[Construct]] 内部メソッドを明示的に設定する場
合に限り、[[Construct]] 内部メソッドを持つ。そのような
[[Construct]] 内部メソッドは、
10.3.2
の定義に適合しなければならない。
実装は、この仕様で定義されていない追加の組込み関数オブ
ジェクトを提供してよい。
10.3.1 [[Call]] ( thisArgument , argumentsList )
The [[Call]] internal method of a built-in function object func takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values ) and returns either a normal completion containing an ECMAScript language value or a throw completion . It performs the following steps when called:
? BuiltinCallOrConstruct (func , thisArgument ,
argumentsList , undefined ) を返す。
10.3.2 [[Construct]] ( argumentsList , newTarget )
The [[Construct]] internal method of a built-in function object func (when the method is present) takes arguments argumentsList (a List of ECMAScript language values ) and newTarget (a constructor ) and returns either a normal completion containing an Object or a throw completion . It performs the following steps when called:
result を ? BuiltinCallOrConstruct (func ,
uninitialized , argumentsList , newTarget ) と
する。Assert : result は Object である。result を返す。
10.3.3 BuiltinCallOrConstruct ( func , thisArgument , argumentsList , newTarget )
The abstract operation BuiltinCallOrConstruct takes arguments func (a built-in function object ), thisArgument (an ECMAScript language value or uninitialized ), argumentsList (a List of ECMAScript language values ), and newTarget (a constructor or undefined ) and returns either a normal completion containing an ECMAScript language value or a throw completion . It performs the following steps when called:
callerContext を running execution context
とする。callerContext がまだ suspend されていなけれ
ば、callerContext を suspend する。calleeContext を新しい execution context
とする。calleeContext の Function を func に設定す
る。calleeRealm を func .[[Realm]] とする。calleeContext の Realm を calleeRealm に
設定する。calleeContext の ScriptOrModule を null
に設定する。calleeContext に対して必要な
implementation-defined な初期化を実行する。calleeContext を execution context stack
に push する; calleeContext はいま
running execution context である。func .[[Async]] が true なら、promiseCapability を
! NewPromiseCapability (%Promise% ) とする。resultsClosure を、引数を持たず、func 、
thisArgument 、argumentsList 、および
newTarget を capture し、呼び出されたとき
次の手順を実行する新しい Abstract Closure と
する:result を、func の仕様に適合する方法で
func を評価した結果 である
Completion Record とする。
thisArgument が uninitialized なら、
this 値は uninitialized である; そうでな
ければ thisArgument が this 値を与え
る。argumentsList が名前付き引数を与え
る。newTarget が NewTarget 値を与える。NOTE : func がこの文書で定義されている場合、
“func の仕様” とは、algorithm step ま
たはその他の手段により指定されたその振る舞い
である。Completion (result ) を返す。AsyncFunctionStart (promiseCapability ,
resultsClosure ) を実行する。calleeContext を execution context
stack から取り除き、callerContext を
running execution context として復元する。promiseCapability .[[Promise]] を返す。result
を、func の仕様に適合する方法で func を
評価した結果 である Completion Record
とする。thisArgument が uninitialized
なら、this 値は uninitialized である; そう
でなければ thisArgument が this 値を与え
る。argumentsList が名前付き引数を与える。
newTarget が NewTarget 値を与える。NOTE : func がこの文書で定義されている場合、
“func の仕様” とは、algorithm step または
その他の手段により指定されたその振る舞いである。calleeContext を execution context stack
から取り除き、callerContext を running
execution context として復元する。? result を返す。
Note
calleeContext が execution context stack
から取り除かれるとき、それが suspend され、後で再開する
ためにアクセス可能な Generator によって保持されている場
合には、破棄してはならない。
10.3.4 CreateBuiltinFunction ( behaviour , length , name , additionalInternalSlotsList [ , realm [ , prototype [ , prefix [ , async ] ] ] ] )
The abstract operation CreateBuiltinFunction takes arguments behaviour (an Abstract Closure , a set of algorithm steps, or some other definition of a function's behaviour provided in this specification), length (a non-negative integer or +∞), name (a property key or a Private Name ), and additionalInternalSlotsList (a List of names of internal slots) and optional arguments realm (a Realm Record ), prototype (an Object or null ), prefix (a String), and async (a Boolean) and returns a built-in function object . additionalInternalSlotsList は、そのオブジェク
トの一部として定義されなければならない追加内部スロットの
名前を含む。この操作は組込み関数オブジェクトを作成する。 It performs the following steps when called:
realm が与えられていなければ、realm を
current Realm Record に設定する。prototype が与えられていなければ、
prototype を
realm .[[Intrinsics]] .[[%Function.prototype% ]]
に設定する。async が与えられていなければ、async を
false に設定する。internalSlotsList を、これから作成される組
込み関数オブジェクトに
10.3
が要求するすべての内部スロットの名前を含む
List とする。additionalInternalSlotsList の要素を
internalSlotsList に append する。func を新しい組込み関数オブジェクトとする。こ
の関数オブジェクトは、呼び出されると、
behaviour に記述された action を、与えられ
た引数を behaviour により指定される対応する
parameter の値として用いて実行する。新しい関
数オブジェクトは、その名前が
internalSlotsList の要素である内部スロット
と、[[InitialName]] internal slot を持つ。func .[[Async]] を async に設定する。func .[[Prototype]] を prototype に設定す
る。func .[[Extensible]] を true に設定する。func .[[Realm]] を realm に設定する。func .[[InitialName]] を null に設定する。SetFunctionLength (func , length ) を実行す
る。prefix が与えられていなければ、SetFunctionName (func , name ) を実行す
る。Else,SetFunctionName (func , name , prefix )
を実行する。 func を返す。
この仕様で定義される各組込み関数は、
CreateBuiltinFunction 抽象操作を呼び出すことによって
作成される。
10.4 組込み特殊オブジェクトの内部メソッドとスロット
この仕様は、数種類の組込み特殊オブジェクトを定義する。
これらのオブジェクトは、いくつかの特定状況を除いて、一般
に通常オブジェクトと類似した振る舞いをする。以下の特殊オ
ブジェクトは、以下で明示的に別段の指定がある場合を除き、
通常オブジェクトの内部メソッドを用いる:
10.4.1 束縛関数特殊オブジェクト
束縛関数特殊オブジェクト は、別の関数オブジェクトを包む
特殊オブジェクトである。束縛関数特殊オブジェクト は呼出し
可能である([[Call]] 内部メソッドを持ち、[[Construct]]
内部メソッドを持つ場合もある)。束縛関数特殊オブジェクト
を呼び出すと、通常はその包まれた関数の呼出しが結果として
生じる。
オブジェクトが 束縛関数特殊オブジェクト
であるのは、その [[Call]] および(該当する場合)
[[Construct]] 内部メソッドが次の実装を用い、かつ他の本質
的内部メソッドが
10.1
にある定義を用いる場合である。これらのメソッドは
BoundFunctionCreate で設定される。
束縛関数特殊オブジェクト は、
Table 25
に列挙された ECMAScript 関数オブジェクトの内部スロット
を持たない。代わりに、それらは [[Prototype]] および
[[Extensible]] に加えて、
Table 26
に列挙された内部スロットを持つ。
Table 26: Internal Slots of Bound Function Exotic Objects
内部スロット
型
説明
[[BoundTargetFunction]]
a callable Object
包まれている関数オブジェクト。
[[BoundThis]]
an ECMAScript language value
包まれた関数を呼び出すときに、常に this 値
として渡される値。
[[BoundArguments]]
a List of ECMAScript language values
その要素が、包まれた関数へのあらゆる呼出しに
おいて最初の引数として用いられる値の list。
10.4.1.1 [[Call]] ( thisArgument , argumentsList )
The [[Call]] internal method of a bound function exotic object func takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values ) and returns either a normal completion containing an ECMAScript language value or a throw completion . It performs the following steps when called:
target を func .[[BoundTargetFunction]] とす
る。boundThis を func .[[BoundThis]] とする。boundArgs を func .[[BoundArguments]] とす
る。args を boundArgs と argumentsList
の list-concatenation とする。? Call (target , boundThis , args ) を返
す。
10.4.1.2 [[Construct]] ( argumentsList , newTarget )
The [[Construct]] internal method of a bound function exotic object func takes arguments argumentsList (a List of ECMAScript language values ) and newTarget (a constructor ) and returns either a normal completion containing an Object or a throw completion . It performs the following steps when called:
target を func .[[BoundTargetFunction]] とす
る。Assert : IsConstructor (target ) is true .boundArgs を func .[[BoundArguments]] と
する。args を boundArgs と argumentsList
の list-concatenation とする。SameValue (func , newTarget ) が true
なら、newTarget を target に設定する。? Construct (target , args , newTarget )
を返す。
10.4.1.3 BoundFunctionCreate ( targetFunction , boundThis , boundArgs )
The abstract operation BoundFunctionCreate takes arguments targetFunction (a function object ), boundThis (an ECMAScript language value), and boundArgs (a List of ECMAScript language values ) and returns either a normal completion containing a function object or a throw completion . これは、新しい束縛関数特殊オブジェクト の作成を規定
するために用いられる。 It performs the following steps when called:
proto を
? targetFunction .[[GetPrototypeOf]] () とする。internalSlotsList を
« [[Prototype]] , [[Extensible]] » と
Table 26
に列挙された内部スロットの
list-concatenation とする。obj を MakeBasicObject (internalSlotsList )
とする。obj .[[Prototype]] を proto に設定する。obj .[[Call]] を
10.4.1.1
に規定されたとおりに設定する。IsConstructor (targetFunction ) が true な
ら、obj .[[Construct]] を
10.4.1.2
に規定されたとおりに設定する。obj .[[BoundTargetFunction]] を
targetFunction に設定する。obj .[[BoundThis]] を boundThis に設定す
る。obj .[[BoundArguments]] を boundArgs に設
定する。obj を返す。
10.4.2 配列特殊オブジェクト
Array は、array index property key に特別な扱いを
与える特殊オブジェクトである(
6.1.7 を参照)。
property name が array index であるプロパティは
element とも呼ばれる。すべての Array は、
non-configurable な "length" プロパティを持ち、そ
の値は常に数学的に厳密に 232 未満である非負整
数 Number である。"length" プロパティの値は、名前が
array index であるすべての own property の名前よりも
数値的に大きい; Array の own property が作成または変更
されるたびに、この不変条件を維持するため必要に応じて他の
プロパティが調整される。具体的には、名前が array index
である own property が追加されるたびに、必要に応じて
"length" プロパティの値は、その array index の数値
に 1 を加えた値に変更される; また、"length" プロパ
ティの値が変更されるたびに、その値が新しい length 以上で
ある名前が array index のすべての own property は削除
される。この制約は Array の own property にのみ適用さ
れ、その prototype から継承され得る "length" また
は array index property の影響を受けない。
オブジェクトが Array 特殊オブジェクト
(または単に Array)であるのは、その [[DefineOwnProperty]]
内部メソッドが次の実装を用い、かつ他の本質的内部メソッド
が
10.1
にある定義を用いる場合である。これらのメソッドは
ArrayCreate で設定される。
10.4.2.1 [[DefineOwnProperty]] ( propertyKey , desc )
The [[DefineOwnProperty]] internal method of an Array exotic object array takes arguments propertyKey (a property key ) and desc (a Property Descriptor ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
propertyKey が "length" なら、
? ArraySetLength (array , desc ) を返す。propertyKey が array index なら、lengthDesc を OrdinaryGetOwnProperty (
array , "length" ) とする。Assert : lengthDesc は undefined では
ない。Assert : IsDataDescriptor (lengthDesc ) is
true .Assert : lengthDesc .[[Configurable]] is
false .length を lengthDesc .[[Value]] とする。Assert : length は非負整数 Number である。index を ! ToUint32 (propertyKey ) とする。index ≥ length かつ
lengthDesc .[[Writable]] が false な
ら、false を返す。succeeded を
! OrdinaryDefineOwnProperty (array ,
propertyKey , desc ) とする。succeeded が false なら、false を
返す。index ≥ length なら、lengthDesc .[[Value]] を
index + 1 𝔽 に設定する。succeeded を
! OrdinaryDefineOwnProperty (array ,
"length" , lengthDesc ) に設定する。Assert : succeeded is true .true を返す。? OrdinaryDefineOwnProperty (array ,
propertyKey , desc ) を返す。
10.4.2.2 ArrayCreate ( length [ , proto ] )
The abstract operation ArrayCreate takes argument length (a non-negative integer ) and optional argument proto (an Object) and returns either a normal completion containing an Array exotic object or a throw completion . これは、新しい Array の作成を規定するために用い
られる。 It performs the following steps when called:
length > 232 - 1 なら、
RangeError 例外を送出する。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 または
類似オブジェクトの作成を規定するために用いられる。それ
は、constructor function が Array を返すことまでは強
制しない。 It performs the following steps when called:
isArray を ? IsArray (originalArray ) とす
る。isArray が false なら、
? ArrayCreate (length ) を返す。constructor を
? Get (originalArray , "constructor" )
とする。IsConstructor (constructor ) が true な
ら、thisRealm を current Realm Record とす
る。constructorRealm を
? GetFunctionRealm (constructor ) とす
る。thisRealm と constructorRealm が同
じ Realm Record でないなら、SameValue (constructor ,
constructorRealm .[[Intrinsics]] .[[%Array% ]])
が true なら、constructor を
undefined に設定する。constructor が Object なら、constructor を
? Get (constructor , %Symbol.species% )
に設定する。constructor が null なら、
constructor を undefined に設定する。constructor が undefined なら、
? ArrayCreate (length ) を返す。IsConstructor (constructor ) が false な
ら、TypeError 例外を送出する。? Construct (constructor , « 𝔽 (length ) »)
を返す。
Note
originalArray が、running execution
context の realm ではない realm に属する標準組込み
Array constructor を用いて作成されていた場合、新し
い Array は running execution context の realm を
用いて作成される。これにより、現在
ArraySpeciesCreate を用いて定義されている
Array.prototype メソッドについて、歴史的にそのよう
な挙動を持っていた Web browser との互換性が維持され
る。
10.4.2.4 ArraySetLength ( array , desc )
The abstract operation ArraySetLength takes arguments array (an Array) and desc (a Property Descriptor ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
desc が [[Value]] フィールドを持たないなら、! OrdinaryDefineOwnProperty (array ,
"length" , desc ) を返す。 newLenDesc を desc の copy とする。newLen を
? ToUint32 (desc .[[Value]] ) とする。numberLen
を ? ToNumber (desc .[[Value]] ) とする。SameValueZero (newLen , numberLen ) が
false なら、RangeError 例外を送出す
る。newLenDesc .[[Value]] を newLen に設定す
る。oldLenDesc を OrdinaryGetOwnProperty (
array , "length" ) とする。Assert : oldLenDesc は undefined では
ない。Assert : IsDataDescriptor (oldLenDesc ) is
true .Assert : oldLenDesc .[[Configurable]] is
false .oldLen を oldLenDesc .[[Value]] とする。newLen ≥ oldLen なら、! OrdinaryDefineOwnProperty (array ,
"length" , newLenDesc ) を返す。 oldLenDesc .[[Writable]] が false な
ら、false を返す。newLenDesc が [[Writable]] フィールドを持
たないか、または newLenDesc .[[Writable]]
が true なら、newWritable を true とする。Else,NOTE : いずれかの element を削除できない場
合に備えて、[[Writable]] 属性を false
に設定するのは延期される。newWritable を false とする。newLenDesc .[[Writable]] を true に設
定する。 succeeded を
! OrdinaryDefineOwnProperty (array ,
"length" , newLenDesc ) とする。succeeded が false なら、false を返
す。array の各 own property key
propertyKey について、propertyKey が
array index であり、かつ
! ToUint32 (propertyKey ) ≥ newLen であ
るものを、数値 index 降順で処理し、次を行うdeleteSucceeded を
! array .[[Delete]] (propertyKey ) とす
る。deleteSucceeded が false なら、newLenDesc .[[Value]] を
! ToUint32 (propertyKey ) +
1 𝔽 に設定する。newWritable が false なら、
newLenDesc .[[Writable]] を false
に設定する。! OrdinaryDefineOwnProperty (array ,
"length" , newLenDesc ) を実行す
る。 false を返す。newWritable が false なら、succeeded を
! OrdinaryDefineOwnProperty (array ,
"length" , PropertyDescriptor {
[[Writable]] : false }) に設定する。Assert : succeeded is true .true を返す。
Note
手順 3 および
4
において、desc .[[Value]] が object である場合、
その valueOf メソッドは 2 回呼び出される。これは、
この仕様の第 2 版以来、この効果を伴うものとして規定されて
いる legacy な挙動である。
10.4.3 文字列特殊オブジェクト
String object は、String 値をカプセル化し、その
String 値の個々の code unit 要素に対応する仮想的な整数
index 付き data property を公開する特殊オブジェクトであ
る。String 特殊オブジェクト は、常に "length" とい
う名前の data property を持ち、その値はカプセル化された
String 値の長さである。code unit data property と
"length" プロパティの両方とも、書込み不可かつ
configurable ではない。
オブジェクトが String 特殊オブジェクト
(または単に String object)であるのは、その
[[GetOwnProperty]] 、[[DefineOwnProperty]] 、
[[OwnPropertyKeys]] 内部メソッドが次の実装を用い、かつ
他の本質的内部メソッドが
10.1
にある定義を用いる場合である。これらのメソッドは
StringCreate において設定される。
String 特殊オブジェクト は通常オブジェクトと同じ内部ス
ロットを持つ。さらに [[StringData]] 内部スロットを持
つ。
10.4.3.1 [[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of a String exotic object str takes argument propertyKey (a property key ) and returns a normal completion containing either a Property Descriptor or undefined . It performs the following steps when called:
desc を OrdinaryGetOwnProperty (str ,
propertyKey ) とする。desc が undefined でなければ、
desc を返す。StringGetOwnProperty (str , propertyKey )
を返す。
10.4.3.2 [[DefineOwnProperty]] ( propertyKey , desc )
The [[DefineOwnProperty]] internal method of a String exotic object str takes arguments propertyKey (a property key ) and desc (a Property Descriptor ) and returns a normal completion containing a Boolean. It performs the following steps when called:
stringDesc を StringGetOwnProperty (str ,
propertyKey ) とする。stringDesc が undefined でなければ、extensible を str .[[Extensible]] とす
る。IsCompatiblePropertyDescriptor (
extensible , desc , stringDesc ) を返
す。! OrdinaryDefineOwnProperty (str ,
propertyKey , desc ) を返す。
10.4.3.3 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of a String exotic object obj takes no arguments and returns a normal completion containing a List of property keys . It performs the following steps when called:
keys を新しい空の List とする。str を obj .[[StringData]] とする。Assert : str は String である。len を str の長さとする。0 ≤ i < len を満たす各整数 i につい
て、昇順で、次を行う! ToString (𝔽 (i )) を keys に append
する。 obj の各 own property key propertyKey
について、propertyKey が array index で
あり、かつ ! ToIntegerOrInfinity (
propertyKey ) ≥ len であるものを、数値
index 昇順で処理し、次を行うpropertyKey を keys に append する。obj の各 own property key propertyKey
について、propertyKey が String であり、
かつ array index ではないものを、プロパティ
作成時刻の昇順で処理し、次を行うpropertyKey を keys に append する。obj の各 own property key propertyKey
について、propertyKey が Symbol である
ものを、プロパティ作成時刻の昇順で処理し、次を
行うpropertyKey を keys に append する。keys を返す。
10.4.3.4 StringCreate ( value , prototype )
The abstract operation StringCreate takes arguments value (a String) and prototype (an Object) and returns a String exotic object . これは、新しい String 特殊オブジェクト の作成を
規定するために用いられる。 It performs the following steps when called:
str を MakeBasicObject (
« [[Prototype]] , [[Extensible]] ,
[[StringData]] ») とする。str .[[Prototype]] を prototype に設定す
る。str .[[StringData]] を value に設定する。str .[[GetOwnProperty]] を
10.4.3.1
に規定されたとおりに設定する。str .[[DefineOwnProperty]] を
10.4.3.2
に規定されたとおりに設定する。str .[[OwnPropertyKeys]] を
10.4.3.3
に規定されたとおりに設定する。length を value の長さとする。! DefinePropertyOrThrow (str , "length" ,
PropertyDescriptor { [[Value]] : 𝔽 (length ),
[[Writable]] : false , [[Enumerable]] : false ,
[[Configurable]] : false }) を実行する。 str を返す。
10.4.3.5 StringGetOwnProperty ( str , propertyKey )
The abstract operation StringGetOwnProperty takes arguments str (an Object that has a [[StringData]] internal slot) and propertyKey (a property key ) and returns a Property Descriptor or undefined . It performs the following steps when called:
propertyKey が String でなければ、
undefined を返す。index を
CanonicalNumericIndexString (propertyKey )
とする。index が整数 Number でなければ、
undefined を返す。index が -0 𝔽 であるか、また
は index < -0 𝔽 なら、
undefined を返す。stringData を str .[[StringData]] とす
る。Assert : stringData は String である。len を stringData の長さとする。ℝ (index ) ≥ len なら、undefined を返
す。resultStr を、ℝ (index ) から
ℝ (index ) + 1 までの stringData の
substring とする。PropertyDescriptor { [[Value]] : resultStr ,
[[Writable]] : false , [[Enumerable]] : true ,
[[Configurable]] : false } を返す。
10.4.4 Arguments 特殊オブジェクト
ほとんどの ECMAScript 関数は、そのコードから利用可能
な arguments object を作成する。関数定義の特性に応じ
て、その arguments object は通常オブジェクトまたは
arguments 特殊オブジェクト のいずれかである。
arguments 特殊オブジェクト は、その array index
property が、対応する ECMAScript 関数の呼出しにおける
仮引数束縛へ対応付けられる特殊オブジェクトである。
オブジェクトが arguments 特殊オブジェクト
であるのは、その内部メソッドが次の実装を用い、ここで指定
されていないものは
10.1
にある定義を用いる場合である。これらのメソッドは
CreateMappedArgumentsObject において設定される。
Note 1
arguments 特殊オブジェクト は通常オブジェクトと同
じ内部スロットを持つ。さらに [[ParameterMap]] 内部スロ
ットを持つ。通常の arguments object も
[[ParameterMap]] 内部スロットを持つが、その値は常に
undefined である。通常の arguments object におい
て [[ParameterMap]] 内部スロットは、
Object.prototype.toString
(20.1.3.6 )
がそれらをそのようなものとして識別するためにのみ用いられ
る。
Note 2
対応する関数オブジェクトの仮引数の数より小さい数値名を
持つ arguments 特殊オブジェクト の整数 index 付き
data property は、初期状態では関数の execution
context における対応する引数束縛と値を共有する。これ
は、そのプロパティを変更すると対応する引数束縛の値も変わ
り、逆もまた同様であることを意味する。この対応関係は、そ
のようなプロパティが削除されてから再定義された場合、また
はそのプロパティが accessor property に変更された場合
に壊れる。arguments object が通常オブジェクトである場
合、そのプロパティの値は関数に渡された引数の単なる copy
であり、プロパティ値と仮引数値の間に動的な連結は存在しな
い。
Note 3
ParameterMap object とその property 値は、
arguments object と引数束縛との対応を規定するための仕
組みとして用いられる。ParameterMap object と、そのプ
ロパティの値であるオブジェクトは、ECMAScript code から
直接観測可能ではない。ECMAScript 実装は、指定された意味
論を実装するために、そのようなオブジェクトを実際に作成し
たり使用したりする必要はない。
Note 4
通常の arguments object は、"callee" という
名前の non-configurable な accessor property を定
義し、そのアクセス時には TypeError 例外を送出する。
"callee" プロパティは、arguments 特殊オブジェクト
においてはより具体的な意味を持つ。arguments 特殊オブ
ジェクトは、non-strict function のある種のクラスに対
してのみ作成される。通常版におけるこのプロパティの定義
は、適合する ECMAScript 実装によってこれが他の方法で定
義されないことを保証するために存在する。
Note 5
ECMAScript 実装の arguments 特殊オブジェクト は、
歴史的に "caller" という名前の accessor property
を含んでいた。ECMAScript 2017 より前、この仕様は通常
の arguments object に throwing な "caller"
プロパティを定義していた。実装はもはやこの拡張を含まない
ため、ECMAScript 2017 では throwing な
"caller" accessor の要件が削除された。
10.4.4.1 [[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of an arguments exotic object args takes argument propertyKey (a property key ) and returns a normal completion containing either a Property Descriptor or undefined . It performs the following steps when called:
desc を OrdinaryGetOwnProperty (args ,
propertyKey ) とする。desc が undefined なら、undefined を
返す。map を args .[[ParameterMap]] とする。isMapped を ! HasOwnProperty (map ,
propertyKey ) とする。isMapped が true なら、desc .[[Value]] を ! Get (map ,
propertyKey ) に設定する。desc を返す。
10.4.4.2 [[DefineOwnProperty]] ( propertyKey , desc )
The [[DefineOwnProperty]] internal method of an arguments exotic object args takes arguments propertyKey (a property key ) and desc (a Property Descriptor ) and returns a normal completion containing a Boolean. It performs the following steps when called:
map を args .[[ParameterMap]] とする。isMapped を ! HasOwnProperty (map ,
propertyKey ) とする。newArgDesc を desc とする。isMapped が true かつ
IsDataDescriptor (desc ) が true なら、desc が [[Value]] フィールドを持たず、
desc が [[Writable]] フィールドを持ち、
かつ desc .[[Writable]] が false な
ら、newArgDesc を desc の copy に設定
する。newArgDesc .[[Value]] を ! Get (map ,
propertyKey ) に設定する。allowed を
! OrdinaryDefineOwnProperty (args ,
propertyKey , newArgDesc ) とする。allowed が false なら、false を返
す。isMapped が true なら、IsAccessorDescriptor (desc ) が true な
ら、! map .[[Delete]] (propertyKey ) を実
行する。 Else,desc が [[Value]] フィールドを持つな
ら、Assert : 次の Set は成功する。なぜなら
arguments object によって対応付け
られる仮引数は常に書込み可能だからであ
る。! Set (map , propertyKey ,
desc .[[Value]] , false ) を実行す
る。 desc が [[Writable]] フィールドを持
ち、かつ desc .[[Writable]] が false
なら、! map .[[Delete]] (propertyKey ) を
実行する。 true を返す。
10.4.4.3 [[Get]] ( propertyKey , receiver )
The [[Get]] internal method of an arguments exotic object args takes arguments propertyKey (a property key ) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion . It performs the following steps when called:
map を args .[[ParameterMap]] とする。isMapped を ! HasOwnProperty (map ,
propertyKey ) とする。isMapped が false なら、
? OrdinaryGet (args , propertyKey ,
receiver ) を返す。Assert : map は propertyKey に対する仮
引数対応付けを含む。! Get (map , propertyKey ) を返す。
10.4.4.4 [[Set]] ( propertyKey , value , receiver )
The [[Set]] internal method of an arguments exotic object args takes arguments propertyKey (a property key ), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
SameValue (args , receiver ) が false な
ら、isMapped を false とする。Else,map を args .[[ParameterMap]] とする。isMapped を ! HasOwnProperty (map ,
propertyKey ) とする。 isMapped が true なら、Assert : 次の Set は成功する。なぜなら
arguments object によって対応付けられ
る仮引数は常に書込み可能だからである。! Set (map , propertyKey , value ,
false ) を実行する。 ? OrdinarySet (args , propertyKey ,
value , receiver ) を返す。
10.4.4.5 [[Delete]] ( propertyKey )
The [[Delete]] internal method of an arguments exotic object args takes argument propertyKey (a property key ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
map を args .[[ParameterMap]] とする。isMapped を ! HasOwnProperty (map ,
propertyKey ) とする。result を ? OrdinaryDelete (args ,
propertyKey ) とする。result が true かつ isMapped が true
なら、! map .[[Delete]] (propertyKey ) を実行す
る。 result を返す。
10.4.4.6 CreateUnmappedArgumentsObject ( argumentsList )
The abstract operation CreateUnmappedArgumentsObject takes argument argumentsList (a List of ECMAScript language values ) and returns an ordinary object . It performs the following steps when called:
len を argumentsList の要素数とする。obj を
OrdinaryObjectCreate (%Object.prototype% ,
« [[ParameterMap]] ») とする。obj .[[ParameterMap]] を undefined に設
定する。! DefinePropertyOrThrow (obj , "length" ,
PropertyDescriptor { [[Value]] : 𝔽 (len ),
[[Writable]] : true , [[Enumerable]] : false ,
[[Configurable]] : true }) を実行する。 index を 0 とする。index < len の間、繰り返すval を argumentsList [index ] とす
る。! CreateDataPropertyOrThrow (obj ,
! ToString (𝔽 (index )), val ) を実行す
る。 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 , argumentsList , env )
The abstract operation CreateMappedArgumentsObject takes arguments func (an ECMAScript function object ), formals (a Parse Node ), argumentsList (a List of ECMAScript language values ), and env (an Environment Record ) and returns an arguments exotic object . It performs the following steps when called:
Assert : formals は rest parameter、
binding pattern、またはいかなる initializer
も含まない。重複識別子を含んでもよい。len を argumentsList の要素数とする。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 に設定す
る。parameterNames を formals の
BoundNames とする。numberOfParameters を parameterNames
の要素数とする。index を 0 とする。index < len の間、繰り返すval を argumentsList [index ] とす
る。! CreateDataPropertyOrThrow (obj ,
! ToString (𝔽 (index )), val ) を実行す
る。 index を index + 1 に設定する。! DefinePropertyOrThrow (obj , "length" ,
PropertyDescriptor { [[Value]] : 𝔽 (len ),
[[Writable]] : true , [[Enumerable]] : false ,
[[Configurable]] : true }) を実行する。 mappedNames を新しい空の List とする。index を numberOfParameters - 1 に設定
する。index ≥ 0 の間、繰り返すname を parameterNames [index ] とす
る。mappedNames が name を含まないなら、name を mappedNames に append す
る。index < len なら、getter を MakeArgGetter (name ,
env ) とする。setter を MakeArgSetter (name ,
env ) とする。! 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 , env )
The abstract operation MakeArgGetter takes arguments name (a String) and env (an Environment Record ) and returns a function object . これは、実行されると env において name に束
縛された値を返す built-in function object を作成す
る。 It performs the following steps when called:
getterClosure を、引数を持たず、name
と env を capture し、呼び出されたとき
次の手順を実行する新しい Abstract Closure
とする:NormalCompletion (
! env .GetBindingValue (name , false ))
を返す。getter を CreateBuiltinFunction (
getterClosure , 0, "" , « ») とする。NOTE : getter は ECMAScript code から直
接アクセス可能になることはない。getter を返す。
10.4.4.7.2 MakeArgSetter ( name , env )
The abstract operation MakeArgSetter takes arguments name (a String) and env (an Environment Record ) and returns a function object . これは、実行されると env において name に束
縛された値を設定する built-in function object を作成
する。 It performs the following steps when called:
setterClosure を、(value ) を引数とし、
name と env を capture し、呼び出された
とき次の手順を実行する新しい Abstract
Closure とする:NormalCompletion (
! env .SetMutableBinding (name , value ,
false )) を返す。setter を CreateBuiltinFunction (
setterClosure , 1, "" , « ») とす
る。NOTE : setter は ECMAScript code から直
接アクセス可能になることはない。setter を返す。
10.4.5 TypedArray 特殊オブジェクト
TypedArray は、canonical numeric string であ
る property key に特別な処理を行う特殊オブジェクトであ
り、そのうち範囲内の整数 index である部分集合を用いて均
一な型の element を index し、残りが prototype
chain の探索を生じさせることなく存在しないという不変条件
を強制する。
Note
任意の Number n に対する ToString (n ) は
canonical numeric string であるため、実装は実際に
string 変換を行うことなく、TypedArray に対する
property key として Number を扱ってよい。
TypedArray は通常オブジェクトと同じ内部スロットを持
ち、さらに [[ViewedArrayBuffer]] 、
[[TypedArrayName]] 、[[ContentType]] 、
[[ByteLength]] 、[[ByteOffset]] 、および
[[ArrayLength]] 内部スロットを持つ。
オブジェクトが TypedArray
であるのは、その [[PreventExtensions]] 、
[[GetOwnProperty]] 、[[HasProperty]] 、
[[DefineOwnProperty]] 、[[Get]] 、[[Set]] 、
[[Delete]] 、および [[OwnPropertyKeys]] 内部メソッド
がこの節の定義を用い、かつ他の本質的内部メソッドが
10.1
にある定義を用いる場合である。これらのメソッドは
TypedArrayCreate によって設定される。
10.4.5.1 [[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of a TypedArray obj takes no arguments and returns a normal completion containing a Boolean. It performs the following steps when called:
NOTE :
6.1.7.3
に規定された拡張可能性関連の不変条件は、基底
buffer の resize によって整数 index 名の
property が増える(または減ってから再び増え
る)可能性があるとき、obj に対してこのメソ
ッドが true を返すことを許さない。IsTypedArrayFixedLength (obj ) が false
なら、false を返す。OrdinaryPreventExtensions (obj ) を返す。
10.4.5.2 [[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of a TypedArray obj takes argument propertyKey (a property key ) and returns a normal completion containing either a Property Descriptor or undefined . It performs the following steps when called:
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 a TypedArray obj takes argument propertyKey (a property key ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
propertyKey が String なら、numericIndex を
CanonicalNumericIndexString (propertyKey )
とする。numericIndex が undefined でなけれ
ば、
IsValidIntegerIndex (obj , numericIndex )
を返す。? OrdinaryHasProperty (obj , propertyKey )
を返す。
10.4.5.4 [[DefineOwnProperty]] ( propertyKey , desc )
The [[DefineOwnProperty]] internal method of a TypedArray obj takes arguments propertyKey (a property key ) and desc (a Property Descriptor ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
propertyKey が String なら、numericIndex を
CanonicalNumericIndexString (propertyKey )
とする。numericIndex が undefined でなけれ
ば、IsValidIntegerIndex (obj ,
numericIndex ) が false なら、
false を返す。desc が [[Configurable]] フィールド
を持ち、かつ desc .[[Configurable]] が
false なら、false を返す。desc が [[Enumerable]] フィールドを持
ち、かつ desc .[[Enumerable]] が
false なら、false を返す。IsAccessorDescriptor (desc ) が true
なら、false を返す。desc が [[Writable]] フィールドを持
ち、かつ desc .[[Writable]] が false
なら、false を返す。desc が [[Value]] フィールドを持つな
ら、? TypedArraySetElement (obj ,
numericIndex , desc .[[Value]] ) を
実行する。true を返す。! OrdinaryDefineOwnProperty (obj ,
propertyKey , desc ) を返す。
10.4.5.5 [[Get]] ( propertyKey , receiver )
The [[Get]] internal method of a TypedArray obj takes arguments propertyKey (a property key ) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion . It performs the following steps when called:
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 a TypedArray obj takes arguments propertyKey (a property key ), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
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 a 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 a 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 を満たす各整数 i に
ついて、昇順で、次を行う! ToString (𝔽 (i )) を keys に
append する。 obj の各 own property key propertyKey
について、propertyKey が String であり、
かつ integer index ではないものを、プロパテ
ィ作成時刻の昇順で処理し、次を行うpropertyKey を keys に append する。obj の各 own property key propertyKey
について、propertyKey が Symbol であるも
のを、プロパティ作成時刻の昇順で処理し、次を行
うpropertyKey を keys に append す
る。keys を返す。
10.4.5.9 TypedArray With Buffer Witness Record
TypedArray With Buffer Witness Record
は、TypedArray と、その view された buffer の byte
length の cache 値をあわせてカプセル化するために用いら
れる Record 値である。これは、view された buffer が
growable SharedArrayBuffer であるとき、byte length
data block に対する ReadSharedMemory event が 1 回
だけになることを助けるために用いられる。
TypedArray With Buffer Witness Record は
Table 27
に列挙されたフィールドを持つ。
Table 27: TypedArray With Buffer Witness Record Fields
フィールド名
値
意味
[[Object]]
a TypedArray
その buffer の byte length が読み込まれ
る TypedArray 。
[[CachedBufferByteLength]]
a non-negative integer or detached
この Record が作成された時点における、オ
ブジェクトの [[ViewedArrayBuffer]] の
byte length。
10.4.5.10 MakeTypedArrayWithBufferWitnessRecord ( obj , order )
The abstract operation MakeTypedArrayWithBufferWitnessRecord takes arguments obj (a TypedArray ) and order (seq-cst or unordered ) and returns a TypedArray With Buffer Witness Record . It performs the following steps when called:
buffer を obj .[[ViewedArrayBuffer]] とす
る。IsDetachedBuffer (buffer ) が true な
ら、byteLength を detached とする。Else,byteLength を ArrayBufferByteLength (
buffer , order ) とする。 TypedArray With Buffer Witness Record {
[[Object]] : obj , [[CachedBufferByteLength]] :
byteLength } を返す。
10.4.5.11 TypedArrayCreate ( prototype )
The abstract operation TypedArrayCreate takes argument prototype (an Object) and returns a TypedArray . これは、新しい TypedArray の作成を規定するため
に用いられる。 It performs the following steps when called:
internalSlotsList を
« [[Prototype]] , [[Extensible]] ,
[[ViewedArrayBuffer]] , [[TypedArrayName]] ,
[[ContentType]] , [[ByteLength]] ,
[[ByteOffset]] , [[ArrayLength]] » とする。typedArray を
MakeBasicObject (internalSlotsList ) とす
る。typedArray .[[PreventExtensions]] を
10.4.5.1
に規定されたとおりに設定する。typedArray .[[GetOwnProperty]] を
10.4.5.2
に規定されたとおりに設定する。typedArray .[[HasProperty]] を
10.4.5.3
に規定されたとおりに設定する。typedArray .[[DefineOwnProperty]] を
10.4.5.4
に規定されたとおりに設定する。typedArray .[[Get]] を
10.4.5.5
に規定されたとおりに設定する。typedArray .[[Set]] を
10.4.5.6
に規定されたとおりに設定する。typedArray .[[Delete]] を
10.4.5.7
に規定されたとおりに設定する。typedArray .[[OwnPropertyKeys]] を
10.4.5.8
に規定されたとおりに設定する。typedArray .[[Prototype]] を prototype に
設定する。typedArray を返す。
10.4.5.12 TypedArrayByteLength ( taRecord )
The abstract operation TypedArrayByteLength takes argument taRecord (a TypedArray With Buffer Witness Record ) and returns a non-negative integer . It performs the following steps when called:
Assert : IsTypedArrayOutOfBounds (taRecord ) is
false .obj を taRecord .[[Object]] とする。obj .[[ByteLength]] が auto でなけれ
ば、obj .[[ByteLength]] を返す。length を TypedArrayLength (taRecord )
とする。elementSize を TypedArrayElementSize (obj )
とする。NOTE : 返される byte length は、基底 buffer
が非整数倍に resize されている場合でも、常
に 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 ) is
false .obj を taRecord .[[Object]] とする。obj .[[ArrayLength]] が auto でなけれ
ば、obj .[[ArrayLength]] を返す。Assert : IsFixedLengthArrayBuffer (
obj .[[ViewedArrayBuffer]] ) is 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. これは、オブジェクトの数値プロパティのいずれかが、
基底 buffer の範囲内に含まれない index にある値を参
照しているかどうかを検査する。 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
とする。Else,elementSize を TypedArrayElementSize (obj )
とする。arrayByteLength を
obj .[[ArrayLength]] × elementSize
とする。byteOffsetEnd を byteOffsetStart +
arrayByteLength とする。 NOTE : [[ByteOffset]] が bufferByteLength
である長さ 0 の TypedArray は、範囲外とは
みなされない。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 が整数 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 なら、
numValue を ? ToBigInt (value ) とする。Else, numValue を ? ToNumber (value ) とす
る。 IsValidIntegerIndex (obj , index ) が
true なら、offset を obj .[[ByteOffset]] とする。elementSize を TypedArrayElementSize (obj )
とする。byteIndexInBuffer を
(ℝ (index ) × elementSize ) + offset
とする。elementType を
TypedArrayElementType (obj ) とする。SetValueInBuffer (obj .[[ViewedArrayBuffer]] ,
byteIndexInBuffer , elementType ,
numValue , true , unordered ) を実行す
る。unused を返す。
Note
この操作は常に成功したように見えるが、TypedArray
の終端を越えて書き込もうとした場合、または detached
ArrayBuffer に裏付けられた TypedArray に書き込もう
とした場合には効果を持たない。
10.4.5.19 IsArrayBufferViewOutOfBounds ( obj )
The abstract operation IsArrayBufferViewOutOfBounds takes argument obj (a TypedArray or a DataView) and returns a Boolean. これは、TypedArray の数値プロパティのいずれか、
または DataView object のメソッドのいずれかが、基底
data block の範囲内に含まれない index にある値を参照
し得るかどうかを検査する。この抽象操作は、上流仕様の便宜
のために存在する。 It performs the following steps when called:
obj が [[DataView]] internal slot を持つ
なら、viewRecord を
MakeDataViewWithBufferWitnessRecord (
obj , seq-cst ) とする。IsViewOutOfBounds (viewRecord ) を返す。taRecord を
MakeTypedArrayWithBufferWitnessRecord (obj ,
seq-cst ) とする。IsTypedArrayOutOfBounds (taRecord ) を返す。
10.4.6 モジュール名前空間特殊オブジェクト
module namespace 特殊オブジェクト は、ECMAScript
Module から export された束縛を公開する特殊オブジェ
クトである(16.2.3
を参照)。module namespace 特殊オブジェクト の String
key 付き own property と、Module によって export
される束縛名との間には 1 対 1 の対応が存在する。export
される束縛には、export * export item を用いて間接
的に export された束縛も含まれる。各 String 値の own
property key は、対応する export 束縛名の
StringValue である。これらが module namespace 特殊オ
ブジェクトの唯一の String key 付き property である。
そのような各 property は { [[Writable]] : true ,
[[Enumerable]] : true , [[Configurable]] :
false } という属性を持つ。module namespace 特殊オ
ブジェクトは拡張可能ではない。
オブジェクトが module namespace 特殊オブジェクト
であるのは、その [[GetPrototypeOf]] 、
[[SetPrototypeOf]] 、[[IsExtensible]] 、
[[PreventExtensions]] 、[[GetOwnProperty]] 、
[[DefineOwnProperty]] 、[[HasProperty]] 、[[Get]] 、
[[Set]] 、[[Delete]] 、および [[OwnPropertyKeys]]
内部メソッドがこの節の定義を用い、かつ他の本質的内部メソ
ッドが
10.1
にある定義を用いる場合である。これらのメソッドは
ModuleNamespaceCreate によって設定される。
module namespace 特殊オブジェクト は、
Table 28
で定義された内部スロットを持つ。
Table 28: Internal Slots of Module Namespace Exotic Objects
内部スロット
型
説明
[[Module]]
a Module Record
この namespace が公開する export を持つ
Module Record 。
[[Exports]]
a List of Strings
このオブジェクトの own property として公
開される export 名の String 値を要素とす
る List 。list は code unit の辞書順に従
って整列される。
10.4.6.1 [[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of a module namespace exotic object takes no arguments and returns a normal completion containing null . It performs the following steps when called:
null を返す。
10.4.6.2 [[SetPrototypeOf]] ( proto )
The [[SetPrototypeOf]] internal method of a module namespace exotic object obj takes argument proto (an Object or null ) and returns a normal completion containing a Boolean. It performs the following steps when called:
! SetImmutablePrototype (obj , proto ) を返
す。
10.4.6.3 [[IsExtensible]] ( )
The [[IsExtensible]] internal method of a module namespace exotic object takes no arguments and returns a normal completion containing false . It performs the following steps when called:
false を返す。
10.4.6.4 [[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of a module namespace exotic object takes no arguments and returns a normal completion containing true . It performs the following steps when called:
true を返す。
10.4.6.5 [[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of a module namespace exotic object obj takes argument propertyKey (a property key ) and returns either a normal completion containing either a Property Descriptor or undefined , or a throw completion . It performs the following steps when called:
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 , desc )
The [[DefineOwnProperty]] internal method of a module namespace exotic object obj takes arguments propertyKey (a property key ) and desc (a Property Descriptor ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
propertyKey が Symbol なら、
! OrdinaryDefineOwnProperty (obj ,
propertyKey , desc ) を返す。current を ? obj .[[GetOwnProperty]] (
propertyKey ) とする。current が undefined なら、false
を返す。desc が [[Configurable]] フィールドを持ち、
かつ desc .[[Configurable]] が true な
ら、false を返す。desc が [[Enumerable]] フィールドを持ち、
かつ desc .[[Enumerable]] が false な
ら、false を返す。IsAccessorDescriptor (desc ) が true な
ら、false を返す。desc が [[Writable]] フィールドを持ち、
かつ desc .[[Writable]] が false なら、
false を返す。desc が [[Value]] フィールドを持つなら、
SameValue (desc .[[Value]] ,
current .[[Value]] ) を返す。true を返す。
10.4.6.7 [[HasProperty]] ( propertyKey )
The [[HasProperty]] internal method of a module namespace exotic object obj takes argument propertyKey (a property key ) and returns a normal completion containing a Boolean. It performs the following steps when called:
propertyKey が Symbol なら、
! OrdinaryHasProperty (obj , propertyKey )
を返す。exports を obj .[[Exports]] とする。exports が propertyKey を含むなら、
true を返す。false を返す。
10.4.6.8 [[Get]] ( propertyKey , receiver )
The [[Get]] internal method of a module namespace exotic object obj takes arguments propertyKey (a property key ) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion . It performs the following steps when called:
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 例外を送出する。? targetEnv .GetBindingValue (
binding .[[BindingName]] , true ) を返す。
Note
ResolveExport は副作用を持たない。この操作が特定の
exportName 、resolveSet の組を引数として呼び出さ
れるたびに、同じ結果を返さなければならない。実装は、各
module namespace 特殊オブジェクト の [[Exports]] に対
する ResolveExport の結果を事前計算または cache す
ることを選んでもよい。
10.4.6.9 [[Set]] ( propertyKey , value , receiver )
The [[Set]] internal method of a module namespace exotic object takes arguments propertyKey (a property key ), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns a normal completion containing false . It performs the following steps when called:
false を返す。
10.4.6.10 [[Delete]] ( propertyKey )
The [[Delete]] internal method of a module namespace exotic object obj takes argument propertyKey (a property key ) and returns a normal completion containing a Boolean. It performs the following steps when called:
propertyKey が Symbol なら、! OrdinaryDelete (obj , propertyKey ) を返
す。 exports を obj .[[Exports]] とする。exports が propertyKey を含むなら、
false を返す。true を返す。
10.4.6.11 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of a module namespace exotic object obj takes no arguments and returns a normal completion containing a List of property keys . It performs the following steps when called:
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 特殊オブジェ
クトの作成を規定するために用いられる。 It performs the following steps when called:
Assert : module .[[Namespace]] is empty .internalSlotsList を
Table 28
に列挙された内部スロットとする。namespace を
MakeBasicObject (internalSlotsList ) とす
る。namespace の本質的内部メソッドを
10.4.6
に規定された定義に設定する。namespace .[[Module]] を module に設定す
る。sortedExports を、exports の要素を
code unit の辞書順に整列した List とする。namespace .[[Exports]] を sortedExports
に設定する。28.3
の定義に対応する own property を
namespace に作成する。module .[[Namespace]] を namespace に設
定する。namespace を返す。
10.4.7 不変プロトタイプ特殊オブジェクト
不変プロトタイプ特殊オブジェクト は、一度初期化される
と変更されない [[Prototype]] 内部スロットを持つ特殊オ
ブジェクトである。
オブジェクトが 不変プロトタイプ特殊オブジェクト
であるのは、その [[SetPrototypeOf]] 内部メソッドが次の
実装を用いる場合である。(そのほかの本質的内部メソッド
は、対象となる具体的な不変プロトタイプ特殊オブジェクト に
応じて、任意の実装を用いてよい。)
Note
他の特殊オブジェクトと異なり、不変プロトタイプ特殊オ
ブジェクトに対しては専用の作成抽象操作は提供されていな
い。これは、それらが %Object.prototype% および host
environment によってのみ使用され、host environment
においては、関係するオブジェクトが他の点でも特殊であり得
るため、それら独自の専用作成操作を必要とするからである。
10.4.7.1 [[SetPrototypeOf]] ( proto )
The [[SetPrototypeOf]] internal method of an immutable prototype exotic object obj takes argument proto (an Object or null ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? 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 オブジェクトの内部メソッドと内部スロット
Proxy オブジェクトは、その本質的内部メソッドが
ECMAScript code を用いて部分的に実装される特殊オブジェ
クトである。すべての Proxy オブジェクトは
[[ProxyHandler]] と呼ばれる内部スロットを持つ。
[[ProxyHandler]] の値は、proxy の handler object
と呼ばれる object、または null である。handler
object のメソッド
(Table 29
を参照)は、Proxy オブジェクトの 1 つ以上の内部メソッド
の実装を補強するために用いられ得る。すべての Proxy オブ
ジェクトはまた [[ProxyTarget]] と呼ばれる内部スロットを
持ち、その値は object または null のいずれかである。
この object は proxy の target object と呼ば
れる。
オブジェクトが
Proxy 特殊オブジェクト
であるのは、その本質的内部メソッド(該当する場合、
[[Call]] および [[Construct]] を含む)がこの節の定義を
用いる場合である。これらの内部メソッドは ProxyCreate に
おいて設定される。
Table 29: Proxy Handler Methods
内部メソッド
handler メソッド
[[GetPrototypeOf]]
getPrototypeOf
[[SetPrototypeOf]]
setPrototypeOf
[[IsExtensible]]
isExtensible
[[PreventExtensions]]
preventExtensions
[[GetOwnProperty]]
getOwnPropertyDescriptor
[[DefineOwnProperty]]
defineProperty
[[HasProperty]]
has
[[Get]]
get
[[Set]]
set
[[Delete]]
deleteProperty
[[OwnPropertyKeys]]
ownKeys
[[Call]]
apply
[[Construct]]
construct
handler メソッドが Proxy オブジェクトの内部メソッ
ド実装を提供するために呼び出されるとき、その handler
メソッドには proxy の target object が引数として渡され
る。proxy の handler object は、必ずしもすべての本質
的内部メソッドに対応するメソッドを持つわけではない。
handler object が内部 trap に対応するメソッドを持たな
い場合、proxy 上で内部メソッドを起動すると、proxy の
target object 上の対応する内部メソッドの起動が結果とし
て生じる。
Proxy オブジェクトの [[ProxyHandler]] および
[[ProxyTarget]] 内部スロットは、オブジェクトが作成される
とき常に初期化され、通常は変更できない。いくつかの Proxy
オブジェクトは、その後 revoked されることを許す
方法で作成される。proxy が revoked されると、その
[[ProxyHandler]] および [[ProxyTarget]] 内部スロットは
null に設定され、それによりその Proxy オブジェクト上
の内部メソッドの以後の起動は TypeError 例外を送出す
るようになる。
Proxy オブジェクトは、任意の ECMAScript code によ
って内部メソッドの実装を提供することを許すため、
6.1.7.3
で定義された不変条件に違反する handler メソッドを持つ
Proxy オブジェクトを定義することが可能である。
6.1.7.3
で定義された内部メソッド不変条件のいくつかは、本質的完全
性不変条件である。これらの不変条件は、この節で規定される
Proxy オブジェクト内部メソッドによって明示的に強制され
る。ECMAScript 実装は、起こり得るすべての不変条件違反の
存在下でも堅牢でなければならない。
以下のアルゴリズム記述において、obj は
ECMAScript Proxy object、propertyKey は
property key 値、value は任意の ECMAScript 言語
値、そして desc は Property Descriptor record
であると仮定する。
10.5.1 [[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing either an Object or null , or a throw completion . It performs the following steps when called:
? 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 例外を送出する。extensibleTarget を ? IsExtensible (target )
とする。extensibleTarget が true なら、
handlerProto を返す。targetProto を
? target .[[GetPrototypeOf]] () とする。SameValue (handlerProto , targetProto ) が
false なら、TypeError 例外を送出する。handlerProto を返す。
Note
Proxy object に対する [[GetPrototypeOf]] は次
の不変条件を強制する:
[[GetPrototypeOf]] の結果は Object または
null のいずれかでなければならない。
target object が拡張可能でない場合、
Proxy object に適用された [[GetPrototypeOf]]
は、Proxy object の target object に適用
された [[GetPrototypeOf]] と同じ値を返さ
なければならない。
10.5.2 [[SetPrototypeOf]] ( proto )
The [[SetPrototypeOf]] internal method of a Proxy exotic object obj takes argument proto (an Object or null ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? ValidateNonRevokedProxy (obj ) を実行する。 target を obj .[[ProxyTarget]] とする。handler を obj .[[ProxyHandler]] とする。Assert : handler は Object である。trap を ? GetMethod (handler ,
"setPrototypeOf" ) とする。trap が undefined なら、? target .[[SetPrototypeOf]] (proto ) を返す。 booleanTrapResult を ToBoolean (? Call (
trap , handler , « target , proto »))
とする。booleanTrapResult が false なら、
false を返す。extensibleTarget を ? IsExtensible (target )
とする。extensibleTarget が true なら、
true を返す。targetProto を
? target .[[GetPrototypeOf]] () とする。SameValue (proto , targetProto ) が false
なら、TypeError 例外を送出する。true を返す。
Note
Proxy object に対する [[SetPrototypeOf]] は次
の不変条件を強制する:
[[SetPrototypeOf]] の結果は Boolean 値であ
る。
target object が拡張可能でない場合、引数の
値は target object に適用された
[[GetPrototypeOf]] の結果と同じでなければな
らない。
10.5.3 [[IsExtensible]] ( )
The [[IsExtensible]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? ValidateNonRevokedProxy (obj ) を実行する。 target を obj .[[ProxyTarget]] とする。handler を obj .[[ProxyHandler]] とする。Assert : handler は Object である。trap を ? GetMethod (handler ,
"isExtensible" ) とする。trap が undefined なら、? IsExtensible (target ) を返す。 booleanTrapResult を ToBoolean (? Call (
trap , handler , « target »)) とする。targetResult を ? IsExtensible (target )
とする。booleanTrapResult が targetResult でない
なら、TypeError 例外を送出する。booleanTrapResult を返す。
Note
Proxy object に対する [[IsExtensible]] は次
の不変条件を強制する:
[[IsExtensible]] の結果は Boolean 値であ
る。
Proxy object に適用された [[IsExtensible]]
は、同じ引数で Proxy object の target
object に適用された [[IsExtensible]] と同
じ値を返さなければならない。
10.5.4 [[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? ValidateNonRevokedProxy (obj ) を実行する。 target を obj .[[ProxyTarget]] とする。handler を obj .[[ProxyHandler]] とする。Assert : handler は Object である。trap を ? GetMethod (handler ,
"preventExtensions" ) とする。trap が undefined なら、? target .[[PreventExtensions]] () を返す。 booleanTrapResult を ToBoolean (? Call (
trap , handler , « target »)) とする。booleanTrapResult が true なら、extensibleTarget を ? IsExtensible (target )
とする。extensibleTarget が true なら、
TypeError 例外を送出する。booleanTrapResult を返す。
Note
Proxy object に対する [[PreventExtensions]]
は次の不変条件を強制する:
[[PreventExtensions]] の結果は Boolean 値で
ある。
Proxy object に適用された
[[PreventExtensions]] は、Proxy object の
target object に適用された [[IsExtensible]]
が false である場合にのみ true を返
す。
10.5.5 [[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of a Proxy exotic object obj takes argument propertyKey (a property key ) and returns either a normal completion containing either a Property Descriptor or undefined , or a throw completion . It performs the following steps when called:
? 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 でなく、かつ
undefined でもないなら、TypeError 例外
を送出する。targetDesc を
? target .[[GetOwnProperty]] (propertyKey ) とする。trapResultObj が undefined なら、targetDesc が undefined なら、
undefined を返す。targetDesc .[[Configurable]] が false な
ら、TypeError 例外を送出する。extensibleTarget を ? IsExtensible (target )
とする。extensibleTarget が false なら、
TypeError 例外を送出する。undefined を返す。extensibleTarget を ? IsExtensible (target )
とする。resultDesc を
? ToPropertyDescriptor (trapResultObj ) とす
る。CompletePropertyDescriptor (resultDesc ) を実
行する。valid を IsCompatiblePropertyDescriptor (
extensibleTarget , resultDesc , targetDesc )
とする。valid が false なら、TypeError 例外
を送出する。resultDesc .[[Configurable]] が false な
ら、targetDesc が undefined または
targetDesc .[[Configurable]] が true
なら、TypeError 例外を送出する。resultDesc が [[Writable]] フィールドを持
ち、かつ resultDesc .[[Writable]] が
false なら、Assert : targetDesc は [[Writable]]
フィールドを持つ。targetDesc .[[Writable]] が true な
ら、TypeError 例外を送出する。resultDesc を返す。
Note
Proxy object に対する [[GetOwnProperty]] は
次の不変条件を強制する:
[[GetOwnProperty]] の結果は Property
Descriptor または undefined のいずれか
でなければならない。
property は、target object の
non-configurable own property として存
在する場合、存在しないものとして報告されてはな
らない。
property は、拡張可能でない target object
の own property として存在する場合、存在し
ないものとして報告されてはならない。
property は、target object の own
property として存在せず、かつ target object
が拡張可能でない場合、存在するものとして報告さ
れてはならない。
property は、それが target object の
non-configurable own property として存在
しない限り、non-configurable として報告さ
れてはならない。
property は、それが target object の
non-configurable かつ non-writable own
property として存在しない限り、
non-configurable かつ non-writable の
両方として報告されてはならない。
10.5.6 [[DefineOwnProperty]] ( propertyKey , desc )
The [[DefineOwnProperty]] internal method of a Proxy exotic object obj takes arguments propertyKey (a property key ) and desc (a Property Descriptor ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? ValidateNonRevokedProxy (obj ) を実行する。 target を obj .[[ProxyTarget]] とする。handler を obj .[[ProxyHandler]] とする。Assert : handler は Object である。trap を ? GetMethod (handler ,
"defineProperty" ) とする。trap が undefined なら、? target .[[DefineOwnProperty]] (propertyKey , desc ) を返す。 descObj を FromPropertyDescriptor (desc ) と
する。booleanTrapResult を ToBoolean (? Call (
trap , handler , « target , propertyKey ,
descObj »)) とする。booleanTrapResult が false なら、
false を返す。targetDesc を
? target .[[GetOwnProperty]] (propertyKey ) とする。extensibleTarget を ? IsExtensible (target )
とする。desc が [[Configurable]] フィールドを持ち、
かつ desc .[[Configurable]] が false な
ら、settingConfigFalse を true とする。Else,settingConfigFalse を false とする。 targetDesc が undefined なら、extensibleTarget が false なら、
TypeError 例外を送出する。settingConfigFalse が true なら、
TypeError 例外を送出する。Else,IsCompatiblePropertyDescriptor (
extensibleTarget , desc , targetDesc ) が
false なら、TypeError 例外を送出す
る。settingConfigFalse が true かつ
targetDesc .[[Configurable]] が true
なら、TypeError 例外を送出する。IsDataDescriptor (targetDesc ) が true 、
targetDesc .[[Configurable]] が false 、
かつ targetDesc .[[Writable]] が true
なら、desc が [[Writable]] フィールドを持ち、
かつ desc .[[Writable]] が false な
ら、TypeError 例外を送出する。 true を返す。
Note
Proxy object に対する [[DefineOwnProperty]]
は次の不変条件を強制する:
[[DefineOwnProperty]] の結果は Boolean 値で
ある。
target object が拡張可能でない場合、
property を追加することはできない。
target object に対応する
non-configurable own property が存在しな
い限り、property を non-configurable に
することはできない。
target object に対応する
non-configurable かつ non-writable own
property が存在しない限り、
non-configurable property を
non-writable にすることはできない。
property に対応する target object の
property が存在する場合、その Property
Descriptor を [[DefineOwnProperty]] を用
いて target object に適用しても例外を送出
してはならない。
10.5.7 [[HasProperty]] ( propertyKey )
The [[HasProperty]] internal method of a Proxy exotic object obj takes argument propertyKey (a property key ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? ValidateNonRevokedProxy (obj ) を実行する。 target を obj .[[ProxyTarget]] とする。handler を obj .[[ProxyHandler]] とする。Assert : handler は Object である。trap を ? GetMethod (handler , "has" )
とする。trap が undefined なら、? target .[[HasProperty]] (propertyKey ) を返す。 booleanTrapResult を ToBoolean (? Call (
trap , handler , « target , propertyKey »))
とする。booleanTrapResult が false なら、targetDesc を
? target .[[GetOwnProperty]] (propertyKey ) とする。targetDesc が undefined でなければ、targetDesc .[[Configurable]] が false
なら、TypeError 例外を送出する。extensibleTarget を
? IsExtensible (target ) とする。extensibleTarget が false なら、
TypeError 例外を送出する。booleanTrapResult を返す。
Note
Proxy object に対する [[HasProperty]] は次
の不変条件を強制する:
[[HasProperty]] の結果は Boolean 値である。
property は、target object の
non-configurable own property として存
在する場合、存在しないものとして報告されてはな
らない。
property は、target object の own
property として存在し、かつ target object
が拡張可能でない場合、存在しないものとして報告
されてはならない。
10.5.8 [[Get]] ( propertyKey , receiver )
The [[Get]] internal method of a Proxy exotic object obj takes arguments propertyKey (a property key ) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion . It performs the following steps when called:
? 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 例外を送出する。IsAccessorDescriptor (targetDesc ) が
true かつ targetDesc .[[Get]] が
undefined なら、trapResult が undefined でなけれ
ば、TypeError 例外を送出する。trapResult を返す。
Note
Proxy object に対する [[Get]] は次の不変条
件を強制する:
target object の property が
non-writable かつ non-configurable な
own data property である場合、property
に対して報告される値は、対応する target
object property の値と同じでなければならな
い。
対応する target object property が、
[[Get]] 属性として undefined を持つ
non-configurable own accessor property
である場合、property に対して報告される値
は undefined でなければならない。
10.5.9 [[Set]] ( propertyKey , value , receiver )
The [[Set]] internal method of a Proxy exotic object obj takes arguments propertyKey (a property key ), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? ValidateNonRevokedProxy (obj ) を実行する。 target を obj .[[ProxyTarget]] とする。handler を obj .[[ProxyHandler]] とする。Assert : handler は Object である。trap を ? GetMethod (handler , "set" )
とする。trap が undefined なら、? target .[[Set]] (propertyKey , value , receiver ) を返す。 booleanTrapResult を ToBoolean (? Call (
trap , handler , « target , propertyKey ,
value , receiver »)) とする。booleanTrapResult が false なら、
false を返す。targetDesc を
? target .[[GetOwnProperty]] (propertyKey ) とする。targetDesc が undefined でなく、かつ
targetDesc .[[Configurable]] が false
なら、IsDataDescriptor (targetDesc ) が true
かつ targetDesc .[[Writable]] が false
なら、SameValue (value , targetDesc .[[Value]] )
が false なら、TypeError 例外を送
出する。IsAccessorDescriptor (targetDesc ) が
true なら、targetDesc .[[Set]] が undefined
なら、TypeError 例外を送出する。true を返す。
Note
Proxy object に対する [[Set]] は次の不変条件
を強制する:
[[Set]] の結果は Boolean 値である。
対応する target object property が
non-writable かつ non-configurable な
own data property である場合、その
property の値を対応する target object
property の値と異なるものに変更することはで
きない。
対応する target object property が、
[[Set]] 属性として undefined を持つ
non-configurable own accessor property
である場合、その property の値を設定するこ
とはできない。
10.5.10 [[Delete]] ( propertyKey )
The [[Delete]] internal method of a Proxy exotic object obj takes argument propertyKey (a property key ) and returns either a normal completion containing a Boolean or a throw completion . It performs the following steps when called:
? ValidateNonRevokedProxy (obj ) を実行する。 target を obj .[[ProxyTarget]] とする。handler を obj .[[ProxyHandler]] とする。Assert : handler は Object である。trap を ? GetMethod (handler ,
"deleteProperty" ) とする。trap が undefined なら、? target .[[Delete]] (propertyKey ) を返す。 booleanTrapResult を ToBoolean (? Call (
trap , handler , « target , propertyKey »))
とする。booleanTrapResult が false なら、
false を返す。targetDesc を
? target .[[GetOwnProperty]] (propertyKey ) とする。targetDesc が undefined なら、true
を返す。targetDesc .[[Configurable]] が false な
ら、TypeError 例外を送出する。extensibleTarget を ? IsExtensible (target )
とする。extensibleTarget が false なら、
TypeError 例外を送出する。true を返す。
Note
Proxy object に対する [[Delete]] は次の不変
条件を強制する:
[[Delete]] の結果は Boolean 値である。
property は、target object の
non-configurable own property として存
在する場合、削除されたものとして報告されてはな
らない。
property は、target object の own
property として存在し、かつ target object
が non-extensible である場合、削除されたも
のとして報告されてはならない。
10.5.11 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing a List of property keys or a throw completion . It performs the following steps when called:
? 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 に重複要素が含まれるなら、
TypeError 例外を送出する。extensibleTarget を ? IsExtensible (target )
とする。targetKeys を
? target .[[OwnPropertyKeys]] () とする。Assert : targetKeys は property key の List
である。Assert : targetKeys は重複要素を含まない。targetConfigurableKeys を新しい空の List
とする。targetNonconfigurableKeys を新しい空の
List とする。targetKeys の各要素 key について、次を行うdesc を
? target .[[GetOwnProperty]] (key ) とする。desc が undefined でなく、かつ
desc .[[Configurable]] が false なら、key を targetNonconfigurableKeys に
append する。Else,key を targetConfigurableKeys に
append する。 extensibleTarget が true かつ
targetNonconfigurableKeys が空なら、trapResult を返す。uncheckedResultKeys を、その要素が
trapResult の要素である List とする。targetNonconfigurableKeys の各要素 key
について、次を行うuncheckedResultKeys が key を含まなけ
れば、TypeError 例外を送出する。uncheckedResultKeys から key を除去す
る。extensibleTarget が true なら、
trapResult を返す。targetConfigurableKeys の各要素 key に
ついて、次を行うuncheckedResultKeys が key を含まなけ
れば、TypeError 例外を送出する。uncheckedResultKeys から key を除去す
る。uncheckedResultKeys が空でなければ、
TypeError 例外を送出する。trapResult を返す。
Note
Proxy object に対する [[OwnPropertyKeys]] は
次の不変条件を強制する:
[[OwnPropertyKeys]] の結果は List である。
返される List は重複要素を含まない。
返される List の各要素は property key であ
る。
結果の List は、target object のすべての
non-configurable own property の key を
含まなければならない。
target object が拡張可能でない場合、結果の
List は target object の own property
のすべての key を含み、かつそれ以外の値を含ん
ではならない。
10.5.12 [[Call]] ( thisArgument , argumentsList )
The [[Call]] internal method of a Proxy exotic object obj takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values ) and returns either a normal completion containing an ECMAScript language value or a throw completion . It performs the following steps when called:
? ValidateNonRevokedProxy (obj ) を実行する。 target を obj .[[ProxyTarget]] とする。handler を obj .[[ProxyHandler]] とする。Assert : handler は Object である。trap を ? GetMethod (handler , "apply" )
とする。trap が undefined なら、? Call (target , thisArgument ,
argumentsList ) を返す。 argArray を CreateArrayFromList (argumentsList )
とする。? Call (trap , handler , « target ,
thisArgument , argArray ») を返す。
Note
Proxy 特殊オブジェクト が [[Call]] 内部メソッドを持
つのは、その [[ProxyTarget]] 内部スロットの初期値が
[[Call]] 内部メソッドを持つ object である場合に限られ
る。
10.5.13 [[Construct]] ( argumentsList , newTarget )
The [[Construct]] internal method of a Proxy exotic object obj takes arguments argumentsList (a List of ECMAScript language values ) and newTarget (a constructor ) and returns either a normal completion containing an Object or a throw completion . It performs the following steps when called:
? ValidateNonRevokedProxy (obj ) を実行する。 target を obj .[[ProxyTarget]] とする。Assert : IsConstructor (target ) is true .handler を obj .[[ProxyHandler]] とする。Assert : handler は Object である。trap を ? GetMethod (handler ,
"construct" ) とする。trap が undefined なら、? Construct (target , argumentsList ,
newTarget ) を返す。 argArray を CreateArrayFromList (argumentsList )
とする。newObj を ? Call (trap , handler ,
« target , argArray , newTarget ») とす
る。newObj が Object でなければ、
TypeError 例外を送出する。newObj を返す。
Note 1
Proxy 特殊オブジェクト が [[Construct]] 内部メソッ
ドを持つのは、その [[ProxyTarget]] 内部スロットの初期値
が [[Construct]] 内部メソッドを持つ object である場合
に限られる。
Note 2
Proxy object に対する [[Construct]] は次の不
変条件を強制する:
[[Construct]] の結果は Object でなければなら
ない。
10.5.14 ValidateNonRevokedProxy ( proxy )
The abstract operation ValidateNonRevokedProxy takes argument proxy (a Proxy exotic object ) and returns either a normal completion containing unused or a throw completion . これは、proxy が revoked されている場合に
TypeError 例外を送出する。 It performs the following steps when called:
proxy .[[ProxyTarget]] が null なら、
TypeError 例外を送出する。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 object の作成を規定する
ために用いられる。 It performs the following steps when called:
target が Object でなければ、
TypeError 例外を送出する。handler が Object でなければ、
TypeError 例外を送出する。proxy を MakeBasicObject (
« [[ProxyHandler]] , [[ProxyTarget]] »)
とする。proxy の本質的内部メソッドのうち [[Call]]
および [[Construct]] を除くものを、
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 を返す。