Class Fields: Updating frontmatter

This commit is contained in:
Rick Waldron 2018-07-30 17:15:03 -04:00 committed by Leo Balter
parent 5d014bdfba
commit 90e8859cdd
33 changed files with 145 additions and 195 deletions

View File

@ -19,8 +19,8 @@ info: |
2. Assert: Assert constructor is an ECMAScript function object.
3. Let fieldRecords be the value of constructor's [[Fields]] internal slot.
4. For each item fieldRecord in order from fieldRecords,
a. If fieldRecord.[[static]] is false, then
i. Perform ? DefineField(O, fieldRecord).
a. Perform ? DefineField(O, fieldRecord).
5. Return.
DefineField(receiver, fieldRecord)
...
@ -32,6 +32,7 @@ info: |
2. If O is not an object, throw a TypeError exception.
3. Let entry be PrivateFieldFind(P, O).
4. If entry is not empty, throw a TypeError exception.
...
features: [class, class-fields-private]
---*/

View File

@ -8,12 +8,12 @@ info: |
GetValue ( V )
...
5. If IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
PrivateFieldGet (P, O )
1. Assert: P is a Private Name value.

View File

@ -8,12 +8,12 @@ info: |
GetValue ( V )
...
5. If IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
PrivateFieldGet (P, O )
1. Assert: P is a Private Name value.

View File

@ -8,12 +8,12 @@ info: |
GetValue ( V )
...
5. If IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
PrivateFieldGet (P, O )
1. Assert: P is a Private Name value.

View File

@ -8,12 +8,12 @@ info: |
GetValue ( V )
...
5. If IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
PrivateFieldGet (P, O )
1. Assert: P is a Private Name value.

View File

@ -8,12 +8,12 @@ info: |
GetValue ( V )
...
5. If IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
PrivateFieldGet (P, O )
1. Assert: P is a Private Name value.

View File

@ -8,12 +8,12 @@ info: |
GetValue ( V )
...
5. If IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
PrivateFieldGet (P, O )
1. Assert: P is a Private Name value.

View File

@ -8,12 +8,12 @@ info: |
GetValue ( V )
...
5. If IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
PrivateFieldGet (P, O )
1. Assert: P is a Private Name value.

View File

@ -9,12 +9,12 @@ info: |
GetValue ( V )
...
5. If IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.
ii. Let field be ? ResolveBinding(GetReferencedName(V), env).
iii. Assert: field is a Private Name.
iv. Return ? PrivateFieldGet(field, base).
PrivateFieldGet (P, O )
1. Assert: P is a Private Name value.

View File

@ -7,7 +7,7 @@ esid: sec-putvalue
info: |
PutValue ( V, W )
...
5. Else if IsPropertyReference(V), then
6. Else if IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.

View File

@ -7,7 +7,7 @@ esid: sec-putvalue
info: |
PutValue ( V, W )
...
5. Else if IsPropertyReference(V), then
6. Else if IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.

View File

@ -8,7 +8,7 @@ esid: sec-putvalue
info: |
PutValue ( V, W )
...
5. Else if IsPropertyReference(V), then
6. Else if IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.

View File

@ -7,7 +7,7 @@ esid: sec-putvalue
info: |
PutValue ( V, W )
...
5. Else if IsPropertyReference(V), then
6. Else if IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.

View File

@ -7,7 +7,7 @@ esid: sec-putvalue
info: |
PutValue ( V, W )
...
5. Else if IsPropertyReference(V), then
6. Else if IsPropertyReference(V), then
...
b. If IsPrivateReference(V), then
i. Let env be the running execution context's PrivateNameEnvironment.

View File

@ -5,10 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename in constructor without being declared in class fields
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
...
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private]
negative:
phase: parse

View File

@ -5,10 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename in function in class without declaring in field
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
...
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private]
negative:
phase: parse

View File

@ -5,10 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename that has not been declared in class.
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
...
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private, class-fields-public]
negative:
phase: parse

View File

@ -5,10 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename that has not been declared in class.
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
...
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private]
negative:
phase: parse

View File

@ -5,10 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename outside of class
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
...
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private]
negative:
phase: parse

View File

@ -5,10 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename outside of class.
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
...
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private]
negative:
phase: parse

View File

@ -5,10 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename on object, outside of class.
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
...
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class-fields-private]
negative:
phase: parse

View File

@ -5,10 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename on object, outside of class.
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
...
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class-fields-private]
negative:
phase: parse

View File

@ -5,15 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename in constructor without being declared in class fields
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
2. If Script is parsed directly from PerformEval,
a. Let env be the running execution context's PrivateNameEnvironment.
b. Repeat while env is not null,
i. For each binding named N in env,
1. If names does not contain N, append N to names.
ii. Let env be env's outer environment reference.
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private]
---*/

View File

@ -5,15 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename in function in class without declaring in field
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
2. If Script is parsed directly from PerformEval,
a. Let env be the running execution context's PrivateNameEnvironment.
b. Repeat while env is not null,
i. For each binding named N in env,
1. If names does not contain N, append N to names.
ii. Let env be env's outer environment reference.
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private]
---*/

View File

@ -5,15 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename that has not been declared in class.
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
2. If Script is parsed directly from PerformEval,
a. Let env be the running execution context's PrivateNameEnvironment.
b. Repeat while env is not null,
i. For each binding named N in env,
1. If names does not contain N, append N to names.
ii. Let env be env's outer environment reference.
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private, class-fields-public]
---*/

