Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require decorators before 'export' keyword #95

Merged
merged 3 commits into from
May 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "SEE LICENSE IN https://tc39.github.io/ecma262/#sec-copyright-and-software-license",
"homepage": "https://tc39.github.io/proposal-decorators/",
"dependencies": {
"ecmarkup": "^3.12.0"
"ecmarkup": "^3.14.0"
},
"devDependencies": {
"@alrra/travis-scripts": "^3.0.0"
Expand Down
68 changes: 52 additions & 16 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,26 @@ <h1>New Productions</h1>
<h1>Updated Productions</h1>

<emu-grammar>
StatementListItem[Yield, Await, Return] :
Statement[?Yield, ?Await, ?Return]
Declaration[?Yield, ?Await, <ins>+Decorators</ins>]

Declaration[Yield, Await, <ins>Decorators</ins>] :
HoistableDeclaration[?Yield, ?Await, ~Default]
ClassDeclaration[?Yield, ?Await, ~Default, <ins>?Decorators</ins>]
LexicalDeclaration[+In, ?Yield, ?Await]

ClassElement[Yield, Await] :
<ins>DecoratorList[?Yield, ?Await]?</ins> MethodDefinition[?Yield, ?Await]
<ins>DecoratorList[?Yield, ?Await]?</ins> `static` MethodDefinition[?Yield, ?Await]
<ins>DecoratorList[?Yield, ?Await]?</ins> FieldDefinition[?Yield, ?Await] `;`
<ins>DecoratorList[?Yield, ?Await]?</ins> `static` FieldDefinition[?Yield, ?Await] `;`

ClassDeclaration[Yield, Await, Default] :
<ins>DecoratorList[?Yield, ?Await]?</ins> `class` BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await]
[+Default] <ins>DecoratorList[?Yield, ?Await]?</ins> `class` ClassTail[?Yield, ?Await]
ClassDeclaration[Yield, Await, Default, <ins>Decorators</ins>] :
`class` BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await]
[+Default] `class` ClassTail[?Yield, ?Await]
<ins>[+Decorators] DecoratorList[?Yield, ?Await] `class` BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await]</ins>
<ins>[+Decorators, +Default] DecoratorList[?Yield, ?Await] `class` ClassTail[?Yield, ?Await]</ins>

ClassExpression[Yield, Await] :
<ins>DecoratorList[?Yield, ?Await]?</ins> `class` BindingIdentifier[?Yield, ?Await]? ClassTail[?Yield, ?Await]
Expand All @@ -130,10 +141,11 @@ <h1>Updated Productions</h1>
`export` ExportClause FromClause `;`
`export` ExportClause `;`
`export` VariableStatement[~Yield, ~Await]
`export` Declaration[~Yield, ~Await]
`export` Declaration[~Yield, ~Await, <ins>~Decorators</ins>]
`export` `default` HoistableDeclaration[~Yield, ~Await, +Default]
`export` `default` ClassDeclaration[~Yield, ~Await, +Default]
`export` `default` [lookahead &lt;! {`function`, `async` [no |LineTerminator| here] `function`, `class`, <ins>`@`</ins>}] AssignmentExpression[+In, ~Yield, ~Await] `;`
<ins>DecoratorList[~Yield, ~Await]</ins> `export` ClassDeclaration[~Yield, ~Await, ~Default, <ins>~Decorators</ins>]
<ins>DecoratorList[~Yield, ~Await]</ins> `export` `default` ClassDeclaration[~Yield, ~Await, +Default, <ins>~Decorators</ins>]
</emu-grammar>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -194,10 +206,10 @@ <h1>The ElementDescriptor Specification Type</h1>
</emu-clause>
</emu-clause>

<emu-clause id="sec-internal-algorithms">
<emu-clause id="sec-internal-class-algorithms">
<h1>Modified class algorithms</h1>

<emu-clause id="runtime-semantics-class-definition-evaluation">
<emu-clause id="runtime-semantics-class-definition-evaluation" aoid="ClassDefinitionEvaluation">
<h1>Runtime Semantics: ClassDefinitionEvaluation</h1>
<p>With parameters _className_ and _decorators_.</p>
<emu-grammar>ClassTail : ClassHeritage? `{` ClassBody? `}`</emu-grammar>
Expand Down Expand Up @@ -316,25 +328,22 @@ <h1>Runtime Semantics: ClassElementEvaluation</h1>
</emu-clause>

