This proposal defines new syntax to access static members of the containing lexical class
declaration.
See the proposal repository for background material and discussion.
The
Method | Purpose |
---|---|
HasBinding(N) |
Determine if an |
CreateMutableBinding(N, D) |
Create a new but uninitialized mutable binding in an |
CreateImmutableBinding(N, S) |
Create a new but uninitialized immutable binding in an |
InitializeBinding(N, V) |
Set the value of an already existing but uninitialized binding in an |
SetMutableBinding(N, V, S) |
Set the value of an already existing mutable binding in an |
GetBindingValue(N, S) |
Returns the value of an already existing binding from an |
DeleteBinding(N) |
Delete a binding from an |
HasThisBinding() |
Determine if an this binding. Return |
HasSuperBinding() |
Determine if an super method binding. Return |
HasClassBinding() |
Determine if an class binding. Return |
WithBaseObject() |
If this with statement, return the with object. Otherwise, return |
Regular declarative Environment Records do not provide a class
binding.
Regular object Environment Records do not provide a class
binding.
A function Environment Record is a declarative this
binding. If a function is not an super
, its function Environment Record also contains the state that is used to perform super
method invocations from within the function. If a function is not an class
, its function Environment Record also contains the state that is used to perform class
property acccess from within the function.
Function Environment Records have the additional state fields listed in
Field Name | Value | Meaning |
---|---|---|
[[ThisValue]] | Any |
This is the |
[[ThisBindingStatus]] |
|
If the value is |
[[FunctionObject]] | Object |
The |
[[HomeObject]] |
Object | |
If the associated function has super property accesses and is not an |
[[InitialClassObject]] |
Object | |
If the associated function has class property access and is not an |
[[NewTarget]] |
Object | |
If this |
Function Environment Records support all of the declarative and HasSuperBinding, HasSuperBinding, and HasClassBinding. In addition, function Environment Records support the methods listed in
Method | Purpose |
---|---|
BindThisValue(V) | Set the [[ThisValue]] and record that it has been initialized. |
GetThisBinding() |
Return the value of this this binding. Throws a this binding has not been initialized.
|
GetSuperBase() |
Return the object that is the base for super property accesses bound in this super property accesses will produce runtime errors.
|
GetClassBinding() |
Return the object that is the base for class property accesses bound in this class property accesses will produce runtime errors.
|
The behaviour of the additional concrete specification methods for function Environment Records is defined by the following algorithms:
The abstract operation NewFunctionEnvironment takes arguments F and newTarget. It performs the following steps when called:
The abstract operation GetClassEnvironment takes no arguments. It finds the class
for a
ECMAScript function objects encapsulate parameterized ECMAScript code closed over a lexical environment and support the dynamic evaluation of that code. An ECMAScript
In addition to [[Extensible]] and [[Prototype]], ECMAScript function objects also have the internal slots listed in
Internal Slot | Type | Description |
---|---|---|
[[Environment]] |
|
The |
[[FormalParameters]] |
|
The root parse node of the source text that defines the function's formal parameter list. |
[[ECMAScriptCode]] |
|
The root parse node of the source text that defines the function's body. |
[[ConstructorKind]] |
|
Whether or not the function is a derived class |
[[Realm]] |
|
The |
[[ScriptOrModule]] |
|
The script or module in which the function was created. |
[[ThisMode]] |
|
Defines how this references are interpreted within the formal parameters and code body of the function. this refers to the |
[[Strict]] | Boolean |
|
[[HomeObject]] | Object |
If the function uses super , this is the object whose [[GetPrototypeOf]] provides the object where super property lookups begin.
|
[[InitialClassObject]] |
Object | |
If the function has class property access, this is the class property lookups begin.
|
[[SourceText]] | sequence of Unicode code points |
The |
[[IsClassConstructor]] | Boolean |
Indicates whether the function is a class |
The abstract operation MakeMethod takes arguments F and homeObject, homeObject, and classObject. It configures F as a method. It performs the following steps when called:
With parameters object and enumerable, enumerable, and optional parameter classObject.
An alternative semantics for this production is given in
With parameter symbol.
super
, return class
, return class
keywordWith parameter symbol.
super
, class
or this
, return Normally, Contains does not look inside most function forms. However, Contains is used to detect new.target
, this
, and , super
super
and class
-property usage within an
With parameter name.
An arguments
, super
, class
, this
, or new.target
. Any reference to arguments
, super
, class
, this
, or new.target
within an super
, the super
or class
is always contained within a non-super
or class
is accessible via the scope that is captured by the
With parameter object and optional parameter functionPrototypeparameters functionPrototype and classObject.
With parameters object and enumerable, enumerable, and optional parameter classObject.
With parameters object and enumerable, enumerable, and optional parameter classObject.
With parameter object and enumerable, enumerable, and optional parameter classObject.
With parameters classBinding and className.
constructor(...args) { super(...args); }
using the syntactic grammar with the constructor() {}
using the syntactic grammar with the With parameters object and enumerable, enumerable, and optional parameter classObject.
With parameter symbol.
super
, class
, or this
, return super
, class
, or this
, return new.target
, this
, super
super
, and class
-property usage within an AsyncArrowFunction.super
unless the source code containing super
is eval code that is being processed by a super
within super
.
The duplicate ExportedNames rule implies that multiple export default
The abstract operation PerformEval takes arguments x, callerRealm, strictCaller, and direct. It performs the following steps when called:
eval
function.The eval code cannot instantiate variable or function bindings in the variable environment of the calling context that invoked the eval if the calling context is evaluating formal parameter initializers or if either the code of the calling context or the eval code is let
, const
, or class
declarations are always instantiated in a new LexicalEnvironment.
The abstract operation CreateDynamicFunction takes arguments constructor (a new
was initially applied to. args is the argument values that were passed to constructor. It performs the following steps when called:
CreateDynamicFunction defines a
Kind | Prefix |
---|---|
© 2020 Ron Buckton, Ecma International
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.