10 일반(Ordinary) 및 이그조틱(Exotic) 객체 동작

10.1 일반 객체의 내부 메서드와 내부 슬롯(Ordinary Object Internal Methods and Internal Slots)

모든 일반 객체[[Prototype]]이라 불리는 내부 슬롯을 가진다. 이 내부 슬롯의 값은 null 혹은 객체이며 상속을 구현하는 데 사용된다. 일반 객체 O 에 속성 P 가 없지만 그 객체의 [[Prototype]] 객체에는 존재한다고 가정하자. P[[Prototype]] 객체의 데이터 프로퍼티를 가리키면 O 는 get 접근에 대해 그것을 상속하여 P 가 마치 O 의 자체 프로퍼티인 것처럼 동작한다. P[[Prototype]] 객체의 쓰기 가능한(writable) 데이터 프로퍼티를 가리키면 O 에서 P 에 대한 set 접근은 O 에 이름이 P 인 새로운 데이터 프로퍼티를 생성한다. P[[Prototype]] 객체의 쓰기 불가능한(non-writable) 데이터 프로퍼티를 가리키면 O 에서 P 에 대한 set 접근은 실패한다. P[[Prototype]] 객체의 접근자(accessor) 프로퍼티를 가리키면 그 접근자는 get 과 set 둘 다에 대해 O 에 상속된다.

모든 일반 객체는 Boolean 값을 갖는 [[Extensible]] 내부 슬롯을 가지며 이는 6.1.7.3 에 명시된 확장성 관련 내부 메서드 불변식을 충족하는 데 사용된다. 즉, 객체의 [[Extensible]] 내부 슬롯 값이 false 로 설정되면 더 이상 그 객체에 새로운 프로퍼티를 추가하거나 객체의 [[Prototype]] 내부 슬롯 값을 수정하거나 이후 [[Extensible]] 값을 true 로 되돌릴 수 없다.

이하의 알고리즘 설명에서 O일반 객체, P프로퍼티 키 값, V 는 임의의 ECMAScript 언어 값, Desc 는 프로퍼티 디스크립터(Property Descriptor) 레코드라고 가정한다.

일반 객체 내부 메서드는 동일하거나 유사한 이름의 추상 연산에 위임한다. 그러한 추상 연산이 또 다른 내부 메서드에 의존하는 경우, 동일 이름의 추상 연산을 직접 호출하지 않고 O 에 그 내부 메서드를 호출한다. 이러한 의미론은 일반 객체 내부 메서드가 이그조틱 객체에 적용될 때 해당 이그조틱 객체가 재정의한 내부 메서드가 호출되도록 보장한다.

10.1.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of 일반 객체 O takes no arguments and returns 객체 또는 null 을 담는 normal completion. It performs the following steps when called:

  1. OrdinaryGetPrototypeOf(O) 를 반환한다.

10.1.1.1 OrdinaryGetPrototypeOf ( O )

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

  1. O.[[Prototype]] 을 반환한다.

10.1.2 [[SetPrototypeOf]] ( V )

The [[SetPrototypeOf]] internal method of 일반 객체 O takes argument V (an Object or null) and returns Boolean 을 담는 normal completion. It performs the following steps when called:

  1. OrdinarySetPrototypeOf(O, V) 를 반환한다.

10.1.2.1 OrdinarySetPrototypeOf ( O, V )

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

  1. currentO.[[Prototype]] 로 둔다.
  2. SameValue(V, current) 가 true 이면 true 를 반환한다.
  3. extensibleO.[[Extensible]] 로 둔다.
  4. extensiblefalse 이면 false 를 반환한다.
  5. pV 로 둔다.
  6. donefalse 로 둔다.
  7. donefalse 인 동안 반복한다,
    1. pnull 이면
      1. donetrue 로 설정한다.
    2. 아니고 SameValue(p, O) 가 true 이면
      1. false 를 반환한다.
    3. 그 밖의 경우,
      1. p.[[GetPrototypeOf]]10.1.1 에 정의된 일반 객체 내부 메서드가 아니면 donetrue 로 설정한다.
      2. 아니면 pp.[[Prototype]] 로 설정한다.
  8. O.[[Prototype]]V 로 설정한다.
  9. true 를 반환한다.
Note

7 단계의 루프는 [[GetPrototypeOf]][[SetPrototypeOf]] 에 대한 일반 객체 정의만 사용하는 객체들로 이루어진 어떤 프로토타입 체인에도 순환이 생기지 않도록 보장한다.

10.1.3 [[IsExtensible]] ( )

The [[IsExtensible]] internal method of 일반 객체 O takes no arguments and returns Boolean 을 담는 normal completion. It performs the following steps when called:

  1. OrdinaryIsExtensible(O) 를 반환한다.

10.1.3.1 OrdinaryIsExtensible ( O )

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

  1. O.[[Extensible]] 를 반환한다.

10.1.4 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of 일반 객체 O takes no arguments and returns true 를 담는 normal completion. It performs the following steps when called:

  1. OrdinaryPreventExtensions(O) 를 반환한다.

10.1.4.1 OrdinaryPreventExtensions ( O )

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

  1. O.[[Extensible]]false 로 설정한다.
  2. true 를 반환한다.

10.1.5 [[GetOwnProperty]] ( P )

The [[GetOwnProperty]] internal method of 일반 객체 O takes argument P (a property key) and returns Property Descriptor 또는 undefined 를 담는 normal completion. It performs the following steps when called:

  1. OrdinaryGetOwnProperty(O, P) 를 반환한다.

10.1.5.1 OrdinaryGetOwnProperty ( O, P )

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

  1. O 가 키 P 인 자체 프로퍼티를 갖지 않으면 undefined 를 반환한다.
  2. 필드가 없는 새 프로퍼티 디스크립터 D 를 생성한다.
  3. X 를 키 PO 의 자체 프로퍼티로 둔다.
  4. X데이터 프로퍼티라면
    1. D.[[Value]]X[[Value]] 속성 값으로 설정한다.
    2. D.[[Writable]]X[[Writable]] 속성 값으로 설정한다.
  5. 그렇지 않으면
    1. 단언: X접근자 프로퍼티이다.
    2. D.[[Get]]X[[Get]] 속성 값으로 설정한다.
    3. D.[[Set]]X[[Set]] 속성 값으로 설정한다.
  6. D.[[Enumerable]]X[[Enumerable]] 속성 값으로 설정한다.
  7. D.[[Configurable]]X[[Configurable]] 속성 값으로 설정한다.
  8. D 를 반환한다.

10.1.6 [[DefineOwnProperty]] ( P, Desc )

The [[DefineOwnProperty]] internal method of 일반 객체 O takes arguments P (a property key) and Desc (a Property Descriptor) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. OrdinaryDefineOwnProperty(O, P, Desc) 를 반환한다.

10.1.6.1 OrdinaryDefineOwnProperty ( O, P, Desc )

The abstract operation OrdinaryDefineOwnProperty takes arguments O (an Object), P (a property key), and Desc (a Property Descriptor) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. current 를 ? O.[[GetOwnProperty]](P) 로 둔다.
  2. extensible 을 ? IsExtensible(O) 로 둔다.
  3. ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current) 를 반환한다.

10.1.6.2 IsCompatiblePropertyDescriptor ( Extensible, Desc, Current )

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

  1. ValidateAndApplyPropertyDescriptor(undefined, "", Extensible, Desc, Current) 를 반환한다.

10.1.6.3 ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current )

The abstract operation ValidateAndApplyPropertyDescriptor takes arguments O (an Object or undefined), P (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 를 반환한다. 적용 가능하고 Oundefined 가 아니면 이름이 P 인 프로퍼티(필요 시 생성됨)에 대해 실제로 적용한다. It performs the following steps when called:

  1. 단언: P프로퍼티 키이다.
  2. currentundefined 이면
    1. extensiblefalse 이면 false 반환.
    2. Oundefined 이면 true 반환.
    3. IsAccessorDescriptor(Desc) 가 true 이면
      1. 객체 O 에 이름 P 인 자체 접근자 프로퍼티를 생성하되 [[Get]], [[Set]], [[Enumerable]], [[Configurable]]Desc 에 해당 필드가 있으면 그 값, 아니면 그 속성의 기본값 으로 설정.
    4. 그렇지 않으면
      1. 객체 O 에 이름 P 인 자체 데이터 프로퍼티를 생성하되 [[Value]], [[Writable]], [[Enumerable]], [[Configurable]]Desc 에 해당 필드가 있으면 그 값, 아니면 그 속성의 기본값 으로 설정.
    5. true 반환.
  3. 단언: current 는 완전히 채워진(Property Descriptor 모든 필드 보유) 프로퍼티 디스크립터이다.
  4. Desc 가 어떤 필드도 갖지 않으면 true 반환.
  5. current.[[Configurable]]false 이면
    1. Desc[[Configurable]] 필드가 있고 Desc.[[Configurable]]true 이면 false 반환.
    2. Desc[[Enumerable]] 필드가 있고 Desc.[[Enumerable]]current.[[Enumerable]] 와 다르면 false 반환.
    3. IsGenericDescriptor(Desc) 가 false 이고 IsAccessorDescriptor(Desc) 가 IsAccessorDescriptor(current) 와 다르면 false 반환.
    4. IsAccessorDescriptor(current) 가 true 이면
      1. Desc[[Get]] 필드가 있고 SameValue(Desc.[[Get]], current.[[Get]]) 가 false 이면 false 반환.
      2. Desc[[Set]] 필드가 있고 SameValue(Desc.[[Set]], current.[[Set]]) 가 false 이면 false 반환.
    5. Else if current.[[Writable]]false 이면
      1. Desc[[Writable]] 필드가 있고 Desc.[[Writable]]true 이면 false 반환.
      2. NOTE: SameValueNaN 에 대해 true 를 반환한다. 여기서 반환하면 기존 프로퍼티가 수정되지 않음을 보장한다.
      3. Desc[[Value]] 필드가 있으면 SameValue(Desc.[[Value]], current.[[Value]]) 를 반환.
  6. Oundefined 가 아니면
    1. IsDataDescriptor(current) 가 true 이고 IsAccessorDescriptor(Desc) 가 true 이면
      1. Desc[[Configurable]] 필드가 있으면 configurable 을 그 값으로, 아니면 current.[[Configurable]] 로 둔다.
      2. Desc[[Enumerable]] 필드가 있으면 enumerable 을 그 값으로, 아니면 current.[[Enumerable]] 로 둔다.
      3. 객체 O 의 이름 P 인 프로퍼티를 접근자 프로퍼티로 교체하되 [[Configurable]][[Enumerable]] 은 각각 configurable, enumerable 로, [[Get]], [[Set]]Desc 에 해당 필드가 있으면 그 값, 아니면 기본값 로 설정.
    2. Else if IsAccessorDescriptor(current) 가 true 이고 IsDataDescriptor(Desc) 가 true 이면
      1. Desc[[Configurable]] 필드가 있으면 configurable 을 그 값으로, 아니면 current.[[Configurable]] 로 둔다.
      2. Desc[[Enumerable]] 필드가 있으면 enumerable 을 그 값으로, 아니면 current.[[Enumerable]] 로 둔다.
      3. 객체 O 의 이름 P 인 프로퍼티를 데이터 프로퍼티로 교체하되 [[Configurable]][[Enumerable]] 은 각각 configurable, enumerable 로, [[Value]], [[Writable]]Desc 에 해당 필드가 있으면 그 값, 아니면 기본값 로 설정.
    3. Else
      1. Desc 의 각 필드에 대해 객체 O 의 이름 P 인 프로퍼티의 대응 속성을 그 필드 값으로 설정.
  7. true 반환.

10.1.7 [[HasProperty]] ( P )

The [[HasProperty]] internal method of 일반 객체 O takes argument P (a property key) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. OrdinaryHasProperty(O, P) 를 반환한다.

10.1.7.1 OrdinaryHasProperty ( O, P )

The abstract operation OrdinaryHasProperty takes arguments O (an Object) and P (a property key) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. hasOwn 을 ? O.[[GetOwnProperty]](P) 로 둔다.
  2. hasOwnundefined 가 아니면 true 반환.
  3. parent 를 ? O.[[GetPrototypeOf]]() 로 둔다.
  4. parentnull 이 아니면
    1. parent.[[HasProperty]](P) 를 반환한다.
  5. false 반환.

10.1.8 [[Get]] ( P, Receiver )

The [[Get]] internal method of 일반 객체 O takes arguments P (a property key) and Receiver (an ECMAScript language value) and returns ECMAScript 언어 값 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. OrdinaryGet(O, P, Receiver) 를 반환한다.

10.1.8.1 OrdinaryGet ( O, P, Receiver )

The abstract operation OrdinaryGet takes arguments O (an Object), P (a property key), and Receiver (an ECMAScript language value) and returns ECMAScript 언어 값 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. desc 를 ? O.[[GetOwnProperty]](P) 로 둔다.
  2. descundefined 이면
    1. parent 를 ? O.[[GetPrototypeOf]]() 로 둔다.
    2. parentnull 이면 undefined 반환.
    3. parent.[[Get]](P, Receiver) 를 반환한다.
  3. IsDataDescriptor(desc) 가 true 이면 desc.[[Value]] 를 반환한다.
  4. 단언: IsAccessorDescriptor(desc) 는 true 이다.
  5. getterdesc.[[Get]] 로 둔다.
  6. getterundefined 이면 undefined 반환.
  7. Call(getter, Receiver) 를 반환한다.

10.1.9 [[Set]] ( P, V, Receiver )

The [[Set]] internal method of 일반 객체 O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. OrdinarySet(O, P, V, Receiver) 를 반환한다.

10.1.9.1 OrdinarySet ( O, P, V, Receiver )

The abstract operation OrdinarySet takes arguments O (an Object), P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. ownDesc 를 ? O.[[GetOwnProperty]](P) 로 둔다.
  2. OrdinarySetWithOwnDescriptor(O, P, V, Receiver, ownDesc) 를 반환한다.

10.1.9.2 OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc )

The abstract operation OrdinarySetWithOwnDescriptor takes arguments O (an Object), P (a property key), V (an ECMAScript language value), Receiver (an ECMAScript language value), and ownDesc (a Property Descriptor or undefined) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. ownDescundefined 이면
    1. parent 를 ? O.[[GetPrototypeOf]]() 로 둔다.
    2. parentnull 이 아니면
      1. parent.[[Set]](P, V, Receiver) 를 반환한다.
    3. 그렇지 않으면
      1. ownDesc 를 PropertyDescriptor { [[Value]]: undefined, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true } 로 설정한다.
  2. IsDataDescriptor(ownDesc) 가 true 이면
    1. ownDesc.[[Writable]]false 이면 false 반환.
    2. Receiver 가 객체가 아니면 false 반환.
    3. existingDescriptor 를 ? Receiver.[[GetOwnProperty]](P) 로 둔다.
    4. existingDescriptorundefined 가 아니면
      1. IsAccessorDescriptor(existingDescriptor) 가 true 이면 false 반환.
      2. existingDescriptor.[[Writable]]false 이면 false 반환.
      3. valueDesc 를 PropertyDescriptor { [[Value]]: V } 로 둔다.
      4. Receiver.[[DefineOwnProperty]](P, valueDesc) 를 반환한다.
    5. 그렇지 않으면
      1. 단언: Receiver 는 현재 프로퍼티 P 를 갖지 않는다.
      2. CreateDataProperty(Receiver, P, V) 를 반환한다.
  3. 단언: IsAccessorDescriptor(ownDesc) 는 true 이다.
  4. setterownDesc.[[Set]] 로 둔다.
  5. setterundefined 이면 false 반환.
  6. Call(setter, Receiver, « V ») 를 수행한다.
  7. true 반환.

10.1.10 [[Delete]] ( P )

The [[Delete]] internal method of 일반 객체 O takes argument P (a property key) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. OrdinaryDelete(O, P) 를 반환한다.

10.1.10.1 OrdinaryDelete ( O, P )

The abstract operation OrdinaryDelete takes arguments O (an Object) and P (a property key) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. desc 를 ? O.[[GetOwnProperty]](P) 로 둔다.
  2. descundefined 이면 true 반환.
  3. desc.[[Configurable]]true 이면
    1. 이름 P 인 자체 프로퍼티를 O 에서 제거한다.
    2. true 반환.
  4. false 반환.

10.1.11 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of 일반 객체 O takes no arguments and returns 프로퍼티 키 List 를 담는 normal completion. It performs the following steps when called:

  1. OrdinaryOwnPropertyKeys(O) 를 반환한다.

10.1.11.1 OrdinaryOwnPropertyKeys ( O )

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

  1. keys 를 새 빈 List 로 둔다.
  2. O 의 각 자체 프로퍼티 키 PP배열 인덱스인 것들을 숫자 인덱스 오름차순으로 순회하며
    1. keysP 를 추가한다.
  3. O 의 각 자체 프로퍼티 키 PP 가 String 이고 배열 인덱스가 아닌 것들을 생성 시점의 시간 순(chronological order) 오름차순으로 순회하며
    1. keysP 를 추가한다.
  4. O 의 각 자체 프로퍼티 키 PP 가 Symbol 인 것들을 생성 시점의 시간 순 오름차순으로 순회하며
    1. keysP 를 추가한다.
  5. keys 를 반환한다.

