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 에 그 내부 메서드를 호출한다. 이러한 의미론은 일반 객체 내부 메서드가 이그조틱 객체에 적용될 때 해당 이그조틱 객체가 재정의한 내부 메서드가 호출되도록 보장한다.
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:
The abstract operation OrdinaryGetPrototypeOf takes argument O (an Object) and returns an Object or null. It performs the following steps when called:
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:
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:
p.[[GetPrototypeOf]] 가 10.1.1 에 정의된 일반 객체 내부 메서드가 아니면 done 을 true 로 설정한다.
아니면 p 를 p.[[Prototype]] 로 설정한다.
O.[[Prototype]] 을 V 로 설정한다.
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:
The abstract operation OrdinaryIsExtensible takes argument O (an Object) and returns a Boolean. It performs the following steps when called:
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:
The abstract operation OrdinaryPreventExtensions takes argument O (an Object) and returns true. It performs the following steps when called:
O.[[Extensible]] 를 false 로 설정한다.
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:
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:
D.[[Enumerable]] 을 X 의 [[Enumerable]] 속성 값으로 설정한다.
D.[[Configurable]] 을 X 의 [[Configurable]] 속성 값으로 설정한다.
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:
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:
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:
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 를 반환한다. 적용 가능하고 O 가 undefined 가 아니면 이름이 P 인 프로퍼티(필요 시 생성됨)에 대해 실제로 적용한다. It performs the following steps when called:
Desc 에 [[Configurable]] 필드가 있으면 configurable 을 그 값으로, 아니면 current.[[Configurable]] 로 둔다.
Desc 에 [[Enumerable]] 필드가 있으면 enumerable 을 그 값으로, 아니면 current.[[Enumerable]] 로 둔다.
객체 O 의 이름 P 인 프로퍼티를 접근자 프로퍼티로 교체하되 [[Configurable]] 과 [[Enumerable]] 은 각각 configurable, enumerable 로, [[Get]], [[Set]] 은 Desc 에 해당 필드가 있으면 그 값, 아니면 기본값 로 설정.
Desc 에 [[Configurable]] 필드가 있으면 configurable 을 그 값으로, 아니면 current.[[Configurable]] 로 둔다.
Desc 에 [[Enumerable]] 필드가 있으면 enumerable 을 그 값으로, 아니면 current.[[Enumerable]] 로 둔다.
객체 O 의 이름 P 인 프로퍼티를 데이터 프로퍼티로 교체하되 [[Configurable]] 과 [[Enumerable]] 은 각각 configurable, enumerable 로, [[Value]], [[Writable]] 은 Desc 에 해당 필드가 있으면 그 값, 아니면 기본값 로 설정.
Else
Desc 의 각 필드에 대해 객체 O 의 이름 P 인 프로퍼티의 대응 속성을 그 필드 값으로 설정.
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:
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:
hasOwn 을 ? O.[[GetOwnProperty]](P) 로 둔다.
hasOwn 이 undefined 가 아니면 true 반환.
parent 를 ? O.[[GetPrototypeOf]]() 로 둔다.
parent 가 null 이 아니면
? parent.[[HasProperty]](P) 를 반환한다.
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:
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:
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:
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:
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:
ownDesc 가 undefined 이면
parent 를 ? O.[[GetPrototypeOf]]() 로 둔다.
parent 가 null 이 아니면
? parent.[[Set]](P, V, Receiver) 를 반환한다.
그렇지 않으면
ownDesc 를 PropertyDescriptor { [[Value]]: undefined, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true } 로 설정한다.
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:
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:
desc 를 ? O.[[GetOwnProperty]](P) 로 둔다.
desc 가 undefined 이면 true 반환.
desc.[[Configurable]] 이 true 이면
이름 P 인 자체 프로퍼티를 O 에서 제거한다.
true 반환.
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:
The abstract operation OrdinaryOwnPropertyKeys takes argument O (an Object) and returns a List of property keys. It performs the following steps when called:
O 의 각 자체 프로퍼티 키P 중 P 가 배열 인덱스인 것들을 숫자 인덱스 오름차순으로 순회하며
keys 에 P 를 추가한다.
O 의 각 자체 프로퍼티 키P 중 P 가 String 이고 배열 인덱스가 아닌 것들을 생성 시점의 시간 순(chronological order) 오름차순으로 순회하며
keys 에 P 를 추가한다.
O 의 각 자체 프로퍼티 키P 중 P 가 Symbol 인 것들을 생성 시점의 시간 순 오름차순으로 순회하며
keys 에 P 를 추가한다.
keys 를 반환한다.
10.1.12 OrdinaryObjectCreate ( proto [ , additionalInternalSlotsList ] )
The abstract operation OrdinaryObjectCreate takes argument proto (an Object or null) and optional argument additionalInternalSlotsList (a List of names of internal slots) and returns an Object. 새 일반 객체를 런타임에 생성하는 과정을 명세하는 데 사용된다. additionalInternalSlotsList 는 [[Prototype]] 과 [[Extensible]] 외에 객체 일부로 정의되어야 하는 추가 내부 슬롯 이름을 담는다. additionalInternalSlotsList 가 제공되지 않으면 새 빈 List 를 사용한다. It performs the following steps when called:
internalSlotsList 를 « [[Prototype]], [[Extensible]] » 로 둔다.
additionalInternalSlotsList 가 주어지면 internalSlotsList 를 그 뒤에 additionalInternalSlotsList 를 이어붙인(list-concatenation) 리스트로 갱신한다.
OrdinaryObjectCreate 는 MakeBasicObject 호출 외에 많은 일을 하지 않지만, 이를 사용함으로써 이그조틱이 아닌 “일반 객체” 를 만들고자 함을 전달한다. 따라서 이 명세에서 결과 객체의 내부 메서드를 비일반적으로 만들 방식으로 이후 수정하는 어떤 알고리즘도 이를 호출하지 않는다. 이그조틱 객체를 생성하는 연산은 MakeBasicObject 를 직접 호출한다.
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:
단언: intrinsicDefaultProto 는 이 명세에서 정의한 intrinsic 객체의 이름이다. 해당 객체는 다른 객체의 [[Prototype]] 값으로 사용되도록 의도된 intrinsic 이어야 한다.
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:
단언: intrinsicDefaultProto 는 이 명세에서 정의한 intrinsic 객체의 이름이다. 해당 객체는 객체의 [[Prototype]] 값으로 사용되도록 의도된 intrinsic 이어야 한다.
proto 를 realm 의 intrinsicDefaultProto 라는 이름의 intrinsic 객체로 설정한다.
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:
O 가 객체가 아니면 TypeError 예외를 던진다.
O 에 internalSlot 내부 슬롯이 없으면 TypeError 예외를 던진다.
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)
this 참조가 형식 매개변수 및 함수 본문 내에서 어떻게 해석되는지 정의. lexical 은 this 가 렉시컬로 둘러싼 함수의 this 값을 가리킴. strict 은 this 값이 호출 시 제공된 그대로 사용됨. global 은 undefined 또는 null 인 this 값을 전역 객체 참조로 해석하고, 다른 this 값은 먼저 ToObject 적용.
단계 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:
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:
thisMode 를 F.[[ThisMode]] 로 둔다.
thisMode 가 lexical 이면 unused 반환.
calleeRealm 을 F.[[Realm]] 로 둔다.
localEnv 를 calleeContext 의 LexicalEnvironment 로 둔다.
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:
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:
F.[[ECMAScriptCode]] 의 EvaluateBody (인수 F, argumentsList) ? 를 반환.
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:
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:
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:
The abstract operation MakeClassConstructor takes argument F (an ECMAScript function object) and returns unused. It performs the following steps when called:
단언: F.[[IsClassConstructor]] 는 false.
F.[[IsClassConstructor]] 를 true 로 설정.
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:
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:
NOTE: key 가 "prototype" 인 class static method 정의 시에만 abrupt completion 반환 가능.
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:
단언: F 는 "name" 자체 프로퍼티가 없는 extensible 객체.
name 이 Symbol 이면
description 을 name.[[Description]] 로 둔다.
description 이 undefined 이면 name 을 빈 문자열로 설정.
그렇지 않으면 name 을 "[", description, "]" 의 문자열 연결로 설정.
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:
ECMAScript 함수를 평가하기 위한 실행 컨텍스트가 설정될 때 새로운 Function Environment Record 가 생성되고 각 형식 매개변수에 대한 바인딩이 그 Environment Record 에서 인스턴스화된다. 함수 본문 내 모든 선언도 인스턴스화된다. 함수의 형식 매개변수에 기본값 초기화자가 없으면 본문 선언들은 매개변수와 동일한 Environment Record 에서 인스턴스화된다. 기본값 매개변수 초기화자가 있으면 본문 선언을 위한 두 번째 Environment Record 가 생성된다. 형식 매개변수와 함수들은 FunctionDeclarationInstantiation 의 일부로 초기화된다. 다른 모든 바인딩은 함수 본문 평가 중 초기화된다.
호출 시 다음 단계를 수행한다:
calleeContext 를 실행 중 실행 컨텍스트로 둔다.
code 를 func.[[ECMAScriptCode]] 로 둔다.
strict 를 func.[[Strict]] 로 둔다.
formals 를 func.[[FormalParameters]] 로 둔다.
parameterNames 를 formals 의 BoundNames 로 둔다.
parameterNames 가 중복 항목을 가지면 hasDuplicates 를 true, 아니면 false 로 둔다.
simpleParameterList 를 IsSimpleParameterList of formals 로 둔다.
hasParameterExpressions 를 ContainsExpression of formals 로 둔다.
varNames 를 code 의 VarDeclaredNames 로 둔다.
varDeclarations 를 code 의 VarScopedDeclarations 로 둔다.
lexicalNames 를 code 의 LexicallyDeclaredNames 로 둔다.
내장 함수 객체는 10.3.1의 정의에 부합하는 [[Call]] 내부 메서드를 가져야 한다.
내장 함수 객체는 “constructor”로 기술되었거나 이 명세의 어떤 알고리즘이 그 [[Construct]] 내부 메서드를 명시적으로 설정한 경우에만 [[Construct]] 내부 메서드를 가진다. 그러한 [[Construct]] 내부 메서드는 10.3.2의 정의를 준수해야 한다.
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:
calleeContext 를 실행 컨텍스트 스택에 push; 이제 calleeContext 가 실행 중 실행 컨텍스트이다.
result 를 F 의 명세에 부합하는 방식으로 F 를 평가하여 얻은 Completion Record 로 둔다. thisArgument 가 uninitialized 이면 this 값은 초기화되지 않은 상태이며; 그렇지 않으면 thisArgument 가 this 값을 제공한다. argumentsList 는 명명된 매개변수들을 제공한다. newTarget 은 NewTarget 값을 제공한다.
NOTE: F 가 이 문서에서 정의된 경우 “the specification of F” 는 알고리즘 단계 등으로 기술된 그 동작을 의미한다.
실행 컨텍스트 스택에서 calleeContext 를 제거하고 callerContext 를 실행 중 실행 컨텍스트로 복원한다.
? result 를 반환한다.
Note
calleeContext 가 실행 컨텍스트 스택에서 제거될 때 접근 가능한 Generator 에 의해 suspend 및 보존되어 후속 재개가 예정된 경우 파괴되어서는 안 된다.
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:
prototype 이 제공되지 않았다면 prototype 을 realm.[[Intrinsics]].[[%Function.prototype%]] 로 설정한다.
internalSlotsList 를 곧 생성할 내장 함수 객체에 대해 10.3가 요구하는 모든 내부 슬롯 이름을 담는 List 로 둔다.
additionalInternalSlotsList 의 요소들을 internalSlotsList 에 추가(Append)한다.
func 를 새 내장 함수 객체로 두되, 호출 시 behaviour 가 지정한 매개변수에 제공 인수를 값으로 하여 behaviour 에 기술된 동작을 수행한다. 새 함수 객체는 internalSlotsList 요소 이름의 내부 슬롯과 [[InitialName]] 내부 슬롯을 가진다.
이 명세에 정의된 각 내장 함수는 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 에서 설치된다.
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:
proto 를 ? targetFunction.[[GetPrototypeOf]]() 로 둔다.
internalSlotsList 를 « [[Prototype]], [[Extensible]] » 와 Table 29에 나열된 내부 슬롯의 리스트 연결로 둔다.
obj.[[BoundTargetFunction]] 을 targetFunction 으로 설정한다.
obj.[[BoundThis]] 를 boundThis 로 설정한다.
obj.[[BoundArguments]] 를 boundArgs 로 설정한다.
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 에서 설치된다.
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:
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:
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:
succeeded 를 ! OrdinaryDefineOwnProperty(A, "length", PropertyDescriptor { [[Writable]]: false }) 로 설정.
단언: succeeded 는 true.
true 반환.
Note
3 및 4 단계에서 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 에서 설치된다.
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:
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:
The [[OwnPropertyKeys]] internal method of String 이그조틱 객체O takes no arguments and returns 프로퍼티 키List 를 담는 normal completion. It performs the following steps when called:
The abstract operation StringCreate takes arguments value (a String) and prototype (an Object) and returns String 이그조틱 객체. 새 String 이그조틱 객체 생성 명세에 사용된다. It performs the following steps when called:
S 를 MakeBasicObject(« [[Prototype]], [[Extensible]], [[StringData]] ») 로 둔다.
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:
대부분의 ECMAScript 함수는 코드에서 사용할 수 있는 arguments 객체를 제공한다. 함수 정의 특성에 따라 그 arguments 객체는 일반 객체이거나 arguments 이그조틱 객체가 된다. arguments 이그조틱 객체는 배열 인덱스 프로퍼티들이 관련 ECMAScript 함수 호출의 형식 매개변수 바인딩에 매핑되는 이그조틱 객체이다.
객체의 내부 메서드가 아래 구현을 사용하고 여기 명시되지 않은 메서드는 10.1의 정의를 사용하면 그 객체는 arguments 이그조틱 객체이다. 이러한 메서드는 CreateMappedArgumentsObject 에서 설치된다.
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 요구를 제거했다.
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:
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:
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:
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:
단언: formals 는 rest 매개변수, 바인딩 패턴, 초기화자를 포함하지 않는다. 중복 식별자는 있을 수 있다.
len 을 argumentsList 요소 개수로 둔다.
obj 를 MakeBasicObject(« [[Prototype]], [[Extensible]], [[ParameterMap]] ») 로 둔다.
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:
getterClosure 를 매개변수 없고 name, env 를 캡처하며 호출 시 다음 단계를 수행하는 새 Abstract Closure 로 둔다:
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:
setterClosure 를 매개변수 (value) 를 가지며 name, env 를 캡처하고 호출 시 다음을 수행하는 새 Abstract Closure 로 둔다:
임의의 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 TypedArrayO takes no arguments and returns Boolean 을 담는 normal completion. It performs the following steps when called:
NOTE: 6.1.7.3에 규정된 확장성 관련 불변식은 O 가 프로퍼티를 얻거나(또는 잃고 다시 얻을) 수 있는 경우 true 를 반환하지 못하게 한다; 이는 underlying buffer 가 resize 될 때 정수 인덱스 이름 프로퍼티에서 발생할 수 있다.
The [[GetOwnProperty]] internal method of TypedArrayO takes argument P (a property key) and returns Property Descriptor 또는 undefined 를 담는 normal completion. It performs the following steps when called:
The [[HasProperty]] internal method of TypedArrayO takes argument P (a property key) and returns Boolean 또는 throw completion 을 담는 normal completion. It performs the following steps when called:
The [[Get]] internal method of TypedArrayO 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:
The [[Set]] internal method of TypedArrayO 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:
The [[Delete]] internal method of TypedArrayO takes argument P (a property key) and returns Boolean 을 담는 normal completion. It performs the following steps when called:
The [[OwnPropertyKeys]] internal method of TypedArrayO takes no arguments and returns 프로퍼티 키List 를 담는 normal completion. It performs the following steps when called:
10.4.5.9 버퍼 증인 레코드가 있는 TypedArray (TypedArray With Buffer Witness Records)
TypedArray With Buffer Witness Record 는 TypedArray 와, 보기 버퍼(viewed buffer)의 캐시된 byte length 를 함께 캡슐화하는 Record 값이다. growable SharedArrayBuffer 를 보는 경우 byte length 데이터 블록에 대한 단일 공유 메모리 읽기 이벤트를 보장하는 데 사용된다.
TypedArray With Buffer Witness Record 는 Table 30에 나온 필드를 가진다.
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:
The abstract operation TypedArrayCreate takes argument prototype (an Object) and returns a TypedArray. 새 TypedArray 생성 명세에 사용된다. It performs the following steps when called:
internalSlotsList 를 « [[Prototype]], [[Extensible]], [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] » 로 둔다.
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:
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:
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:
O 를 taRecord.[[Object]] 로 둔다.
bufferByteLength 를 taRecord.[[CachedBufferByteLength]] 로 둔다.
단언: IsDetachedBuffer(O.[[ViewedArrayBuffer]]) 는 bufferByteLength 가 detached 일 때 그리고 그럴 때에만 true.
The abstract operation IsValidIntegerIndex takes arguments O (a TypedArray) and index (a Number) and returns a Boolean. It performs the following steps when called:
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:
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:
O.[[ContentType]] 가 bigint 이면 numValue 를 ? ToBigInt(value) 로 둔다.
이 연산은 항상 성공하는 것처럼 보이나, 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:
모듈 네임스페이스 이그조틱 객체는 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 에 의해 설치된다.
이 객체의 자체 프로퍼티로 노출되는 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:
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:
The [[IsExtensible]] internal method of 모듈 네임스페이스 이그조틱 객체 takes no arguments and returns false 를 담는 normal completion. It performs the following steps when called:
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:
Desc 에 [[Writable]] 필드가 있고 그 값이 false 이면 false 반환.
Desc 에 [[Value]] 필드가 있으면 SameValue(Desc.[[Value]], current.[[Value]]) 반환.
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:
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:
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:
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:
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:
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:
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 구현은 모든 가능한 불변식 위반 존재 시에도 견고해야 한다.
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:
SameValue(handlerProto, targetProto) 가 false 이면 TypeError 예외 throw.
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:
SameValue(V, targetProto) 가 false 이면 TypeError 예외 throw.
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:
booleanTrapResult 가 targetResult 와 다르면 TypeError 예외 throw.
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:
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:
targetDesc 가 undefined 이거나 targetDesc.[[Configurable]] 이 true 이면
TypeError 예외 throw.
resultDesc 에 [[Writable]] 필드가 있고 resultDesc.[[Writable]] 이 false 이면
단언: targetDesc 는 [[Writable]] 필드를 가진다.
targetDesc.[[Writable]] 이 true 이면 TypeError 예외 throw.
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:
settingConfigFalse 가 true 이고 targetDesc.[[Configurable]] 이 true 이면 TypeError 예외 throw.
IsDataDescriptor(targetDesc) 가 true 이고 targetDesc.[[Configurable]] 이 false 이며 targetDesc.[[Writable]] 이 true 이면
Desc 에 [[Writable]] 필드가 있고 Desc.[[Writable]] 이 false 이면 TypeError 예외 throw.
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:
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:
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:
targetDesc.[[Set]] 이 undefined 이면 TypeError 예외 throw.
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:
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:
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:
newObj 를 ? Call(trap, handler, « target, argArray, newTarget ») 로 둔다.
newObj 가 Object 가 아니면 TypeError 예외 throw.
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:
proxy.[[ProxyTarget]] 이 null 이면 TypeError 예외 throw.
단언: proxy.[[ProxyHandler]] 는 null 이 아님.
unused 반환.
10.5.15 ProxyCreate ( target, handler )
The abstract operation ProxyCreate takes arguments target (an ECMAScript language value) and handler (an ECMAScript language value) and returns Proxy 이그조틱 객체를 담는 normal completion 또는 throw completion. 새 Proxy 객체 생성 과정을 명세하는 데 사용된다. It performs the following steps when called:
target 이 Object 가 아니면 TypeError 예외 throw.
handler 가 Object 가 아니면 TypeError 예외 throw.
P 를 MakeBasicObject(« [[ProxyHandler]], [[ProxyTarget]] ») 로 둔다.
P 의 핵심 내부 메서드( [[Call]], [[Construct]] 제외)를 10.5 에 지정된 정의로 설정.