Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #47 from tc39/ecma262
Browse files Browse the repository at this point in the history
Updates based on ecma262 PR feedback
  • Loading branch information
rbuckton authored Jun 28, 2021
2 parents 289a8c1 + 4e2bf53 commit ae15dde
Show file tree
Hide file tree
Showing 13 changed files with 217 additions and 31 deletions.
11 changes: 11 additions & 0 deletions spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ <h1>Miscellaneous</h1>
</emu-clause>
</emu-clause>

<emu-clause id="sec-ordinary-and-exotic-objects-behaviours">
<h1>Ordinary and Exotic Objects Behaviours</h1>
<emu-clause id="sec-ecmascript-function-objects">
<h1>ECMAScript Function Objects</h1>
<emu-clause id="sec-ecmascript-function-objects-call-thisargument-argumentslist">
<h1>[[Call]] ( _thisArgument_, _argumentsList_ )</h1>
<emu-import href="sec-runtime-semantics-evaluatebody-patch.html"></emu-import>
</emu-clause>
</emu-clause>
</emu-clause>

<emu-clause id="sec-ecmascript-language-statements-and-declarations">
<h1>ECMAScript Language: Statements and Declarations</h1>
<emu-clause id="sec-continue-statement">
Expand Down
148 changes: 131 additions & 17 deletions spec/sec-class-definitions-patch.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ <h2>Syntax</h2>
<emu-clause id="sec-class-definitions-static-semantics-early-errors">
<h1>Static Semantics: Early Errors</h1>
<ins class="block">
<emu-grammar>ClassStaticBlockBody: ClassStaticBlockStatementList</emu-grammar>
<emu-grammar>ClassStaticBlockBody : ClassStaticBlockStatementList</emu-grammar>
<ul>
<li>
<p>It is a Syntax Error if the LexicallyDeclaredNames of |ClassStaticBlockStatementList| contains any duplicate entries.</p>
It is a Syntax Error if the LexicallyDeclaredNames of |ClassStaticBlockStatementList| contains any duplicate entries.
</li>
<li>
<p>It is a Syntax Error if any element of the LexicallyDeclaredNames of |ClassStaticBlockStatementList| also occurs in the VarDeclaredNames of |ClassStaticBlockStatementList|.</p>
It is a Syntax Error if any element of the LexicallyDeclaredNames of |ClassStaticBlockStatementList| also occurs in the VarDeclaredNames of |ClassStaticBlockStatementList|.
</li>
<li>
<p>It is a Syntax Error if ContainsDuplicateLabels of |ClassStaticBlockStatementList| with argument &laquo; &raquo; is *true*.</p>
It is a Syntax Error if ContainsDuplicateLabels of |ClassStaticBlockStatementList| with argument &laquo; &raquo; is *true*.
</li>
<li>
<p>It is a Syntax Error if ContainsUndefinedBreakTarget of |ClassStaticBlockStatementList| with argument &laquo; &raquo; is *true*.</p>
It is a Syntax Error if ContainsUndefinedBreakTarget of |ClassStaticBlockStatementList| with argument &laquo; &raquo; is *true*.
</li>
<li>
<p>It is a Syntax Error if ContainsUndefinedContinueTarget of |ClassStaticBlockStatementList| with arguments &laquo; &raquo; and &laquo; &raquo; is *true*.</p>
It is a Syntax Error if ContainsUndefinedContinueTarget of |ClassStaticBlockStatementList| with arguments &laquo; &raquo; and &laquo; &raquo; is *true*.
</li>
<li>
<p>It is a Syntax Error if ContainsArguments of |ClassStaticBlockStatementList| is *true*.</p>
It is a Syntax Error if ContainsArguments of |ClassStaticBlockStatementList| is *true*.
</li>
<li>
<p>It is a Syntax Error if |ClassStaticBlockStatementList| Contains |SuperCall| is *true*.</p>
It is a Syntax Error if |ClassStaticBlockStatementList| Contains |SuperCall| is *true*.
</li>
<li>
<p>It is a Syntax Error if ContainsAwait of |ClassStaticBlockStatementList| is *true*.</p>
It is a Syntax Error if ContainsAwait of |ClassStaticBlockStatementList| is *true*.
</li>
</ul>
</ins>
Expand Down Expand Up @@ -113,6 +113,63 @@ <h1>Static Semantics: IsStatic</h1>
</emu-alg>
</emu-clause>


