diff --git a/spec.html b/spec.html index 316a7d44eb..c5d31ec373 100644 --- a/spec.html +++ b/spec.html @@ -2537,7 +2537,7 @@
The List type is used to explain the evaluation of argument lists (see
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 « ».
-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 either an ECMAScript value or an abstract value represented by a name associated with the Record type. Field names are always enclosed in double brackets, for example [[value]].
+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 either an ECMAScript value or an abstract value represented by a name associated with the Record type. Field names are always enclosed in double brackets, for example [[value]].
For notational convenience within this specification, an object literal-like syntax can be used to express a Record value. For example, {[[field1]]: 42, [[field2]]: *false*, [[field3]]: ~empty~} defines a Record value that has three fields, each of which is initialized to a specific value. Field name order is not significant. Any fields that are not explicitly listed are considered to be absent.
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]]: *false*, [[Configurable]]: *true*}.
@@ -5935,7 +5935,8 @@An execution context is a specification device that is used to track the runtime evaluation of code by an ECMAScript implementation. At any point in time, there is at most one execution context that is actually executing code. This is known as the running execution context. A stack is used to track execution contexts. The running execution context is always the top element of this stack. A new execution context is created whenever control is transferred from the executable code associated with the currently running execution context to executable code that is not associated with that execution context. The newly created execution context is pushed onto the stack and becomes the running execution context.
+An execution context is a specification device that is used to track the runtime evaluation of code by an ECMAScript implementation. At any point in time, there is at most one execution context that is actually executing code. This is known as the running execution context.
+An execution context stack is used to track execution contexts. The running execution context is always the top element of this stack. A new execution context is created whenever control is transferred from the executable code associated with the currently running execution context to executable code that is not associated with that execution context. The newly created execution context is pushed onto the stack and becomes the running execution context.
An execution context contains whatever implementation specific state is necessary to track the execution progress of its associated code. Each execution context has at least the state components listed in
+ ScriptOrModule + | ++ The Module Record or Script Record from which associated code originates. If there is no originating script or module, as is the case for the original execution context created in InitializeHostDefinedRealm, the value is *null*. + | +
Evaluation of code by the running execution context may be suspended at various points defined within this specification. Once the running execution context has been suspended a different execution context may become the running execution context and commence evaluating its code. At some later time a suspended execution context may again become the running execution context and continue evaluating its code at the point where it had previously been suspended. Transition of the running execution context status among execution contexts usually occurs in stack-like last-in/first-out manner. However, some ECMAScript features require non-LIFO transitions of the running execution context.
-The value of the Realm component of the running execution context is also called the current Realm. The value of the Function component of the running execution context is also called the active function object.
+The value of the Realm component of the running execution context is also called the current Realm. The value of the Function component of the running execution context is also called the active function object.
Execution contexts for ECMAScript code have the additional state components listed in
+ [[ScriptOrModule]] + | ++ A Script Record or Module Record + | ++ The script or module for the initial execution context when this PendingJob is initiated. + | +||||||||||||||||||
[[HostDefined]]
@@ -6216,7 +6249,8 @@ EnqueueJob (_queueName_, _job_, _arguments_)1. Assert: _arguments_ is a List that has the same number of elements as the number of parameters required by _job_. 1. Let _callerContext_ be the running execution context. 1. Let _callerRealm_ be _callerContext_'s Realm. - 1. Let _pending_ be PendingJob{ [[Job]]: _job_, [[Arguments]]: _arguments_, [[Realm]]: _callerRealm_, [[HostDefined]]: *undefined* }. + 1. Let _callerScriptOrModule_ be _callerContext_'s ScriptOrModule. + 1. Let _pending_ be PendingJob{ [[Job]]: _job_, [[Arguments]]: _arguments_, [[Realm]]: _callerRealm_, [[ScriptOrModule]]: _callerScriptOrModule_, [[HostDefined]]: *undefined* }. 1. Perform any implementation or host environment defined processing of _pending_. This may include modifying the [[HostDefined]] field or any other field of _pending_. 1. Add _pending_ at the back of the Job Queue named by _queueName_. 1. Return NormalCompletion(~empty~). @@ -6236,7 +6270,7 @@NextJob resultJob abstract operations must not contain a Return step or a ReturnIfAbrupt step. The NextJob _result_ operation is equivalent to the following steps: NextJob result1. Let _newContext_ be a new execution context. 1. Set _newContext_'s Function to *null*. 1. Set _newContext_'s Realm to _nextPending_.[[Realm]]. + 1. Set _newContext_'s ScriptOrModule to _nextPending_.[[ScriptOrModule]]. 1. Push _newContext_ onto the execution context stack; _newContext_ is now the running execution context. 1. Perform any implementation or host environment defined job initialization using _nextPending_. 1. Perform the abstract operation named by _nextPending_.[[Job]] using the elements of _nextPending_.[[Arguments]] as its arguments. @@ -6260,17 +6295,18 @@InitializeHostDefinedRealm( )1. Let _newContext_ be a new execution context. 1. Set the Function of _newContext_ to *null*. 1. Set the Realm of _newContext_ to _realm_. + 1. Set the ScriptOrModule of _newContext_ to *null*. 1. Push _newContext_ onto the execution context stack; _newContext_ is now the running execution context. 1. If the host requires use of an exotic object to serve as _realm_'s global object, let _global_ be such an object created in an implementation defined manner. Otherwise, let _global_ be *undefined*, indicating that an ordinary object should be created as the global object. 1. If the host requires that the `this` binding in _realm_'s global scope return an object other than the global object, let _thisValue_ be such an object created in an implementation defined manner. Otherwise, let _thisValue_ be *undefined*, indicating that _realm_'s global `this` binding should be the global object. 1. Perform SetRealmGlobalObject(_realm_, _global_, _thisValue_). 1. Let _globalObj_ be ? SetDefaultGlobalBindings(_realm_). 1. Create any implementation defined global object properties on _globalObj_. - 1. In an implementation dependent manner, obtain the ECMAScript source texts (see clauseECMAScript Function ObjectsThe Code Realm in which the function was created and which provides any intrinsic objects that are accessed when evaluating the function. |
||||||||||||||||||||
+ [[ScriptOrModule]] + | ++ Script Record or Module Record + | ++ The script or module in which the function was created. + | +||||||||||||||||||
[[ThisMode]]
@@ -6786,6 +6833,7 @@ PrepareForOrdinaryCall( _F_, _newTarget_ )1. Set the Function of _calleeContext_ to _F_. 1. Let _calleeRealm_ be the value of _F_'s [[Realm]] internal slot. 1. Set the Realm of _calleeContext_ to _calleeRealm_. + 1. Set the ScriptOrModule of _calleeContext_ to the value of _F_'s [[ScriptOrModule]] internal slot. 1. Let _localEnv_ be NewFunctionEnvironment(_F_, _newTarget_). 1. Set the LexicalEnvironment of _calleeContext_ to _localEnv_. 1. Set the VariableEnvironment of _calleeContext_ to _localEnv_. @@ -6895,6 +6943,7 @@FunctionInitialize (_F_, _kind_, _ParameterList_, _Body_, _Scope_)1. Set the [[Environment]] internal slot of _F_ to the value of _Scope_. 1. Set the [[FormalParameters]] internal slot of _F_ to _ParameterList_ . 1. Set the [[ECMAScriptCode]] internal slot of _F_ to _Body_. + 1. Set the [[ScriptOrModule]] internal slot of _F_ to GetActiveScriptOrModule(). 1. If _kind_ is ~Arrow~, set the [[ThisMode]] internal slot of _F_ to ~lexical~. 1. Else if _Strict_ is *true*, set the [[ThisMode]] internal slot of _F_ to ~strict~. 1. Else set the [[ThisMode]] internal slot of _F_ to ~global~. @@ -7145,7 +7194,7 @@FunctionDeclarationInstantiation(_func_, _argumentsList_)Built-in Function ObjectsThe built-in function objects defined in this specification may be implemented as either ECMAScript function objects ( If a built-in function object is implemented as an exotic object it must have the ordinary object behaviour specified in If a built-in function object is implemented as an exotic object it must have the ordinary object behaviour specified in Unless otherwise specified every built-in function object has the %FunctionPrototype% object ( The behaviour specified for each built-in function via algorithm steps or other means is the specification of the function body behaviour for both [[Call]] and [[Construct]] invocations of the function. However, [[Construct]] invocation is not supported by all built-in functions. For each built-in function, when invoked with [[Call]], the [[Call]] _thisArgument_ provides the *this* value, the [[Call]] _argumentsList_ provides the named parameters, and the NewTarget value is *undefined*. When invoked with [[Construct]], the *this* value is uninitialized, the [[Construct]] _argumentsList_ provides the named parameters, and the [[Construct]] _newTarget_ parameter provides the NewTarget value. If the built-in function is implemented as an ECMAScript function object then this specified behaviour must be implemented by the ECMAScript code that is the body of the function. Built-in functions that are ECMAScript function objects must be strict mode functions. If a built-in constructor has any [[Call]] behaviour other than throwing a *TypeError* exception, an ECMAScript implementation of the function must be done in a manner that does not cause the function's [[FunctionKind]] internal slot to have the value `"classConstructor"`. Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in the description of a particular function. When a built-in constructor is called as part of a `new` expression the _argumentsList_ parameter of the invoked [[Construct]] internal method provides the values for the built-in constructor's named parameters. @@ -7163,6 +7212,7 @@[[Call]] ( _thisArgument_, _argumentsList_)1. Set the Function of _calleeContext_ to _F_. 1. Let _calleeRealm_ be the value of _F_'s [[Realm]] internal slot. 1. Set the Realm of _calleeContext_ to _calleeRealm_. + 1. Set the ScriptOrModule of _calleeContext_ to the value of _F_'s [[ScriptOrModule]] internal slot. 1. Perform any necessary implementation defined initialization of _calleeContext_. 1. Push _calleeContext_ onto the execution context stack; _calleeContext_ is now the running execution context. 1. Let _result_ be the Completion Record that is the result of evaluating _F_ in an implementation defined manner that conforms to the specification of _F_. _thisArgument_ is the *this* value, _argumentsList_ provides the named parameters, and the NewTarget value is *undefined*. @@ -7177,9 +7227,9 @@[[Call]] ( _thisArgument_, _argumentsList_)[[Construct]] (_argumentsList_, _newTarget_)-The [[Construct]] internal method for built-in function object _F_ is called with parameters _argumentsList_ and _newTarget_. The steps performed are the same as [[Call]] (see The [[Construct]] internal method for built-in function object _F_ is called with parameters _argumentsList_ and _newTarget_. The steps performed are the same as [[Call]] (see CreateBuiltinFunction(_realm_, _steps_, _prototype_, _internalSlotsList_)Each built-in function defined in this specification is created as if by calling the CreateBuiltinFunction abstract operation, unless otherwise specified. @@ -19472,17 +19523,110 @@Static Semantics: VarScopedDeclarationsRuntime Semantics: Evaluation+Script Records+ +A Script Record encapsulates information about a script being evaluated. Each script record contains the fields listed in
ParseScript ( _sourceText_, _hostDefined_ )+ +The abstract operation ParseScript with arguments _sourceText_ and _hostDefined_ creates a Script Record based upon the result of parsing _sourceText_ as a |Script|. ParseScript performs the following steps: + +An implementation may parse script source text and analyze it for Early Error conditions prior to evaluation of ParseScript for that script source text. However, the reporting of any errors must be deferred until the point where this specification actually performs ParseScript upon that source text. +Runtime Semantics: ScriptEvaluation-With argument _realm_. -ScriptEvaluation ( _scriptRecord_ )+Runtime Semantics: GlobalDeclarationInstantiation (_script_, _env_)Runtime Semantics: ScriptEvaluationJob ( _sourceText_ )-The job ScriptEvaluationJob with parameter _sourceText_ parses, validates, and evaluates _sourceText_ as a |Script|. +Runtime Semantics: ScriptEvaluationJob ( _sourceText_, _hostDefined_ )+The job ScriptEvaluationJob with parameters _sourceText_ and _hostDefined_ parses, validates, and evaluates _sourceText_ as a |Script|. An implementation may parse a _sourceText_ as a |Script| and analyze it for Early Error conditions prior to the execution of the ScriptEvaluationJob for that _sourceText_. However, the reporting of any errors must be deferred until the ScriptEvaluationJob is actually executed. -Abstract Module RecordsModule Record defines the fields listed in
Source Text Module RecordsRuntime Semantics: ParseModule ( _sourceText_ )-The abstract operation ParseModule with argument _sourceText_ creates a Source Text Module Record based upon the result of parsing _sourceText_ as a |Module|. ParseModule performs the following steps: +ParseModule ( _sourceText_, _hostDefined_ )+The abstract operation ParseModule with arguments _sourceText_ and _hostDefined_ creates a Source Text Module Record based upon the result of parsing _sourceText_ as a |Module|. ParseModule performs the following steps: Runtime Semantics: ParseModule ( _sourceText_ )1. Append _ee_ to _starExportEntries_. 1. Else, 1. Append _ee_ to _indirectExportEntries_. - 1. Return Source Text Module Record {[[Realm]]: *undefined*, [[Environment]]: *undefined*, [[Namespace]]: *undefined*, [[Evaluated]]: *false*, [[ECMAScriptCode]]: _body_, [[RequestedModules]]: _requestedModules_, [[ImportEntries]]: _importEntries_, [[LocalExportEntries]]: _localExportEntries_, [[StarExportEntries]]: _starExportEntries_, [[IndirectExportEntries]]: _indirectExportEntries_}. + 1. Return Source Text Module Record {[[Realm]]: *undefined*, [[Environment]]: *undefined*, [[HostDefined]]: _hostDefined_, [[Namespace]]: *undefined*, [[Evaluated]]: *false*, [[ECMAScriptCode]]: _body_, [[RequestedModules]]: _requestedModules_, [[ImportEntries]]: _importEntries_, [[LocalExportEntries]]: _localExportEntries_, [[StarExportEntries]]: _starExportEntries_, [[IndirectExportEntries]]: _indirectExportEntries_}.An implementation may parse module source text and analyze it for Early Error conditions prior to the evaluation of ParseModule for that module source text. However, the reporting of any errors must be deferred until the point where this specification actually performs ParseModule upon that source text. @@ -20719,6 +20872,7 @@ModuleEvaluation() Concrete Method1. Let _moduleCxt_ be a new ECMAScript code execution context. 1. Set the Function of _moduleCxt_ to *null*. 1. Set the Realm of _moduleCxt_ to _module_.[[Realm]]. + 1. Set the ScriptOrModule of _moduleCxt_ to _module_. 1. Assert: _module_ has been linked and declarations in its module environment have been instantiated. 1. Set the VariableEnvironment of _moduleCxt_ to _module_.[[Environment]]. 1. Set the LexicalEnvironment of _moduleCxt_ to _module_.[[Environment]]. @@ -20772,14 +20926,14 @@Runtime Semantics: GetModuleNamespace( _module_ )Runtime Semantics: TopLevelModuleEvaluationJob ( _sourceText_)-A TopLevelModuleEvaluationJob with parameter _sourceText_ is a job that parses, validates, and evaluates _sourceText_ as a |Module|. +Runtime Semantics: TopLevelModuleEvaluationJob ( _sourceText_, _hostDefined_ )+A TopLevelModuleEvaluationJob with parameters _sourceText_ and _hostDefined_ is a job that parses, validates, and evaluates _sourceText_ as a |Module|. Runtime Semantics: EvaluationError Handling and Language Extensions-An implementation must report most errors at the time the relevant ECMAScript language construct is evaluated. An early error is an error that can be detected and reported prior to the evaluation of any construct in the |Script| containing the error. The presence of an early error prevents the evaluation of the construct. An implementation must report early errors in a |Script| as part of the ScriptEvaluationJob for that |Script|. Early errors in a |Module| are reported at the point when the |Module| would be evaluated and the |Module| is never initialized. Early errors in eval code are reported at the time `eval` is called and prevent evaluation of the eval code. All errors that are not early errors are runtime errors. +An implementation must report most errors at the time the relevant ECMAScript language construct is evaluated. An early error is an error that can be detected and reported prior to the evaluation of any construct in the |Script| containing the error. The presence of an early error prevents the evaluation of the construct. An implementation must report early errors in a |Script| as part of parsing that |Script| in ParseScript. Early errors in a |Module| are reported at the point when the |Module| would be evaluated and the |Module| is never initialized. Early errors in eval code are reported at the time `eval` is called and prevent evaluation of the eval code. All errors that are not early errors are runtime errors. An implementation must report as an early error any occurrence of a condition that is listed in a “Static Semantics: Early Errors” subclause of this specification. An implementation shall not treat other kinds of errors as early errors even if the compiler can prove that a construct cannot execute without error under any circumstances. An implementation may issue an early warning in such a case, but it should not report the error until the relevant construct is actually executed. An implementation shall report all errors as specified, except for the following: @@ -21458,6 +21612,18 @@Error Handling and Language ExtensionsAn implementation may define behaviour other than throwing *RangeError* for `toFixed`, `toExponential`, and `toPrecision` when the _fractionDigits_ or _precision_ argument is outside the specified range. +HostReportErrors( _errorList_ )+ +HostReportErrors is an implementation-defined abstract operation that allows host environments to report parsing errors, early errors, and runtime errors. + +An implementation of HostReportErrors must complete normally in all cases. The default implementation of HostReportErrors is to do nothing. + +Forbidden Extensions@@ -21591,6 +21757,7 @@Runtime Semantics: PerformEval( _x_, _evalRealm_, _strictCaller_, _direct_)<
1. Let _evalCxt_ be a new ECMAScript code execution context.
1. Set the _evalCxt_'s Function to *null*.
1. Set the _evalCxt_'s Realm to _evalRealm_.
+ 1. Set the _evalCxt_'s ScriptOrModule to _ctx_'s ScriptOrModule.
1. Set the _evalCxt_'s VariableEnvironment to _varEnv_.
1. Set the _evalCxt_'s LexicalEnvironment to _lexEnv_.
1. Push _evalCxt_ on to the execution context stack; _evalCxt_ is now the running execution context.
@@ -34581,7 +34748,7 @@ |