View File

@ -5,15 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename that has not been declared in class.
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
2. If Script is parsed directly from PerformEval,
a. Let env be the running execution context's PrivateNameEnvironment.
b. Repeat while env is not null,
i. For each binding named N in env,
1. If names does not contain N, append N to names.
ii. Let env be env's outer environment reference.
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private]
---*/

View File

@ -5,15 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename outside of class
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
2. If Script is parsed directly from PerformEval,
a. Let env be the running execution context's PrivateNameEnvironment.
b. Repeat while env is not null,
i. For each binding named N in env,
1. If names does not contain N, append N to names.
ii. Let env be env's outer environment reference.
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private]
---*/

View File

@ -5,15 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename outside of class.
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
2. If Script is parsed directly from PerformEval,
a. Let env be the running execution context's PrivateNameEnvironment.
b. Repeat while env is not null,
i. For each binding named N in env,
1. If names does not contain N, append N to names.
ii. Let env be env's outer environment reference.
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class, class-fields-private]
---*/

View File

@ -5,9 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename on object, outside of class.
info: |
Static Semantics: Early Errors
1. Let names be an empty List.
...
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class-fields-private]
---*/

View File

@ -5,9 +5,10 @@ esid: sec-scripts-static-semantics-early-errors
description: Early error when referencing privatename on object, outside of class.
info: |
Static Semantics: Early Errors
1. Let names be an empty List.
...
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
ScriptBody : StatementList
It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List as an argument is false unless the source code is eval code that is being processed by a direct eval.
features: [class-fields-private]
---*/

View File

@ -1,16 +1,11 @@
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-scripts-static-semantics-early-errors
esid: sec-all-private-names-valid
description: Referencing privatename in class within class does not error.
info: |
Static Semantics: Early Errors
Script : ScriptBody
1. Let names be an empty List.
...
3. If AllPrivateNamesValid of ScriptBody with the argument names is false, throw a SyntaxError exception.
Static Semantics: AllPrivateNamesValid
AllPrivateNamesValid is an abstract operation which takes names as an argument.
MemberExpression : MemberExpression . PrivateName
@ -21,9 +16,9 @@ info: |
1. If StringValue of PrivateName is in names, return true.
2. Return false.
ClassBody:ClassElementList
ClassBody : ClassElementList
1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody.
2.Return AllPrivateNamesValid of ClassElementList with the argument newNames.
2. Return AllPrivateNamesValid of ClassElementList with the argument newNames.
For all other grammatical productions, recurse on subexpressions/substatements, passing in the names of the caller. If all pieces return true, then return true. If any returns false, return false.

View File

@ -9,26 +9,17 @@ info: |
...
27. For each ClassElement e in order from elements
a. If IsStatic of e is false, then
i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
i. Let fields be the result of performing ClassElementEvaluation
for e with arguments proto and false.
b. Else,
i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
i. Let fields be the result of performing ClassElementEvaluation
for e with arguments F and false.
c. If fields is an abrupt completion, then
i. Set the running execution context's LexicalEnvironment to lex.
ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
iii. Return Completion(status).
i. Set the running execution context's LexicalEnvironment to lex.
ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
iii. Return Completion(status).
Runtime Semantics: ClassElementEvaluation
...
ClassElement : static FieldDefinition ;
1. Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
Runtime Semantics: ClassFieldDefinitionEvaluation
With parameters isStatic and homeObject.
FieldDefinition : ClassElementNameInitializer
1. Let fieldName be the result of evaluating ClassElementName.
2. ReturnIfAbrupt(fieldName).
features: [class-fields]
features: [class-static-fields-public]
---*/
function f() {

View File

@ -7,28 +7,19 @@ esid: runtime-semantics-class-definition-evaluation
info: |
Runtime Semantics: ClassDefinitionEvaluation
...
33. Let result be InitializeStaticFields(F).
34. If result is an abrupt completion, then
a. Set the running execution context's LexicalEnvironment to lex.
b. Return Completion(result).
27. For each ClassElement e in order from elements
a. If IsStatic of e is false, then
i. Let fields be the result of performing ClassElementEvaluation
for e with arguments proto and false.
b. Else,
i. Let fields be the result of performing ClassElementEvaluation
for e with arguments F and false.
c. If fields is an abrupt completion, then
i. Set the running execution context's LexicalEnvironment to lex.
ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
iii. Return Completion(status).
InitializeStaticFields(F)
1. Assert: Type(F) is Object.
2. Assert: F is an ECMAScript function object.
3. Let fieldRecords be the value of F's [[Fields]] internal slot.
4. For each item fieldRecord in order from fieldRecords,
a. If fieldRecord.[[static]] is true, then
i. Perform ? DefineField(F, fieldRecord).
DefineField(receiver, fieldRecord)
1. Assert: Type(receiver) is Object.
2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation.
3. Let fieldName be fieldRecord.[[Name]].
4. Let initializer be fieldRecord.[[Initializer]].
5. If initializer is not empty, then
a. Let initValue be ? Call(initializer, receiver).
features: [class-fields]
features: [class-static-fields-public]
---*/
function f() {
@ -39,4 +30,4 @@ assert.throws(Test262Error, function() {
class C {
static x = f();
}
})
});