10.1.12 OrdinaryObjectCreate ( proto [ , additionalInternalSlotsList ] )

The abstract operation OrdinaryObjectCreate takes argument proto (an Object or null) and optional argument additionalInternalSlotsList (a List of names of internal slots) and returns an Object. 새 일반 객체를 런타임에 생성하는 과정을 명세하는 데 사용된다. additionalInternalSlotsList[[Prototype]][[Extensible]] 외에 객체 일부로 정의되어야 하는 추가 내부 슬롯 이름을 담는다. additionalInternalSlotsList 가 제공되지 않으면 새 빈 List 를 사용한다. It performs the following steps when called:

  1. internalSlotsList 를 « [[Prototype]], [[Extensible]] » 로 둔다.
  2. additionalInternalSlotsList 가 주어지면 internalSlotsList 를 그 뒤에 additionalInternalSlotsList 를 이어붙인(list-concatenation) 리스트로 갱신한다.
  3. OMakeBasicObject(internalSlotsList) 로 둔다.
  4. O.[[Prototype]]proto 로 설정한다.
  5. O 를 반환한다.
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 객체 또는 throw completion 을 담는 normal completion. 생성자"prototype" 프로퍼티가 존재하면 거기서 가져온 값을 [[Prototype]] 으로 하는 일반 객체를 생성한다. 그렇지 않으면 intrinsicDefaultProto 로 명명된 intrinsic 이 [[Prototype]] 으로 사용된다. internalSlotsList 는 객체 일부로 정의되어야 하는 추가 내부 슬롯 이름을 담으며 제공되지 않으면 새 빈 List 를 사용한다. It performs the following steps when called:

  1. 단언: intrinsicDefaultProto 는 이 명세에서 정의한 intrinsic 객체의 이름이다. 해당 객체는 다른 객체의 [[Prototype]] 값으로 사용되도록 의도된 intrinsic 이어야 한다.
  2. proto 를 ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) 로 둔다.
  3. internalSlotsList 가 존재하면 slotsListinternalSlotsList 로 둔다.
  4. 아니면 slotsList 를 새 빈 List 로 둔다.
  5. OrdinaryObjectCreate(proto, slotsList) 를 반환한다.

10.1.14 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )

The abstract operation GetPrototypeFromConstructor takes arguments constructor (a function object) and intrinsicDefaultProto (a String) and returns 객체 또는 throw completion 을 담는 normal completion. 특정 생성자에 대응하는 객체를 만들 때 사용할 [[Prototype]] 값을 결정한다. 생성자"prototype" 프로퍼티가 존재하면 그 값이 사용되고, 그렇지 않으면 intrinsicDefaultProto 로 명명된 intrinsic 이 [[Prototype]] 으로 사용된다. It performs the following steps when called:

  1. 단언: intrinsicDefaultProto 는 이 명세에서 정의한 intrinsic 객체의 이름이다. 해당 객체는 객체의 [[Prototype]] 값으로 사용되도록 의도된 intrinsic 이어야 한다.
  2. proto 를 ? Get(constructor, "prototype") 로 둔다.
  3. proto 가 객체가 아니면
    1. realm 을 ? GetFunctionRealm(constructor) 로 둔다.
    2. protorealmintrinsicDefaultProto 라는 이름의 intrinsic 객체로 설정한다.
  4. proto 를 반환한다.
Note

constructor[[Prototype]] 값을 제공하지 않으면 사용되는 기본값은 실행 중인 실행 컨텍스트가 아니라 constructor 함수의 realm 에서 얻는다.

10.1.15 RequireInternalSlot ( O, internalSlot )

The abstract operation RequireInternalSlot takes arguments O (an ECMAScript language value) and internalSlot (an internal slot name) and returns unused 또는 throw completion 을 담는 normal completion. O 가 객체가 아니거나 지정된 내부 슬롯을 가지지 않으면 예외를 던진다. It performs the following steps when called:

  1. O 가 객체가 아니면 TypeError 예외를 던진다.
  2. OinternalSlot 내부 슬롯이 없으면 TypeError 예외를 던진다.
  3. unused 를 반환한다.

10.2 ECMAScript 함수 객체(ECMAScript Function Objects)

ECMAScript 함수 객체는 렉시컬 환경을 클로즈(over)한 매개변수화된 ECMAScript 코드를 캡슐화하며 그 코드를 동적으로 평가할 수 있게 해준다. ECMAScript 함수 객체일반 객체(ordinary object)이며 다른 일반 객체와 동일한 내부 슬롯과 내부 메서드를 가진다. ECMAScript 함수 객체의 코드는 strict 모드 코드(11.2.2) 또는 비 strict 코드일 수 있다. 코드가 strict 모드 코드인 ECMAScript 함수 객체strict 함수라 한다. 코드가 strict 모드 코드가 아닌 것을 non‑strict 함수라 한다.

[[Extensible]][[Prototype]] 외에도, ECMAScript 함수 객체Table 28에 나열된 내부 슬롯을 추가로 가진다.

Table 28: ECMAScript 함수 객체의 내부 슬롯(Internal Slots of ECMAScript Function Objects)
Internal Slot Type Description
[[Environment]] an Environment Record 함수가 클로즈한 Environment Record. 함수 코드 평가 시 외부 환경(outer environment)으로 사용.
[[PrivateEnvironment]] a PrivateEnvironment Record or null 함수가 클로즈한 Private NamePrivateEnvironment Record. 함수가 문법적으로 어떤 클래스 내부에도 포함되지 않았다면 null. 함수 코드 평가 시 내부 클래스들의 외부 PrivateEnvironment로 사용.
[[FormalParameters]] a Parse Node 함수의 형식 매개변수 목록을 정의하는 소스 텍스트의 루트 Parse Node.
[[ECMAScriptCode]] a Parse Node 함수 본문을 정의하는 소스 텍스트의 루트 Parse Node.
[[ConstructorKind]] base or derived 함수가 파생 클래스 생성자인지 여부.
[[Realm]] a Realm Record 함수가 생성된 realm이며 함수 평가 시 접근되는 intrinsic 객체들을 제공.
[[ScriptOrModule]] a Script Record or a Module Record 함수가 생성된 스크립트 또는 모듈.
[[ThisMode]] lexical, strict, or global this 참조가 형식 매개변수 및 함수 본문 내에서 어떻게 해석되는지 정의. lexicalthis 가 렉시컬로 둘러싼 함수의 this 값을 가리킴. strictthis 값이 호출 시 제공된 그대로 사용됨. globalundefined 또는 nullthis 값을 전역 객체 참조로 해석하고, 다른 this 값은 먼저 ToObject 적용.
[[Strict]] a Boolean true 이면 strict 함수, false 이면 non‑strict 함수.
[[HomeObject]] an Object 함수가 super를 사용한다면, super 프로퍼티 조회의 시작점을 제공하는 [[GetPrototypeOf]] 대상 객체.
[[SourceText]] a sequence of Unicode code points 함수를 정의하는 소스 텍스트.
[[Fields]] a List of ClassFieldDefinition Records 함수가 클래스라면, 비정적 필드 및 그 초기화자를 나타내는 Record들의 목록.
[[PrivateMethods]] a List of PrivateElements 함수가 클래스라면, 비정적 private 메서드 및 접근자들을 나타내는 목록.
[[ClassFieldInitializerName]] a String, a Symbol, a Private Name, or empty 함수가 클래스 필드 초기화자로 생성된 경우, 필드의 NamedEvaluation에 사용할 이름; 그렇지 않으면 empty.
[[IsClassConstructor]] a Boolean 함수가 클래스 생성자인지 나타냄. (true 이면 함수의 [[Call]] 호출은 즉시 TypeError 예외 throw).

모든 ECMAScript 함수 객체는 여기 정의된 [[Call]] 내부 메서드를 가진다. 동시에 생성자인 ECMAScript 함수는 추가로 [[Construct]] 내부 메서드를 가진다.

10.2.1 [[Call]] ( thisArgument, argumentsList )

The [[Call]] internal method of ECMAScript 함수 객체 F takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns ECMAScript 언어 값 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. callerContext 를 실행 중 실행 컨텍스트로 둔다.
  2. calleeContextPrepareForOrdinaryCall(F, undefined) 로 둔다.
  3. 단언: calleeContext 가 이제 실행 중 실행 컨텍스트.
  4. F.[[IsClassConstructor]]true 이면
    1. TypeError 객체 error 를 생성한다.
    2. NOTE: errorcalleeContext 에서 FRealm Record 로 생성된다.
    3. 실행 컨텍스트 스택에서 calleeContext 를 제거하고 callerContext 를 실행 중 실행 컨텍스트로 복원한다.
    4. ThrowCompletion(error) 를 반환한다.
  5. OrdinaryCallBindThis(F, calleeContext, thisArgument) 를 수행한다.
  6. resultCompletion(OrdinaryCallEvaluateBody(F, argumentsList)) 로 둔다.
  7. 실행 컨텍스트 스택에서 calleeContext 를 제거하고 callerContext 를 실행 중 실행 컨텍스트로 복원한다.
  8. resultreturn completion 이면 result.[[Value]] 반환.
  9. 단언: resultthrow completion.
  10. result 를 반환한다.
Note

단계 7 에서 calleeContext 가 스택에서 제거될 때 접근 가능한 Generator 에 의해 나중 재개를 위해 suspend 및 보존된 경우 파괴되면 안 된다.

10.2.1.1 PrepareForOrdinaryCall ( F, newTarget )

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

  1. callerContext 를 실행 중 실행 컨텍스트로 둔다.
  2. calleeContext 를 새 ECMAScript 코드 실행 컨텍스트로 둔다.
  3. calleeContext 의 Function 을 F 로 설정.
  4. calleeRealmF.[[Realm]] 로 둔다.
  5. calleeContextRealmcalleeRealm 으로 설정.
  6. calleeContext 의 ScriptOrModule 을 F.[[ScriptOrModule]] 로 설정.
  7. localEnvNewFunctionEnvironment(F, newTarget) 로 둔다.
  8. calleeContext 의 LexicalEnvironment 를 localEnv 로 설정.
  9. calleeContext 의 VariableEnvironment 를 localEnv 로 설정.
  10. calleeContext 의 PrivateEnvironment 를 F.[[PrivateEnvironment]] 로 설정.
  11. callerContext 가 아직 suspend 되어 있지 않다면 suspend 한다.
  12. calleeContext 를 실행 컨텍스트 스택에 push; calleeContext 가 이제 실행 중 실행 컨텍스트.
  13. NOTE: 이 지점 이후 생성되는 모든 예외 객체는 calleeRealm 과 연관됨.
  14. calleeContext 반환.

10.2.1.2 OrdinaryCallBindThis ( F, calleeContext, thisArgument )

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

  1. thisModeF.[[ThisMode]] 로 둔다.
  2. thisModelexical 이면 unused 반환.
  3. calleeRealmF.[[Realm]] 로 둔다.
  4. localEnvcalleeContext 의 LexicalEnvironment 로 둔다.
  5. thisModestrict 이면
    1. thisValuethisArgument 로 둔다.
  6. 그렇지 않으면
    1. thisArgumentundefined 또는 null 이면
      1. globalEnvcalleeRealm.[[GlobalEnv]] 로 둔다.
      2. 단언: globalEnvGlobal Environment Record.
      3. thisValueglobalEnv.[[GlobalThisValue]] 로 둔다.
    2. 아니면
      1. thisValue 를 ! ToObject(thisArgument) 로 둔다.
      2. NOTE: ToObjectcalleeRealm 을 사용하여 wrapper 객체를 생성.
  7. 단언: localEnvFunction Environment Record.
  8. 단언: 다음 단계는 localEnv.[[ThisBindingStatus]]initialized 가 아니므로 abrupt completion 을 반환하지 않는다.
  9. BindThisValue(localEnv, thisValue) 수행.
  10. unused 반환.

10.2.1.3 Runtime Semantics: EvaluateBody

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

FunctionBody : FunctionStatementList
  1. FunctionBody 의 EvaluateFunctionBody (인수 functionObject, argumentsList) ? 를 반환.
ConciseBody : ExpressionBody
  1. ConciseBody 의 EvaluateConciseBody (인수 functionObject, argumentsList) ? 를 반환.
GeneratorBody : FunctionBody
  1. GeneratorBody 의 EvaluateGeneratorBody (인수 functionObject, argumentsList) ? 를 반환.
AsyncGeneratorBody : FunctionBody
  1. AsyncGeneratorBody 의 EvaluateAsyncGeneratorBody (인수 functionObject, argumentsList) ? 를 반환.
AsyncFunctionBody : FunctionBody
  1. AsyncFunctionBody 의 EvaluateAsyncFunctionBody (인수 functionObject, argumentsList) ? 를 반환.
AsyncConciseBody : ExpressionBody
  1. AsyncConciseBody 의 EvaluateAsyncConciseBody (인수 functionObject, argumentsList) ? 를 반환.
Initializer : = AssignmentExpression
  1. 단언: argumentsList 는 비어 있다.
  2. 단언: functionObject.[[ClassFieldInitializerName]]empty 가 아니다.
    1. IsAnonymousFunctionDefinition(AssignmentExpression) 이 true 이면
      1. valueInitializer 의 NamedEvaluation (인수 functionObject.[[ClassFieldInitializerName]]) ? 로 둔다.
    2. 그렇지 않으면
      1. rhsAssignmentExpression 의 Evaluation ? 로 둔다.
      2. value 를 ? GetValue(rhs) 로 둔다.
  3. ReturnCompletion(value) 를 반환.
Note

필드 초기화자는 함수 경계를 형성하지만 FunctionDeclarationInstantiation 호출은 관측 가능한 효과가 없으므로 생략된다.

ClassStaticBlockBody : ClassStaticBlockStatementList
  1. 단언: argumentsList 는 비어 있다.
  2. ClassStaticBlockBody 의 EvaluateClassStaticBlockBody (인수 functionObject) ? 를 반환.

10.2.1.4 OrdinaryCallEvaluateBody ( F, argumentsList )

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

  1. F.[[ECMAScriptCode]]EvaluateBody (인수 F, argumentsList) ? 를 반환.

10.2.2 [[Construct]] ( argumentsList, newTarget )

The [[Construct]] internal method of ECMAScript 함수 객체 F takes arguments argumentsList (a List of ECMAScript language values) and newTarget (a constructor) and returns 객체 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. callerContext 를 실행 중 실행 컨텍스트로 둔다.
  2. kindF.[[ConstructorKind]] 로 둔다.
  3. kindbase 이면
    1. thisArgument 를 ? OrdinaryCreateFromConstructor(newTarget, "%Object.prototype%") 로 둔다.
  4. calleeContextPrepareForOrdinaryCall(F, newTarget) 로 둔다.
  5. 단언: calleeContext 가 이제 실행 중 실행 컨텍스트.
  6. kindbase 이면
    1. OrdinaryCallBindThis(F, calleeContext, thisArgument) 수행.
    2. initializeResultCompletion(InitializeInstanceElements(thisArgument, F)) 로 둔다.
    3. initializeResultabrupt completion 이면
      1. 실행 컨텍스트 스택에서 calleeContext 제거 후 callerContext 복원.
      2. initializeResult 반환.
  7. constructorEnvcalleeContext 의 LexicalEnvironment 로 둔다.
  8. resultCompletion(OrdinaryCallEvaluateBody(F, argumentsList)) 로 둔다.
  9. 실행 컨텍스트 스택에서 calleeContext 제거 후 callerContext 복원.
  10. resultthrow completion 이면
    1. result 반환.
  11. 단언: resultreturn completion.
  12. result.[[Value]] 가 객체이면 그 값 반환.
  13. kindbase 이면 thisArgument 반환.
  14. result.[[Value]]undefined 가 아니면 TypeError 예외 throw.
  15. thisBinding 을 ? constructorEnv.GetThisBinding() 로 둔다.
  16. 단언: thisBinding 은 객체.
  17. thisBinding 반환.

10.2.3 OrdinaryFunctionCreate ( functionPrototype, sourceText, ParameterList, Body, thisMode, env, privateEnv )

