Skip to content

Commit

Permalink
Editorial: Convert NativeFunctionName to an SDO
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Jul 14, 2022
1 parent b8f230e commit 9f5369e
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -30118,17 +30118,19 @@ <h1>Function.prototype.toString ( )</h1>
1. Let _sourceText_ be an implementation-defined sequence of Unicode code points that represents _func_ using the syntax of |NativeFunction|.
1. Else,
1. Throw a *TypeError* exception.
1. Assert: ParseText(_sourceText_, |NativeFunction|) is a Parse Node.
1. If _func_ has an [[InitialName]] internal slot and _func_.[[InitialName]] is a String, then
1. Assert: NativeFunctionName(_sourceText_) is _func_.[[InitialName]].
1. Let _parsedFunction_ be ParseText(_sourceText_, |NativeFunction|).
1. Assert: _parsedFunction_ is a Parse Node.
1. If _func_ has an [[InitialName]] internal slot, then
1. Assert: NativeFunctionName of _parsedFunction_ is _func_.[[InitialName]].
1. Return CodePointsToString(_sourceText_).
</emu-alg>

<emu-grammar type="definition">
NativeFunction :
`function` NativeFunctionName? `(` FormalParameters[~Yield, ~Await] `)` `{` `[` `native` `code` `]` `}`
`function` NativeFunctionName `(` FormalParameters[~Yield, ~Await] `)` `{` `[` `native` `code` `]` `}`

NativeFunctionName :
[empty]
NativeFunctionAccessor? LiteralPropertyName
NativeFunctionAccessor? `[` StringLiteral `]`

Expand All @@ -30137,31 +30139,26 @@ <h1>Function.prototype.toString ( )</h1>
`set`
</emu-grammar>

<emu-clause id="sec-nativefunctionname" type="abstract operation">
<h1>
NativeFunctionName (
_sourceText_: a sequence of Unicode code points,
): a String
</h1>
<emu-clause id="sec-nativefunctionname" type="sdo">
<h1>Runtime Semantics: NativeFunctionName ( ): a String</h1>
<dl class="header">
<dt>description</dt>
<dd>It returns the name of a built-in function object represented by source text.</dd>
</dl>
<emu-grammar>NativeFunction : `function` NativeFunctionName `(` FormalParameters[~Yield, ~Await] `)` `{` `[` `native` `code` `]` `}`</emu-grammar>
<emu-alg>
1. Let _function_ be ParseText(_sourceText_, |NativeFunction|).
1. If |NativeFunctionName| is not present in _function_, return *""*.
1. Let _name_ be the |NativeFunctionName| of _function_.
1. If _name_ is <emu-grammar>NativeFunctionName : NativeFunctionAccessor? LiteralPropertyName</emu-grammar> , then
1. Let _propertyNameNode_ be the |LiteralPropertyName| of _name_.
1. If |NativeFunctionName| is <emu-grammar>NativeFunctionName : [empty]</emu-grammar> , return *""*.
1. Else if |NativeFunctionName| is <emu-grammar>NativeFunctionName : NativeFunctionAccessor? LiteralPropertyName</emu-grammar> , then
1. Let _baseNameNode_ be the |LiteralPropertyName| of |NativeFunctionName|.
1. Else,
1. Assert: _name_ is <emu-grammar>NativeFunctionName : NativeFunctionAccessor? `[` StringLiteral `]`</emu-grammar> .
1. Let _propertyNameNode_ be the |StringLiteral| of _name_.
1. Let _propertyName_ be the result of evaluating _propertyNameNode_.
1. Assert: Type(_propertyName_) is String.
1. If |NativeFunctionAccessor| is not present in _name_, return _propertyName_.
1. Let _accessor_ be the |NativeFunctionAccessor| of _name_.
1. Assert: |NativeFunctionName| is <emu-grammar>NativeFunctionName : NativeFunctionAccessor? `[` StringLiteral `]`</emu-grammar> .
1. Let _baseNameNode_ be the |StringLiteral| of |NativeFunctionName|.
1. Let _baseName_ be the result of evaluating _baseNameNode_.
1. Assert: Type(_baseName_) is String.
1. If |NativeFunctionAccessor| is not present in |NativeFunctionName|, return _baseName_.
1. Let _accessor_ be the |NativeFunctionAccessor| of |NativeFunctionName|.
1. Let _prefix_ be the source text matched by _accessor_.
1. Return the string-concatenation of CodePointsToString(_prefix_), the code unit 0x0020 (SPACE), and _propertyName_.
1. Return the string-concatenation of CodePointsToString(_prefix_), the code unit 0x0020 (SPACE), and _baseName_.
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down

0 comments on commit 9f5369e

Please sign in to comment.