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
- 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
- Return
false .
- Return
true .
15.4.4 Runtime Semantics: DefineMethod
With parameter object and optional parameter functionPrototype.
- Let propKey be the result of evaluating
PropertyName . ReturnIfAbrupt (propKey).- Let scope be the
running execution context 's LexicalEnvironment. - 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 , scope). - Perform
MakeMethod (closure, object). - Return the
Record { [[Key]]: propKey, [[Closure]]: closure }.
15.4.5 Runtime Semantics: MethodDefinitionEvaluation
With parameters object and enumerable.
- Let methodDef be ?
DefineMethod ofMethodDefinition with argument object. - Perform
SetFunctionName (methodDef.[[Closure]], methodDef.[[Key]]). - Let desc be the PropertyDescriptor { [[Value]]: methodDef.[[Closure]], [[Writable]]:
true , [[Enumerable]]: enumerable, [[Configurable]]:true }. - Return ?
DefinePropertyOrThrow (object, methodDef.[[Key]], desc).
- Let propKey be the result of evaluating
PropertyName . ReturnIfAbrupt (propKey).- Let scope be the
running execution context 's LexicalEnvironment. - 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 , scope). - Perform
MakeMethod (closure, object). - Perform
SetFunctionName (closure, propKey,"get" ). - Let desc be the PropertyDescriptor { [[Get]]: closure, [[Enumerable]]: enumerable, [[Configurable]]:
true }. - Return ?
DefinePropertyOrThrow (object, propKey, desc).
- Let propKey be the result of evaluating
PropertyName . ReturnIfAbrupt (propKey).- Let scope be the
running execution context 's LexicalEnvironment. - Let sourceText be the source text matched by
MethodDefinition . - Let closure be
OrdinaryFunctionCreate (%Function.prototype% , sourceText,PropertySetParameterList ,FunctionBody ,non-lexical-this , scope). - Perform
MakeMethod (closure, object). - Perform
SetFunctionName (closure, propKey,"set" ). - Let desc be the PropertyDescriptor { [[Set]]: closure, [[Enumerable]]: enumerable, [[Configurable]]:
true }. - Return ?
DefinePropertyOrThrow (object, propKey, desc).
- Let propKey be the result of evaluating
PropertyName . ReturnIfAbrupt (propKey).- Let scope be the
running execution context 's LexicalEnvironment. - Let sourceText be the source text matched by
GeneratorMethod . - Let closure be
OrdinaryFunctionCreate (%GeneratorFunction.prototype% , sourceText,UniqueFormalParameters ,GeneratorBody ,non-lexical-this , scope). - 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 }). - Let desc be the PropertyDescriptor { [[Value]]: closure, [[Writable]]:
true , [[Enumerable]]: enumerable, [[Configurable]]:true }. - Return ?
DefinePropertyOrThrow (object, propKey, desc).
- Let propKey be the result of evaluating
PropertyName . ReturnIfAbrupt (propKey).- Let scope be the
running execution context 's LexicalEnvironment. - Let sourceText be the source text matched by
AsyncGeneratorMethod . - Let closure be !
OrdinaryFunctionCreate (%AsyncGeneratorFunction.prototype% , sourceText,UniqueFormalParameters ,AsyncGeneratorBody ,non-lexical-this , scope). - 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 }). - Let desc be PropertyDescriptor { [[Value]]: closure, [[Writable]]:
true , [[Enumerable]]: enumerable, [[Configurable]]:true }. - Return ?
DefinePropertyOrThrow (object, propKey, desc).
- Let propKey be the result of evaluating
PropertyName . ReturnIfAbrupt (propKey).- Let scope be the LexicalEnvironment of the
running execution context . - Let sourceText be the source text matched by
AsyncMethod . - Let closure be !
OrdinaryFunctionCreate (%AsyncFunction.prototype% , sourceText,UniqueFormalParameters ,AsyncFunctionBody ,non-lexical-this , scope). - Perform !
MakeMethod (closure, object). - Perform !
SetFunctionName (closure, propKey). - Let desc be the PropertyDescriptor { [[Value]]: closure, [[Writable]]:
true , [[Enumerable]]: enumerable, [[Configurable]]:true }. - Return ?
DefinePropertyOrThrow (object, propKey, desc).