The abstract operation OrdinaryFunctionCreate takes arguments functionPrototype (an Object), sourceText (a sequence of Unicode code points), ParameterList (a Parse Node), Body (a Parse Node), thisMode (lexical-this or non-lexical-this), env (an Environment Record), and privateEnv (a PrivateEnvironment Record or null) and returns an ECMAScript function object. 기본 [[Call]] 내부 메서드만 있고 [[Construct]] 내부 메서드는 없는(단, 이후 MakeConstructor 같은 연산으로 추가될 수 있음) 새 함수를 런타임에 생성하는 과정을 명세한다. sourceText 는 생성할 함수 문법 정의의 소스 텍스트. It performs the following steps when called:

  1. internalSlotsListTable 28 에 나열된 내부 슬롯으로 둔다.
  2. FOrdinaryObjectCreate(functionPrototype, internalSlotsList) 로 둔다.
  3. F.[[Call]]10.2.1 에 명시된 정의로 설정.
  4. F.[[SourceText]]sourceText 로 설정.
  5. F.[[FormalParameters]]ParameterList 로 설정.
  6. F.[[ECMAScriptCode]]Body 로 설정.
  7. Strict 를 IsStrict(Body) 로 둔다.
  8. F.[[Strict]]Strict 로 설정.
  9. thisModelexical-this 이면 F.[[ThisMode]]lexical 로 설정.
  10. Else if Stricttrue 이면 F.[[ThisMode]]strict 로 설정.
  11. Else F.[[ThisMode]]global 로 설정.
  12. F.[[IsClassConstructor]]false 로 설정.
  13. F.[[Environment]]env 로 설정.
  14. F.[[PrivateEnvironment]]privateEnv 로 설정.
  15. F.[[ScriptOrModule]]GetActiveScriptOrModule() 로 설정.
  16. F.[[Realm]]current Realm Record 로 설정.
  17. F.[[HomeObject]]undefined 로 설정.
  18. F.[[Fields]] 를 새 빈 List 로 설정.
  19. F.[[PrivateMethods]] 를 새 빈 List 로 설정.
  20. F.[[ClassFieldInitializerName]]empty 로 설정.
  21. lenParameterList 의 ExpectedArgumentCount 로 둔다.
  22. SetFunctionLength(F, len) 수행.
  23. F 반환.

