모든 일반 객체는 [[Prototype]]이라는 내부 슬롯을 가진다. 이 내부 슬롯의 값은 null 또는 객체이며 상속을 구현하는 데 사용된다. propertyKey라는 이름의 프로퍼티가 일반 객체 obj에는 없지만 그 [[Prototype]] 객체에는 존재한다고 가정하자. propertyKey가 [[Prototype]] 객체의 데이터 프로퍼티를 가리키면, obj는 get 접근에 대해 그것을 상속받아 propertyKey가 obj의 프로퍼티인 것처럼 동작한다. propertyKey가 [[Prototype]] 객체의 쓰기 가능한 데이터 프로퍼티를 가리키면, obj에서 propertyKey에 대한 set 접근은 obj에 propertyKey라는 이름의 새로운 데이터 프로퍼티를 생성한다. propertyKey가 [[Prototype]] 객체의 쓰기 불가능한 데이터 프로퍼티를 가리키면, obj에서 propertyKey에 대한 set 접근은 실패한다. propertyKey가 [[Prototype]] 객체의 접근자 프로퍼티를 가리키면, 그 접근자는 get 접근과 set 접근 모두에 대해 obj에 상속된다.
모든 일반 객체는 Boolean 값의 [[Extensible]] 내부 슬롯을 가지며, 이는 6.1.7.3에 명시된 확장 가능성과 관련된 내부 메서드 불변식을 충족하는 데 사용된다. 즉, 객체의 [[Extensible]] 내부 슬롯 값이 한 번 false로 설정되면, 더 이상 그 객체에 프로퍼티를 추가하거나, 객체의 [[Prototype]] 내부 슬롯 값을 수정하거나, 이후 [[Extensible]]의 값을 true로 다시 변경하는 것은 불가능하다.
다음 알고리즘 설명에서, obj는 일반 객체이고, propertyKey는 프로퍼티 키 값이며, value는 임의의 ECMAScript 언어 값이고, desc는 Property Descriptor 레코드라고 가정한다.
각 일반 객체 내부 메서드는 유사한 이름의 추상 연산에 위임한다. 그러한 추상 연산이 다른 내부 메서드에 의존한다면, 유사한 이름의 추상 연산을 직접 호출하는 대신 그 내부 메서드가 obj에 대해 호출된다. 이러한 의미론은 일반 객체 내부 메서드가 이색 객체에 적용될 때, 이색 객체가 재정의한 내부 메서드가 호출되도록 보장한다.
10.1.1[[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of 일반 객체 obj takes no arguments and returns a normal completion containing either an Object or null. It performs the following steps when called:
The abstract operation OrdinaryGetPrototypeOf takes argument obj (an Object) and returns an Object or null. It performs the following steps when called:
obj.[[Prototype]]를 반환한다.
10.1.2[[SetPrototypeOf]] ( proto )
The [[SetPrototypeOf]] internal method of 일반 객체 obj takes argument proto (an Object or null) and returns a normal completion containing a Boolean. It performs the following steps when called:
The abstract operation OrdinarySetPrototypeOf takes arguments obj (an Object) and proto (an Object or null) and returns a Boolean. It performs the following steps when called:
cursor.[[GetPrototypeOf]]가 10.1.1에 정의된 일반 객체 내부 메서드가 아니면, done을 true로 설정한다.
그렇지 않으면, cursor를 cursor.[[Prototype]]로 설정한다.
obj.[[Prototype]]를 proto로 설정한다.
true를 반환한다.
Note
단계 7의 반복은 [[GetPrototypeOf]] 및 [[SetPrototypeOf]]에 대해 일반 객체 정의를 사용하는 객체만 포함하는 모든 프로토타입 체인에 순환이 없음을 보장한다.
10.1.3[[IsExtensible]] ( )
The [[IsExtensible]] internal method of 일반 객체 obj takes no arguments and returns a normal completion containing a Boolean. It performs the following steps when called:
The abstract operation OrdinaryIsExtensible takes argument obj (an Object) and returns a Boolean. It performs the following steps when called:
obj.[[Extensible]]를 반환한다.
10.1.4[[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of 일반 객체 obj takes no arguments and returns a normal completion containing true. It performs the following steps when called:
The abstract operation OrdinaryPreventExtensions takes argument obj (an Object) and returns true. It performs the following steps when called:
obj.[[Extensible]]를 false로 설정한다.
true를 반환한다.
10.1.5[[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of 일반 객체 obj takes argument propertyKey (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:
The abstract operation OrdinaryGetOwnProperty takes arguments obj (an Object) and propertyKey (a property key) and returns a Property Descriptor or undefined. It performs the following steps when called:
obj가 키가 propertyKey인 자체 프로퍼티를 가지지 않으면, undefined를 반환한다.
The [[DefineOwnProperty]] internal method of 일반 객체 obj takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The abstract operation OrdinaryDefineOwnProperty takes arguments obj (an Object), propertyKey (a property key), and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
current를 ? obj.[[GetOwnProperty]](propertyKey)라고 하자.
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 ( obj, propertyKey, extensible, desc, current )
The abstract operation ValidateAndApplyPropertyDescriptor takes arguments obj (an Object or undefined), propertyKey (a property key), extensible (a Boolean), desc (a Property Descriptor), and current (a Property Descriptor or undefined) and returns a Boolean. 이것은 desc를, 명시된 extensibility와 현재 프로퍼티 current를 가진 객체의 프로퍼티로 적용하면서 불변식을 유지할 수 있는 경우에만 true를 반환한다. 그러한 적용이 가능하고 obj가 undefined가 아니면, propertyKey라는 이름의 프로퍼티에 대해 그 적용이 수행된다(필요하면 생성된다). It performs the following steps when called:
desc에 해당 필드가 있으면 그 값으로, 없으면 해당 속성의 기본값으로 [[Get]], [[Set]], [[Enumerable]], [[Configurable]] 속성이 설정된 propertyKey라는 이름의 자체 접근자 프로퍼티를 객체 obj에 생성한다.
그렇지 않으면,
desc에 해당 필드가 있으면 그 값으로, 없으면 해당 속성의 기본값으로 [[Value]], [[Writable]], [[Enumerable]], [[Configurable]] 속성이 설정된 propertyKey라는 이름의 자체 데이터 프로퍼티를 객체 obj에 생성한다.
desc가 [[Configurable]] 필드를 가지면 configurable을 desc.[[Configurable]]라고 하자; 그렇지 않으면 configurable을 current.[[Configurable]]라고 하자.
desc가 [[Enumerable]] 필드를 가지면 enumerable을 desc.[[Enumerable]]라고 하자; 그렇지 않으면 enumerable을 current.[[Enumerable]]라고 하자.
객체 obj의 propertyKey라는 이름의 프로퍼티를, [[Configurable]]과 [[Enumerable]] 속성은 각각 configurable과 enumerable로 설정하고, [[Get]]과 [[Set]] 속성은 desc에 해당 필드가 있으면 그 값으로, 없으면 해당 속성의 기본값으로 설정한 접근자 프로퍼티로 교체한다.
desc가 [[Configurable]] 필드를 가지면 configurable을 desc.[[Configurable]]라고 하자; 그렇지 않으면 configurable을 current.[[Configurable]]라고 하자.
desc가 [[Enumerable]] 필드를 가지면 enumerable을 desc.[[Enumerable]]라고 하자; 그렇지 않으면 enumerable을 current.[[Enumerable]]라고 하자.
객체 obj의 propertyKey라는 이름의 프로퍼티를, [[Configurable]]과 [[Enumerable]] 속성은 각각 configurable과 enumerable로 설정하고, [[Value]]와 [[Writable]] 속성은 desc에 해당 필드가 있으면 그 값으로, 없으면 해당 속성의 기본값으로 설정한 데이터 프로퍼티로 교체한다.
그렇지 않으면,
desc의 각 필드 이름 fieldName에 대해, 객체 obj의 propertyKey라는 이름의 프로퍼티에서 fieldName이라는 속성을 desc의 fieldName 필드 값으로 설정한다.
true를 반환한다.
10.1.7[[HasProperty]] ( propertyKey )
The [[HasProperty]] internal method of 일반 객체 obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The abstract operation OrdinaryHasProperty takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
hasOwn을 ? obj.[[GetOwnProperty]](propertyKey)라고 하자.
hasOwn이 undefined가 아니면, true를 반환한다.
parent를 ? obj.[[GetPrototypeOf]]()라고 하자.
parent가 null이 아니면,
? parent.[[HasProperty]](propertyKey)를 반환한다.
false를 반환한다.
10.1.8[[Get]] ( propertyKey, receiver )
The [[Get]] internal method of 일반 객체 obj takes arguments propertyKey (a property key) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:
The abstract operation OrdinaryGet takes arguments obj (an Object), propertyKey (a property key), and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:
The [[Set]] internal method of 일반 객체 obj takes arguments propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The abstract operation OrdinarySet takes arguments obj (an Object), propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
ownDesc를 ? obj.[[GetOwnProperty]](propertyKey)라고 하자.
The abstract operation OrdinarySetWithOwnDescriptor takes arguments obj (an Object), propertyKey (a property key), value (an ECMAScript language value), receiver (an ECMAScript language value), and ownDesc (a Property Descriptor or undefined) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The [[Delete]] internal method of 일반 객체 obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The abstract operation OrdinaryDelete takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
desc를 ? obj.[[GetOwnProperty]](propertyKey)라고 하자.
desc가 undefined이면, true를 반환한다.
desc.[[Configurable]]가 true이면,
obj에서 이름이 propertyKey인 자체 프로퍼티를 제거한다.
true를 반환한다.
false를 반환한다.
10.1.11[[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of 일반 객체 obj takes no arguments and returns a normal completion containing a List of property keys. It performs the following steps when called:
The abstract operation OrdinaryOwnPropertyKeys takes argument obj (an Object) and returns a List of property keys. It performs the following steps when called:
obj의 각 자체 프로퍼티 키 propertyKey 중 propertyKey가 배열 인덱스인 것에 대해, 숫자 인덱스 오름차순으로, 다음을 수행한다
propertyKey를 keys에 추가한다.
obj의 각 자체 프로퍼티 키 propertyKey 중 propertyKey가 String이고 배열 인덱스가 아닌 것에 대해, 프로퍼티 생성의 시간순 오름차순으로, 다음을 수행한다
propertyKey를 keys에 추가한다.
obj의 각 자체 프로퍼티 키 propertyKey 중 propertyKey가 Symbol인 것에 대해, 프로퍼티 생성의 시간순 오름차순으로, 다음을 수행한다
propertyKey를 keys에 추가한다.
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]] »라고 하자.
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 either a normal completion containing an Object or a throw completion. 이것은 [[Prototype]] 값이 생성자의 "prototype" 프로퍼티에서 존재하면 거기서 가져와지는 일반 객체를 생성한다. 그렇지 않으면 intrinsicDefaultProto로 명명된 intrinsic이 [[Prototype]]에 사용된다. internalSlotsList는 객체의 일부로 정의되어야 하는 추가 내부 슬롯들의 이름을 담고 있다. internalSlotsList가 제공되지 않으면, 새로운 빈 List가 사용된다. It performs the following steps when called:
Assert: intrinsicDefaultProto는 이 명세에서 intrinsic 객체의 이름이다. 대응하는 객체는 객체의 [[Prototype]] 값으로 사용되도록 의도된 intrinsic이어야 한다.
The abstract operation GetPrototypeFromConstructor takes arguments constructor (a function object) and intrinsicDefaultProto (a String) and returns either a normal completion containing an Object or a throw completion. 이것은 특정 생성자에 대응하는 객체를 만들 때 사용해야 하는 [[Prototype]] 값을 결정한다. 그 값은 생성자의 "prototype" 프로퍼티가 존재하면 거기서 가져온다. 그렇지 않으면 intrinsicDefaultProto로 명명된 intrinsic이 [[Prototype]]에 사용된다. It performs the following steps when called:
Assert: intrinsicDefaultProto는 이 명세에서 intrinsic 객체의 이름이다. 대응하는 객체는 객체의 [[Prototype]] 값으로 사용되도록 의도된 intrinsic이어야 한다.
proto를 realm의 intrinsicDefaultProto라는 이름의 intrinsic 객체로 설정한다.
proto를 반환한다.
Note
constructor가 [[Prototype]] 값을 제공하지 않으면, 사용되는 기본값은 실행 중인 실행 컨텍스트가 아니라 constructor 함수의 realm에서 가져온다.
10.1.15 RequireInternalSlot ( obj, internalSlot )
The abstract operation RequireInternalSlot takes arguments obj (an ECMAScript language value) and internalSlot (an internal slot name) and returns either a normal completion containing unused or a throw completion. 이것은 obj가 Object이고 주어진 내부 슬롯을 가지는 경우가 아니면 예외를 던진다. It performs the following steps when called:
obj가 Object가 아니면, TypeError 예외를 던진다.
obj가 internalSlot 내부 슬롯을 가지지 않으면, TypeError 예외를 던진다.
unused를 반환한다.
10.2 ECMAScript 함수 객체
ECMAScript 함수 객체는 어휘 환경에 대해 닫힌 매개변수화된
ECMAScript 코드를 캡슐화하며, 그 코드의 동적 평가를 지원한다.
ECMAScript 함수 객체는 일반 객체이며, 다른 일반 객체와 동일한 내부 슬롯과
동일한 내부 메서드를 가진다. ECMAScript 함수 객체의 코드는 strict mode
코드(11.2.2)이거나 non-strict
코드일 수 있다. 코드가 strict mode 코드인 ECMAScript 함수 객체는
strict function
이라고 한다. 코드가 strict mode 코드가 아닌 것은
non-strict
function이라고 한다.
[[Extensible]]과 [[Prototype]] 외에도, ECMAScript 함수 객체는
Table 25
에 나열된 내부 슬롯도 가진다.
Table 25: Internal Slots of ECMAScript Function Objects
함수의 형식 매개변수와 코드 본문 안에서 this 참조가 어떻게
해석되는지를 정의한다. lexical은 this가 어휘적으로 둘러싼
함수의 this 값을 가리킨다는 뜻이다. strict는 this 값이
함수 호출 시 제공된 그대로 사용된다는 뜻이다. global은 this
값이 undefined 또는 null이면 전역 객체에 대한 참조로
해석되고, 그 외의 this 값은 먼저 ToObject에 전달된다는 뜻이다.
함수가 클래스 필드의 initializer로 생성된 경우, 필드의
NamedEvaluation에 사용할 이름이며, 그렇지 않으면 empty이다.
[[IsClassConstructor]]
a Boolean
함수가 클래스 생성자인지 여부를 나타낸다. (true이면, 함수의
[[Call]]을 호출할 때 즉시 TypeError 예외를 던진다.)
모든 ECMAScript 함수 객체는 여기 정의된 [[Call]] 내부 메서드를 가진다.
추가로 생성자이기도 한 ECMAScript 함수는 [[Construct]] 내부 메서드도
가진다.
10.2.1[[Call]] ( thisArgument, argumentsList )
The [[Call]] internal method of an ECMAScript function objectfunc takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:
The abstract operation PrepareForOrdinaryCall takes arguments func (an ECMAScript function object) and newTarget (an Object or undefined) and returns an execution context. It performs the following steps when called:
The abstract operation OrdinaryCallBindThis takes arguments func (an ECMAScript function object), calleeContext (an execution context), and thisArgument (an ECMAScript language value) and returns unused. It performs the following steps when called:
The abstract operation OrdinaryFunctionCreate takes arguments functionPrototype (an Object), sourceText (a sequence of Unicode code points), parameterList (a Parse Node), body (a Parse Node), thisMode (lexical-this or non-lexical-this), env (an Environment Record), and privateEnv (a PrivateEnvironment Record or null) and returns an ECMAScript function object. 이것은 기본 [[Call]] 내부 메서드를 가지고 [[Construct]] 내부
메서드는 가지지 않는 새로운 함수의 런타임 생성을 명세하는 데
사용된다(다만 MakeConstructor 같은 연산에 의해 이후 추가될 수는
있다). sourceText는 생성될 함수의 구문 정의에 대한 source
text이다. It performs the following steps when called:
The abstract operation AddRestrictedFunctionProperties takes arguments func (a function object) and realm (a Realm Record) and returns unused. It performs the following steps when called:
The abstract operation MakeConstructor takes argument func (an ECMAScript function object or a built-in function object) and optional arguments writablePrototype (a Boolean) and prototype (an Object) and returns unused. 이것은 func를 생성자로 변환한다. It performs the following steps when called:
The abstract operation MakeClassConstructor takes argument func (an ECMAScript function object) and returns unused. It performs the following steps when called:
The abstract operation MakeMethod takes arguments func (an ECMAScript function object) and homeObject (an Object) and returns unused. 이것은 func를 메서드로 구성한다. It performs the following steps when called:
10.2.9 SetFunctionName ( func, name [ , prefix ] )
The abstract operation SetFunctionName takes arguments func (a function object) and name (a property key or Private Name) and optional argument prefix (a String) and returns unused. 이것은 func에 "name" 프로퍼티를 추가한다. It performs the following steps when called:
The abstract operation SetFunctionLength takes arguments func (a function object) and length (a non-negative integer or +∞) and returns unused. 이것은 func에 "length" 프로퍼티를 추가한다. It performs the following steps when called:
Assert: func는 "length" 자체 프로퍼티를 가지지 않는 확장 가능한
객체이다.
ECMAScript 함수를 평가하기 위한 execution context가 설정될 때,
새로운 Function Environment Record가 생성되고 각 형식 매개변수에 대한
바인딩이 그 Environment Record 안에 instantiate된다. 함수 본문 안의
각 선언도 역시 instantiate된다. 함수의 형식 매개변수에 기본값
initializer가 포함되어 있지 않다면, 본문 선언은 매개변수와 같은
Environment Record 안에 instantiate된다. 기본값 매개변수 initializer가
존재하면, 본문 선언을 위해 두 번째 Environment Record가 생성된다.
형식 매개변수와 함수는 FunctionDeclarationInstantiation의 일부로
초기화된다. 다른 모든 바인딩은 함수 본문 평가 중에 초기화된다.
NOTE: non-strict 함수는 최상위 lexical declaration을 위해 별도의 Environment Record를 사용하는데, 이는 direct eval이 eval 코드에 의해 도입된 var 스코프 선언이 기존 최상위 lexical 스코프 선언과 충돌하는지를 판별할 수 있도록 하기 위함이다. strict 함수에는 이것이 필요하지 않은데, strict direct eval은 항상 모든 선언을 새로운 Environment Record에 배치하기 때문이다.
내장 함수 객체는
10.3.1
의 정의에 부합하는 [[Call]] 내부 메서드를 가져야 한다.
내장 함수 객체는 그것이 “constructor”로 설명되거나, 또는 이 명세의 어떤
알고리즘이 그 [[Construct]] 내부 메서드를 명시적으로 설정하는 경우에만
[[Construct]] 내부 메서드를 가진다. 그러한 [[Construct]] 내부 메서드는
10.3.2
의 정의에 부합해야 한다.
구현은 이 명세에 정의되지 않은 추가적인 내장 함수 객체를 제공할 수
있다.
10.3.1[[Call]] ( thisArgument, argumentsList )
The [[Call]] internal method of 내장 함수 객체 func takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:
The abstract operation BuiltinCallOrConstruct takes arguments func (a built-in function object), thisArgument (an ECMAScript language value or uninitialized), argumentsList (a List of ECMAScript language values), and newTarget (a constructor or undefined) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:
func, thisArgument, argumentsList, newTarget을 캡처하고,
호출될 때 다음 단계를 수행하는 매개변수 없는 새로운 Abstract
Closure를 resultsClosure라고 하자:
result를, func의 명세에 부합하는 방식으로 func를
평가한 결과인
Completion Record라고 하자. thisArgument가 uninitialized이면
this 값은 초기화되지 않은 상태이고; 그렇지 않으면
thisArgument가 this 값을 제공한다. argumentsList는 이름 있는
매개변수를 제공한다. newTarget은 NewTarget 값을 제공한다.
NOTE: func가 이 문서에 정의되어 있다면, “func의 명세”는
알고리즘 단계나 다른 수단을 통해 명시된 그 동작이다.
result를, func의 명세에
부합하는 방식으로 func를
평가한 결과인 Completion
Record라고 하자. thisArgument가 uninitialized이면 this 값은
초기화되지 않은 상태이고; 그렇지 않으면 thisArgument가 this 값을
제공한다. argumentsList는 이름 있는 매개변수를 제공한다.
newTarget은 NewTarget 값을 제공한다.
NOTE: func가 이 문서에 정의되어 있다면, “func의 명세”는
알고리즘 단계나 다른 수단을 통해 명시된 그 동작이다.
The abstract operation CreateBuiltinFunction takes arguments behaviour (an Abstract Closure, a set of algorithm steps, or some other definition of a function's behaviour provided in this specification), length (a non-negative integer or +∞), name (a property key or a Private Name), and additionalInternalSlotsList (a List of names of internal slots) and optional arguments realm (a Realm Record), prototype (an Object or null), prefix (a String), and async (a Boolean) and returns a built-in function object. additionalInternalSlotsList는 객체의 일부로 정의되어야 하는 추가
내부 슬롯의 이름들을 담고 있다. 이 연산은 내장 함수 객체를
생성한다. It performs the following steps when called:
func를, 호출되었을 때 제공된 인수들을 behaviour가 명시하는
대응 매개변수의 값으로 사용하여 behaviour가 설명하는 동작을
수행하는 새로운 내장 함수 객체라고 하자. 이 새로운 함수 객체는
이름이 internalSlotsList의 요소인 내부 슬롯들과 [[InitialName]]
내부 슬롯을 가진다.
이 명세에 정의된 각 내장 함수는 CreateBuiltinFunction 추상 연산을
호출하여 생성된다.
10.4 내장 이색 객체 내부 메서드와 슬롯
이 명세는 여러 종류의 내장 이색 객체를 정의한다. 이 객체들은 일반적으로
몇몇 특정 상황을 제외하면 일반 객체와 유사하게 동작한다. 다음 이색 객체들은,
아래에서 명시적으로 달리 규정된 경우를 제외하고는, 일반 객체 내부 메서드를
사용한다:
10.4.1 바인드 함수 이색 객체
바인드 함수 이색 객체는 다른 함수 객체를 감싸는 이색 객체이다. 바인드
함수 이색 객체는 호출 가능하다([[Call]] 내부 메서드를 가지며,
[[Construct]] 내부 메서드를 가질 수도 있다). 바인드 함수 이색 객체를
호출하면 일반적으로 그것이 감싸고 있는 함수가 호출된다.
객체는 그 [[Call]] 및 (해당하는 경우) [[Construct]] 내부 메서드가
다음 구현을 사용하고, 다른 essential 내부 메서드는
10.1
에서 찾을 수 있는 정의를 사용할 때
바인드 함수 이색 객체
이다. 이 메서드들은 BoundFunctionCreate에서 설치된다.
바인드 함수 이색 객체는
Table 25
에 나열된 ECMAScript 함수 객체의 내부 슬롯을 가지지 않는다. 대신
[[Prototype]] 및 [[Extensible]] 외에
Table 26
에 나열된 내부 슬롯을 가진다.
Table 26: Internal Slots of Bound Function Exotic Objects
그 요소들이 감싸고 있는 함수에 대한 모든 호출의 첫 번째 인수들로
사용되는 값들의 리스트.
10.4.1.1[[Call]] ( thisArgument, argumentsList )
The [[Call]] internal method of 바인드 함수 이색 객체func takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:
Array는 배열 인덱스 프로퍼티 키를 특별하게 처리하는 이색 객체이다
(참조: 6.1.7). 프로퍼티 이름이
배열 인덱스인 프로퍼티는 element라고도 불린다. 모든 Array는
non-configurable한 "length" 프로퍼티를 가지며, 그 값은 수학적 값이
엄격히 232보다 작은, 항상 음이 아닌 정수 Number이다.
"length" 프로퍼티의 값은 이름이 배열 인덱스인 모든 자체 프로퍼티의
이름보다 수치적으로 더 크며; Array의 자체 프로퍼티가 생성되거나 변경될
때마다, 이 불변식을 유지하기 위해 다른 프로퍼티들이 필요에 따라 조정된다.
구체적으로, 이름이 배열 인덱스인 자체 프로퍼티가 추가될 때마다,
"length" 프로퍼티의 값은 필요하면 그 배열 인덱스의 수치값보다 1 큰
값으로 변경된다; 그리고 "length" 프로퍼티의 값이 변경될 때마다, 값이
새로운 length보다 작지 않은 이름의 배열 인덱스인 모든 자체 프로퍼티는
삭제된다. 이 제약은 Array의 자체 프로퍼티에만 적용되며, 그 프로토타입으로부터
상속될 수 있는 "length" 또는 배열 인덱스 프로퍼티의 영향을 받지
않는다.
객체는 그 [[DefineOwnProperty]] 내부 메서드가 다음 구현을 사용하고,
다른 essential 내부 메서드는
10.1
에서 찾을 수 있는 정의를 사용할 때
Array
이색 객체(또는 단순히 Array)이다. 이 메서드들은 ArrayCreate에서
설치된다.
The [[DefineOwnProperty]] internal method of Array 이색 객체array takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The abstract operation ArrayCreate takes argument length (a non-negative integer) and optional argument proto (an Object) and returns either a normal completion containing an Array exotic object or a throw completion. 이것은 새로운 Array의 생성을 명세하는 데 사용된다. It performs the following steps when called:
The abstract operation ArraySpeciesCreate takes arguments originalArray (an Object) and length (a non-negative integer) and returns either a normal completion containing an Object or a throw completion. 이것은 originalArray로부터 파생된 생성자 함수를 사용하여 새로운
Array 또는 유사 객체를 생성하는 것을 명세하는 데 사용된다. 이
연산은 생성자 함수가 Array를 반환해야 한다고 강제하지는 않는다. It performs the following steps when called:
originalArray가 현재 실행 중인 execution context의 realm이 아닌
realm에 대한 표준 내장 Array 생성자를 사용하여 생성되었다면, 새로운
Array는 현재 실행 중인 execution context의 realm을 사용하여
생성된다. 이것은 현재 ArraySpeciesCreate를 사용하여 정의되는
Array.prototype 메서드들에 대해 역사적으로 그러한 동작을 가져온
웹 브라우저와의 호환성을 유지한다.
10.4.2.4 ArraySetLength ( array, desc )
The abstract operation ArraySetLength takes arguments array (an Array) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
단계 3 및
4에서,
desc.[[Value]]가 객체라면 그 valueOf 메서드는 두 번 호출된다.
이것은 이 명세 제2판부터 이러한 효과를 갖도록 명시된 legacy
동작이다.
10.4.3 문자열 이색 객체
String 객체는 String 값을 캡슐화하고, 그 String 값의 개별 코드 유닛
요소에 대응하는 가상 정수 인덱스 데이터 프로퍼티를 노출하는 이색
객체이다. 문자열 이색 객체는 항상 "length"라는 데이터 프로퍼티를
가지며, 그 값은 캡슐화된 String 값의 길이이다. 코드 유닛 데이터
프로퍼티와 "length" 프로퍼티는 모두 non-writable이고
non-configurable이다.
객체는 그 [[GetOwnProperty]], [[DefineOwnProperty]], 그리고
[[OwnPropertyKeys]] 내부 메서드가 다음 구현을 사용하고, 다른 essential
내부 메서드는
10.1
에서 찾을 수 있는 정의를 사용할 때
문자열
이색 객체(또는 단순히 String 객체)이다. 이 메서드들은
StringCreate에서 설치된다.
문자열 이색 객체는 일반 객체와 동일한 내부 슬롯을 가진다. 또한
[[StringData]] 내부 슬롯도 가진다.
10.4.3.1[[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of 문자열 이색 객체str takes argument propertyKey (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:
The [[DefineOwnProperty]] internal method of 문자열 이색 객체str takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns a normal completion containing a Boolean. It performs the following steps when called:
The [[OwnPropertyKeys]] internal method of 문자열 이색 객체obj takes no arguments and returns a normal completion containing a List of property keys. It performs the following steps when called:
obj의 각 자체 프로퍼티 키 propertyKey 중, propertyKey가
배열 인덱스이고 ! ToIntegerOrInfinity(propertyKey) ≥ len인
것에 대해, 숫자 인덱스 오름차순으로, 다음을 수행한다
propertyKey를 keys에 추가한다.
obj의 각 자체 프로퍼티 키 propertyKey 중, propertyKey가
String이고 배열 인덱스가 아닌 것에 대해, 프로퍼티 생성의 시간순
오름차순으로, 다음을 수행한다
propertyKey를 keys에 추가한다.
obj의 각 자체 프로퍼티 키 propertyKey 중, propertyKey가
Symbol인 것에 대해, 프로퍼티 생성의 시간순 오름차순으로, 다음을
수행한다
propertyKey를 keys에 추가한다.
keys를 반환한다.
10.4.3.4 StringCreate ( value, prototype )
The abstract operation StringCreate takes arguments value (a String) and prototype (an Object) and returns a String exotic object. 이것은 새로운 문자열 이색 객체의 생성을 명세하는 데
사용된다. It performs the following steps when called:
str를 MakeBasicObject(« [[Prototype]], [[Extensible]],
[[StringData]] »)라고 하자.
The abstract operation StringGetOwnProperty takes arguments str (an Object that has a [[StringData]] internal slot) and propertyKey (a property key) and returns a Property Descriptor or undefined. It performs the following steps when called:
대부분의 ECMAScript 함수는 자신의 코드에서 arguments 객체를 사용할 수
있게 한다. 함수 정의의 특성에 따라, 그 arguments 객체는 일반 객체이거나
arguments 이색 객체이다. arguments 이색 객체는 그 배열 인덱스
프로퍼티들이 연관된 ECMAScript 함수의 호출에 대한 형식 매개변수
바인딩에 매핑되는 이색 객체이다.
객체는, 여기에서 명시되지 않은 내부 메서드는
10.1
에 있는 정의를 사용하면서, 그 내부 메서드가 다음 구현을 사용할 때
arguments 이색 객체
이다. 이 메서드들은 CreateMappedArgumentsObject에서 설치된다.
arguments 이색 객체는 일반 객체와 동일한 내부 슬롯을 가진다. 또한
[[ParameterMap]] 내부 슬롯도 가진다. 일반 arguments 객체도
[[ParameterMap]] 내부 슬롯을 가지며, 그 값은 항상 undefined이다.
일반 arguments 객체의 경우 [[ParameterMap]] 내부 슬롯은
Object.prototype.toString
(20.1.3.6)에서
그것들을 그러한 것으로 식별하기 위해서만 사용된다.
Note 2
숫자 이름 값이 해당 함수 객체의 형식 매개변수 개수보다 작은
arguments 이색 객체의 정수 인덱스 데이터 프로퍼티는 처음에는 함수의
execution context 안의 대응 인수 바인딩과 그 값을 공유한다. 이는
프로퍼티를 변경하면 대응하는 인수 바인딩의 값도 바뀌고 그 반대도
마찬가지임을 뜻한다. 그러한 프로퍼티가 삭제된 뒤 다시 정의되거나,
그 프로퍼티가 접근자 프로퍼티로 변경되면 이 대응 관계는 깨진다.
arguments 객체가 일반 객체인 경우, 그 프로퍼티 값은 단순히 함수에
전달된 인수의 복사본이며, 프로퍼티 값과 형식 매개변수 값 사이에 동적
연결은 없다.
Note 3
ParameterMap 객체와 그 프로퍼티 값은 arguments 객체와 인수 바인딩
사이의 대응을 명세하기 위한 장치로 사용된다. ParameterMap 객체와 그
프로퍼티 값인 객체들은 ECMAScript 코드로부터 직접 관찰될 수 없다.
ECMAScript 구현은 명시된 의미론을 구현하기 위해 실제로 그러한 객체를
생성하거나 사용할 필요가 없다.
Note 4
일반 arguments 객체는 "callee"라는 이름의 non-configurable
접근자 프로퍼티를 정의하며, 이에 접근하면 TypeError 예외를 던진다.
"callee" 프로퍼티는 오직 일부 non-strict 함수들에 대해서만 생성되는
arguments 이색 객체에서는 더 구체적인 의미를 가진다. 일반 변형에서
이 프로퍼티를 이렇게 정의하는 것은, ECMAScript 적합 구현이 그것을
다른 방식으로 정의하지 않도록 보장하기 위해 존재한다.
Note 5
ECMAScript 구현의 arguments 이색 객체는 역사적으로 "caller"라는
이름의 접근자 프로퍼티를 포함해 왔다. ECMAScript 2017 이전에는, 이
명세는 일반 arguments 객체에 대해 예외를 던지는 "caller" 프로퍼티를
정의하고 있었다. 구현들이 더 이상 이 확장을 포함하지 않기 때문에,
ECMAScript 2017은 예외를 던지는 "caller" 접근자 요구사항을
제거했다.
10.4.4.1[[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of arguments 이색 객체args takes argument propertyKey (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:
The [[DefineOwnProperty]] internal method of arguments 이색 객체args takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns a normal completion containing a Boolean. It performs the following steps when called:
Assert: 다음 Set은 성공할 것인데, arguments 객체에 의해
매핑되는 형식 매개변수는 항상 쓰기 가능하기 때문이다.
! Set(map, propertyKey, desc.[[Value]], false)
를 수행한다.
desc가 [[Writable]] 필드를 가지고
desc.[[Writable]]가 false이면,
! map.[[Delete]](propertyKey)를 수행한다.
true를 반환한다.
10.4.4.3[[Get]] ( propertyKey, receiver )
The [[Get]] internal method of arguments 이색 객체args takes arguments propertyKey (a property key) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:
The [[Set]] internal method of arguments 이색 객체args takes arguments propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The [[Delete]] internal method of arguments 이색 객체args takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
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 MakeArgGetter takes arguments name (a String) and env (an Environment Record) and returns a function object. 이것은 실행되었을 때 env 안에서 name에 바인딩된 값을
반환하는 built-in 함수 객체를 생성한다. It performs the following steps when called:
name과 env를 캡처하고, 호출될 때 다음 단계를 수행하는
매개변수 없는 새로운 Abstract Closure를 getterClosure라고
하자:
The abstract operation MakeArgSetter takes arguments name (a String) and env (an Environment Record) and returns a function object. 이것은 실행되었을 때 env 안에서 name에 바인딩된 값을
설정하는 built-in 함수 객체를 생성한다. It performs the following steps when called:
name과 env를 캡처하고, (value) 매개변수를 가지며 호출될
때 다음 단계를 수행하는 새로운 Abstract Closure를
setterClosure라고 하자:
TypedArray는 canonical numeric string인 프로퍼티 키를 특별하게
처리하는 이색 객체이며, 그 중 경계 내 정수 인덱스인 부분집합을 사용해
균일한 타입의 element에 인덱싱하고, 나머지는 프로토타입 체인 탐색을
발생시키지 않고 존재하지 않음을 보장하는 불변식을 강제한다.
Note
임의의 Number n에 대한 ToString(n)은 canonical numeric
string이므로, 구현은 TypedArray의 프로퍼티 키로 Number를 실제 문자열
변환 없이 취급할 수 있다.
TypedArray는 일반 객체와 동일한 내부 슬롯을 가지며, 추가로
[[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]],
[[ByteLength]], [[ByteOffset]], [[ArrayLength]] 내부 슬롯을 가진다.
객체는 그 [[PreventExtensions]], [[GetOwnProperty]],
[[HasProperty]], [[DefineOwnProperty]], [[Get]], [[Set]], [[Delete]],
[[OwnPropertyKeys]] 내부 메서드가 이 절의 정의를 사용하고, 다른
essential 내부 메서드는
10.1
에서 찾을 수 있는 정의를 사용할 때
TypedArray
이다. 이 메서드들은 TypedArrayCreate에 의해 설치된다.
10.4.5.1[[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of TypedArrayobj takes no arguments and returns a normal completion containing a Boolean. It performs the following steps when called:
NOTE: 6.1.7.3
에 명시된 확장 가능성과 관련된 불변식은, obj가 프로퍼티를 얻을
수 있거나(또는 잃었다가 다시 얻을 수 있거나), 이는 그 기반
버퍼가 리사이즈될 때 정수 인덱스 이름을 가진 프로퍼티에서 발생할
수 있는데, 그 경우 이 메서드가 true를 반환하는 것을 허용하지
않는다.
The [[GetOwnProperty]] internal method of TypedArrayobj takes argument propertyKey (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:
The [[HasProperty]] internal method of TypedArrayobj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The [[DefineOwnProperty]] internal method of TypedArrayobj takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The [[Get]] internal method of TypedArrayobj takes arguments propertyKey (a property key) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:
The [[Set]] internal method of TypedArrayobj takes arguments propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The [[Delete]] internal method of TypedArrayobj takes argument propertyKey (a property key) and returns a normal completion containing a Boolean. It performs the following steps when called:
The [[OwnPropertyKeys]] internal method of TypedArrayobj takes no arguments and returns a normal completion containing a List of property keys. It performs the following steps when called:
obj의 각 자체 프로퍼티 키 propertyKey 중, propertyKey가
String이고 정수 인덱스가 아닌 것에 대해, 프로퍼티 생성의 시간순
오름차순으로, 다음을 수행한다
propertyKey를 keys에 추가한다.
obj의 각 자체 프로퍼티 키 propertyKey 중, propertyKey가
Symbol인 것에 대해, 프로퍼티 생성의 시간순 오름차순으로, 다음을
수행한다
propertyKey를 keys에 추가한다.
keys를 반환한다.
10.4.5.9 버퍼 witness record를 가진 TypedArray
TypedArray With Buffer Witness Record
는 viewed buffer의 캐시된 바이트 길이와 함께 TypedArray를 캡슐화하는
데 사용되는 Record 값이다. 이는 viewed buffer가 growable
SharedArrayBuffer일 때 byte length data block에 대한 ReadSharedMemory
event가 하나만 존재하도록 보장하는 데 도움을 주기 위해 사용된다.
TypedArray With Buffer Witness Record는
Table 27
에 나열된 필드를 가진다.
Record가 생성되었을 때 객체의 [[ViewedArrayBuffer]]의 바이트
길이.
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:
typedArray.[[OwnPropertyKeys]]를
10.4.5.8
에 명시된 대로 설정한다.
typedArray.[[Prototype]]를 prototype으로 설정한다.
typedArray를 반환한다.
10.4.5.12 TypedArrayByteLength ( taRecord )
The abstract operation TypedArrayByteLength takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a non-negative integer. It performs the following steps when called:
NOTE: 반환되는 byte length는, 기반 버퍼가 정수배가 아닌 크기로
리사이즈된 경우에도 항상 elementSize의 정수배이다.
length × elementSize를 반환한다.
10.4.5.13 TypedArrayLength ( taRecord )
The abstract operation TypedArrayLength takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a non-negative integer. It performs the following steps when called:
The abstract operation IsTypedArrayOutOfBounds takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a Boolean. 이것은 객체의 수치 프로퍼티 중 어느 하나라도 기반 버퍼의 경계 안에
포함되지 않는 인덱스의 값을 참조하는지를 검사한다. It performs the following steps when called:
obj를 taRecord.[[Object]]라고 하자.
bufferByteLength를 taRecord.[[CachedBufferByteLength]]
라고 하자.
The abstract operation IsValidIntegerIndex takes arguments obj (a TypedArray) and index (a Number) and returns a Boolean. It performs the following steps when called:
The abstract operation TypedArrayGetElement takes arguments obj (a TypedArray) and index (a Number) and returns a Number, a BigInt, or undefined. It performs the following steps when called:
10.4.5.18 TypedArraySetElement ( obj, index, value )
The abstract operation TypedArraySetElement takes arguments obj (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:
obj.[[ContentType]]가 bigint이면, numValue를 ?
ToBigInt(value)라고 하자.
SetValueInBuffer(obj.[[ViewedArrayBuffer]], byteIndexInBuffer,
elementType, numValue, true, unordered)를 수행한다.
unused를 반환한다.
Note
이 연산은 항상 성공한 것처럼 보이지만, TypedArray의 끝을 넘어
쓰려고 시도하거나 detached ArrayBuffer를 backing으로 가진
TypedArray에 쓰려고 시도할 때는 아무 효과가 없다.
10.4.5.19 IsArrayBufferViewOutOfBounds ( obj )
The abstract operation IsArrayBufferViewOutOfBounds takes argument obj (a TypedArray or a DataView) and returns a Boolean. 이것은 TypedArray의 수치 프로퍼티들이나 DataView 객체의 메서드
중 어느 하나라도 기반 data block의 경계 안에 포함되지 않는 인덱스의
값을 참조할 수 있는지를 검사한다. 이 추상 연산은 상위 명세를 위한
편의 기능으로 존재한다. It performs the following steps when called:
모듈 네임스페이스 이색 객체는 ECMAScript Module에서 export된
바인딩을 노출하는 이색 객체이다 (참조:
16.2.3). 모듈 네임스페이스 이색
객체의 String 키를 가진 자체 프로퍼티와 Module이 export한 바인딩
이름 사이에는 일대일 대응이 있다. export된 바인딩에는 export *
export item을 사용하여 간접적으로 export된 바인딩도 포함된다.
각 String 값의 자체 프로퍼티 키는 대응하는 export된 바인딩 이름의
StringValue이다. 이것들만이 모듈 네임스페이스 이색 객체의 String 키
프로퍼티이다. 각 그러한 프로퍼티는 { [[Writable]]: true,
[[Enumerable]]: true, [[Configurable]]: false } 속성을 가진다.
모듈 네임스페이스 이색 객체는 확장 가능하지 않다.
객체는 그 [[GetPrototypeOf]], [[SetPrototypeOf]], [[IsExtensible]],
[[PreventExtensions]], [[GetOwnProperty]], [[DefineOwnProperty]],
[[HasProperty]], [[Get]], [[Set]], [[Delete]], [[OwnPropertyKeys]] 내부
메서드가 이 절의 정의를 사용하고, 다른 essential 내부 메서드는
10.1
에서 찾을 수 있는 정의를 사용할 때
모듈 네임스페이스 이색 객체
이다. 이 메서드들은 ModuleNamespaceCreate에 의해 설치된다.
이 객체의 자체 프로퍼티로 노출되는 export 이름들의 String 값을
요소로 가지는 List. 이 리스트는 코드 유닛 사전식 순서에 따라
정렬된다.
10.4.6.1[[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of 모듈 네임스페이스 이색 객체 takes no arguments and returns a normal completion containing null. It performs the following steps when called:
null을 반환한다.
10.4.6.2[[SetPrototypeOf]] ( proto )
The [[SetPrototypeOf]] internal method of 모듈 네임스페이스 이색 객체obj takes argument proto (an Object or null) and returns a normal completion containing a Boolean. It performs the following steps when called:
The [[IsExtensible]] internal method of 모듈 네임스페이스 이색 객체 takes no arguments and returns a normal completion containing false. It performs the following steps when called:
false를 반환한다.
10.4.6.4[[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of 모듈 네임스페이스 이색 객체 takes no arguments and returns a normal completion containing true. It performs the following steps when called:
The [[DefineOwnProperty]] internal method of 모듈 네임스페이스 이색 객체obj takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The [[HasProperty]] internal method of 모듈 네임스페이스 이색 객체obj takes argument propertyKey (a property key) and returns a normal completion containing a Boolean. It performs the following steps when called:
The [[Get]] internal method of 모듈 네임스페이스 이색 객체obj takes arguments propertyKey (a property key) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:
? targetEnv.GetBindingValue(binding.[[BindingName]], true)
를 반환한다.
Note
ResolveExport는 부작용이 없다. 이 연산이 특정 exportName,
resolveSet 쌍을 인수로 호출될 때마다 반드시 같은 결과를 반환해야
한다. 구현은 각 모듈 네임스페이스 이색 객체의 [[Exports]]에 대한
ResolveExport 결과를 미리 계산하거나 캐시하도록 선택할 수 있다.
10.4.6.9[[Set]] ( propertyKey, value, receiver )
The [[Set]] internal method of 모듈 네임스페이스 이색 객체 takes arguments propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns a normal completion containing false. It performs the following steps when called:
false를 반환한다.
10.4.6.10[[Delete]] ( propertyKey )
The [[Delete]] internal method of 모듈 네임스페이스 이색 객체obj takes argument propertyKey (a property key) and returns a normal completion containing a Boolean. 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 불변 프로토타입 이색 객체obj takes argument proto (an Object or null) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
The abstract operation SetImmutablePrototype takes arguments obj (an Object) and proto (an Object or null) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
프록시 객체는 essential 내부 메서드가 부분적으로 ECMAScript 코드를
사용하여 구현되는 이색 객체이다. 모든 프록시 객체는 [[ProxyHandler]]라는
내부 슬롯을 가진다. [[ProxyHandler]]의 값은 프록시의
handler object라고 불리는 객체이거나 null이다. handler
object의 메서드(참조:
Table 29)는 프록시 객체의
하나 이상의 내부 메서드 구현을 보강하는 데 사용될 수 있다. 모든 프록시
객체는 또한 [[ProxyTarget]]이라는 내부 슬롯을 가지며, 그 값은 객체 또는
null이다. 이 객체는 프록시의 target object라고 불린다.
객체는 그 essential 내부 메서드(해당하는 경우 [[Call]] 및
[[Construct]] 포함)가 이 절의 정의를 사용할 때
프록시 이색 객체
이다. 이 내부 메서드들은 ProxyCreate에서 설치된다.
Table 29: Proxy Handler Methods
내부 메서드
핸들러 메서드
[[GetPrototypeOf]]
getPrototypeOf
[[SetPrototypeOf]]
setPrototypeOf
[[IsExtensible]]
isExtensible
[[PreventExtensions]]
preventExtensions
[[GetOwnProperty]]
getOwnPropertyDescriptor
[[DefineOwnProperty]]
defineProperty
[[HasProperty]]
has
[[Get]]
get
[[Set]]
set
[[Delete]]
deleteProperty
[[OwnPropertyKeys]]
ownKeys
[[Call]]
apply
[[Construct]]
construct
프록시 객체 내부 메서드의 구현을 제공하기 위해 handler 메서드가
호출될 때, 그 handler 메서드에는 프록시의 target object가 매개변수로
전달된다. 프록시의 handler object가 반드시 모든 essential 내부 메서드에
대응하는 메서드를 가지는 것은 아니다. 프록시에 대한 내부 메서드 호출은,
handler object가 대응하는 내부 trap에 대한 메서드를 가지지 않을 경우,
프록시의 target object에 대한 대응 내부 메서드 호출이 일어나게 한다.
프록시 객체의 [[ProxyHandler]] 및 [[ProxyTarget]] 내부 슬롯은 객체가
생성될 때 항상 초기화되며, 일반적으로 수정될 수 없다. 일부 프록시 객체는
나중에 revoked될 수 있도록 허용하는 방식으로 생성된다. 프록시가
revoked되면, 그 [[ProxyHandler]]와 [[ProxyTarget]] 내부 슬롯은 null로
설정되며, 그 결과 그 프록시 객체에 대한 이후의 내부 메서드 호출은
TypeError 예외를 던지게 된다.
프록시 객체는 내부 메서드의 구현을 임의의 ECMAScript 코드로 제공할 수
있게 허용하기 때문에,
6.1.7.3
에 정의된 불변식을 위반하는 handler 메서드를 가진 프록시 객체를 정의하는
것이 가능하다.
6.1.7.3
에 정의된 내부 메서드 불변식 중 일부는 essential 무결성 불변식이다.
이러한 불변식은 이 절에 명시된 프록시 객체 내부 메서드에 의해 명시적으로
강제된다. ECMAScript 구현은 가능한 모든 불변식 위반이 존재하는 상황에서도
견고해야 한다.
다음 알고리즘 설명에서, obj는 ECMAScript 프록시 객체이고,
propertyKey는 프로퍼티 키 값이며, value는 임의의 ECMAScript 언어
값이고, desc는 Property Descriptor 레코드라고 가정한다.
10.5.1[[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of 프록시 이색 객체obj takes no arguments and returns either a normal completion containing either an Object or null, or a throw completion. It performs the following steps when called:
target 객체가 확장 가능하지 않다면, 프록시 객체에 적용된
[[GetPrototypeOf]]는 프록시 객체의 target 객체에 적용된
[[GetPrototypeOf]]와 같은 값을 반환해야 한다.
10.5.2[[SetPrototypeOf]] ( proto )
The [[SetPrototypeOf]] internal method of 프록시 이색 객체obj takes argument proto (an Object or null) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
target 객체가 확장 가능하지 않다면, 인수 값은 target 객체에
[[GetPrototypeOf]]를 적용한 결과와 같아야 한다.
10.5.3[[IsExtensible]] ( )
The [[IsExtensible]] internal method of 프록시 이색 객체obj takes no arguments and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
프록시 객체에 적용된 [[IsExtensible]]는 같은 인수로 프록시 객체의
target 객체에 적용된 [[IsExtensible]]와 같은 값을 반환해야 한다.
10.5.4[[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of 프록시 이색 객체obj takes no arguments and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
프록시 객체에 적용된 [[PreventExtensions]]는 프록시 객체의 target
객체에 [[IsExtensible]]를 적용했을 때 false인 경우에만 true를
반환한다.
10.5.5[[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of 프록시 이색 객체obj takes argument propertyKey (a property key) and returns either a normal completion containing either a Property Descriptor or undefined, or a throw completion. It performs the following steps when called:
target 객체에 non-configurable 자체 프로퍼티로 존재하는
프로퍼티는 존재하지 않는 것으로 보고될 수 없다.
non-extensible target 객체의 자체 프로퍼티로 존재하는 프로퍼티는
존재하지 않는 것으로 보고될 수 없다.
target 객체에 자체 프로퍼티로 존재하지 않고 target 객체가 확장
가능하지 않은 경우, 그 프로퍼티는 존재하는 것으로 보고될 수 없다.
프로퍼티는 target 객체의 대응하는 non-configurable 자체 프로퍼티로
존재하지 않는 한 non-configurable로 보고될 수 없다.
프로퍼티는 target 객체의 대응하는 non-configurable,
non-writable 자체 프로퍼티로 존재하지 않는 한,
non-configurable이면서 non-writable인 것으로 보고될 수 없다.
10.5.6[[DefineOwnProperty]] ( propertyKey, desc )
The [[DefineOwnProperty]] internal method of 프록시 이색 객체obj takes arguments propertyKey (a property key) and desc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
desc가 [[Writable]] 필드를 가지고
desc.[[Writable]]가 false이면, TypeError 예외를
던진다.
true를 반환한다.
Note
프록시 객체에 대한 [[DefineOwnProperty]]는 다음 불변식을
강제한다:
[[DefineOwnProperty]]의 결과는 Boolean 값이다.
target 객체가 확장 가능하지 않다면 프로퍼티는 추가될 수 없다.
target 객체에 대응하는 non-configurable 자체 프로퍼티가 존재하지
않는 한, 프로퍼티는 non-configurable일 수 없다.
target 객체에 대응하는 non-configurable, non-writable 자체
프로퍼티가 존재하지 않는 한, non-configurable 프로퍼티는
non-writable일 수 없다.
프로퍼티가 대응하는 target 객체 프로퍼티를 가지는 경우, 그
프로퍼티의 Property Descriptor를 [[DefineOwnProperty]]를 사용하여
target 객체에 적용해도 예외를 던지지 않는다.
10.5.7[[HasProperty]] ( propertyKey )
The [[HasProperty]] internal method of 프록시 이색 객체obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
target 객체에 non-configurable 자체 프로퍼티로 존재하는
프로퍼티는 존재하지 않는 것으로 보고될 수 없다.
target 객체의 자체 프로퍼티로 존재하고 target 객체가 확장
가능하지 않은 경우, 그 프로퍼티는 존재하지 않는 것으로 보고될 수
없다.
10.5.8[[Get]] ( propertyKey, receiver )
The [[Get]] internal method of 프록시 이색 객체obj takes arguments propertyKey (a property key) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:
target 객체의 대응 프로퍼티가 non-writable,
non-configurable 자체 데이터 프로퍼티라면, 프로퍼티에 대해 보고된
값은 그 target 객체 프로퍼티의 값과 같아야 한다.
target 객체의 대응 프로퍼티가 [[Get]] 속성으로 undefined를 가진
non-configurable 자체 접근자 프로퍼티라면, 프로퍼티에 대해 보고된
값은 반드시 undefined이어야 한다.
10.5.9[[Set]] ( propertyKey, value, receiver )
The [[Set]] internal method of 프록시 이색 객체obj takes arguments propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
대응하는 target 객체 프로퍼티가 non-writable,
non-configurable 자체 데이터 프로퍼티인 경우, 그 프로퍼티의 값을
대응하는 target 객체 프로퍼티의 값과 다르게 변경할 수 없다.
대응하는 target 객체 프로퍼티가 [[Set]] 속성으로 undefined를
가진 non-configurable 자체 접근자 프로퍼티인 경우, 그 프로퍼티의
값을 설정할 수 없다.
10.5.10[[Delete]] ( propertyKey )
The [[Delete]] internal method of 프록시 이색 객체obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
결과 List는 target 객체의 모든 non-configurable 자체 프로퍼티의
키를 포함해야 한다.
target 객체가 확장 가능하지 않다면, 결과 List는 target 객체의
모든 자체 프로퍼티의 키를 포함해야 하며 다른 값은 포함해서는 안
된다.
10.5.12[[Call]] ( thisArgument, argumentsList )
The [[Call]] internal method of 프록시 이색 객체obj takes arguments thisArgument (an ECMAScript language value) and argumentsList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:
newObj를 ? Call(trap, handler,
« target, argArray, newTarget »)라고 하자.
newObj가 Object가 아니면, TypeError 예외를 던진다.
newObj를 반환한다.
Note 1
프록시 이색 객체는 그 [[ProxyTarget]] 내부 슬롯의 초기값이
[[Construct]] 내부 메서드를 가진 객체인 경우에만 [[Construct]]
내부 메서드를 가진다.
Note 2
프록시 객체에 대한 [[Construct]]는 다음 불변식을 강제한다:
[[Construct]]의 결과는 반드시 Object여야 한다.
10.5.14 ValidateNonRevokedProxy ( proxy )
The abstract operation ValidateNonRevokedProxy takes argument proxy (a Proxy exotic object) and returns either a normal completion containing unused or a throw completion. proxy가 revoked되었으면 TypeError 예외를 던진다. It performs the following steps when called:
The abstract operation ProxyCreate takes arguments target (an ECMAScript language value) and handler (an ECMAScript language value) and returns either a normal completion containing a Proxy exotic object or a throw completion. 이것은 새로운 프록시 객체의 생성을 명세하는 데 사용된다. It performs the following steps when called:
target이 Object가 아니면, TypeError 예외를 던진다.
handler가 Object가 아니면, TypeError 예외를 던진다.
proxy를 MakeBasicObject(« [[ProxyHandler]], [[ProxyTarget]] »)
라고 하자.
proxy의 essential 내부 메서드 중 [[Call]]과 [[Construct]]를
제외한 것들을
10.5
에 명시된 정의로 설정한다.