6.2 ECMAScript Specification Types
A specification type corresponds to meta-values that are used within algorithms to describe the semantics of ECMAScript language constructs and
6.2.1 The Enum Specification Type
Enums are values which are internal to the specification and not directly observable from ECMAScript code. Enums are denoted using a
6.2.2 The List and Record Specification Types
The List type is used to explain the evaluation of argument lists (see new
expressions, in function calls, and in other algorithms where a simple ordered list of values is needed. Values of the List type are simply ordered sequences of list elements containing the individual values. These sequences may be of any length. The elements of a list may be randomly accessed using 0-origin indices. For notational convenience an array-like syntax can be used to access List elements. For example, arguments[2] is shorthand for saying the 3rd element of the List arguments.
When an algorithm iterates over the elements of a List without specifying an order, the order used is the order of the elements in the List.
For notational convenience within this specification, a literal syntax can be used to express a new List value. For example, « 1, 2 » defines a List value that has two elements each of which is initialized to a specific value. A new empty List can be expressed as « ».
In this specification, the phrase "the list-concatenation of A, B, ..." (where each argument is a possibly empty List) denotes a new List value whose elements are the concatenation of the elements (in order) of each of the arguments (in order).
The Record type is used to describe data aggregations within the algorithms of this specification. A Record type value consists of one or more named fields. The value of each field is an
For notational convenience within this specification, an object literal-like syntax can be used to express a Record value. For example, { [[Field1]]: 42, [[Field2]]:
In specification text and algorithms, dot notation may be used to refer to a specific field of a Record value. For example, if R is the record shown in the previous paragraph then R.[[Field2]] is shorthand for “the field of R named [[Field2]]”.
Schema for commonly used Record field combinations may be named, and that name may be used as a prefix to a literal Record value to identify the specific kind of aggregations that is being described. For example: PropertyDescriptor { [[Value]]: 42, [[Writable]]:
6.2.3 The Set and Relation Specification Types
The Set type is used to explain a collection of unordered elements for use in the
The Relation type is used to explain constraints on Sets. Values of the Relation type are Sets of ordered pairs of values from its value domain. For example, a Relation on events is a set of ordered pairs of events. For a Relation R and two values a and b in the value domain of R, a R b is shorthand for saying the ordered pair (a, b) is a member of R. A Relation is least with respect to some conditions when it is the smallest Relation that satisfies those conditions.
A strict partial order is a Relation value R that satisfies the following.
-
For all a, b, and c in R's domain:
- It is not the case that a R a, and
- If a R b and b R c, then a R c.
The two properties above are called irreflexivity and transitivity, respectively.
A strict total order is a Relation value R that satisfies the following.
-
For all a, b, and c in R's domain:
- a is b or a R b or b R a, and
- It is not the case that a R a, and
- If a R b and b R c, then a R c.
The three properties above are called totality, irreflexivity, and transitivity, respectively.
6.2.4 The Completion Record Specification Type
The Completion Record specification type is used to explain the runtime propagation of values and control flow such as the behaviour of statements (break
, continue
, return
and throw
) that perform nonlocal transfers of control.
Completion Records have the fields defined in
Field Name | Value | Meaning |
---|---|---|
[[Type]] |
|
The type of completion that occurred. |
[[Value]] |
any value except a |
The value that was produced. |
[[Target]] |
a String or |
The target label for directed control transfers. |
The following shorthand terms are sometimes used to refer to Completion Records.
- normal completion refers to any Completion Record with a [[Type]] value of
normal . - break completion refers to any Completion Record with a [[Type]] value of
break . - continue completion refers to any Completion Record with a [[Type]] value of
continue . - return completion refers to any Completion Record with a [[Type]] value of
return . - throw completion refers to any Completion Record with a [[Type]] value of
throw . - abrupt completion refers to any Completion Record with a [[Type]] value other than
normal . - a normal completion containing some type of value refers to a normal completion that has a value of that type in its [[Value]] field.
Callable objects that are defined in this specification only return a normal completion or a throw completion. Returning any other kind of Completion Record is considered an editorial error.
6.2.4.1 NormalCompletion ( value )
The abstract operation NormalCompletion takes argument value (any value except a
- Return
Completion Record { [[Type]]:normal , [[Value]]: value, [[Target]]:empty }.
6.2.4.2 ThrowCompletion ( value )
The abstract operation ThrowCompletion takes argument value (an
- Return
Completion Record { [[Type]]:throw , [[Value]]: value, [[Target]]:empty }.
6.2.4.3 UpdateEmpty ( completionRecord, value )
The abstract operation UpdateEmpty takes arguments completionRecord (a
Assert : If completionRecord is either areturn completion or athrow completion , then completionRecord.[[Value]] is notempty .- If completionRecord.[[Value]] is not
empty , return ? completionRecord. - Return
Completion Record { [[Type]]: completionRecord.[[Type]], [[Value]]: value, [[Target]]: completionRecord.[[Target]] }.
6.2.5 The Reference Record Specification Type
The Reference Record type is used to explain the behaviour of such operators as delete
, typeof
, the assignment operators, the super
A Reference Record is a resolved name or property binding; its fields are defined by
Field Name | Value | Meaning |
---|---|---|
[[Base]] | an |
The value or |
[[ReferencedName]] | a String, a Symbol, or a |
The name of the binding. Always a String if [[Base]] value is an |
[[Strict]] | a Boolean | |
[[ThisValue]] | an |
If not super |
The following
6.2.5.1 IsPropertyReference ( V )
The abstract operation IsPropertyReference takes argument V (a
- If V.[[Base]] is
unresolvable , returnfalse . - If V.[[Base]] is an
Environment Record , returnfalse ; otherwise returntrue .
6.2.5.2 IsUnresolvableReference ( V )
The abstract operation IsUnresolvableReference takes argument V (a
- If V.[[Base]] is
unresolvable , returntrue ; otherwise returnfalse .
6.2.5.3 IsSuperReference ( V )
The abstract operation IsSuperReference takes argument V (a
- If V.[[ThisValue]] is not
empty , returntrue ; otherwise returnfalse .
6.2.5.4 IsPrivateReference ( V )
The abstract operation IsPrivateReference takes argument V (a
- If V.[[ReferencedName]] is a
Private Name , returntrue ; otherwise returnfalse .
6.2.5.5 GetValue ( V )
The abstract operation GetValue takes argument V (a
- If V is not a
Reference Record , return V. - If
IsUnresolvableReference (V) istrue , throw aReferenceError exception. - If
IsPropertyReference (V) istrue , then- Let baseObj be ?
ToObject (V.[[Base]]). - If
IsPrivateReference (V) istrue , then- Return ?
PrivateGet (baseObj, V.[[ReferencedName]]).
- Return ?
- Return ? baseObj.[[Get]](V.[[ReferencedName]],
GetThisValue (V)).
- Let baseObj be ?
- Else,
- Let base be V.[[Base]].
Assert : base is anEnvironment Record .- Return ? base.GetBindingValue(V.[[ReferencedName]], V.[[Strict]]) (see
9.1 ).
The object that may be created in step
6.2.5.6 PutValue ( V, W )
The abstract operation PutValue takes arguments V (a
- If V is not a
Reference Record , throw aReferenceError exception. - If
IsUnresolvableReference (V) istrue , then- If V.[[Strict]] is
true , throw aReferenceError exception. - Let globalObj be
GetGlobalObject (). - Perform ?
Set (globalObj, V.[[ReferencedName]], W,false ). - Return
unused .
- If V.[[Strict]] is
- If
IsPropertyReference (V) istrue , then- Let baseObj be ?
ToObject (V.[[Base]]). - If
IsPrivateReference (V) istrue , then- Return ?
PrivateSet (baseObj, V.[[ReferencedName]], W).
- Return ?
- Let succeeded be ? baseObj.[[Set]](V.[[ReferencedName]], W,
GetThisValue (V)). - If succeeded is
false and V.[[Strict]] istrue , throw aTypeError exception. - Return
unused .
- Let baseObj be ?
- Else,
- Let base be V.[[Base]].
Assert : base is anEnvironment Record .- Return ? base.SetMutableBinding(V.[[ReferencedName]], W, V.[[Strict]]) (see
9.1 ).
The object that may be created in step
6.2.5.7 GetThisValue ( V )
The abstract operation GetThisValue takes argument V (a
Assert :IsPropertyReference (V) istrue .- If
IsSuperReference (V) istrue , return V.[[ThisValue]]; otherwise return V.[[Base]].
6.2.5.8 InitializeReferencedBinding ( V, W )
The abstract operation InitializeReferencedBinding takes arguments V (a
Assert :IsUnresolvableReference (V) isfalse .- Let base be V.[[Base]].
Assert : base is anEnvironment Record .- Return ? base.InitializeBinding(V.[[ReferencedName]], W).
6.2.5.9 MakePrivateReference ( baseValue, privateIdentifier )
The abstract operation MakePrivateReference takes arguments baseValue (an
- Let privEnv be the
running execution context 's PrivateEnvironment. Assert : privEnv is notnull .- Let privateName be
ResolvePrivateIdentifier (privEnv, privateIdentifier). - Return the
Reference Record { [[Base]]: baseValue, [[ReferencedName]]: privateName, [[Strict]]:true , [[ThisValue]]:empty }.
6.2.6 The Property Descriptor Specification Type
The Property Descriptor type is used to explain the manipulation and reification of Object property attributes. A Property Descriptor is a
Property Descriptor values may be further classified as data Property Descriptors and accessor Property Descriptors based upon the existence or use of certain fields. A data Property Descriptor is one that includes any fields named either [[Value]] or [[Writable]]. An accessor Property Descriptor is one that includes any fields named either [[Get]] or [[Set]]. Any Property Descriptor may have fields named [[Enumerable]] and [[Configurable]]. A Property Descriptor value may not be both a data Property Descriptor and an accessor Property Descriptor; however, it may be neither (in which case it is a generic Property Descriptor). A fully populated Property Descriptor is one that is either an accessor Property Descriptor or a data Property Descriptor and that has all of the corresponding fields defined in
The following
6.2.6.1 IsAccessorDescriptor ( Desc )
The abstract operation IsAccessorDescriptor takes argument Desc (a
- If Desc is
undefined , returnfalse . - If Desc has a [[Get]] field, return
true . - If Desc has a [[Set]] field, return
true . - Return
false .
6.2.6.2 IsDataDescriptor ( Desc )
The abstract operation IsDataDescriptor takes argument Desc (a
- If Desc is
undefined , returnfalse . - If Desc has a [[Value]] field, return
true . - If Desc has a [[Writable]] field, return
true . - Return
false .
6.2.6.3 IsGenericDescriptor ( Desc )
The abstract operation IsGenericDescriptor takes argument Desc (a
- If Desc is
undefined , returnfalse . - If
IsAccessorDescriptor (Desc) istrue , returnfalse . - If
IsDataDescriptor (Desc) istrue , returnfalse . - Return
true .
6.2.6.4 FromPropertyDescriptor ( Desc )
The abstract operation FromPropertyDescriptor takes argument Desc (a
- If Desc is
undefined , returnundefined . - Let obj be
OrdinaryObjectCreate (%Object.prototype% ). Assert : obj is an extensibleordinary object with no own properties.- If Desc has a [[Value]] field, then
- Perform !
CreateDataPropertyOrThrow (obj,"value" , Desc.[[Value]]).
- Perform !
- If Desc has a [[Writable]] field, then
- Perform !
CreateDataPropertyOrThrow (obj,"writable" , Desc.[[Writable]]).
- Perform !
- If Desc has a [[Get]] field, then
- Perform !
CreateDataPropertyOrThrow (obj,"get" , Desc.[[Get]]).
- Perform !
- If Desc has a [[Set]] field, then
- Perform !
CreateDataPropertyOrThrow (obj,"set" , Desc.[[Set]]).
- Perform !
- If Desc has an [[Enumerable]] field, then
- Perform !
CreateDataPropertyOrThrow (obj,"enumerable" , Desc.[[Enumerable]]).
- Perform !
- If Desc has a [[Configurable]] field, then
- Perform !
CreateDataPropertyOrThrow (obj,"configurable" , Desc.[[Configurable]]).
- Perform !
- Return obj.
6.2.6.5 ToPropertyDescriptor ( Obj )
The abstract operation ToPropertyDescriptor takes argument Obj (an
- If Obj
is not an Object , throw aTypeError exception. - Let desc be a new
Property Descriptor that initially has no fields. - Let hasEnumerable be ?
HasProperty (Obj,"enumerable" ). - If hasEnumerable is
true , then - Let hasConfigurable be ?
HasProperty (Obj,"configurable" ). - If hasConfigurable is
true , then - Let hasValue be ?
HasProperty (Obj,"value" ). - If hasValue is
true , then- Let value be ?
Get (Obj,"value" ). - Set desc.[[Value]] to value.
- Let value be ?
- Let hasWritable be ?
HasProperty (Obj,"writable" ). - If hasWritable is
true , then - Let hasGet be ?
HasProperty (Obj,"get" ). - If hasGet is
true , then- Let getter be ?
Get (Obj,"get" ). - If
IsCallable (getter) isfalse and getter is notundefined , throw aTypeError exception. - Set desc.[[Get]] to getter.
- Let getter be ?
- Let hasSet be ?
HasProperty (Obj,"set" ). - If hasSet is
true , then- Let setter be ?
Get (Obj,"set" ). - If
IsCallable (setter) isfalse and setter is notundefined , throw aTypeError exception. - Set desc.[[Set]] to setter.
- Let setter be ?
- If desc has a [[Get]] field or desc has a [[Set]] field, then
- If desc has a [[Value]] field or desc has a [[Writable]] field, throw a
TypeError exception.
- If desc has a [[Value]] field or desc has a [[Writable]] field, throw a
- Return desc.
6.2.6.6 CompletePropertyDescriptor ( Desc )
The abstract operation CompletePropertyDescriptor takes argument Desc (a
- Let like be the
Record { [[Value]]:undefined , [[Writable]]:false , [[Get]]:undefined , [[Set]]:undefined , [[Enumerable]]:false , [[Configurable]]:false }. - If
IsGenericDescriptor (Desc) istrue orIsDataDescriptor (Desc) istrue , then- If Desc does not have a [[Value]] field, set Desc.[[Value]] to like.[[Value]].
- If Desc does not have a [[Writable]] field, set Desc.[[Writable]] to like.[[Writable]].
- Else,
- If Desc does not have a [[Get]] field, set Desc.[[Get]] to like.[[Get]].
- If Desc does not have a [[Set]] field, set Desc.[[Set]] to like.[[Set]].
- If Desc does not have an [[Enumerable]] field, set Desc.[[Enumerable]] to like.[[Enumerable]].
- If Desc does not have a [[Configurable]] field, set Desc.[[Configurable]] to like.[[Configurable]].
- Return
unused .
6.2.7 The Environment Record Specification Type
The
6.2.8 The Abstract Closure Specification Type
The Abstract Closure specification type is used to refer to algorithm steps together with a collection of values. Abstract Closures are meta-values and are invoked using function application style such as closure(arg1, arg2). Like
In algorithm steps that create an Abstract Closure, values are captured with the verb "capture" followed by a list of aliases. When an Abstract Closure is created, it captures the value that is associated with each alias at that time. In steps that specify the algorithm to be performed when an Abstract Closure is called, each captured value is referred to by the alias that was used to capture the value.
If an Abstract Closure returns a
Abstract Closures are created inline as part of other algorithms, shown in the following example.
- Let addend be 41.
- Let closure be a new
Abstract Closure with parameters (x) that captures addend and performs the following steps when called:- Return x + addend.
- Let val be closure(1).
Assert : val is 42.
6.2.9 Data Blocks
The Data Block specification type is used to describe a distinct and mutable sequence of byte-sized (8 bit) numeric values. A byte value is an
For notational convenience within this specification, an array-like syntax can be used to access the individual bytes of a Data Block value. This notation presents a Data Block value as a 0-origined
A data block that resides in memory that can be referenced from multiple
The semantics of Shared Data Blocks is defined using
The following
6.2.9.1 CreateByteDataBlock ( size )
The abstract operation CreateByteDataBlock takes argument size (a non-negative
- If size > 253 - 1, throw a
RangeError exception. - Let db be a new
Data Block value consisting of size bytes. If it is impossible to create such aData Block , throw aRangeError exception. - Set all of the bytes of db to 0.
- Return db.
6.2.9.2 CreateSharedByteDataBlock ( size )
The abstract operation CreateSharedByteDataBlock takes argument size (a non-negative
- Let db be a new
Shared Data Block value consisting of size bytes. If it is impossible to create such aShared Data Block , throw aRangeError exception. - Let execution be the [[CandidateExecution]] field of the
surrounding agent 'sAgent Record . - Let eventsRecord be the
Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] isAgentSignifier (). - Let zero be « 0 ».
- For each index i of db, do
- Append
WriteSharedMemory { [[Order]]:init , [[NoTear]]:true , [[Block]]: db, [[ByteIndex]]: i, [[ElementSize]]: 1, [[Payload]]: zero } to eventsRecord.[[EventList]].
- Append
- Return db.
6.2.9.3 CopyDataBlockBytes ( toBlock, toIndex, fromBlock, fromIndex, count )
The abstract operation CopyDataBlockBytes takes arguments toBlock (a
Assert : fromBlock and toBlock are distinct values.- Let fromSize be the number of bytes in fromBlock.
Assert : fromIndex + count ≤ fromSize.- Let toSize be the number of bytes in toBlock.
Assert : toIndex + count ≤ toSize.- Repeat, while count > 0,
- If fromBlock is a
Shared Data Block , then- Let execution be the [[CandidateExecution]] field of the
surrounding agent 'sAgent Record . - Let eventsRecord be the
Agent Events Record of execution.[[EventsRecords]] whose [[AgentSignifier]] isAgentSignifier (). - Let bytes be a
List whose sole element is a nondeterministically chosenbyte value . - NOTE: In implementations, bytes is the result of a non-atomic read instruction on the underlying hardware. The nondeterminism is a semantic prescription of the
memory model to describe observable behaviour of hardware with weak consistency. - Let readEvent be
ReadSharedMemory { [[Order]]:unordered , [[NoTear]]:true , [[Block]]: fromBlock, [[ByteIndex]]: fromIndex, [[ElementSize]]: 1 }. - Append readEvent to eventsRecord.[[EventList]].
- Append
Chosen Value Record { [[Event]]: readEvent, [[ChosenValue]]: bytes } to execution.[[ChosenValues]]. - If toBlock is a
Shared Data Block , then- Append
WriteSharedMemory { [[Order]]:unordered , [[NoTear]]:true , [[Block]]: toBlock, [[ByteIndex]]: toIndex, [[ElementSize]]: 1, [[Payload]]: bytes } to eventsRecord.[[EventList]].
- Append
- Else,
- Set toBlock[toIndex] to bytes[0].
- Let execution be the [[CandidateExecution]] field of the
- Else,
Assert : toBlock is not aShared Data Block .- Set toBlock[toIndex] to fromBlock[fromIndex].
- Set toIndex to toIndex + 1.
- Set fromIndex to fromIndex + 1.
- Set count to count - 1.
- If fromBlock is a
- Return
unused .
6.2.10 The PrivateElement Specification Type
The PrivateElement type is a
Values of the PrivateElement type are
Field Name | Values of the [[Kind]] field for which it is present | Value | Meaning |
---|---|---|---|
[[Key]] | All |
a |
The name of the field, method, or accessor. |
[[Kind]] | All |
|
The kind of the element. |
[[Value]] |
|
an |
The value of the field. |
[[Get]] |
|
a |
The getter for a private accessor. |
[[Set]] |
|
a |
The setter for a private accessor. |
6.2.11 The ClassFieldDefinition Record Specification Type
The ClassFieldDefinition type is a
Values of the ClassFieldDefinition type are
Field Name | Value | Meaning |
---|---|---|
[[Name]] |
a |
The name of the field. |
[[Initializer]] |
an ECMAScript |
The initializer of the field, if any. |
6.2.12 Private Names
The Private Name specification type is used to describe a globally unique value (one which differs from any other Private Name, even if they are otherwise indistinguishable) which represents the key of a private class element (field, method, or accessor). Each Private Name has an associated immutable [[Description]] which
6.2.13 The ClassStaticBlockDefinition Record Specification Type
A ClassStaticBlockDefinition Record is a
ClassStaticBlockDefinition Records have the fields listed in
Field Name | Value | Meaning |
---|---|---|
[[BodyFunction]] |
an ECMAScript |
The |