10.2.4 AddRestrictedFunctionProperties ( F, realm )

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

  1. 단언: realm.[[Intrinsics]].[[%ThrowTypeError%]] 가 존재하며 초기화됨.
  2. throwerrealm.[[Intrinsics]].[[%ThrowTypeError%]] 로 둔다.
  3. DefinePropertyOrThrow(F, "caller", PropertyDescriptor { [[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: true }) 수행.
  4. DefinePropertyOrThrow(F, "arguments", PropertyDescriptor { [[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: true }) 수행.
  5. unused 반환.

10.2.4.1 %ThrowTypeError% ( )

이 함수는 %ThrowTypeError% intrinsic 객체이다.

realm 마다 한 번 정의되는 익명 내장 함수 객체이다.

호출 시 다음 단계를 수행한다:

  1. TypeError 예외를 throw 한다.

이 함수의 [[Extensible]] 내부 슬롯 값은 false 이다.

이 함수의 "length" 프로퍼티 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

이 함수의 "name" 프로퍼티 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

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

The abstract operation MakeConstructor takes argument F (an ECMAScript function object or a built-in function object) and optional arguments writablePrototype (a Boolean) and prototype (an Object) and returns unused. F생성자로 변환한다. It performs the following steps when called:

  1. F 가 ECMAScript 함수 객체이면
    1. 단언: IsConstructor(F) 는 false.
    2. 단언: F"prototype" 자체 프로퍼티가 없는 extensible 객체.
    3. F.[[Construct]]10.2.2 에 명시된 정의로 설정.
  2. 그렇지 않으면
    1. F.[[Construct]]10.3.2 에 명시된 정의로 설정.
  3. F.[[ConstructorKind]]base 로 설정.
  4. writablePrototype 이 제공되지 않았다면 true 로 설정.
  5. prototype 이 제공되지 않았다면
    1. prototypeOrdinaryObjectCreate(%Object.prototype%) 로 둔다.
    2. DefinePropertyOrThrow(prototype, "constructor", PropertyDescriptor { [[Value]]: F, [[Writable]]: writablePrototype, [[Enumerable]]: false, [[Configurable]]: true }) 수행.
  6. DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]: prototype, [[Writable]]: writablePrototype, [[Enumerable]]: false, [[Configurable]]: false }) 수행.
  7. unused 반환.

10.2.6 MakeClassConstructor ( F )

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

  1. 단언: F.[[IsClassConstructor]]false.
  2. F.[[IsClassConstructor]]true 로 설정.
  3. unused 반환.

10.2.7 MakeMethod ( F, homeObject )

The abstract operation MakeMethod takes arguments F (an ECMAScript function object) and homeObject (an Object) and returns unused. F 를 메서드로 구성한다. It performs the following steps when called:

  1. 단언: homeObject일반 객체.
  2. F.[[HomeObject]]homeObject 로 설정.
  3. unused 반환.

10.2.8 DefineMethodProperty ( homeObject, key, closure, enumerable )

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

  1. 단언: homeObject 는 ordinary 이며 extensible 한 객체.
  2. keyPrivate Name 이면
    1. PrivateElement { [[Key]]: key, [[Kind]]: method, [[Value]]: closure } 를 반환.
  3. 그렇지 않으면
    1. desc 를 PropertyDescriptor { [[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true } 로 둔다.
    2. DefinePropertyOrThrow(homeObject, key, desc) 수행.
    3. NOTE: key"prototype" 인 class static method 정의 시에만 abrupt completion 반환 가능.
    4. unused 반환.

10.2.9 SetFunctionName ( F, name [ , prefix ] )

The abstract operation SetFunctionName takes arguments F (a function object) and name (a property key or Private Name) and optional argument prefix (a String) and returns unused. F"name" 프로퍼티를 추가한다. It performs the following steps when called:

  1. 단언: F"name" 자체 프로퍼티가 없는 extensible 객체.
  2. name 이 Symbol 이면
    1. descriptionname.[[Description]] 로 둔다.
    2. descriptionundefined 이면 name 을 빈 문자열로 설정.
    3. 그렇지 않으면 name"[", description, "]" 의 문자열 연결로 설정.
  3. Else if namePrivate Name 이면
    1. namename.[[Description]] 로 설정.
  4. F[[InitialName]] 내부 슬롯을 가진다면
    1. F.[[InitialName]]name 으로 설정.
  5. prefix 가 존재하면
    1. name 을 (prefix + 0x0020(SPACE) + name) 문자열 연결로 설정.
    2. F[[InitialName]] 내부 슬롯을 가진다면
      1. NOTE: 다음 선택은 이 Abstract Operation 이 호출될 때마다 독립적으로 이루어짐.
      2. 선택적으로 F.[[InitialName]]name 으로 설정.
  6. DefinePropertyOrThrow(F, "name", PropertyDescriptor { [[Value]]: name, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }) 수행.
  7. unused 반환.

10.2.10 SetFunctionLength ( F, length )

The abstract operation SetFunctionLength takes arguments F (a function object) and length (a non-negative integer or +∞) and returns unused. F"length" 프로퍼티를 추가한다. It performs the following steps when called:

  1. 단언: F"length" 자체 프로퍼티가 없는 extensible 객체.
  2. DefinePropertyOrThrow(F, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }) 수행.
  3. unused 반환.

10.2.11 FunctionDeclarationInstantiation ( func, argumentsList )

The abstract operation FunctionDeclarationInstantiation takes arguments func (an ECMAScript function object) and argumentsList (a List of ECMAScript language values) and returns unused 를 담는 normal completion 또는 throw completion. func 는 실행 컨텍스트를 설정 중인 함수 객체이다.

Note

ECMAScript 함수를 평가하기 위한 실행 컨텍스트가 설정될 때 새로운 Function Environment Record 가 생성되고 각 형식 매개변수에 대한 바인딩이 그 Environment Record 에서 인스턴스화된다. 함수 본문 내 모든 선언도 인스턴스화된다. 함수의 형식 매개변수에 기본값 초기화자가 없으면 본문 선언들은 매개변수와 동일한 Environment Record 에서 인스턴스화된다. 기본값 매개변수 초기화자가 있으면 본문 선언을 위한 두 번째 Environment Record 가 생성된다. 형식 매개변수와 함수들은 FunctionDeclarationInstantiation 의 일부로 초기화된다. 다른 모든 바인딩은 함수 본문 평가 중 초기화된다.

호출 시 다음 단계를 수행한다:

  1. calleeContext 를 실행 중 실행 컨텍스트로 둔다.
  2. codefunc.[[ECMAScriptCode]] 로 둔다.
  3. strictfunc.[[Strict]] 로 둔다.
  4. formalsfunc.[[FormalParameters]] 로 둔다.
  5. parameterNamesformals 의 BoundNames 로 둔다.
  6. parameterNames 가 중복 항목을 가지면 hasDuplicatestrue, 아니면 false 로 둔다.
  7. simpleParameterList 를 IsSimpleParameterList of formals 로 둔다.
  8. hasParameterExpressions 를 ContainsExpression of formals 로 둔다.
  9. varNamescode 의 VarDeclaredNames 로 둔다.
  10. varDeclarationscode 의 VarScopedDeclarations 로 둔다.
  11. lexicalNamescode 의 LexicallyDeclaredNames 로 둔다.
  12. functionNames 를 새 빈 List 로 둔다.
  13. functionsToInitialize 를 새 빈 List 로 둔다.
  14. varDeclarations 의 각 요소 d 에 대해 (역순으로):
    1. dVariableDeclaration, ForBinding, BindingIdentifier 가 아니면
      1. 단언: dFunctionDeclaration, GeneratorDeclaration, AsyncFunctionDeclaration, AsyncGeneratorDeclaration 중 하나.
      2. fnd 의 BoundNames 의 유일한 요소로 둔다.
      3. functionNamesfn 을 포함하지 않으면
        1. fnfunctionNames 의 첫 요소로 삽입.
        2. NOTE: 동일 이름 함수 선언이 여러 개면 마지막 선언 사용.
        3. dfunctionsToInitialize 의 첫 요소로 삽입.
  15. argumentsObjectNeededtrue 로 둔다.
  16. func.[[ThisMode]]lexical 이면
    1. NOTE: 화살표 함수는 arguments 객체를 갖지 않는다.
    2. argumentsObjectNeededfalse 로 설정.
  17. Else if parameterNames"arguments" 를 포함하면
    1. argumentsObjectNeededfalse 로.
  18. Else if hasParameterExpressionsfalse 이면
    1. functionNames"arguments" 를 포함하거나 lexicalNames"arguments" 를 포함하면
      1. argumentsObjectNeededfalse 로.
  19. stricttrue 이거나 hasParameterExpressionsfalse 이면
    1. NOTE: strict 모드 eval 은 외부에서 보이는 새 바인딩을 만들 수 없으므로 매개변수에 단일 Environment Record 만 필요.
    2. envcalleeContext 의 LexicalEnvironment 로 둔다.
  20. Else
    1. NOTE: 형식 매개변수 리스트 내 direct eval 이 만든 바인딩이 매개변수 선언 환경 밖에 위치하도록 분리된 Environment Record 필요.
    2. calleeEnvcalleeContext 의 LexicalEnvironment 로 둔다.
    3. envNewDeclarativeEnvironment(calleeEnv) 로 둔다.
    4. 단언: calleeContext 의 VariableEnvironment 와 calleeEnv 는 동일한 Environment Record.
    5. calleeContext 의 LexicalEnvironment 를 env 로 설정.
  21. parameterNames 의 각 String paramName 에 대해
    1. alreadyDeclared 를 ! env.HasBinding(paramName) 로 둔다.
    2. NOTE: 중복 매개변수 이름은 기본값/나머지 매개변수 없는 non‑strict 함수에만 가능(초기 에러 규칙).
    3. alreadyDeclaredfalse 이면
      1. env.CreateMutableBinding(paramName, false) 수행.
      2. hasDuplicatestrue 이면
        1. env.InitializeBinding(paramName, undefined) 수행.
  22. argumentsObjectNeededtrue 이면
    1. stricttrue 이거나 simpleParameterListfalse 이면
      1. aoCreateUnmappedArgumentsObject(argumentsList) 로 둔다.
    2. Else
      1. NOTE: mapped arguments 객체는 rest, 기본값, 구조분해 매개변수 없는 non‑strict 함수에만 제공.
      2. aoCreateMappedArgumentsObject(func, formals, argumentsList, env) 로 둔다.
    3. stricttrue 이면
      1. env.CreateImmutableBinding("arguments", false) 수행.
      2. NOTE: strict 코드에서는 이 바인딩에 할당 시도 자체가 조기 에러로 금지되어 불변성 관측 불가.
    4. Else
      1. env.CreateMutableBinding("arguments", false) 수행.
    5. env.InitializeBinding("arguments", ao) 수행.
    6. parameterBindingsparameterNames 와 « "arguments" » 의 리스트 연결로 둔다.
  23. Else
    1. parameterBindingsparameterNames 로 둔다.
  24. iteratorRecordCreateListIteratorRecord(argumentsList) 로 둔다.
  25. hasDuplicatestrue 이면
    1. usedEnvundefined 로 둔다.
  26. Else
    1. usedEnvenv 로 둔다.
  27. NOTE: 다음 단계는 표현식 위치에서 YieldExpression 사용으로만 ReturnCompletion 이 가능하나 파라미터 리스트에서 조기 에러로 금지됨.
  28. ? IteratorBindingInitialization of formals (인수 iteratorRecord, usedEnv) 수행.
  29. hasParameterExpressionsfalse 이면
    1. NOTE: 매개변수와 최상위 var 에 단일 Environment Record 사용.
    2. instantiatedVarNamesparameterBindings 복사본으로 둔다.
    3. varNames 의 각 n 에 대해
      1. instantiatedVarNamesn 을 포함하지 않으면
        1. instantiatedVarNamesn 추가.
        2. env.CreateMutableBinding(n, false) 수행.
        3. env.InitializeBinding(n, undefined) 수행.
    4. varEnvenv 로 둔다.
  30. Else
    1. NOTE: 형식 매개변수 표현식이 만든 클로저가 함수 본문 선언을 보지 못하도록 별도 Environment Record 필요.
    2. varEnvNewDeclarativeEnvironment(env) 로 둔다.
    3. calleeContext 의 VariableEnvironment 를 varEnv 로 설정.
    4. instantiatedVarNames 를 새 빈 List 로 둔다.
    5. varNames 의 각 n 에 대해
      1. instantiatedVarNamesn 을 포함하지 않으면
        1. instantiatedVarNamesn 추가.
        2. varEnv.CreateMutableBinding(n, false) 수행.
        3. (parameterBindingsn 을 포함하지 않거나 functionNamesn 을 포함하면)
          1. initialValueundefined 로 둔다.
        4. Else
          1. initialValue 를 ! env.GetBindingValue(n, false) 로 둔다.
        5. varEnv.InitializeBinding(n, initialValue) 수행.
        6. NOTE: 형식 매개변수와 같은 이름의 var 는 초기에는 해당 매개변수 초기화 값과 동일.
  31. stricttrue 이면
    1. lexEnvvarEnv 로 둔다.
  32. Else
    1. Normative Optional
      호스트가 웹 브라우저이거나 블록 수준 함수 선언 웹 레거시 호환 의미 를 지원하면
      1. code Contains xtrue 인 어떤 Block, CaseClause, DefaultClause xStatementList 에 직접 포함된 각 FunctionDeclaration f 에 대해
        1. FfBindingIdentifier 의 StringValue 로 둔다.
        2. FunctionDeclaration fFBindingIdentifier 로 갖는 VariableStatement 로 대체해도 func 에 대해 Early Errors 가 발생하지 않고 parameterNamesF 를 포함하지 않으면
          1. NOTE: F 에 대한 var 바인딩은 VarDeclaredName 이 아니고 형식 매개변수 이름도 아니며 다른 FunctionDeclaration 도 아닐 때만 여기서 인스턴스화.
          2. instantiatedVarNamesF 를 포함하지 않고 F"arguments" 가 아니면
            1. varEnv.CreateMutableBinding(F, false) 수행.
            2. varEnv.InitializeBinding(F, undefined) 수행.
            3. instantiatedVarNamesF 추가.
          3. FunctionDeclaration f 평가 시 15.2.6 의 Evaluation 알고리즘 대신 다음 수행:
            1. fEnv 를 실행 중 실행 컨텍스트의 VariableEnvironment 로 둔다.
            2. bEnv 를 실행 중 실행 컨텍스트의 LexicalEnvironment 로 둔다.
            3. fObj 를 ! bEnv.GetBindingValue(F, false) 로 둔다.
            4. fEnv.SetMutableBinding(F, fObj, false) 수행.
            5. unused 반환.
    2. lexEnvNewDeclarativeEnvironment(varEnv) 로 둔다.
    3. NOTE: non‑strict 함수는 direct eval 이 생성한 var 스코프 선언과 기존 최상위 lexical 선언 충돌 여부를 판단할 수 있도록 top-level lexical 선언에 별도의 Environment Record 사용. strict 함수는 항상 새 Environment Record 사용하므로 불필요.
  33. calleeContext 의 LexicalEnvironment 를 lexEnv 로 설정.
  34. lexDeclarationscode 의 LexicallyScopedDeclarations 로 둔다.
  35. lexDeclarations 의 각 d 에 대해
    1. NOTE: lexical 선언 이름은 함수/제너레이터 선언, 형식 매개변수, var 이름과 같을 수 없으며 여기서 인스턴스화만 되고 초기화는 안 됨.
    2. d 의 BoundNames 각 dn 에 대해
      1. IsConstantDeclaration of dtrue 이면
        1. lexEnv.CreateImmutableBinding(dn, true) 수행.
      2. Else
        1. lexEnv.CreateMutableBinding(dn, false) 수행.
  36. privateEnvcalleeContext 의 PrivateEnvironment 로 둔다.
  37. functionsToInitialize 의 각 Parse Node f 에 대해
    1. fnf 의 BoundNames 유일 요소로 둔다.
    2. fo 를 InstantiateFunctionObject of f (인수 lexEnv, privateEnv) 로 둔다.
    3. varEnv.SetMutableBinding(fn, fo, false) 수행.
  38. unused 반환.

10.3 내장 함수 객체(Built-in Function Objects)

내장 함수 객체일반 객체이며; 10.1에 규정된 일반 객체 요건을 만족해야 한다.

모든 일반 객체에 요구되는 내부 슬롯(10.1 참조)에 더해, 내장 함수 객체는 다음 내부 슬롯도 가져야 한다:

  • [[Realm]]: 함수가 생성된 realm 을 나타내는 Realm Record.
  • [[InitialName]]: 함수의 초기 이름인 String. 20.2.3.5에서 사용된다.

명시적으로 달리 지정되지 않은 한, 내장 함수 객체[[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 내장 함수 객체 F takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns ECMAScript 언어 값 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. BuiltinCallOrConstruct(F, thisArgument, argumentsList, undefined) 를 반환한다.

10.3.2 [[Construct]] ( argumentsList, newTarget )

The [[Construct]] internal method of 내장 함수 객체 F (이 메서드가 존재할 때) takes arguments argumentsList (a List of ECMAScript language values) and newTarget (a constructor) and returns 객체 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. result 를 ? BuiltinCallOrConstruct(F, uninitialized, argumentsList, newTarget) 로 둔다.
  2. 단언: result 는 Object.
  3. result 를 반환한다.

10.3.3 BuiltinCallOrConstruct ( F, thisArgument, argumentsList, newTarget )

The abstract operation BuiltinCallOrConstruct takes arguments F (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 ECMAScript 언어 값 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. callerContext 를 실행 중 실행 컨텍스트로 둔다.
  2. callerContext 가 아직 suspend 되어 있지 않다면 suspend 한다.
  3. calleeContext 를 새 실행 컨텍스트로 둔다.
  4. calleeContext 의 Function 을 F 로 설정한다.
  5. calleeRealmF.[[Realm]] 로 둔다.
  6. calleeContextRealmcalleeRealm 로 설정한다.
  7. calleeContext 의 ScriptOrModule 을 null 로 설정한다.
  8. 구현 정의된 필요 초기화를 calleeContext 에 수행한다.
  9. calleeContext 를 실행 컨텍스트 스택에 push; 이제 calleeContext 가 실행 중 실행 컨텍스트이다.
  10. resultF 의 명세에 부합하는 방식으로 F 를 평가하여 얻은 Completion Record 로 둔다. thisArgumentuninitialized 이면 this 값은 초기화되지 않은 상태이며; 그렇지 않으면 thisArgumentthis 값을 제공한다. argumentsList 는 명명된 매개변수들을 제공한다. newTarget 은 NewTarget 값을 제공한다.
  11. NOTE: F 가 이 문서에서 정의된 경우 “the specification of F” 는 알고리즘 단계 등으로 기술된 그 동작을 의미한다.
  12. 실행 컨텍스트 스택에서 calleeContext 를 제거하고 callerContext 를 실행 중 실행 컨텍스트로 복원한다.
  13. result 를 반환한다.
Note

calleeContext 가 실행 컨텍스트 스택에서 제거될 때 접근 가능한 Generator 에 의해 suspend 및 보존되어 후속 재개가 예정된 경우 파괴되어서는 안 된다.

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

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), and prefix (a String) and returns a built-in function object. additionalInternalSlotsList 는 객체 일부로 정의되어야 하는 추가 내부 슬롯 이름을 담는다. 이 연산은 내장 함수 객체를 생성한다. It performs the following steps when called:

  1. realm 이 제공되지 않았다면 current Realm Record 로 설정한다.
  2. prototype 이 제공되지 않았다면 prototyperealm.[[Intrinsics]].[[%Function.prototype%]] 로 설정한다.
  3. internalSlotsList 를 곧 생성할 내장 함수 객체에 대해 10.3가 요구하는 모든 내부 슬롯 이름을 담는 List 로 둔다.
  4. additionalInternalSlotsList 의 요소들을 internalSlotsList 에 추가(Append)한다.
  5. func 를 새 내장 함수 객체로 두되, 호출 시 behaviour 가 지정한 매개변수에 제공 인수를 값으로 하여 behaviour 에 기술된 동작을 수행한다. 새 함수 객체internalSlotsList 요소 이름의 내부 슬롯과 [[InitialName]] 내부 슬롯을 가진다.
  6. func.[[Prototype]]prototype 으로 설정한다.
  7. func.[[Extensible]]true 로 설정한다.
  8. func.[[Realm]]realm 으로 설정한다.
  9. func.[[InitialName]]null 로 설정한다.
  10. SetFunctionLength(func, length) 를 수행한다.
  11. prefix 가 제공되지 않았다면
    1. SetFunctionName(func, name) 를 수행한다.
  12. 그렇지 않으면
    1. SetFunctionName(func, name, prefix) 를 수행한다.
  13. func 를 반환한다.

이 명세에 정의된 각 내장 함수는 CreateBuiltinFunction 추상 연산을 호출하여 생성된다.

10.4 내장 이그조틱 객체의 내부 메서드와 슬롯(Built-in Exotic Object Internal Methods and Slots)

이 명세는 여러 종류의 내장 이그조틱 객체를 정의한다. 이 객체들은 특정한 몇몇 상황을 제외하면 일반 객체와 유사하게 동작한다. 다음 이그조틱 객체들은 아래에서 명시적으로 달리 지정된 경우를 제외하고 일반 객체 내부 메서드를 사용한다:

10.4.1 바운드 함수 이그조틱 객체(Bound Function Exotic Objects)

바운드 함수 이그조틱 객체는 다른 함수 객체를 감싸는 이그조틱 객체이다. 바운드 함수 이그조틱 객체는 호출 가능(callable)하며([[Call]] 내부 메서드를 가지며 필요 시 [[Construct]] 내부 메서드도 가질 수 있음), 호출하면 보통 감싼 함수가 호출된다.

객체의 [[Call]] 및 (해당하는 경우) [[Construct]] 내부 메서드가 아래 구현을 사용하고, 그 외 핵심 내부 메서드가 10.1의 정의를 사용한다면 그 객체는 바운드 함수 이그조틱 객체이다. 이러한 메서드는 BoundFunctionCreate 에서 설치된다.

바운드 함수 이그조틱 객체Table 28에 나열된 ECMAScript 함수 객체의 내부 슬롯을 가지지 않는다. 대신 Table 29에 나열된 내부 슬롯을 [[Prototype]], [[Extensible]]와 더불어 가진다.

Table 29: 바운드 함수 이그조틱 객체의 내부 슬롯(Internal Slots of Bound Function Exotic Objects)
Internal Slot Type Description
[[BoundTargetFunction]] a callable Object 감싸진(wrapped) 함수 객체.
[[BoundThis]] an ECMAScript language value 감싸진 함수를 호출할 때 항상 this 값으로 전달되는 값.
[[BoundArguments]] a List of ECMAScript language values 감싸진 함수 호출 시 선행 인수로 사용되는 값들의 리스트.

10.4.1.1 [[Call]] ( thisArgument, argumentsList )

The [[Call]] internal method of 바운드 함수 이그조틱 객체 F takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns ECMAScript 언어 값 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. targetF.[[BoundTargetFunction]] 로 둔다.
  2. boundThisF.[[BoundThis]] 로 둔다.
  3. boundArgsF.[[BoundArguments]] 로 둔다.
  4. argsboundArgsargumentsList 의 리스트 연결(list-concatenation)으로 둔다.
  5. Call(target, boundThis, args) 를 반환한다.

10.4.1.2 [[Construct]] ( argumentsList, newTarget )

The [[Construct]] internal method of 바운드 함수 이그조틱 객체 F takes arguments argumentsList (a List of ECMAScript language values) and newTarget (a constructor) and returns 객체 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. targetF.[[BoundTargetFunction]] 로 둔다.
  2. 단언: IsConstructor(target) 는 true.
  3. boundArgsF.[[BoundArguments]] 로 둔다.
  4. argsboundArgsargumentsList 의 리스트 연결로 둔다.
  5. SameValue(F, newTarget) 가 true 이면 newTargettarget 으로 설정한다.
  6. Construct(target, args, newTarget) 를 반환한다.

10.4.1.3 BoundFunctionCreate ( targetFunction, boundThis, boundArgs )

The abstract operation BoundFunctionCreate takes arguments targetFunction (a function object), boundThis (an ECMAScript language value), and boundArgs (a List of ECMAScript language values) and returns 함수 객체 또는 throw completion 을 담는 normal completion. 새 바운드 함수 이그조틱 객체 생성을 명세하는 데 사용된다. It performs the following steps when called:

  1. proto 를 ? targetFunction.[[GetPrototypeOf]]() 로 둔다.
  2. internalSlotsList 를 « [[Prototype]], [[Extensible]] » 와 Table 29에 나열된 내부 슬롯의 리스트 연결로 둔다.
  3. objMakeBasicObject(internalSlotsList) 로 둔다.
  4. obj.[[Prototype]]proto 로 설정한다.
  5. obj.[[Call]]10.4.1.1에 기술된 대로 설정한다.
  6. IsConstructor(targetFunction) 가 true 이면
    1. obj.[[Construct]]10.4.1.2에 기술된 대로 설정한다.
  7. obj.[[BoundTargetFunction]]targetFunction 으로 설정한다.
  8. obj.[[BoundThis]]boundThis 로 설정한다.
  9. obj.[[BoundArguments]]boundArgs 로 설정한다.
  10. obj 를 반환한다.

10.4.2 배열(Array) 이그조틱 객체(Array Exotic Objects)

Array 는 배열 인덱스 프로퍼티 키(6.1.7 참조)에 특별 취급을 제공하는 이그조틱 객체이다. 프로퍼티 이름배열 인덱스인 프로퍼티를 element 라고도 부른다. 모든 Array 는 재정의 불가(non-configurable) "length" 프로퍼티를 가지며 그 값은 232 보다 작은 0 이상 정수 Number 이다. "length" 프로퍼티 값은 이름이 배열 인덱스인 모든 자체 프로퍼티 이름보다 수치적으로 크다; Array 의 자체 프로퍼티가 생성되거나 변경될 때마다 이 불변식을 유지하도록 다른 프로퍼티들이 필요 시 조정된다. 구체적으로 배열 인덱스 이름의 자체 프로퍼티가 추가되면 "length" 값은 필요 시 그 인덱스의 수치 값보다 1 큰 값으로 변경되고; "length" 값이 변경되면 새 length 보다 크거나 같았던 배열 인덱스 이름의 모든 자체 프로퍼티는 삭제된다. 이 제약은 Array 의 자체 프로퍼티에만 적용되며 프로토타입에서 상속될 수 있는 "length" 또는 배열 인덱스 프로퍼티에는 영향받지 않는다.

객체의 [[DefineOwnProperty]] 내부 메서드가 아래 구현을 사용하고 그 외 핵심 내부 메서드가 10.1의 정의를 사용하면 그 객체는 Array 이그조틱 객체(간단히 Array)이다. 이러한 메서드는 ArrayCreate 에서 설치된다.

10.4.2.1 [[DefineOwnProperty]] ( P, Desc )

The [[DefineOwnProperty]] internal method of Array 이그조틱 객체 A takes arguments P (a property key) and Desc (a Property Descriptor) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. P"length" 이면
    1. ArraySetLength(A, Desc) 를 반환한다.
  2. Else if P배열 인덱스이면
    1. lengthDescOrdinaryGetOwnProperty(A, "length") 로 둔다.
    2. 단언: lengthDescundefined 가 아님.
    3. 단언: IsDataDescriptor(lengthDesc) 는 true.
    4. 단언: lengthDesc.[[Configurable]]false.
    5. lengthlengthDesc.[[Value]] 로 둔다.
    6. 단언: length 는 0 이상 정수 Number.
    7. index 를 ! ToUint32(P) 로 둔다.
    8. indexlength 이고 lengthDesc.[[Writable]]false 이면 false 반환.
    9. succeeded 를 ! OrdinaryDefineOwnProperty(A, P, Desc) 로 둔다.
    10. succeededfalse 이면 false 반환.
    11. indexlength 이면
      1. lengthDesc.[[Value]]index + 1𝔽 로 설정.
      2. succeeded 를 ! OrdinaryDefineOwnProperty(A, "length", lengthDesc) 로 설정.
      3. 단언: succeededtrue.
    12. true 반환.
  3. OrdinaryDefineOwnProperty(A, P, 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 Array 이그조틱 객체 또는 throw completion 을 담는 normal completion. 새 Array 생성 명세에 사용된다. It performs the following steps when called:

  1. length > 232 - 1 이면 RangeError 예외 throw.
  2. proto 가 제공되지 않았다면 proto%Array.prototype% 으로 설정.
  3. AMakeBasicObject[[Prototype]], [[Extensible]] ») 로 둔다.
  4. A.[[Prototype]]proto 로 설정.
  5. A.[[DefineOwnProperty]]10.4.2.1에 지정된 대로 설정.
  6. OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) 수행.
  7. A 반환.

10.4.2.3 ArraySpeciesCreate ( originalArray, length )

The abstract operation ArraySpeciesCreate takes arguments originalArray (an Object) and length (a non-negative integer) and returns 객체 또는 throw completion 을 담는 normal completion. originalArray 에서 파생된 constructor 함수를 사용하여 새 Array 또는 유사 객체를 생성하는 과정을 명세한다. constructor 가 반드시 Array 를 반환하도록 강제하지 않는다. It performs the following steps when called:

  1. isArray 를 ? IsArray(originalArray) 로 둔다.
  2. isArrayfalse 이면 ? ArrayCreate(length) 반환.
  3. C 를 ? Get(originalArray, "constructor") 로 둔다.
  4. IsConstructor(C) 가 true 이면
    1. thisRealmcurrent Realm Record 로 둔다.
    2. realmC 를 ? GetFunctionRealm(C) 로 둔다.
    3. thisRealmrealmC 가 동일 Realm Record 가 아니면
      1. SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) 가 true 이면 Cundefined 로 설정.
  5. C 가 Object 이면
    1. C 를 ? Get(C, %Symbol.species%) 로 설정.
    2. Cnull 이면 Cundefined 로 설정.
  6. Cundefined 이면 ? ArrayCreate(length) 반환.
  7. IsConstructor(C) 가 false 이면 TypeError 예외 throw.
  8. Construct(C, « 𝔽(length) ») 반환.
Note

originalArray 가 실행 중 실행 컨텍스트의 realm 이 아닌 realm 의 표준 내장 Array 생성자로 생성되었다면, 실행 중 실행 컨텍스트 realm 을 사용하여 새 Array 가 생성된다. 이는 ArraySpeciesCreate 로 정의된 Array.prototype 메서드들에 대해 역사적으로 그러한 동작을 가진 웹 브라우저와의 호환성을 유지한다.

10.4.2.4 ArraySetLength ( A, Desc )

The abstract operation ArraySetLength takes arguments A (an Array) and Desc (a Property Descriptor) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. Desc[[Value]] 필드를 가지지 않으면
    1. OrdinaryDefineOwnProperty(A, "length", Desc) 반환.
  2. newLenDescDesc 의 복사본으로 둔다.
  3. newLen 을 ? ToUint32(Desc.[[Value]]) 로 둔다.
  4. numberLen 을 ? ToNumber(Desc.[[Value]]) 로 둔다.
  5. SameValueZero(newLen, numberLen) 가 false 이면 RangeError 예외 throw.
  6. newLenDesc.[[Value]]newLen 으로 설정.
  7. oldLenDescOrdinaryGetOwnProperty(A, "length") 로 둔다.
  8. 단언: oldLenDescundefined 아님.
  9. 단언: IsDataDescriptor(oldLenDesc) 는 true.
  10. 단언: oldLenDesc.[[Configurable]]false.
  11. oldLenoldLenDesc.[[Value]] 로 둔다.
  12. newLenoldLen 이면
    1. OrdinaryDefineOwnProperty(A, "length", newLenDesc) 반환.
  13. oldLenDesc.[[Writable]]false 이면 false 반환.
  14. newLenDesc[[Writable]] 필드를 가지지 않거나 newLenDesc.[[Writable]]true 이면
    1. newWritabletrue 로 둔다.
  15. Else
    1. NOTE: 어떤 element 를 삭제할 수 없는 경우를 대비하여 [[Writable]]false 로 설정하는 것을 지연.
    2. newWritablefalse 로 둔다.
    3. newLenDesc.[[Writable]]true 로 설정.
  16. succeeded 를 ! OrdinaryDefineOwnProperty(A, "length", newLenDesc) 로 둔다.
  17. succeededfalse 이면 false 반환.
  18. A 의 각 자체 프로퍼티 키 PP배열 인덱스이고 ! ToUint32(P) ≥ newLen 인 것들을 내림차순 숫자 인덱스 순으로 순회하며
    1. deleteSucceeded 를 ! A.[[Delete]](P) 로 둔다.
    2. deleteSucceededfalse 이면
      1. newLenDesc.[[Value]] 를 ! ToUint32(P) + 1𝔽 로 설정.
      2. newWritablefalse 이면 newLenDesc.[[Writable]]false 로 설정.
      3. OrdinaryDefineOwnProperty(A, "length", newLenDesc) 수행.
      4. false 반환.
  19. newWritablefalse 이면
    1. succeeded 를 ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor { [[Writable]]: false }) 로 설정.
    2. 단언: succeededtrue.
  20. true 반환.
Note

34 단계에서 Desc.[[Value]] 가 객체이면 그 valueOf 메서드는 두 번 호출된다. 이는 명세 2부터 이런 효과로 규정된 레거시 동작이다.

10.4.3 문자열(String) 이그조틱 객체(String Exotic Objects)

String 객체는 String 값을 캡슐화하고 그 String 값의 개별 코드 유닛 요소에 해당하는 가상 정수 인덱스 데이터 프로퍼티를 노출하는 이그조틱 객체이다. String 이그조틱 객체는 캡슐화된 String 값 길이를 값으로 갖는 "length" 데이터 프로퍼티를 항상 가진다. 코드 유닛 데이터 프로퍼티"length" 프로퍼티 모두 쓰기 불가능 및 재정의 불가이다.

객체의 [[GetOwnProperty]], [[DefineOwnProperty]], [[OwnPropertyKeys]] 내부 메서드가 아래 구현을 사용하고 그 외 핵심 내부 메서드가 10.1 정의를 사용하면 그 객체는 String 이그조틱 객체(간단히 String 객체)이다. 이러한 메서드는 StringCreate 에서 설치된다.

String 이그조틱 객체일반 객체와 동일한 내부 슬롯을 갖는다. 추가로 [[StringData]] 내부 슬롯을 가진다.

10.4.3.1 [[GetOwnProperty]] ( P )

The [[GetOwnProperty]] internal method of String 이그조틱 객체 S takes argument P (a property key) and returns Property Descriptor 또는 undefined 를 담는 normal completion. It performs the following steps when called:

  1. descOrdinaryGetOwnProperty(S, P) 로 둔다.
  2. descundefined 가 아니면 desc 반환.
  3. StringGetOwnProperty(S, P) 반환.

10.4.3.2 [[DefineOwnProperty]] ( P, Desc )

The [[DefineOwnProperty]] internal method of String 이그조틱 객체 S takes arguments P (a property key) and Desc (a Property Descriptor) and returns Boolean 을 담는 normal completion. It performs the following steps when called:

  1. stringDescStringGetOwnProperty(S, P) 로 둔다.
  2. stringDescundefined 가 아니면
    1. extensibleS.[[Extensible]] 로 둔다.
    2. IsCompatiblePropertyDescriptor(extensible, Desc, stringDesc) 반환.
  3. OrdinaryDefineOwnProperty(S, P, Desc) 반환.

10.4.3.3 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of String 이그조틱 객체 O takes no arguments and returns 프로퍼티 키 List 를 담는 normal completion. It performs the following steps when called:

  1. keys 를 새 빈 List 로 둔다.
  2. strO.[[StringData]] 로 둔다.
  3. 단언: str 은 String.
  4. lenstr 의 길이로 둔다.
  5. 0 ≤ i < len 인 각 정수 i 에 대해 오름차순으로
    1. ToString(𝔽(i)) 를 keys 에 추가.
  6. O 의 각 자체 프로퍼티 키 PP배열 인덱스이며 ! ToIntegerOrInfinity(P) ≥ len 인 것들을 숫자 인덱스 오름차순으로
    1. Pkeys 에 추가.
  7. O 의 각 자체 프로퍼티 키 PP 가 String 이고 배열 인덱스가 아닌 것들을 생성 시점 시간 순으로
    1. Pkeys 에 추가.
  8. O 의 각 자체 프로퍼티 키 PP 가 Symbol 인 것들을 생성 시점 시간 순으로
    1. Pkeys 에 추가.
  9. keys 반환.

10.4.3.4 StringCreate ( value, prototype )

The abstract operation StringCreate takes arguments value (a String) and prototype (an Object) and returns String 이그조틱 객체. 새 String 이그조틱 객체 생성 명세에 사용된다. It performs the following steps when called:

  1. SMakeBasicObject[[Prototype]], [[Extensible]], [[StringData]] ») 로 둔다.
  2. S.[[Prototype]]prototype 으로 설정.
  3. S.[[StringData]]value 로 설정.
  4. S.[[GetOwnProperty]]10.4.3.1에 지정된 대로 설정.
  5. S.[[DefineOwnProperty]]10.4.3.2에 지정된 대로 설정.
  6. S.[[OwnPropertyKeys]]10.4.3.3에 지정된 대로 설정.
  7. lengthvalue 길이로 둔다.
  8. DefinePropertyOrThrow(S, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }) 수행.
  9. S 반환.

