15.4 Method Definitions
Syntax
15.4.1 Static Semantics: Early Errors
-
It is a Syntax Error if
FunctionBodyContainsUseStrict ofFunctionBody istrue andIsSimpleParameterList ofUniqueFormalParameters isfalse . -
It is a Syntax Error if any element of the
BoundNames ofUniqueFormalParameters also occurs in theLexicallyDeclaredNames ofFunctionBody .
-
It is a Syntax Error if
BoundNames ofPropertySetParameterList contains any duplicate elements. -
It is a Syntax Error if
FunctionBodyContainsUseStrict ofFunctionBody istrue andIsSimpleParameterList ofPropertySetParameterList isfalse . -
It is a Syntax Error if any element of the
BoundNames ofPropertySetParameterList also occurs in theLexicallyDeclaredNames ofFunctionBody .
15.4.2 Static Semantics: HasDirectSuper
The
- If
UniqueFormalParameters Contains SuperCall istrue , returntrue . - Return
FunctionBody Contains SuperCall .
- Return
FunctionBody Contains SuperCall .
- If
PropertySetParameterList Contains SuperCall istrue , returntrue . - Return
FunctionBody Contains SuperCall .
- If
UniqueFormalParameters Contains SuperCall istrue , returntrue . - Return
GeneratorBody Contains SuperCall .
- If
UniqueFormalParameters Contains SuperCall istrue , returntrue . - Return
AsyncGeneratorBody Contains SuperCall .
- If
UniqueFormalParameters Contains SuperCall istrue , returntrue . - Return
AsyncFunctionBody Contains SuperCall .
15.4.3 Static Semantics: SpecialMethod
The
- Return
false .
- Return
true .
15.4.4 Runtime Semantics: DefineMethod
The
- Let propKey be ?
Evaluation ofClassElementName . - Let env be the
running execution context 's LexicalEnvironment. - Let privateEnv be the
running execution context 's PrivateEnvironment. - If functionPrototype is present, then
- Let prototype be functionPrototype.
- Else,
- Let prototype be
%Function.prototype% .
- Let prototype be
- Let sourceText be the
source text matched by MethodDefinition . - Let closure be
OrdinaryFunctionCreate (prototype, sourceText,UniqueFormalParameters ,FunctionBody ,non-lexical-this , env, privateEnv). - Perform
MakeMethod (closure, object). - Return the
Record { [[Key]]: propKey, [[Closure]]: closure }.
15.4.5 Runtime Semantics: MethodDefinitionEvaluation
The
- Let methodDef be ?
DefineMethod ofMethodDefinition with argument object. - Perform
SetFunctionName (methodDef.[[Closure]], methodDef.[[Key]]). - Return
DefineMethodProperty (object, methodDef.[[Key]], methodDef.[[Closure]], enumerable).
- Let propKey be ?
Evaluation ofClassElementName . - Let env be the
running execution context 's LexicalEnvironment. - Let privateEnv be the
running execution context 's PrivateEnvironment. - Let sourceText be the
source text matched by MethodDefinition . - Let formalParameterList be an instance of the production
.FormalParameters : [empty] - Let closure be
OrdinaryFunctionCreate (%Function.prototype% , sourceText, formalParameterList,FunctionBody ,non-lexical-this , env, privateEnv). - Perform
MakeMethod (closure, object). - Perform
SetFunctionName (closure, propKey,"get" ). - If propKey is a
Private Name , then- Return
PrivateElement { [[Key]]: propKey, [[Kind]]:accessor , [[Get]]: closure, [[Set]]:undefined }.
- Return
- Else,
- Let desc be the PropertyDescriptor { [[Get]]: closure, [[Enumerable]]: enumerable, [[Configurable]]:
true }. - Perform ?
DefinePropertyOrThrow (object, propKey, desc). - Return
unused .
- Let desc be the PropertyDescriptor { [[Get]]: closure, [[Enumerable]]: enumerable, [[Configurable]]:
- Let propKey be ?
Evaluation ofClassElementName . - Let env be the
running execution context 's LexicalEnvironment. - Let privateEnv be the
running execution context 's PrivateEnvironment. - Let sourceText be the
source text matched by MethodDefinition . - Let closure be
OrdinaryFunctionCreate (%Function.prototype% , sourceText,PropertySetParameterList ,FunctionBody ,non-lexical-this , env, privateEnv). - Perform
MakeMethod (closure, object). - Perform
SetFunctionName (closure, propKey,"set" ). - If propKey is a
Private Name , then- Return
PrivateElement { [[Key]]: propKey, [[Kind]]:accessor , [[Get]]:undefined , [[Set]]: closure }.
- Return
- Else,
- Let desc be the PropertyDescriptor { [[Set]]: closure, [[Enumerable]]: enumerable, [[Configurable]]:
true }. - Perform ?
DefinePropertyOrThrow (object, propKey, desc). - Return
unused .
- Let desc be the PropertyDescriptor { [[Set]]: closure, [[Enumerable]]: enumerable, [[Configurable]]:
- Let propKey be ?
Evaluation ofClassElementName . - Let env be the
running execution context 's LexicalEnvironment. - Let privateEnv be the
running execution context 's PrivateEnvironment. - Let sourceText be the
source text matched by GeneratorMethod . - Let closure be
OrdinaryFunctionCreate (%GeneratorFunction.prototype% , sourceText,UniqueFormalParameters ,GeneratorBody ,non-lexical-this , env, privateEnv). - Perform
MakeMethod (closure, object). - Perform
SetFunctionName (closure, propKey). - Let prototype be
OrdinaryObjectCreate (%GeneratorFunction.prototype.prototype% ). - Perform !
DefinePropertyOrThrow (closure,"prototype" , PropertyDescriptor { [[Value]]: prototype, [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:false }). - Return
DefineMethodProperty (object, propKey, closure, enumerable).
- Let propKey be ?
Evaluation ofClassElementName . - Let env be the
running execution context 's LexicalEnvironment. - Let privateEnv be the
running execution context 's PrivateEnvironment. - Let sourceText be the
source text matched by AsyncGeneratorMethod . - Let closure be
OrdinaryFunctionCreate (%AsyncGeneratorFunction.prototype% , sourceText,UniqueFormalParameters ,AsyncGeneratorBody ,non-lexical-this , env, privateEnv). - Perform
MakeMethod (closure, object). - Perform
SetFunctionName (closure, propKey). - Let prototype be
OrdinaryObjectCreate (%AsyncGeneratorFunction.prototype.prototype% ). - Perform !
DefinePropertyOrThrow (closure,"prototype" , PropertyDescriptor { [[Value]]: prototype, [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:false }). - Return
DefineMethodProperty (object, propKey, closure, enumerable).
- Let propKey be ?
Evaluation ofClassElementName . - Let env be the LexicalEnvironment of the
running execution context . - Let privateEnv be the
running execution context 's PrivateEnvironment. - Let sourceText be the
source text matched by AsyncMethod . - Let closure be
OrdinaryFunctionCreate (%AsyncFunction.prototype% , sourceText,UniqueFormalParameters ,AsyncFunctionBody ,non-lexical-this , env, privateEnv). - Perform
MakeMethod (closure, object). - Perform
SetFunctionName (closure, propKey). - Return
DefineMethodProperty (object, propKey, closure, enumerable).