<!-- es6num="14.5.15" -->
<emu-clause id="sec-runtime-semantics-bindingclassdeclarationevaluation">
<emu-clause id="sec-runtime-semantics-bindingclassdeclarationevaluation" aoid="BindingClassDeclarationEvaluation">
<h1>Runtime Semantics: BindingClassDeclarationEvaluation</h1>
<p>With parameter _decorators_.</p>
<emu-grammar>ClassDeclaration : <ins>DecoratorList?</ins> `class` BindingIdentifier ClassTail</emu-grammar>
<emu-alg>
1. <ins>If |DecoratorList_opt| is present, let _decorators_ be the result of performing DecoratorListEvaluation of |DecoratorList|.</ins>
1. <ins>Otherwise, let _decorators_ be a new empty List.</ins>
1. Let _className_ be StringValue of |BindingIdentifier|.
1. Let _value_ be the result of ClassDefinitionEvaluation of |ClassTail| with arguments _className_<ins> and _decorators</ins>.
1. Let _value_ be the result of ClassDefinitionEvaluation of |ClassTail| with arguments _className_ <ins>and _decorators_</ins>.
1. ReturnIfAbrupt(_value_).
1. Let _hasNameProperty_ be ? HasOwnProperty(_value_, `"name"`).
1. If _hasNameProperty_ is *false*, perform SetFunctionName(_value_, _className_).
1. Let _env_ be the running execution context's LexicalEnvironment.
1. Perform ? InitializeBoundName(_className_, _value_, _env_).
1. Return _value_.
</emu-alg>
<emu-grammar>ClassDeclaration : <ins>DecoratorList?</ins> `class` ClassTail</emu-grammar>
<emu-grammar>ClassDeclaration : `class` ClassTail</emu-grammar>
<emu-alg>
1. <ins>If |DecoratorList| is present, let _decorators_ be the result of performing DecoratorListEvaluation of |DecoratorList|.</ins>
1. <ins>Otherwise, let _decorators_ be a new empty List.</ins>
1. Return the result of ClassDefinitionEvaluation of |ClassTail| with arguments *undefined* <ins>and _decorators_</ins>.
</emu-alg>
<emu-note>
Expand All @@ -347,15 +356,17 @@ <h1>Runtime Semantics: BindingClassDeclarationEvaluation</h1>
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>ClassDeclaration : <ins>DecoratorList?</ins> `class` BindingIdentifier ClassTail</emu-grammar>
<emu-alg>
1. Perform ? BindingClassDeclarationEvaluation of this |ClassDeclaration|.
1. <ins>If |DecoratorList_opt| is present, let _decorators_ be the result of DecoratorListEvaluation of |DecoratorList|.</ins>
1. <ins>Otherwise, let _decorators_ be a new empty List.</ins>
1. Perform ? BindingClassDeclarationEvaluation of this |ClassDeclaration| with argument _decorators_.
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 : <ins>DecoratorList?</ins> `class` BindingIdentifier? ClassTail</emu-grammar>
<emu-alg>
1. <ins>If |DecoratorList_opt| is present, let _decorators_ be the result of performing DecoratorListEvaluation of |DecoratorList|.</ins>
1. <ins>If |DecoratorList_opt| is present, let _decorators_ be the result of DecoratorListEvaluation of |DecoratorList|.</ins>
1. <ins>Otherwise, let _decorators_ be a new empty List.</ins>
1. If |BindingIdentifier_opt| is not present, let _className_ be *undefined*.
1. Else, let _className_ be StringValue of |BindingIdentifier|.
Expand Down Expand Up @@ -410,6 +421,31 @@ <h1>CoalesceClassElements ( _elements_ )</h1>

</emu-clause>

<emu-clause id="sec-internal-exports-algorithms">
<h1>Modified Exports algorithms</h1>
<emu-clause id="sec-exports-runtime-semantics-evaluation">
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>ExportDeclaration: DecoratorList `export` ClassDeclaration</emu-grammar>
<emu-alg>
1. <ins>Let _decorators_ be the result of DecoratorListEvaluation of |DecoratorList|.</ins>
1. Perform ? BindingClassDeclarationEvaluation of |ClassDeclaration| <ins>with parameter _decorators_.</ins>
1. Return NormalCompletion(~empty~).
</emu-alg>
<emu-grammar>ExportDeclaration: DecoratorList? `export` `default` ClassDeclaration</emu-grammar>
<emu-alg>
1. <ins>Let _decorators_ be the result of DecoratorListEvaluation of |DecoratorList_opt|.</ins>
1. Let _value_ be the result of BindingClassDeclarationEvaluation of |ClassDeclaration| <ins>with parameter _decorators_.</ins>
1. ReturnIfAbrupt(_value_)
1. Let _className_ be the sole element of BoundNames of |ClassDeclaration|.
1. If _className_ is `"*default*"`, then
1. Let _hasNameProperty_ be ? HasOwnProperty(_value_, `"name"`).
1. If _hasNameProperty_ is *false*, perform SetFunctionName(_value_, `"default"`).
1. Let _env_ be the running execution context's LexicalEnvironment.
1. Perform ? InitializeBoundName(`"*default*"`, _value_, _env_).
1. Return NormalCompletion(~empty~).
</emu-alg>
</emu-clause>
</emu-clause>

</emu-clause>

Expand Down