10.4.3.5 StringGetOwnProperty ( S, P )

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

  1. P 가 String 이 아니면 undefined 반환.
  2. indexCanonicalNumericIndexString(P) 로 둔다.
  3. index 가 정수 Number 가 아니면 undefined 반환.
  4. index-0𝔽 이거나 index < -0𝔽 이면 undefined 반환.
  5. strS.[[StringData]] 로 둔다.
  6. 단언: str 은 String.
  7. lenstr 길이로 둔다.
  8. (index) ≥ len 이면 undefined 반환.
  9. resultStrstr(index) 부터 (index) + 1 까지 부분 문자열로 둔다.
  10. PropertyDescriptor { [[Value]]: resultStr, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: false } 반환.

10.4.4 Arguments 이그조틱 객체(Arguments Exotic Objects)

대부분의 ECMAScript 함수는 코드에서 사용할 수 있는 arguments 객체를 제공한다. 함수 정의 특성에 따라 그 arguments 객체는 일반 객체이거나 arguments 이그조틱 객체가 된다. arguments 이그조틱 객체배열 인덱스 프로퍼티들이 관련 ECMAScript 함수 호출의 형식 매개변수 바인딩에 매핑되는 이그조틱 객체이다.

객체의 내부 메서드가 아래 구현을 사용하고 여기 명시되지 않은 메서드는 10.1의 정의를 사용하면 그 객체는 arguments 이그조틱 객체이다. 이러한 메서드는 CreateMappedArgumentsObject 에서 설치된다.

Note 1

CreateUnmappedArgumentsObject 는 이 절에 묶여 있지만, 이그조틱이 아닌 일반 객체를 생성한다.

Arguments 이그조틱 객체일반 객체와 동일한 내부 슬롯을 가지며 추가로 [[ParameterMap]] 내부 슬롯을 가진다. 일반 arguments 객체 또한 값이 항상 undefined[[ParameterMap]] 내부 슬롯을 갖는다. 일반 arguments 객체의 [[ParameterMap]] 내부 슬롯은 Object.prototype.toString (20.1.3.6)이 그것을 식별하는 데만 사용된다.

Note 2

arguments 이그조틱 객체 중 숫자 이름 값이 대응 함수 객체의 형식 매개변수 수보다 작은 정수 인덱스 데이터 프로퍼티는 초기에는 함수 실행 컨텍스트의 해당 인자 바인딩과 값을 공유한다. 즉 프로퍼티를 바꾸면 매개변수 바인딩 값도 바뀌며 그 반대도 같다. 이 대응 관계는 그러한 프로퍼티가 삭제 후 재정의되거나 접근자 프로퍼티로 바뀌면 끊어진다. arguments 객체가 일반 객체인 경우 그 프로퍼티 값은 단지 전달된 인자의 복사이며 동적 연결은 없다.

Note 3

ParameterMap 객체와 그 프로퍼티 값들은 arguments 객체와 인자 바인딩 간의 대응 관계를 명세하기 위한 장치이다. ParameterMap 객체와 그 프로퍼티 값 객체들은 ECMAScript 코드에서 직접 관측될 수 없다. 구현은 명세된 의미론을 위해 실제로 이러한 객체를 생성하거나 사용할 필요가 없다.

Note 4

일반 arguments 객체는 접근 시 TypeError 예외를 throw 하는 재정의 불가 accessor 프로퍼티 "callee" 를 정의한다. "callee" 프로퍼티는 non‑strict 함수 일부에 대해서만 생성되는 arguments 이그조틱 객체에서 더 구체적 의미를 가진다. 일반 변형에서의 정의는 적합한 구현이 다른 방식으로 정의하지 못하도록 하기 위함이다.

Note 5

역사적으로 arguments 이그조틱 객체 구현은 "caller" 라는 accessor 프로퍼티를 포함했다. ECMAScript 2017 이전 명세는 일반 arguments 객체에 throwing "caller" 프로퍼티 정의를 포함했다. 구현이 더 이상 이 확장을 포함하지 않으므로 ECMAScript 2017 은 throwing "caller" accessor 요구를 제거했다.

10.4.4.1 [[GetOwnProperty]] ( P )

The [[GetOwnProperty]] internal method of arguments 이그조틱 객체 args takes argument P (a property key) and returns Property Descriptor 또는 undefined 를 담는 normal completion. It performs the following steps when called:

  1. descOrdinaryGetOwnProperty(args, P) 로 둔다.
  2. descundefined 이면 undefined 반환.
  3. mapargs.[[ParameterMap]] 로 둔다.
  4. isMapped 를 ! HasOwnProperty(map, P) 로 둔다.
  5. isMappedtrue 이면
    1. desc.[[Value]] 를 ! Get(map, P) 로 설정.
  6. desc 반환.

10.4.4.2 [[DefineOwnProperty]] ( P, Desc )

The [[DefineOwnProperty]] internal method of arguments 이그조틱 객체 args takes arguments P (a property key) and Desc (a Property Descriptor) and returns Boolean 을 담는 normal completion. It performs the following steps when called:

  1. mapargs.[[ParameterMap]] 로 둔다.
  2. isMapped 를 ! HasOwnProperty(map, P) 로 둔다.
  3. newArgDescDesc 로 둔다.
  4. isMappedtrue 이고 IsDataDescriptor(Desc) 가 true 이면
    1. Desc[[Value]] 필드를 갖지 않고 [[Writable]] 필드를 가지며 그 값이 false 이면
      1. newArgDescDesc 복사본으로 둔다.
      2. newArgDesc.[[Value]] 를 ! Get(map, P) 로 설정.
  5. allowed 를 ! OrdinaryDefineOwnProperty(args, P, newArgDesc) 로 둔다.
  6. allowedfalse 이면 false 반환.
  7. isMappedtrue 이면
    1. IsAccessorDescriptor(Desc) 가 true 이면
      1. map.[[Delete]](P) 수행.
    2. Else
      1. Desc[[Value]] 필드를 가지면
        1. 단언: arguments 객체가 매핑한 형식 매개변수는 항상 writable 이므로 Set 성공.
        2. Set(map, P, Desc.[[Value]], false) 수행.
      2. Desc[[Writable]] 필드를 가지고 그 값이 false 이면
        1. map.[[Delete]](P) 수행.
  8. true 반환.

10.4.4.3 [[Get]] ( P, Receiver )

The [[Get]] internal method of arguments 이그조틱 객체 args takes arguments P (a property key) and Receiver (an ECMAScript language value) and returns ECMAScript 언어 값 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. mapargs.[[ParameterMap]] 로 둔다.
  2. isMapped 를 ! HasOwnProperty(map, P) 로 둔다.
  3. isMappedfalse 이면
    1. OrdinaryGet(args, P, Receiver) 반환.
  4. Else
    1. 단언: mapP 에 대한 형식 매개변수 매핑을 포함.
    2. Get(map, P) 반환.

10.4.4.4 [[Set]] ( P, V, Receiver )

The [[Set]] internal method of arguments 이그조틱 객체 args takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. SameValue(args, Receiver) 가 false 이면
    1. isMappedfalse 로 둔다.
  2. Else
    1. mapargs.[[ParameterMap]] 로 둔다.
    2. isMapped 를 ! HasOwnProperty(map, P) 로 둔다.
  3. isMappedtrue 이면
    1. 단언: 아래 Set 은 성공 (매핑된 형식 매개변수는 항상 writable).
    2. Set(map, P, V, false) 수행.
  4. OrdinarySet(args, P, V, Receiver) 반환.

10.4.4.5 [[Delete]] ( P )

The [[Delete]] internal method of arguments 이그조틱 객체 args takes argument P (a property key) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. mapargs.[[ParameterMap]] 로 둔다.
  2. isMapped 를 ! HasOwnProperty(map, P) 로 둔다.
  3. result 를 ? OrdinaryDelete(args, P) 로 둔다.
  4. resulttrue 이고 isMappedtrue 이면
    1. map.[[Delete]](P) 수행.
  5. result 반환.

10.4.4.6 CreateUnmappedArgumentsObject ( argumentsList )

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

  1. lenargumentsList 요소 개수로 둔다.
  2. objOrdinaryObjectCreate(%Object.prototype%, « [[ParameterMap]] ») 로 둔다.
  3. obj.[[ParameterMap]]undefined 로 설정.
  4. DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(len), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }) 수행.
  5. index 를 0 으로 둔다.
  6. index < len 인 동안 반복
    1. valargumentsList[index] 로 둔다.
    2. CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), val) 수행.
    3. indexindex + 1 로 설정.
  7. DefinePropertyOrThrow(obj, %Symbol.iterator%, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }) 수행.
  8. DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Get]]: %ThrowTypeError%, [[Set]]: %ThrowTypeError%, [[Enumerable]]: false, [[Configurable]]: false }) 수행.
  9. obj 반환.

10.4.4.7 CreateMappedArgumentsObject ( func, formals, argumentsList, env )

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

  1. 단언: formals 는 rest 매개변수, 바인딩 패턴, 초기화자를 포함하지 않는다. 중복 식별자는 있을 수 있다.
  2. lenargumentsList 요소 개수로 둔다.
  3. objMakeBasicObject[[Prototype]], [[Extensible]], [[ParameterMap]] ») 로 둔다.
  4. obj.[[GetOwnProperty]]10.4.4.1에 지정된 대로 설정.
  5. obj.[[DefineOwnProperty]]10.4.4.2에 지정된 대로 설정.
  6. obj.[[Get]]10.4.4.3에 지정된 대로 설정.
  7. obj.[[Set]]10.4.4.4에 지정된 대로 설정.
  8. obj.[[Delete]]10.4.4.5에 지정된 대로 설정.
  9. obj.[[Prototype]]%Object.prototype% 으로 설정.
  10. mapOrdinaryObjectCreate(null) 로 둔다.
  11. obj.[[ParameterMap]]map 으로 설정.
  12. parameterNamesformals 의 BoundNames 로 둔다.
  13. numberOfParametersparameterNames 요소 개수로 둔다.
  14. index 를 0 으로 둔다.
  15. index < len 인 동안 반복
    1. valargumentsList[index] 로 둔다.
    2. CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), val) 수행.
    3. indexindex + 1 로 설정.
  16. DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(len), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }) 수행.
  17. mappedNames 를 새 빈 List 로 둔다.
  18. indexnumberOfParameters - 1 로 설정.
  19. index ≥ 0 인 동안 반복
    1. nameparameterNames[index] 로 둔다.
    2. mappedNamesname 을 포함하지 않으면
      1. mappedNamesname 추가.
      2. index < len 이면
        1. gMakeArgGetter(name, env) 로 둔다.
        2. pMakeArgSetter(name, env) 로 둔다.
        3. map.[[DefineOwnProperty]](! ToString(𝔽(index)), PropertyDescriptor { [[Set]]: p, [[Get]]: g, [[Enumerable]]: false, [[Configurable]]: true }) 수행.
    3. indexindex - 1 로 설정.
  20. DefinePropertyOrThrow(obj, %Symbol.iterator%, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }) 수행.
  21. DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Value]]: func, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }) 수행.
  22. obj 반환.

10.4.4.7.1 MakeArgGetter ( name, env )