<emu-clause id="sec-static-semantics-privateboundidentifiers" type="sdo" aoid="PrivateBoundIdentifiers">
<h1>Static Semantics: PrivateBoundIdentifiers</h1>
<emu-grammar>
FieldDefinition : ClassElementName Initializer?
</emu-grammar>
<emu-alg>
1. Return PrivateBoundIdentifiers of |ClassElementName|.
</emu-alg>

<emu-grammar>
ClassElementName : PrivateIdentifier
</emu-grammar>
<emu-alg>
1. Return a List whose sole element is the StringValue of |PrivateIdentifier|.
</emu-alg>

<emu-grammar>
ClassElementName : PropertyName

<ins>ClassElement : ClassStaticBlock</ins>

ClassElement : `;`
</emu-grammar>
<emu-alg>
1. Return a new empty List.
</emu-alg>

<emu-grammar>
ClassElementList : ClassElementList ClassElement
</emu-grammar>
<emu-alg>
1. Let _names_ be PrivateBoundIdentifiers of |ClassElementList|.
1. Append to _names_ the elements of PrivateBoundIdentifiers of |ClassElement|.
1. Return _names_.
</emu-alg>

<emu-grammar>
MethodDefinition :
ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}`
`get` ClassElementName `(` `)` `{` FunctionBody `}`
`set` ClassElementName `(` PropertySetParameterList `)` `{` FunctionBody `}`

GeneratorMethod :
`*` ClassElementName `(` UniqueFormalParameters `)` `{` GeneratorBody `}`

AsyncMethod :
`async` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}`