The abstract operation MakeArgGetter takes arguments name (a String) and env (an Environment Record) and returns a function object. 실행 시 env 에서 name 에 바인딩된 값을 반환하는 내장 함수 객체를 생성한다. It performs the following steps when called:

  1. getterClosure 를 매개변수 없고 name, env 를 캡처하며 호출 시 다음 단계를 수행하는 새 Abstract Closure 로 둔다:
    1. NormalCompletion(! env.GetBindingValue(name, false)) 반환.
  2. getterCreateBuiltinFunction(getterClosure, 0, "", « ») 로 둔다.
  3. NOTE: getter 는 ECMAScript 코드에서 직접 접근 불가.
  4. getter 반환.

10.4.4.7.2 MakeArgSetter ( name, env )

The abstract operation MakeArgSetter takes arguments name (a String) and env (an Environment Record) and returns a function object. 실행 시 env 에서 name 에 바인딩된 값을 설정하는 내장 함수 객체를 생성한다. It performs the following steps when called:

  1. setterClosure 를 매개변수 (value) 를 가지며 name, env 를 캡처하고 호출 시 다음을 수행하는 새 Abstract Closure 로 둔다:
    1. NormalCompletion(! env.SetMutableBinding(name, value, false)) 반환.
  2. setterCreateBuiltinFunction(setterClosure, 1, "", « ») 로 둔다.
  3. NOTE: setter 는 ECMAScript 코드에서 직접 접근 불가.
  4. setter 반환.

10.4.5 TypedArray 이그조틱 객체(TypedArray Exotic Objects)

TypedArray 는 정규화 수치 문자열(canonical numeric string) 프로퍼티 키를 특별 처리하고 그 중 경계 내(in-bounds) 정수 인덱스를 균일 타입 요소에 매핑하며 나머지는 프로토타입 체인 탐색 없이 부재로 유지하는 이그조틱 객체이다.

Note

임의의 Number n 에 대해 ToString(n)이 정규화 수치 문자열이므로, 구현은 실제 문자열 변환 없이 Number 를 TypedArray 프로퍼티 키로 다룰 수 있다.

TypedArray일반 객체와 동일한 내부 슬롯을 가지며 추가로 [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] 내부 슬롯을 가진다.

객체의 [[PreventExtensions]], [[GetOwnProperty]], [[HasProperty]], [[DefineOwnProperty]], [[Get]], [[Set]], [[Delete]], [[OwnPropertyKeys]] 내부 메서드가 이 절의 정의를 사용하고 그 외 핵심 내부 메서드가 10.1 정의를 사용하면 그 객체는 TypedArray 이다. 이러한 메서드는 TypedArrayCreate 에 의해 설치된다.

10.4.5.1 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of TypedArray O takes no arguments and returns Boolean 을 담는 normal completion. It performs the following steps when called:

  1. NOTE: 6.1.7.3에 규정된 확장성 관련 불변식은 O 가 프로퍼티를 얻거나(또는 잃고 다시 얻을) 수 있는 경우 true 를 반환하지 못하게 한다; 이는 underlying buffer 가 resize 될 때 정수 인덱스 이름 프로퍼티에서 발생할 수 있다.
  2. IsTypedArrayFixedLength(O) 가 false 이면 false 반환.
  3. OrdinaryPreventExtensions(O) 반환.

10.4.5.2 [[GetOwnProperty]] ( P )

The [[GetOwnProperty]] internal method of TypedArray O takes argument P (a property key) and returns Property Descriptor 또는 undefined 를 담는 normal completion. It performs the following steps when called:

  1. P 가 String 이면
    1. numericIndexCanonicalNumericIndexString(P) 로 둔다.
    2. numericIndexundefined 가 아니면
      1. valueTypedArrayGetElement(O, numericIndex) 로 둔다.
      2. valueundefined 이면 undefined 반환.
      3. PropertyDescriptor { [[Value]]: value, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true } 반환.
  2. OrdinaryGetOwnProperty(O, P) 반환.

10.4.5.3 [[HasProperty]] ( P )

The [[HasProperty]] internal method of TypedArray O takes argument P (a property key) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. P 가 String 이면
    1. numericIndexCanonicalNumericIndexString(P) 로 둔다.
    2. numericIndexundefined 가 아니면 IsValidIntegerIndex(O, numericIndex) 반환.
  2. OrdinaryHasProperty(O, P) 반환.

10.4.5.4 [[DefineOwnProperty]] ( P, Desc )

The [[DefineOwnProperty]] internal method of TypedArray O takes arguments P (a property key) and Desc (a Property Descriptor) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. P 가 String 이면
    1. numericIndexCanonicalNumericIndexString(P) 로 둔다.
    2. numericIndexundefined 가 아니면
      1. IsValidIntegerIndex(O, numericIndex) 가 false 이면 false 반환.
      2. Desc[[Configurable]] 필드가 있고 그 값이 false 이면 false 반환.
      3. Desc[[Enumerable]] 필드가 있고 그 값이 false 이면 false 반환.
      4. IsAccessorDescriptor(Desc) 가 true 이면 false 반환.
      5. Desc[[Writable]] 필드가 있고 그 값이 false 이면 false 반환.
      6. Desc[[Value]] 필드가 있으면 ? TypedArraySetElement(O, numericIndex, Desc.[[Value]]) 수행.
      7. true 반환.
  2. OrdinaryDefineOwnProperty(O, P, Desc) 반환.

10.4.5.5 [[Get]] ( P, Receiver )

The [[Get]] internal method of TypedArray O takes arguments P (a property key) and Receiver (an ECMAScript language value) and returns ECMAScript 언어 값 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. P 가 String 이면
    1. numericIndexCanonicalNumericIndexString(P) 로 둔다.
    2. numericIndexundefined 가 아니면
      1. TypedArrayGetElement(O, numericIndex) 반환.
  2. OrdinaryGet(O, P, Receiver) 반환.

10.4.5.6 [[Set]] ( P, V, Receiver )

The [[Set]] internal method of TypedArray O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. P 가 String 이면
    1. numericIndexCanonicalNumericIndexString(P) 로 둔다.
    2. numericIndexundefined 가 아니면
      1. SameValue(O, Receiver) 가 true 이면
        1. TypedArraySetElement(O, numericIndex, V) 수행.
        2. true 반환.
      2. IsValidIntegerIndex(O, numericIndex) 가 false 이면 true 반환.
  2. OrdinarySet(O, P, V, Receiver) 반환.

10.4.5.7 [[Delete]] ( P )

The [[Delete]] internal method of TypedArray O takes argument P (a property key) and returns Boolean 을 담는 normal completion. It performs the following steps when called:

  1. P 가 String 이면
    1. numericIndexCanonicalNumericIndexString(P) 로 둔다.
    2. numericIndexundefined 가 아니면
      1. IsValidIntegerIndex(O, numericIndex) 가 false 이면 true 반환; else false 반환.
  2. OrdinaryDelete(O, P) 반환.

10.4.5.8 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of TypedArray O takes no arguments and returns 프로퍼티 키 List 를 담는 normal completion. It performs the following steps when called:

  1. taRecordMakeTypedArrayWithBufferWitnessRecord(O, seq-cst) 로 둔다.
  2. keys 를 새 빈 List 로 둔다.
  3. IsTypedArrayOutOfBounds(taRecord) 가 false 이면
    1. lengthTypedArrayLength(taRecord) 로 둔다.
    2. 0 ≤ i < length 인 각 정수 i 에 대해 오름차순으로
      1. ToString(𝔽(i)) 를 keys 에 추가.
  4. O 의 각 자체 프로퍼티 키 PP 가 String 이고 정수 인덱스가 아닌 것들을 생성 시점 시간 순으로
    1. Pkeys 에 추가.
  5. O 의 각 자체 프로퍼티 키 PP 가 Symbol 인 것들을 생성 시점 시간 순으로
    1. Pkeys 에 추가.
  6. keys 반환.

10.4.5.9 버퍼 증인 레코드가 있는 TypedArray (TypedArray With Buffer Witness Records)

TypedArray With Buffer Witness RecordTypedArray 와, 보기 버퍼(viewed buffer)의 캐시된 byte length 를 함께 캡슐화하는 Record 값이다. growable SharedArrayBuffer 를 보는 경우 byte length 데이터 블록에 대한 단일 공유 메모리 읽기 이벤트를 보장하는 데 사용된다.

TypedArray With Buffer Witness Record 는 Table 30에 나온 필드를 가진다.

Table 30: TypedArray With Buffer Witness Record Fields
Field Name Value Meaning
[[Object]] a TypedArray 버퍼 byte length 가 로드된 TypedArray.
[[CachedBufferByteLength]] a non-negative integer or detached Record 생성 시 객체의 [[ViewedArrayBuffer]] byte length.

10.4.5.10 MakeTypedArrayWithBufferWitnessRecord ( obj, order )

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

  1. bufferobj.[[ViewedArrayBuffer]] 로 둔다.
  2. IsDetachedBuffer(buffer) 가 true 이면
    1. byteLengthdetached 로 둔다.
  3. Else
    1. byteLengthArrayBufferByteLength(buffer, order) 로 둔다.
  4. TypedArray With Buffer Witness Record { [[Object]]: obj, [[CachedBufferByteLength]]: byteLength } 를 반환.

10.4.5.11 TypedArrayCreate ( prototype )

The abstract operation TypedArrayCreate takes argument prototype (an Object) and returns a TypedArray. 새 TypedArray 생성 명세에 사용된다. It performs the following steps when called:

  1. internalSlotsList 를 « [[Prototype]], [[Extensible]], [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] » 로 둔다.
  2. AMakeBasicObject(internalSlotsList) 로 둔다.
  3. A.[[PreventExtensions]]10.4.5.1에 지정된 대로 설정.
  4. A.[[GetOwnProperty]]10.4.5.2에 지정된 대로 설정.
  5. A.[[HasProperty]]10.4.5.3에 지정된 대로 설정.
  6. A.[[DefineOwnProperty]]10.4.5.4에 지정된 대로 설정.
  7. A.[[Get]]10.4.5.5에 지정된 대로 설정.
  8. A.[[Set]]10.4.5.6에 지정된 대로 설정.
  9. A.[[Delete]]10.4.5.7에 지정된 대로 설정.
  10. A.[[OwnPropertyKeys]]10.4.5.8에 지정된 대로 설정.
  11. A.[[Prototype]]prototype 으로 설정.
  12. A 반환.

10.4.5.12 TypedArrayByteLength ( taRecord )

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

  1. IsTypedArrayOutOfBounds(taRecord) 가 true 이면 0 반환.
  2. lengthTypedArrayLength(taRecord) 로 둔다.
  3. length = 0 이면 0 반환.
  4. OtaRecord.[[Object]] 로 둔다.
  5. O.[[ByteLength]]auto 가 아니면 O.[[ByteLength]] 반환.
  6. elementSizeTypedArrayElementSize(O) 로 둔다.
  7. length × elementSize 반환.

10.4.5.13 TypedArrayLength ( taRecord )

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

  1. 단언: IsTypedArrayOutOfBounds(taRecord) 는 false.
  2. OtaRecord.[[Object]] 로 둔다.
  3. O.[[ArrayLength]]auto 가 아니면 O.[[ArrayLength]] 반환.
  4. 단언: IsFixedLengthArrayBuffer(O.[[ViewedArrayBuffer]]) 는 false.
  5. byteOffsetO.[[ByteOffset]] 로 둔다.
  6. elementSizeTypedArrayElementSize(O) 로 둔다.
  7. byteLengthtaRecord.[[CachedBufferByteLength]] 로 둔다.
  8. 단언: byteLengthdetached 아님.
  9. floor((byteLength - byteOffset) / elementSize) 반환.

10.4.5.14 IsTypedArrayOutOfBounds ( taRecord )

The abstract operation IsTypedArrayOutOfBounds takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a Boolean. 객체의 어떤 수치 프로퍼티라도 underlying buffer 범위를 벗어난 인덱스 값을 참조하는지 검사한다. It performs the following steps when called:

  1. OtaRecord.[[Object]] 로 둔다.
  2. bufferByteLengthtaRecord.[[CachedBufferByteLength]] 로 둔다.
  3. 단언: IsDetachedBuffer(O.[[ViewedArrayBuffer]]) 는 bufferByteLengthdetached 일 때 그리고 그럴 때에만 true.
  4. bufferByteLengthdetached 이면 true 반환.
  5. byteOffsetStartO.[[ByteOffset]] 로 둔다.
  6. O.[[ArrayLength]]auto 이면
    1. byteOffsetEndbufferByteLength 로 둔다.
  7. Else
    1. elementSizeTypedArrayElementSize(O) 로 둔다.
    2. byteOffsetEndbyteOffsetStart + O.[[ArrayLength]] × elementSize 로 둔다.
  8. byteOffsetStart > bufferByteLength 또는 byteOffsetEnd > bufferByteLength 이면 true 반환.
  9. NOTE: 길이 0 TypedArray 는 out-of-bounds 로 간주되지 않는다.
  10. false 반환.

10.4.5.15 IsTypedArrayFixedLength ( O )

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

  1. O.[[ArrayLength]]auto 이면 false 반환.
  2. bufferO.[[ViewedArrayBuffer]] 로 둔다.
  3. IsFixedLengthArrayBuffer(buffer) 가 false 이고 IsSharedArrayBuffer(buffer) 가 false 이면 false 반환.
  4. true 반환.

10.4.5.16 IsValidIntegerIndex ( O, index )

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

  1. IsDetachedBuffer(O.[[ViewedArrayBuffer]]) 가 true 이면 false 반환.
  2. index 가 정수 Number 가 아니면 false 반환.
  3. index-0𝔽 이거나 index < -0𝔽 이면 false 반환.
  4. taRecordMakeTypedArrayWithBufferWitnessRecord(O, unordered) 로 둔다.
  5. NOTE: O 의 버퍼가 growable SharedArrayBuffer 일 때 경계 검사(bound check)는 동기화 연산이 아니다.
  6. IsTypedArrayOutOfBounds(taRecord) 가 true 이면 false 반환.
  7. lengthTypedArrayLength(taRecord) 로 둔다.
  8. (index) ≥ length 이면 false 반환.
  9. true 반환.

10.4.5.17 TypedArrayGetElement ( O, index )

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

  1. IsValidIntegerIndex(O, index) 가 false 이면 undefined 반환.
  2. offsetO.[[ByteOffset]] 로 둔다.
  3. elementSizeTypedArrayElementSize(O) 로 둔다.
  4. byteIndexInBuffer 를 ((index) × elementSize) + offset 으로 둔다.
  5. elementTypeTypedArrayElementType(O) 로 둔다.
  6. GetValueFromBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, true, unordered) 반환.

10.4.5.18 TypedArraySetElement ( O, index, value )

The abstract operation TypedArraySetElement takes arguments O (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns unused 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. O.[[ContentType]]bigint 이면 numValue 를 ? ToBigInt(value) 로 둔다.
  2. 아니면 numValue 를 ? ToNumber(value) 로 둔다.
  3. IsValidIntegerIndex(O, index) 가 true 이면
    1. offsetO.[[ByteOffset]] 로 둔다.
    2. elementSizeTypedArrayElementSize(O) 로 둔다.
    3. byteIndexInBuffer 를 ((index) × elementSize) + offset 으로 둔다.
    4. elementTypeTypedArrayElementType(O) 로 둔다.
    5. SetValueInBuffer(O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue, true, unordered) 수행.
  4. unused 반환.
Note

이 연산은 항상 성공하는 것처럼 보이나, TypedArray 끝을 넘어 쓰거나 분리(detached)된 ArrayBuffer 기반 TypedArray 에 쓰려 할 때는 효과가 없다.

10.4.5.19 IsArrayBufferViewOutOfBounds ( O )

The abstract operation IsArrayBufferViewOutOfBounds takes argument O (a TypedArray or a DataView) and returns a Boolean. TypedArray 의 수치 프로퍼티 또는 DataView 메서드가 underlying data block 범위를 벗어난 인덱스 값을 참조할 수 있는지 검사한다. 상위(spec) 명세 편의를 위해 존재. It performs the following steps when called:

  1. O[[DataView]] 내부 슬롯을 가지면
    1. viewRecordMakeDataViewWithBufferWitnessRecord(O, seq-cst) 로 둔다.
    2. IsViewOutOfBounds(viewRecord) 반환.
  2. taRecordMakeTypedArrayWithBufferWitnessRecord(O, seq-cst) 로 둔다.
  3. IsTypedArrayOutOfBounds(taRecord) 반환.

10.4.6 모듈 네임스페이스 이그조틱 객체(Module Namespace Exotic Objects)

모듈 네임스페이스 이그조틱 객체는 ECMAScript Module에서 export 된 바인딩을 노출하는 이그조틱 객체이다(16.2.3 참조). 모듈 네임스페이스 이그조틱 객체의 String-keyed 자체 프로퍼티와 Module 이 export 한 바인딩 이름 사이엔 1:1 대응이 있다. export 된 바인딩에는 export * 로 간접 export 된 바인딩도 포함된다. 각 String 값인 자체 프로퍼티 키는 해당 export 바인딩 이름의 StringValue 이다. 이들이 모듈 네임스페이스 이그조틱 객체의 유일한 String-keyed 프로퍼티이다. 각 프로퍼티는 { [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false } 속성을 가진다. 모듈 네임스페이스 이그조틱 객체는 비확장(extensible 아님)이다.

객체의 [[GetPrototypeOf]], [[SetPrototypeOf]], [[IsExtensible]], [[PreventExtensions]], [[GetOwnProperty]], [[DefineOwnProperty]], [[HasProperty]], [[Get]], [[Set]], [[Delete]], [[OwnPropertyKeys]] 내부 메서드가 이 절의 정의를 사용하고 그 외 핵심 내부 메서드가 10.1 정의를 사용하면 그 객체는 모듈 네임스페이스 이그조틱 객체이다. 이러한 메서드는 ModuleNamespaceCreate 에 의해 설치된다.

모듈 네임스페이스 이그조틱 객체Table 31에 정의된 내부 슬롯을 가진다.

Table 31: 모듈 네임스페이스 이그조틱 객체의 내부 슬롯(Internal Slots of Module Namespace Exotic Objects)
Internal Slot Type Description
[[Module]] a Module Record 이 네임스페이스가 export 를 노출하는 Module Record.
[[Exports]] a List of Strings 이 객체의 자체 프로퍼티로 노출되는 export 이름들의 String 값 요소를 가진 List. 코드 유닛 사전식 순서로 정렬됨.

10.4.6.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of 모듈 네임스페이스 이그조틱 객체 takes no arguments and returns null 을 담는 normal completion. It performs the following steps when called:

  1. null 반환.

10.4.6.2 [[SetPrototypeOf]] ( V )

The [[SetPrototypeOf]] internal method of 모듈 네임스페이스 이그조틱 객체 O takes argument V (an Object or null) and returns Boolean 을 담는 normal completion. It performs the following steps when called:

  1. SetImmutablePrototype(O, V) 반환.

10.4.6.3 [[IsExtensible]] ( )

The [[IsExtensible]] internal method of 모듈 네임스페이스 이그조틱 객체 takes no arguments and returns false 를 담는 normal completion. It performs the following steps when called:

  1. false 반환.

10.4.6.4 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of 모듈 네임스페이스 이그조틱 객체 takes no arguments and returns true 를 담는 normal completion. It performs the following steps when called:

  1. true 반환.

10.4.6.5 [[GetOwnProperty]] ( P )

The [[GetOwnProperty]] internal method of 모듈 네임스페이스 이그조틱 객체 O takes argument P (a property key) and returns Property Descriptor 또는 undefined 를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. P 가 Symbol 이면 OrdinaryGetOwnProperty(O, P) 반환.
  2. exportsO.[[Exports]] 로 둔다.
  3. exportsP 를 포함하지 않으면 undefined 반환.
  4. value 를 ? O.[[Get]](P, O) 로 둔다.
  5. PropertyDescriptor { [[Value]]: value, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false } 반환.

10.4.6.6 [[DefineOwnProperty]] ( P, Desc )

The [[DefineOwnProperty]] internal method of 모듈 네임스페이스 이그조틱 객체 O takes arguments P (a property key) and Desc (a Property Descriptor) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. P 가 Symbol 이면 ! OrdinaryDefineOwnProperty(O, P, Desc) 반환.
  2. current 를 ? O.[[GetOwnProperty]](P) 로 둔다.
  3. currentundefined 이면 false 반환.
  4. Desc[[Configurable]] 필드가 있고 그 값이 true 이면 false 반환.
  5. Desc[[Enumerable]] 필드가 있고 그 값이 false 이면 false 반환.
  6. IsAccessorDescriptor(Desc) 가 true 이면 false 반환.
  7. Desc[[Writable]] 필드가 있고 그 값이 false 이면 false 반환.
  8. Desc[[Value]] 필드가 있으면 SameValue(Desc.[[Value]], current.[[Value]]) 반환.
  9. true 반환.

10.4.6.7 [[HasProperty]] ( P )

The [[HasProperty]] internal method of 모듈 네임스페이스 이그조틱 객체 O takes argument P (a property key) and returns Boolean 을 담는 normal completion. It performs the following steps when called:

  1. P 가 Symbol 이면 ! OrdinaryHasProperty(O, P) 반환.
  2. exportsO.[[Exports]] 로 둔다.
  3. exportsP 를 포함하면 true 반환.
  4. false 반환.

10.4.6.8 [[Get]] ( P, Receiver )

The [[Get]] internal method of 모듈 네임스페이스 이그조틱 객체 O takes arguments P (a property key) and Receiver (an ECMAScript language value) and returns ECMAScript 언어 값 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. P 가 Symbol 이면
    1. OrdinaryGet(O, P, Receiver) 반환.
  2. exportsO.[[Exports]] 로 둔다.
  3. exportsP 를 포함하지 않으면 undefined 반환.
  4. mO.[[Module]] 로 둔다.
  5. bindingm.ResolveExport(P) 로 둔다.
  6. 단언: bindingResolvedBinding Record.
  7. targetModulebinding.[[Module]] 로 둔다.
  8. 단언: targetModuleundefined 가 아님.
  9. binding.[[BindingName]]namespace 이면
    1. GetModuleNamespace(targetModule) 반환.
  10. targetEnvtargetModule.[[Environment]] 로 둔다.
  11. targetEnvempty 이면 ReferenceError 예외 throw.
  12. targetEnv.GetBindingValue(binding.[[BindingName]], true) 반환.
Note

ResolveExport 는 부작용이 없다. 특정 exportName, resolveSet 인수 쌍으로 이 연산을 호출할 때마다 동일 결과를 반환해야 한다. 구현은 각 모듈 네임스페이스 이그조틱 객체[[Exports]] 에 대한 ResolveExport 결과를 미리 계산하거나 캐시할 수 있다.

10.4.6.9 [[Set]] ( P, V, Receiver )

The [[Set]] internal method of 모듈 네임스페이스 이그조틱 객체 takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns false 를 담는 normal completion. It performs the following steps when called:

  1. false 반환.

10.4.6.10 [[Delete]] ( P )

The [[Delete]] internal method of 모듈 네임스페이스 이그조틱 객체 O takes argument P (a property key) and returns Boolean 을 담는 normal completion. It performs the following steps when called:

  1. P 가 Symbol 이면
    1. OrdinaryDelete(O, P) 반환.
  2. exportsO.[[Exports]] 로 둔다.
  3. exportsP 를 포함하면 false 반환.
  4. true 반환.

10.4.6.11 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of 모듈 네임스페이스 이그조틱 객체 O takes no arguments and returns 프로퍼티 키 List 를 담는 normal completion. It performs the following steps when called:

  1. exportsO.[[Exports]] 로 둔다.
  2. symbolKeysOrdinaryOwnPropertyKeys(O) 로 둔다.
  3. exportssymbolKeys 의 리스트 연결(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. 새 모듈 네임스페이스 이그조틱 객체 생성 명세에 사용된다. It performs the following steps when called:

  1. 단언: module.[[Namespace]]empty.
  2. internalSlotsListTable 31에 나열된 내부 슬롯으로 둔다.
  3. MMakeBasicObject(internalSlotsList) 로 둔다.
  4. M 의 핵심 내부 메서드를 10.4.6에 지정된 정의로 설정.
  5. M.[[Module]]module 로 설정.
  6. sortedExportsexports 요소를 코드 유닛 사전식 순서로 정렬한 List 로 둔다.
  7. M.[[Exports]]sortedExports 로 설정.
  8. 28.3에 정의된 대로 M 의 자체 프로퍼티를 생성.
  9. module.[[Namespace]]M 으로 설정.
  10. M 반환.

10.4.7 불변 프로토타입 이그조틱 객체(Immutable Prototype Exotic Objects)

불변 프로토타입 이그조틱 객체는 초기화 이후 변경되지 않는 [[Prototype]] 내부 슬롯을 가진 이그조틱 객체이다.

객체의 [[SetPrototypeOf]] 내부 메서드가 아래 구현을 사용한다면 그 객체는 불변 프로토타입 이그조틱 객체이다. (그 외 핵심 내부 메서드는 구체적 객체에 따라 임의 구현을 사용할 수 있다.)

Note

다른 이그조틱 객체와 달리 불변 프로토타입 이그조틱 객체를 위한 전용 생성 추상 연산은 제공되지 않는다. 이는 %Object.prototype%호스트 환경에서만 사용되고, 호스트 환경에서는 관련 객체들이 다른 방식으로도 이그조틱일 수 있어 자체 전용 생성 연산이 필요하기 때문이다.

10.4.7.1 [[SetPrototypeOf]] ( V )

The [[SetPrototypeOf]] internal method of 불변 프로토타입 이그조틱 객체 O takes argument V (an Object or null) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. SetImmutablePrototype(O, V) 반환.

10.4.7.2 SetImmutablePrototype ( O, V )

The abstract operation SetImmutablePrototype takes arguments O (an Object) and V (an Object or null) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. current 를 ? O.[[GetPrototypeOf]]() 로 둔다.
  2. SameValue(V, current) 가 true 이면 true 반환.
  3. false 반환.

10.5 Proxy 객체의 내부 메서드와 내부 슬롯(Proxy Object Internal Methods and Internal Slots)

Proxy 객체는 필수 내부 메서드가 ECMAScript 코드로 일부 구현된 이그조틱 객체이다. 모든 Proxy 객체는 [[ProxyHandler]] 라는 내부 슬롯을 가진다. [[ProxyHandler]] 의 값은 프록시의 handler object 라 불리는 객체이거나 null 이다. 핸들러 객체의 메서드들(Table 32 참조)은 하나 이상 Proxy 객체 내부 메서드 구현을 확장(augment)하는 데 사용될 수 있다. 모든 Proxy 객체는 또한 [[ProxyTarget]] 이라 불리는 내부 슬롯을 가지며 그 값은 객체 또는 null 이다. 이 객체를 프록시의 target object 라고 한다.

객체의 (해당한다면 [[Call]][[Construct]] 포함) 필수 내부 메서드가 이 절의 정의를 사용한다면 그 객체는 Proxy 이그조틱 객체이다. 이러한 내부 메서드는 ProxyCreate 에서 설치된다.

Table 32: Proxy Handler Methods
Internal Method Handler Method
[[GetPrototypeOf]] getPrototypeOf
[[SetPrototypeOf]] setPrototypeOf
[[IsExtensible]] isExtensible
[[PreventExtensions]] preventExtensions
[[GetOwnProperty]] getOwnPropertyDescriptor
[[DefineOwnProperty]] defineProperty
[[HasProperty]] has
[[Get]] get
[[Set]] set
[[Delete]] deleteProperty
[[OwnPropertyKeys]] ownKeys
[[Call]] apply
[[Construct]] construct

프록시 객체 내부 메서드 구현을 제공하기 위해 핸들러 메서드가 호출될 때 핸들러 메서드에는 프록시의 target 객체가 매개변수로 전달된다. 프록시의 핸들러 객체가 모든 필수 내부 메서드에 대응하는 메서드를 반드시 가질 필요는 없다. 프록시에서 내부 메서드를 호출했을 때 핸들러 객체가 해당 내부 트랩에 대응하는 메서드를 가지지 않으면 프록시 target 객체의 대응 내부 메서드가 호출된다.

Proxy 객체의 [[ProxyHandler]][[ProxyTarget]] 내부 슬롯은 객체 생성 시 항상 초기화되며 일반적으로 수정될 수 없다. 일부 Proxy 객체는 이후 revoked 될 수 있는 방식으로 생성된다. 프록시가 철회(revoke)되면 그 [[ProxyHandler]][[ProxyTarget]] 내부 슬롯이 null 로 설정되어 이후 그 Proxy 객체의 내부 메서드 호출은 TypeError 예외를 던진다.

Proxy 객체는 내부 메서드 구현을 임의의 ECMAScript 코드로 제공할 수 있게 하므로, 6.1.7.3 에 정의된 불변식을 위반하는 핸들러 메서드를 가진 Proxy 객체를 정의할 가능성이 있다. 6.1.7.3 에 정의된 내부 메서드 불변식 중 일부는 필수 무결성 불변식이며, 이들은 이 절에 명시된 Proxy 객체 내부 메서드에 의해 명시적으로 강제된다. ECMAScript 구현은 모든 가능한 불변식 위반 존재 시에도 견고해야 한다.

이하 알고리즘 설명에서 O 는 ECMAScript Proxy 객체, P프로퍼티 키 값, V 는 임의의 ECMAScript 언어 값, DescProperty Descriptor 레코드라고 가정한다.

10.5.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of a Proxy exotic object O takes no arguments and returns Object 또는 null 을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 를 수행한다.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "getPrototypeOf") 로 둔다.
  6. trapundefined 이면
    1. target.[[GetPrototypeOf]]() 를 반환한다.
  7. handlerProto 를 ? Call(trap, handler, « target ») 로 둔다.
  8. handlerProto 가 Object 도 아니고 null 도 아니면 TypeError 예외 throw.
  9. extensibleTarget 을 ? IsExtensible(target) 로 둔다.
  10. extensibleTargettrue 이면 handlerProto 반환.
  11. targetProto 를 ? target.[[GetPrototypeOf]]() 로 둔다.
  12. SameValue(handlerProto, targetProto) 가 false 이면 TypeError 예외 throw.
  13. handlerProto 반환.
Note

Proxy 객체의 [[GetPrototypeOf]] 는 다음 불변식을 강제한다:

  • [[GetPrototypeOf]] 결과는 Object 또는 null 이어야 한다.
  • target 객체가 비확장(non-extensible) 이면 Proxy 객체에 적용한 [[GetPrototypeOf]] 는 target 객체에 적용한 [[GetPrototypeOf]] 와 동일 값을 반환해야 한다.

10.5.2 [[SetPrototypeOf]] ( V )

The [[SetPrototypeOf]] internal method of a Proxy exotic object O takes argument V (an Object or null) and returns Boolean 을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "setPrototypeOf") 로 둔다.
  6. trapundefined 이면
    1. target.[[SetPrototypeOf]](V) 반환.
  7. booleanTrapResultToBoolean(? Call(trap, handler, « target, V »)) 로 둔다.
  8. booleanTrapResultfalse 이면 false 반환.
  9. extensibleTarget 을 ? IsExtensible(target) 로 둔다.
  10. extensibleTargettrue 이면 true 반환.
  11. targetProto 를 ? target.[[GetPrototypeOf]]() 로 둔다.
  12. SameValue(V, targetProto) 가 false 이면 TypeError 예외 throw.
  13. true 반환.
Note

Proxy 객체의 [[SetPrototypeOf]] 는 다음 불변식을 강제한다:

  • [[SetPrototypeOf]] 의 결과는 Boolean 값이다.
  • target 객체가 비확장이라면 인수 값은 target 객체에 적용한 [[GetPrototypeOf]] 결과와 동일해야 한다.

10.5.3 [[IsExtensible]] ( )

The [[IsExtensible]] internal method of a Proxy exotic object O takes no arguments and returns Boolean 을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "isExtensible") 로 둔다.
  6. trapundefined 이면
    1. IsExtensible(target) 반환.
  7. booleanTrapResultToBoolean(? Call(trap, handler, « target »)) 로 둔다.
  8. targetResult 를 ? IsExtensible(target) 로 둔다.
  9. booleanTrapResulttargetResult 와 다르면 TypeError 예외 throw.
  10. booleanTrapResult 반환.
Note

Proxy 객체의 [[IsExtensible]] 는 다음 불변식을 강제한다:

  • [[IsExtensible]] 결과는 Boolean 값이다.
  • Proxy 객체에 적용한 [[IsExtensible]] 결과는 동일 인수로 target 객체에 적용한 [[IsExtensible]] 결과와 동일해야 한다.

10.5.4 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of a Proxy exotic object O takes no arguments and returns Boolean 을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "preventExtensions") 로 둔다.
  6. trapundefined 이면
    1. target.[[PreventExtensions]]() 반환.
  7. booleanTrapResultToBoolean(? Call(trap, handler, « target »)) 로 둔다.
  8. booleanTrapResulttrue 이면
    1. extensibleTarget 을 ? IsExtensible(target) 로 둔다.
    2. extensibleTargettrue 이면 TypeError 예외 throw.
  9. booleanTrapResult 반환.
Note

Proxy 객체의 [[PreventExtensions]] 는 다음 불변식을 강제한다:

  • [[PreventExtensions]] 결과는 Boolean 값이다.
  • Proxy 객체에 적용한 [[PreventExtensions]]true 를 반환하는 경우는 target 객체에 적용한 [[IsExtensible]]false 일 때뿐이다.

10.5.5 [[GetOwnProperty]] ( P )