AsyncGeneratorMethod :
`async` `*` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}`
</emu-grammar>
<emu-alg>
1. Return PrivateBoundIdentifiers of |ClassElementName|.
</emu-alg>
</emu-clause>

<emu-clause id="sec-static-semantics-containsawait" type="sdo" aoid="ContainsAwait">
<h1><ins>Static Semantics: ContainsAwait</ins></h1>

Expand Down Expand Up @@ -218,7 +275,7 @@ <h1><ins>Static Semantics: ComputedPropertyContainsAwait</ins></h1>
</emu-alg>
<emu-grammar>PropertyName : ComputedPropertyName</emu-grammar>
<emu-alg>
1. Return the result of ComputedPropertyContainsAwait for |ComputedPropertyName|.
1. Return the result of ContainsAwait for |ComputedPropertyName|.
</emu-alg>
<emu-grammar>
MethodDefinition :
Expand All @@ -242,7 +299,11 @@ <h1><ins>Static Semantics: ComputedPropertyContainsAwait</ins></h1>
1. Let ComputedPropertyContainsAwait for |ClassElementList| is *true*, return *true*.
1. Return the result of ComputedPropertyContainsAwait for |ClassElement|.
</emu-alg>
<emu-grammar>ClassElement : `;`</emu-grammar>
<emu-grammar>
ClassElement : ClassStaticBlock

ClassElement : `;`
</emu-grammar>
<emu-alg>
1. Return *false*.
</emu-alg>
Expand All @@ -265,16 +326,29 @@ <h1><ins>Static Semantics: ComputedPropertyContainsAwait</ins></h1>
<h1><ins>Runtime Semantics: ClassStaticBlockDefinitionEvaluation</ins></h1>
<ins class="block">
<p>With parameter _homeObject_.</p>
<emu-grammar>ClassStaticBlock: `static` `{` ClassStaticBlockBody `}`</emu-grammar>
<emu-grammar>ClassStaticBlock : `static` `{` ClassStaticBlockBody `}`</emu-grammar>
<emu-alg>
1. Let _lex_ be the running execution context's LexicalEnvironment.
1. Let _privateScope_ be the running execution context's PrivateEnvironment.
1. Let _sourceText_ be the empty sequence of Unicode code points.
1. Let _body_ be OrdinaryFunctionCreate(%Function.prototype%, _sourceText_, &laquo; &raquo;, |ClassStaticBlockBody|, ~non-lexical-this~, _lex_, _privateScope_).
1. Perform MakeMethod(_body_, _homeObject_).
1. Return the ClassStaticBlockDefinition Record { [[Body]]: _body_ }.
1. Let _formalParameters_ be an instance of the production <emu-grammar>FormalParameters : [empty]</emu-grammar>.
1. Let _bodyFunction_ be OrdinaryFunctionCreate(%Function.prototype%, _sourceText_, _formalParameters_, |ClassStaticBlockBody|, ~non-lexical-this~, _lex_, _privateScope_).
1. Perform MakeMethod(_bodyFunction_, _homeObject_).
1. Return the ClassStaticBlockDefinition Record { [[BodyFunction]]: _bodyFunction_ }.
</emu-alg>
<emu-note>The function created for _bodyFunction_ is never directly accessible to ECMAScript code.</emu-note>
</ins>
</emu-clause>

<emu-clause id="sec-runtime-semantics-evaluateclassstaticblockbody" type="sdo" aoid="EvaluateClassStaticBlockBody">
<h1><ins>Runtime Semantics: EvaluateClassStaticBlockBody</ins></h1>
<ins class="block">
<p>With parameter _functionObject_.</p>
<emu-grammar>ClassStaticBlockBody : ClassStaticBlockStatementList</emu-grammar>
<emu-alg>
1. Perform ? FunctionDeclarationInstantiation(_functionObject_, &laquo; &raquo;).
1. Return the result of evaluating |ClassStaticBlockStatementList|.
</emu-alg>
<emu-note>The function created for _body_ is never directly accessible to ECMAScript code.</emu-note>
</ins>
</emu-clause>

Expand All @@ -301,7 +375,7 @@ <h1>Runtime Semantics: ClassElementEvaluation</h1>
</emu-alg>

<ins class="block">
<emu-grammar>ClassElement: ClassStaticBlock</emu-grammar>
<emu-grammar>ClassElement : ClassStaticBlock</emu-grammar>
<emu-alg>
1. Return ClassStaticBlockDefinitionEvaluation of |ClassStaticBlock| with argument _object_.
</emu-alg>
Expand Down Expand Up @@ -426,4 +500,44 @@ <h1>Runtime Semantics: ClassDefinitionEvaluation</h1>
1. Return _F_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-class-definitions-runtime-semantics-evaluation">
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>ClassDeclaration : `class` BindingIdentifier ClassTail</emu-grammar>
<emu-alg>
1. Perform ? BindingClassDeclarationEvaluation of this |ClassDeclaration|.
1. Return NormalCompletion(~empty~).
</emu-alg>
<emu-note>
<p><emu-grammar>ClassDeclaration : `class` ClassTail</emu-grammar> only occurs as part of an |ExportDeclaration| and is never directly evaluated.</p>
</emu-note>
<emu-grammar>ClassExpression : `class` ClassTail</emu-grammar>
<emu-alg>
1. Let _value_ be ? ClassDefinitionEvaluation of |ClassTail| with arguments *undefined* and *""*.
1. Set _value_.[[SourceText]] to the source text matched by |ClassExpression|.
1. Return _value_.
</emu-alg>
<emu-grammar>ClassExpression : `class` BindingIdentifier ClassTail</emu-grammar>
<emu-alg>
1. Let _className_ be StringValue of |BindingIdentifier|.
1. Let _value_ be ? ClassDefinitionEvaluation of |ClassTail| with arguments _className_ and _className_.
1. Set _value_.[[SourceText]] to the source text matched by |ClassExpression|.
1. Return _value_.
</emu-alg>
<emu-grammar>ClassElementName : PrivateIdentifier</emu-grammar>
<emu-alg>
1. Let _privateIdentifier_ be StringValue of |PrivateIdentifier|.
1. Let _privateEnvRec_ be the running execution context's PrivateEnvironment.
1. Let _names_ be _privateEnvRec_.[[Names]].
1. Assert: Exactly one element of _names_ is a Private Name whose [[Description]] is _privateIdentifier_.
1. Let _privateName_ be the Private Name in _names_ whose [[Description]] is _privateIdentifier_.
1. Return _privateName_.
</emu-alg>
<ins class="block">
<emu-grammar>ClassStaticBlockStatementList : [empty]</emu-grammar>
<emu-alg>
1. Return NormalCompletion(*undefined*).
</emu-alg>
</ins>
</emu-clause>
</emu-clause>
2 changes: 1 addition & 1 deletion spec/sec-ecmascript-specification-types-patch.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1><ins>ClassStaticBlockDefinition Records</ins></h1>
</tr>
<tr>
<td>
[[Body]]
[[BodyFunction]]
</td>
<td>
An function object.
Expand Down
3 changes: 2 additions & 1 deletion spec/sec-operations-on-objects-patch.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ <h1>Operations on Objects</h1>
<emu-clause id="sec-evaluatestaticblock" aoid="EvaluateStaticBlock">
<h1><ins>EvaluateStaticBlock ( _receiver_ , _blockRecord_ )</ins></h1>
<ins class="block">
<p>The abstract operation EvaluateStaticBlock takes arguments _receiver_ (an Object) and _blockRecord_ (a ClassStaticBlockDefinition Record). It performs the following steps when called:</p>
<emu-alg>
1. Assert: Type(_receiver_) is Object.
1. Assert: _blockRecord_ is a ClassStaticBlockDefinition Record.
1. Perform ? Call(_blockRecord_.[[Body]], _receiver_).
1. Perform ? Call(_blockRecord_.[[BodyFunction]], _receiver_).
</emu-alg>
</ins>
</emu-clause>
Expand Down
60 changes: 60 additions & 0 deletions spec/sec-runtime-semantics-evaluatebody-patch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<emu-clause id="sec-runtime-semantics-evaluatebody" type="sdo" aoid="EvaluateBody">
<h1>Runtime Semantics: EvaluateBody</h1>
<p>With parameters _functionObject_ and _argumentsList_ (a List).</p>
<emu-grammar>FunctionBody : FunctionStatementList</emu-grammar>
<emu-alg>
1. Return ? EvaluateFunctionBody of |FunctionBody| with arguments _functionObject_ and _argumentsList_.
</emu-alg>
<emu-grammar>ConciseBody : ExpressionBody</emu-grammar>
<emu-alg>
1. Return ? EvaluateConciseBody of |ConciseBody| with arguments _functionObject_ and _argumentsList_.
</emu-alg>
<emu-grammar>GeneratorBody : FunctionBody</emu-grammar>
<emu-alg>
1. Return ? EvaluateGeneratorBody of |GeneratorBody| with arguments _functionObject_ and _argumentsList_.
</emu-alg>
<emu-grammar>
AsyncGeneratorBody : FunctionBody
</emu-grammar>
<emu-alg>
1. Return ? EvaluateAsyncGeneratorBody of |AsyncGeneratorBody| with arguments _functionObject_ and _argumentsList_.
</emu-alg>
<emu-grammar>
AsyncFunctionBody : FunctionBody
</emu-grammar>
<emu-alg>
1. Return ? EvaluateAsyncFunctionBody of |AsyncFunctionBody| with arguments _functionObject_ and _argumentsList_.
</emu-alg>
<emu-grammar>
AsyncConciseBody : ExpressionBody
</emu-grammar>
<emu-alg>
1. Return ? EvaluateAsyncConciseBody of |AsyncConciseBody| with arguments _functionObject_ and _argumentsList_.
</emu-alg>
<emu-grammar>
Initializer :
`=` AssignmentExpression
</emu-grammar>
<emu-alg>
1. Assert: _argumentsList_ is empty.
1. Assert: _functionObject_.[[ClassFieldInitializerName]] is not ~empty~.
1. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true*, then
1. Let _value_ be NamedEvaluation of |Initializer| with argument _functionObject_.[[ClassFieldInitializerName]].
1. Else,
1. Let _rhs_ be the result of evaluating |AssignmentExpression|.
1. Let _value_ be ? GetValue(_rhs_).
1. Return Completion { [[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~ }.
</emu-alg>
<emu-note>
<p>Even though field initializers constitute a function boundary, calling FunctionDeclarationInstantiation does not have any observable effect and so is omitted.</p>
</emu-note>
<ins class="block">
<emu-grammar>
ClassStaticBlockBody : ClassStaticBlockStatementList
</emu-grammar>
<emu-alg>
1. Assert: _argumentsList_ is empty.
1. Return ? EvaluateClassStaticBlockBody of |ClassStaticBlockBody| with argument _functionObject_.
</emu-alg>
</ins>
</emu-clause>
2 changes: 1 addition & 1 deletion spec/sec-static-semantics-contains-patch.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h1>Static Semantics: Contains</h1>
</emu-note>

<ins class="block">
<emu-grammar>ClassStaticBlock: `static` `{` ClassStaticBlockBody `}`</emu-grammar>
<emu-grammar>ClassStaticBlock : `static` `{` ClassStaticBlockBody `}`</emu-grammar>
<emu-alg>
1. Return *false*.
</emu-alg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ <h1>Static Semantics: ContainsDuplicateLabels</h1>
1. Return *false*.
</emu-alg>
<ins class="block">
<emu-grammar>ClassStaticBlockStatementList: [empty]</emu-grammar>
<emu-grammar>ClassStaticBlockStatementList : [empty]</emu-grammar>
<emu-alg>
1. Return *false*.
</emu-alg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ <h1>Static Semantics: ContainsUndefinedBreakTarget</h1>
1. Return *false*.
</emu-alg>
<ins class="block">
<emu-grammar>ClassStaticBlockStatementList: [empty]</emu-grammar>
<emu-grammar>ClassStaticBlockStatementList : [empty]</emu-grammar>
<emu-alg>
1. Return *false*.
</emu-alg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ <h1>Static Semantics: ContainsUndefinedContinueTarget</h1>
1. Return *false*.
</emu-alg>
<ins class="block">
<emu-grammar>ClassStaticBlockStatementList: [empty]</emu-grammar>
<emu-grammar>ClassStaticBlockStatementList : [empty]</emu-grammar>
<emu-alg>
1. Return *false*.
</emu-alg>
Expand Down
4 changes: 2 additions & 2 deletions spec/sec-static-semantics-lexicallydeclarednames-patch.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ <h1>Static Semantics: LexicallyDeclaredNames</h1>
1. Return TopLevelLexicallyDeclaredNames of |StatementList|.
</emu-alg>
<ins class="block">
<emu-grammar>ClassStaticBlockStatementList: [empty]</emu-grammar>
<emu-grammar>ClassStaticBlockStatementList : [empty]</emu-grammar>
<emu-alg>
1. Return a new empty List.
</emu-alg>
<emu-grammar>ClassStaticBlockStatementList: StatementList</emu-grammar>
<emu-grammar>ClassStaticBlockStatementList : StatementList</emu-grammar>
<emu-alg>
1. Return the TopLevelLexicallyDeclaredNames of |StatementList|.
</emu-alg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ <h1>Static Semantics: LexicallyScopedDeclarations</h1>
1. Return the TopLevelLexicallyScopedDeclarations of |StatementList|.
</emu-alg>
<ins class="block">
<emu-grammar>ClassStaticBlockStatementList: [empty]</emu-grammar>
<emu-grammar>ClassStaticBlockStatementList : [empty]</emu-grammar>
<emu-alg>
1. Return a new empty List.
</emu-alg>
<emu-grammar>ClassStaticBlockStatementList: StatementList</emu-grammar>
<emu-grammar>ClassStaticBlockStatementList : StatementList</emu-grammar>
<emu-alg>
1. Return the TopLevelLexicallyScopedDeclarations of |StatementList|.
</emu-alg>
Expand Down
4 changes: 2 additions & 2 deletions spec/sec-static-semantics-vardeclarednames-patch.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ <h1>Static Semantics: VarDeclaredNames</h1>
1. Return TopLevelVarDeclaredNames of |StatementList|.
</emu-alg>
<ins class="block">
<emu-grammar>ClassStaticBlockStatementList: [empty]</emu-grammar>
<emu-grammar>ClassStaticBlockStatementList : [empty]</emu-grammar>
<emu-alg>
1. Return a new empty List.
</emu-alg>
<emu-grammar>ClassStaticBlockStatementList: StatementList</emu-grammar>
<emu-grammar>ClassStaticBlockStatementList : StatementList</emu-grammar>
<emu-alg>
1. Return the TopLevelVarDeclaredNames of |StatementList|.
</emu-alg>
Expand Down
Loading

0 comments on commit ae15dde

Please sign in to comment.