The [[GetOwnProperty]] internal method of a Proxy exotic object O takes argument P (a property key) and returns Property Descriptor 또는 undefined 를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "getOwnPropertyDescriptor") 로 둔다.
  6. trapundefined 이면
    1. target.[[GetOwnProperty]](P) 반환.
  7. trapResultObj 를 ? Call(trap, handler, « target, P ») 로 둔다.
  8. trapResultObj 가 Object 도 아니고 undefined 도 아니면 TypeError 예외 throw.
  9. targetDesc 를 ? target.[[GetOwnProperty]](P) 로 둔다.
  10. trapResultObjundefined 이면
    1. targetDescundefined 이면 undefined 반환.
    2. targetDesc.[[Configurable]]false 이면 TypeError 예외 throw.
    3. extensibleTarget 을 ? IsExtensible(target) 로 둔다.
    4. extensibleTargetfalse 이면 TypeError 예외 throw.
    5. undefined 반환.
  11. extensibleTarget 을 ? IsExtensible(target) 로 둔다.
  12. resultDesc 를 ? ToPropertyDescriptor(trapResultObj) 로 둔다.
  13. CompletePropertyDescriptor(resultDesc) 수행.
  14. validIsCompatiblePropertyDescriptor(extensibleTarget, resultDesc, targetDesc) 로 둔다.
  15. validfalse 이면 TypeError 예외 throw.
  16. resultDesc.[[Configurable]]false 이면
    1. targetDescundefined 이거나 targetDesc.[[Configurable]]true 이면
      1. TypeError 예외 throw.
    2. resultDesc[[Writable]] 필드가 있고 resultDesc.[[Writable]]false 이면
      1. 단언: targetDesc[[Writable]] 필드를 가진다.
      2. targetDesc.[[Writable]]true 이면 TypeError 예외 throw.
  17. resultDesc 반환.
Note

Proxy 객체의 [[GetOwnProperty]] 는 다음 불변식을 강제한다:

  • [[GetOwnProperty]] 결과는 Object 또는 undefined 여야 한다.
  • target 객체에 비구성 가능(non-configurable) 자체 프로퍼티로 존재하면 그 프로퍼티를 비존재로 보고할 수 없다.
  • target 객체가 비확장이고 해당 프로퍼티가 자체 프로퍼티로 존재하면 비존재로 보고할 수 없다.
  • target 객체가 비확장이고 해당 프로퍼티가 target 에 자체 프로퍼티로 존재하지 않으면 존재한다고 보고할 수 없다.
  • target 객체에 대응 비구성 가능 자체 프로퍼티가 없으면 프로퍼티를 비구성 가능으로 보고할 수 없다.
  • target 객체에 대응 비구성 가능·비쓰기(non-writable) 자체 프로퍼티가 없으면 프로퍼티를 동시에 비구성 가능 & 비쓰기라고 보고할 수 없다.

10.5.6 [[DefineOwnProperty]] ( P, Desc )

The [[DefineOwnProperty]] internal method of a Proxy exotic object O takes arguments P (a property key) and Desc (a Property Descriptor) and returns Boolean 을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "defineProperty") 로 둔다.
  6. trapundefined 이면
    1. target.[[DefineOwnProperty]](P, Desc) 반환.
  7. descObjFromPropertyDescriptor(Desc) 로 둔다.
  8. booleanTrapResultToBoolean(? Call(trap, handler, « target, P, descObj »)) 로 둔다.
  9. booleanTrapResultfalse 이면 false 반환.
  10. targetDesc 를 ? target.[[GetOwnProperty]](P) 로 둔다.
  11. extensibleTarget 을 ? IsExtensible(target) 로 둔다.
  12. Desc[[Configurable]] 필드가 있고 Desc.[[Configurable]]false 이면
    1. settingConfigFalsetrue 로 둔다.
  13. Else
    1. settingConfigFalsefalse 로 둔다.
  14. targetDescundefined 이면
    1. extensibleTargetfalse 이면 TypeError 예외 throw.
    2. settingConfigFalsetrue 이면 TypeError 예외 throw.
  15. Else
    1. IsCompatiblePropertyDescriptor(extensibleTarget, Desc, targetDesc) 가 false 이면 TypeError 예외 throw.
    2. settingConfigFalsetrue 이고 targetDesc.[[Configurable]]true 이면 TypeError 예외 throw.
    3. IsDataDescriptor(targetDesc) 가 true 이고 targetDesc.[[Configurable]]false 이며 targetDesc.[[Writable]]true 이면
      1. Desc[[Writable]] 필드가 있고 Desc.[[Writable]]false 이면 TypeError 예외 throw.
  16. true 반환.
Note

Proxy 객체의 [[DefineOwnProperty]] 는 다음 불변식을 강제한다:

  • [[DefineOwnProperty]] 결과는 Boolean 값이다.
  • target 객체가 비확장이라면 프로퍼티를 추가할 수 없다.
  • target 객체에 대응 비구성 가능 자체 프로퍼티가 없으면 프로퍼티를 비구성 가능으로 만들 수 없다.
  • 대응 비구성 가능·비쓰기 자체 프로퍼티가 없으면 비구성 가능 프로퍼티를 비쓰기 상태로 만들 수 없다.
  • 프로퍼티에 대응하는 target 프로퍼티가 존재한다면 그 프로퍼티의 Descriptor 를 target 에 [[DefineOwnProperty]] 로 적용해도 예외가 발생하지 않아야 한다.

10.5.7 [[HasProperty]] ( P )

The [[HasProperty]] internal method of a Proxy exotic object O takes argument P (a property key) and returns Boolean 을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "has") 로 둔다.
  6. trapundefined 이면
    1. target.[[HasProperty]](P) 반환.
  7. booleanTrapResultToBoolean(? Call(trap, handler, « target, P »)) 로 둔다.
  8. booleanTrapResultfalse 이면
    1. targetDesc 를 ? target.[[GetOwnProperty]](P) 로 둔다.
    2. targetDescundefined 가 아니면
      1. targetDesc.[[Configurable]]false 이면 TypeError 예외 throw.
      2. extensibleTarget 을 ? IsExtensible(target) 로 둔다.
      3. extensibleTargetfalse 이면 TypeError 예외 throw.
  9. booleanTrapResult 반환.
Note

Proxy 객체의 [[HasProperty]] 는 다음 불변식을 강제한다:

  • [[HasProperty]] 결과는 Boolean 값이다.
  • target 객체에 비구성 가능 자체 프로퍼티로 존재하면 비존재로 보고할 수 없다.
  • target 객체가 비확장이고 해당 프로퍼티가 자체 프로퍼티로 존재하면 비존재로 보고할 수 없다.

10.5.8 [[Get]] ( P, Receiver )

The [[Get]] internal method of a Proxy exotic object O takes arguments P (a property key) and Receiver (an ECMAScript language value) and returns ECMAScript 언어 값 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "get") 로 둔다.
  6. trapundefined 이면
    1. target.[[Get]](P, Receiver) 반환.
  7. trapResult 를 ? Call(trap, handler, « target, P, Receiver ») 로 둔다.
  8. targetDesc 를 ? target.[[GetOwnProperty]](P) 로 둔다.
  9. targetDescundefined 가 아니고 targetDesc.[[Configurable]]false 이면
    1. IsDataDescriptor(targetDesc) 가 true 이고 targetDesc.[[Writable]]false 이면
      1. SameValue(trapResult, targetDesc.[[Value]]) 가 false 이면 TypeError 예외 throw.
    2. IsAccessorDescriptor(targetDesc) 가 true 이고 targetDesc.[[Get]]undefined 이면
      1. trapResultundefined 가 아니면 TypeError 예외 throw.
  10. trapResult 반환.
Note

Proxy 객체의 [[Get]] 는 다음 불변식을 강제한다:

  • target 객체 프로퍼티가 비쓰기·비구성 가능 자체 데이터 프로퍼티라면 보고되는 값은 target 프로퍼티 값과 동일해야 한다.
  • target 객체 프로퍼티가 [[Get]]undefined 인 비구성 가능 자체 접근자 프로퍼티라면 보고되는 값은 undefined 이어야 한다.

10.5.9 [[Set]] ( P, V, Receiver )

The [[Set]] internal method of a Proxy exotic object O takes arguments P (a property key), V (an ECMAScript language value), and Receiver (an ECMAScript language value) and returns Boolean 을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "set") 로 둔다.
  6. trapundefined 이면
    1. target.[[Set]](P, V, Receiver) 반환.
  7. booleanTrapResultToBoolean(? Call(trap, handler, « target, P, V, Receiver »)) 로 둔다.
  8. booleanTrapResultfalse 이면 false 반환.
  9. targetDesc 를 ? target.[[GetOwnProperty]](P) 로 둔다.
  10. targetDescundefined 가 아니고 targetDesc.[[Configurable]]false 이면
    1. IsDataDescriptor(targetDesc) 가 true 이고 targetDesc.[[Writable]]false 이면
      1. SameValue(V, targetDesc.[[Value]]) 가 false 이면 TypeError 예외 throw.
    2. IsAccessorDescriptor(targetDesc) 가 true 이면
      1. targetDesc.[[Set]]undefined 이면 TypeError 예외 throw.
  11. true 반환.
Note

Proxy 객체의 [[Set]] 는 다음 불변식을 강제한다:

  • [[Set]] 결과는 Boolean 값이다.
  • 대응 target 프로퍼티가 비쓰기·비구성 가능 자체 데이터 프로퍼티라면 그 값을 다른 값으로 바꿀 수 없다.
  • 대응 target 프로퍼티가 [[Set]]undefined 인 비구성 가능 자체 접근자 프로퍼티라면 값을 설정할 수 없다.

10.5.10 [[Delete]] ( P )

The [[Delete]] internal method of a Proxy exotic object O takes argument P (a property key) and returns Boolean 을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "deleteProperty") 로 둔다.
  6. trapundefined 이면
    1. target.[[Delete]](P) 반환.
  7. booleanTrapResultToBoolean(? Call(trap, handler, « target, P »)) 로 둔다.
  8. booleanTrapResultfalse 이면 false 반환.
  9. targetDesc 를 ? target.[[GetOwnProperty]](P) 로 둔다.
  10. targetDescundefined 이면 true 반환.
  11. targetDesc.[[Configurable]]false 이면 TypeError 예외 throw.
  12. extensibleTarget 을 ? IsExtensible(target) 로 둔다.
  13. extensibleTargetfalse 이면 TypeError 예외 throw.
  14. true 반환.
Note

Proxy 객체의 [[Delete]] 는 다음 불변식을 강제한다:

  • [[Delete]] 결과는 Boolean 값이다.
  • target 객체에 비구성 가능 자체 프로퍼티로 존재하면 삭제되었다고 보고할 수 없다.
  • target 객체가 비확장이고 해당 프로퍼티가 자체 프로퍼티로 존재하면 삭제되었다고 보고할 수 없다.

10.5.11 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of a Proxy exotic object O takes no arguments and returns 프로퍼티 키 List 를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "ownKeys") 로 둔다.
  6. trapundefined 이면
    1. target.[[OwnPropertyKeys]]() 반환.
  7. trapResultArray 를 ? Call(trap, handler, « target ») 로 둔다.
  8. trapResult 를 ? CreateListFromArrayLike(trapResultArray, property-key) 로 둔다.
  9. trapResult 가 중복 항목을 포함하면 TypeError 예외 throw.
  10. extensibleTarget 을 ? IsExtensible(target) 로 둔다.
  11. targetKeys 를 ? target.[[OwnPropertyKeys]]() 로 둔다.
  12. 단언: targetKeys프로퍼티 키들의 List.
  13. 단언: targetKeys 는 중복 항목이 없다.
  14. targetConfigurableKeys 를 새 빈 List 로 둔다.
  15. targetNonconfigurableKeys 를 새 빈 List 로 둔다.
  16. targetKeys 의 각 요소 key 에 대해
    1. desc 를 ? target.[[GetOwnProperty]](key) 로 둔다.
    2. descundefined 가 아니고 desc.[[Configurable]]false 이면
      1. targetNonconfigurableKeyskey 추가.
    3. Else
      1. targetConfigurableKeyskey 추가.
  17. extensibleTargettrue 이고 targetNonconfigurableKeys 가 비어 있으면
    1. trapResult 반환.
  18. uncheckedResultKeystrapResult 요소들로 구성된 List 로 둔다.
  19. targetNonconfigurableKeys 의 각 key 에 대해
    1. uncheckedResultKeyskey 를 포함하지 않으면 TypeError 예외 throw.
    2. uncheckedResultKeys 에서 key 제거.
  20. extensibleTargettrue 이면 trapResult 반환.
  21. targetConfigurableKeys 의 각 key 에 대해
    1. uncheckedResultKeyskey 를 포함하지 않으면 TypeError 예외 throw.
    2. uncheckedResultKeys 에서 key 제거.
  22. uncheckedResultKeys 가 비어 있지 않으면 TypeError 예외 throw.
  23. trapResult 반환.
Note

Proxy 객체의 [[OwnPropertyKeys]] 는 다음 불변식을 강제한다:

  • [[OwnPropertyKeys]] 결과는 List 이다.
  • 반환된 List 에는 중복 항목이 없다.
  • 반환 List 의 각 요소는 프로퍼티 키이다.
  • 결과 List 는 target 객체의 모든 비구성 가능 자체 프로퍼티의 키를 포함해야 한다.
  • target 객체가 비확장이라면 결과 List 는 target 객체 자체 프로퍼티의 모든 키만 포함해야 한다.

10.5.12 [[Call]] ( thisArgument, argumentsList )

The [[Call]] internal method of a Proxy exotic object O takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns ECMAScript 언어 값 또는 throw completion 을 담는 normal completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. handlerO.[[ProxyHandler]] 로 둔다.
  4. 단언: handler 는 Object.
  5. trap 을 ? GetMethod(handler, "apply") 로 둔다.
  6. trapundefined 이면
    1. Call(target, thisArgument, argumentsList) 반환.
  7. argArrayCreateArrayFromList(argumentsList) 로 둔다.
  8. Call(trap, handler, « target, thisArgument, argArray ») 반환.
Note

Proxy 이그조틱 객체[[ProxyTarget]] 내부 슬롯 초기 값이 [[Call]] 내부 메서드를 가진 객체인 경우에만 [[Call]] 내부 메서드를 가진다.

10.5.13 [[Construct]] ( argumentsList, newTarget )

The [[Construct]] internal method of a Proxy exotic object O takes arguments argumentsList (a List of ECMAScript language values) and newTarget (a constructor) and returns Object 를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(O) 수행.
  2. targetO.[[ProxyTarget]] 로 둔다.
  3. 단언: IsConstructor(target) 는 true.
  4. handlerO.[[ProxyHandler]] 로 둔다.
  5. 단언: handler 는 Object.
  6. trap 을 ? GetMethod(handler, "construct") 로 둔다.
  7. trapundefined 이면
    1. Construct(target, argumentsList, newTarget) 반환.
  8. argArrayCreateArrayFromList(argumentsList) 로 둔다.
  9. newObj 를 ? Call(trap, handler, « target, argArray, newTarget ») 로 둔다.
  10. newObj 가 Object 가 아니면 TypeError 예외 throw.
  11. newObj 반환.
Note 1

Proxy 이그조틱 객체[[ProxyTarget]] 내부 슬롯 초기 값이 [[Construct]] 내부 메서드를 가진 객체인 경우에만 [[Construct]] 내부 메서드를 가진다.

Note 2

Proxy 객체의 [[Construct]] 는 다음 불변식을 강제한다:

  • [[Construct]] 결과는 Object 이어야 한다.

10.5.14 ValidateNonRevokedProxy ( proxy )

The abstract operation ValidateNonRevokedProxy takes argument proxy (a Proxy exotic object) and returns unused 를 담는 normal completion 또는 throw completion. proxy 가 revoke 되었다면 TypeError 예외를 던진다. It performs the following steps when called:

  1. proxy.[[ProxyTarget]]null 이면 TypeError 예외 throw.
  2. 단언: proxy.[[ProxyHandler]]null 이 아님.
  3. unused 반환.

10.5.15 ProxyCreate ( target, handler )

The abstract operation ProxyCreate takes arguments target (an ECMAScript language value) and handler (an ECMAScript language value) and returns Proxy 이그조틱 객체를 담는 normal completion 또는 throw completion. 새 Proxy 객체 생성 과정을 명세하는 데 사용된다. It performs the following steps when called:

  1. target 이 Object 가 아니면 TypeError 예외 throw.
  2. handler 가 Object 가 아니면 TypeError 예외 throw.
  3. PMakeBasicObject[[ProxyHandler]], [[ProxyTarget]] ») 로 둔다.
  4. P 의 핵심 내부 메서드( [[Call]], [[Construct]] 제외)를 10.5 에 지정된 정의로 설정.
  5. IsCallable(target) 이 true 이면
    1. P.[[Call]]10.5.12 에서 지정된 대로 설정.
    2. IsConstructor(target) 이 true 이면
      1. P.[[Construct]]10.5.13 에서 지정된 대로 설정.
  6. P.[[ProxyTarget]]target 으로 설정.
  7. P.[[ProxyHandler]]handler 로 설정.
  8. P 반환.