Rename fields to names or members
Rename variables and flag names so that the classes can be reused by private methods implementation. In particular: Rename "fields" to "members" in the initializer so that we can initialize both fields and private methods/accessors there, for example: instance_fields_initializer -> instance_members_initializer InitializeClassFieldsStatement -> InitializeClassMembersStatement Rename "private field" to "private name" for the private symbols used to implement private fields so that we can use them to store private methods/accessors later as well, for example: private_field_name_var -> private_name_var NewPrivateFieldSymbol -> NewPrivateNameSymbol The follow-on is in https://chromium-review.googlesource.com/c/v8/v8/+/1301018 The design doc is in https://docs.google.com/document/d/1T-Ql6HOIH2U_8YjWkwK2rTfywwb7b3Qe8d3jkz72KwA/edit?usp=sharing Bug: v8:8330 Change-Id: I1cdca8def711da879b6e4d67c5ff0a5a4a36abbe Reviewed-on: https://chromium-review.googlesource.com/c/1312597 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Reviewed-by: Adam Klein <adamk@chromium.org> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Joyee Cheung <joyee@igalia.com> Cr-Commit-Position: refs/heads/master@{#57289}
This commit is contained in:
parent
e42abbfebe
commit
6c3d784c16
@ -484,8 +484,8 @@ void AstTraversalVisitor<Subclass>::VisitClassLiteral(ClassLiteral* expr) {
|
|||||||
if (expr->static_fields_initializer() != nullptr) {
|
if (expr->static_fields_initializer() != nullptr) {
|
||||||
RECURSE_EXPRESSION(Visit(expr->static_fields_initializer()));
|
RECURSE_EXPRESSION(Visit(expr->static_fields_initializer()));
|
||||||
}
|
}
|
||||||
if (expr->instance_fields_initializer_function() != nullptr) {
|
if (expr->instance_members_initializer_function() != nullptr) {
|
||||||
RECURSE_EXPRESSION(Visit(expr->instance_fields_initializer_function()));
|
RECURSE_EXPRESSION(Visit(expr->instance_members_initializer_function()));
|
||||||
}
|
}
|
||||||
ZonePtrList<ClassLiteral::Property>* props = expr->properties();
|
ZonePtrList<ClassLiteral::Property>* props = expr->properties();
|
||||||
for (int i = 0; i < props->length(); ++i) {
|
for (int i = 0; i < props->length(); ++i) {
|
||||||
@ -498,8 +498,8 @@ void AstTraversalVisitor<Subclass>::VisitClassLiteral(ClassLiteral* expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class Subclass>
|
template <class Subclass>
|
||||||
void AstTraversalVisitor<Subclass>::VisitInitializeClassFieldsStatement(
|
void AstTraversalVisitor<Subclass>::VisitInitializeClassMembersStatement(
|
||||||
InitializeClassFieldsStatement* stmt) {
|
InitializeClassMembersStatement* stmt) {
|
||||||
PROCESS_NODE(stmt);
|
PROCESS_NODE(stmt);
|
||||||
ZonePtrList<ClassLiteral::Property>* props = stmt->fields();
|
ZonePtrList<ClassLiteral::Property>* props = stmt->fields();
|
||||||
for (int i = 0; i < props->length(); ++i) {
|
for (int i = 0; i < props->length(); ++i) {
|
||||||
|
@ -65,7 +65,7 @@ namespace internal {
|
|||||||
V(TryCatchStatement) \
|
V(TryCatchStatement) \
|
||||||
V(TryFinallyStatement) \
|
V(TryFinallyStatement) \
|
||||||
V(DebuggerStatement) \
|
V(DebuggerStatement) \
|
||||||
V(InitializeClassFieldsStatement)
|
V(InitializeClassMembersStatement)
|
||||||
|
|
||||||
#define LITERAL_NODE_LIST(V) \
|
#define LITERAL_NODE_LIST(V) \
|
||||||
V(RegExpLiteral) \
|
V(RegExpLiteral) \
|
||||||
@ -1598,9 +1598,9 @@ class VariableProxy final : public Expression {
|
|||||||
HoleCheckModeField::update(bit_field_, HoleCheckMode::kRequired);
|
HoleCheckModeField::update(bit_field_, HoleCheckMode::kRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_private_field() const { return IsPrivateField::decode(bit_field_); }
|
bool is_private_name() const { return IsPrivateName::decode(bit_field_); }
|
||||||
void set_is_private_field() {
|
void set_is_private_name() {
|
||||||
bit_field_ = IsPrivateField::update(bit_field_, true);
|
bit_field_ = IsPrivateName::update(bit_field_, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind this proxy to the variable var.
|
// Bind this proxy to the variable var.
|
||||||
@ -1631,7 +1631,7 @@ class VariableProxy final : public Expression {
|
|||||||
IsAssignedField::encode(false) |
|
IsAssignedField::encode(false) |
|
||||||
IsResolvedField::encode(false) |
|
IsResolvedField::encode(false) |
|
||||||
HoleCheckModeField::encode(HoleCheckMode::kElided) |
|
HoleCheckModeField::encode(HoleCheckMode::kElided) |
|
||||||
IsPrivateField::encode(false);
|
IsPrivateName::encode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit VariableProxy(const VariableProxy* copy_from);
|
explicit VariableProxy(const VariableProxy* copy_from);
|
||||||
@ -1643,7 +1643,7 @@ class VariableProxy final : public Expression {
|
|||||||
class IsNewTargetField : public BitField<bool, IsResolvedField::kNext, 1> {};
|
class IsNewTargetField : public BitField<bool, IsResolvedField::kNext, 1> {};
|
||||||
class HoleCheckModeField
|
class HoleCheckModeField
|
||||||
: public BitField<HoleCheckMode, IsNewTargetField::kNext, 1> {};
|
: public BitField<HoleCheckMode, IsNewTargetField::kNext, 1> {};
|
||||||
class IsPrivateField : public BitField<bool, HoleCheckModeField::kNext, 1> {};
|
class IsPrivateName : public BitField<bool, HoleCheckModeField::kNext, 1> {};
|
||||||
|
|
||||||
union {
|
union {
|
||||||
const AstRawString* raw_name_; // if !is_resolved_
|
const AstRawString* raw_name_; // if !is_resolved_
|
||||||
@ -2401,11 +2401,11 @@ class FunctionLiteral final : public Expression {
|
|||||||
function_literal_id_ = function_literal_id;
|
function_literal_id_ = function_literal_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_requires_instance_fields_initializer(bool value) {
|
void set_requires_instance_members_initializer(bool value) {
|
||||||
bit_field_ = RequiresInstanceFieldsInitializer::update(bit_field_, value);
|
bit_field_ = RequiresInstanceMembersInitializer::update(bit_field_, value);
|
||||||
}
|
}
|
||||||
bool requires_instance_fields_initializer() const {
|
bool requires_instance_members_initializer() const {
|
||||||
return RequiresInstanceFieldsInitializer::decode(bit_field_);
|
return RequiresInstanceMembersInitializer::decode(bit_field_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProducedPreParsedScopeData* produced_preparsed_scope_data() const {
|
ProducedPreParsedScopeData* produced_preparsed_scope_data() const {
|
||||||
@ -2440,7 +2440,7 @@ class FunctionLiteral final : public Expression {
|
|||||||
HasDuplicateParameters::encode(has_duplicate_parameters ==
|
HasDuplicateParameters::encode(has_duplicate_parameters ==
|
||||||
kHasDuplicateParameters) |
|
kHasDuplicateParameters) |
|
||||||
DontOptimizeReasonField::encode(BailoutReason::kNoReason) |
|
DontOptimizeReasonField::encode(BailoutReason::kNoReason) |
|
||||||
RequiresInstanceFieldsInitializer::encode(false) |
|
RequiresInstanceMembersInitializer::encode(false) |
|
||||||
HasBracesField::encode(has_braces) | IIFEBit::encode(false);
|
HasBracesField::encode(has_braces) | IIFEBit::encode(false);
|
||||||
if (eager_compile_hint == kShouldEagerCompile) SetShouldEagerCompile();
|
if (eager_compile_hint == kShouldEagerCompile) SetShouldEagerCompile();
|
||||||
body.CopyTo(&body_, zone);
|
body.CopyTo(&body_, zone);
|
||||||
@ -2452,10 +2452,10 @@ class FunctionLiteral final : public Expression {
|
|||||||
class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {};
|
class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {};
|
||||||
class DontOptimizeReasonField
|
class DontOptimizeReasonField
|
||||||
: public BitField<BailoutReason, HasDuplicateParameters::kNext, 8> {};
|
: public BitField<BailoutReason, HasDuplicateParameters::kNext, 8> {};
|
||||||
class RequiresInstanceFieldsInitializer
|
class RequiresInstanceMembersInitializer
|
||||||
: public BitField<bool, DontOptimizeReasonField::kNext, 1> {};
|
: public BitField<bool, DontOptimizeReasonField::kNext, 1> {};
|
||||||
class HasBracesField
|
class HasBracesField
|
||||||
: public BitField<bool, RequiresInstanceFieldsInitializer::kNext, 1> {};
|
: public BitField<bool, RequiresInstanceMembersInitializer::kNext, 1> {};
|
||||||
class IIFEBit : public BitField<bool, HasBracesField::kNext, 1> {};
|
class IIFEBit : public BitField<bool, HasBracesField::kNext, 1> {};
|
||||||
|
|
||||||
int expected_property_count_;
|
int expected_property_count_;
|
||||||
@ -2497,12 +2497,12 @@ class ClassLiteralProperty final : public LiteralProperty {
|
|||||||
return private_or_computed_name_var_;
|
return private_or_computed_name_var_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_private_field_name_var(Variable* var) {
|
void set_private_name_var(Variable* var) {
|
||||||
DCHECK_EQ(FIELD, kind());
|
DCHECK_EQ(FIELD, kind());
|
||||||
DCHECK(is_private());
|
DCHECK(is_private());
|
||||||
private_or_computed_name_var_ = var;
|
private_or_computed_name_var_ = var;
|
||||||
}
|
}
|
||||||
Variable* private_field_name_var() const {
|
Variable* private_name_var() const {
|
||||||
DCHECK_EQ(FIELD, kind());
|
DCHECK_EQ(FIELD, kind());
|
||||||
DCHECK(is_private());
|
DCHECK(is_private());
|
||||||
return private_or_computed_name_var_;
|
return private_or_computed_name_var_;
|
||||||
@ -2520,7 +2520,7 @@ class ClassLiteralProperty final : public LiteralProperty {
|
|||||||
Variable* private_or_computed_name_var_;
|
Variable* private_or_computed_name_var_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class InitializeClassFieldsStatement final : public Statement {
|
class InitializeClassMembersStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
typedef ClassLiteralProperty Property;
|
typedef ClassLiteralProperty Property;
|
||||||
|
|
||||||
@ -2529,8 +2529,8 @@ class InitializeClassFieldsStatement final : public Statement {
|
|||||||
private:
|
private:
|
||||||
friend class AstNodeFactory;
|
friend class AstNodeFactory;
|
||||||
|
|
||||||
InitializeClassFieldsStatement(ZonePtrList<Property>* fields, int pos)
|
InitializeClassMembersStatement(ZonePtrList<Property>* fields, int pos)
|
||||||
: Statement(pos, kInitializeClassFieldsStatement), fields_(fields) {}
|
: Statement(pos, kInitializeClassMembersStatement), fields_(fields) {}
|
||||||
|
|
||||||
ZonePtrList<Property>* fields_;
|
ZonePtrList<Property>* fields_;
|
||||||
};
|
};
|
||||||
@ -2564,8 +2564,8 @@ class ClassLiteral final : public Expression {
|
|||||||
return static_fields_initializer_;
|
return static_fields_initializer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionLiteral* instance_fields_initializer_function() const {
|
FunctionLiteral* instance_members_initializer_function() const {
|
||||||
return instance_fields_initializer_function_;
|
return instance_members_initializer_function_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -2574,7 +2574,7 @@ class ClassLiteral final : public Expression {
|
|||||||
ClassLiteral(Scope* scope, Variable* class_variable, Expression* extends,
|
ClassLiteral(Scope* scope, Variable* class_variable, Expression* extends,
|
||||||
FunctionLiteral* constructor, ZonePtrList<Property>* properties,
|
FunctionLiteral* constructor, ZonePtrList<Property>* properties,
|
||||||
FunctionLiteral* static_fields_initializer,
|
FunctionLiteral* static_fields_initializer,
|
||||||
FunctionLiteral* instance_fields_initializer_function,
|
FunctionLiteral* instance_members_initializer_function,
|
||||||
int start_position, int end_position,
|
int start_position, int end_position,
|
||||||
bool has_name_static_property, bool has_static_computed_names,
|
bool has_name_static_property, bool has_static_computed_names,
|
||||||
bool is_anonymous)
|
bool is_anonymous)
|
||||||
@ -2586,8 +2586,8 @@ class ClassLiteral final : public Expression {
|
|||||||
constructor_(constructor),
|
constructor_(constructor),
|
||||||
properties_(properties),
|
properties_(properties),
|
||||||
static_fields_initializer_(static_fields_initializer),
|
static_fields_initializer_(static_fields_initializer),
|
||||||
instance_fields_initializer_function_(
|
instance_members_initializer_function_(
|
||||||
instance_fields_initializer_function) {
|
instance_members_initializer_function) {
|
||||||
bit_field_ |= HasNameStaticProperty::encode(has_name_static_property) |
|
bit_field_ |= HasNameStaticProperty::encode(has_name_static_property) |
|
||||||
HasStaticComputedNames::encode(has_static_computed_names) |
|
HasStaticComputedNames::encode(has_static_computed_names) |
|
||||||
IsAnonymousExpression::encode(is_anonymous);
|
IsAnonymousExpression::encode(is_anonymous);
|
||||||
@ -2600,7 +2600,7 @@ class ClassLiteral final : public Expression {
|
|||||||
FunctionLiteral* constructor_;
|
FunctionLiteral* constructor_;
|
||||||
ZonePtrList<Property>* properties_;
|
ZonePtrList<Property>* properties_;
|
||||||
FunctionLiteral* static_fields_initializer_;
|
FunctionLiteral* static_fields_initializer_;
|
||||||
FunctionLiteral* instance_fields_initializer_function_;
|
FunctionLiteral* instance_members_initializer_function_;
|
||||||
class HasNameStaticProperty
|
class HasNameStaticProperty
|
||||||
: public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
|
: public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
|
||||||
class HasStaticComputedNames
|
class HasStaticComputedNames
|
||||||
@ -3337,12 +3337,12 @@ class AstNodeFactory final {
|
|||||||
FunctionLiteral* constructor,
|
FunctionLiteral* constructor,
|
||||||
ZonePtrList<ClassLiteral::Property>* properties,
|
ZonePtrList<ClassLiteral::Property>* properties,
|
||||||
FunctionLiteral* static_fields_initializer,
|
FunctionLiteral* static_fields_initializer,
|
||||||
FunctionLiteral* instance_fields_initializer_function, int start_position,
|
FunctionLiteral* instance_members_initializer_function,
|
||||||
int end_position, bool has_name_static_property,
|
int start_position, int end_position, bool has_name_static_property,
|
||||||
bool has_static_computed_names, bool is_anonymous) {
|
bool has_static_computed_names, bool is_anonymous) {
|
||||||
return new (zone_) ClassLiteral(
|
return new (zone_) ClassLiteral(
|
||||||
scope, variable, extends, constructor, properties,
|
scope, variable, extends, constructor, properties,
|
||||||
static_fields_initializer, instance_fields_initializer_function,
|
static_fields_initializer, instance_members_initializer_function,
|
||||||
start_position, end_position, has_name_static_property,
|
start_position, end_position, has_name_static_property,
|
||||||
has_static_computed_names, is_anonymous);
|
has_static_computed_names, is_anonymous);
|
||||||
}
|
}
|
||||||
@ -3407,9 +3407,9 @@ class AstNodeFactory final {
|
|||||||
return new (zone_) ImportCallExpression(args, pos);
|
return new (zone_) ImportCallExpression(args, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeClassFieldsStatement* NewInitializeClassFieldsStatement(
|
InitializeClassMembersStatement* NewInitializeClassMembersStatement(
|
||||||
ZonePtrList<ClassLiteral::Property>* args, int pos) {
|
ZonePtrList<ClassLiteral::Property>* args, int pos) {
|
||||||
return new (zone_) InitializeClassFieldsStatement(args, pos);
|
return new (zone_) InitializeClassMembersStatement(args, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
Zone* zone() const { return zone_; }
|
Zone* zone() const { return zone_; }
|
||||||
|
@ -205,8 +205,8 @@ void CallPrinter::VisitClassLiteral(ClassLiteral* node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallPrinter::VisitInitializeClassFieldsStatement(
|
void CallPrinter::VisitInitializeClassMembersStatement(
|
||||||
InitializeClassFieldsStatement* node) {
|
InitializeClassMembersStatement* node) {
|
||||||
for (int i = 0; i < node->fields()->length(); i++) {
|
for (int i = 0; i < node->fields()->length(); i++) {
|
||||||
Find(node->fields()->at(i)->value());
|
Find(node->fields()->at(i)->value());
|
||||||
}
|
}
|
||||||
@ -778,7 +778,7 @@ const char* AstPrinter::PrintProgram(FunctionLiteral* program) {
|
|||||||
if (program->raw_inferred_name()) {
|
if (program->raw_inferred_name()) {
|
||||||
PrintLiteralIndented("INFERRED NAME", program->raw_inferred_name(), true);
|
PrintLiteralIndented("INFERRED NAME", program->raw_inferred_name(), true);
|
||||||
}
|
}
|
||||||
if (program->requires_instance_fields_initializer()) {
|
if (program->requires_instance_members_initializer()) {
|
||||||
Print(" REQUIRES INSTANCE FIELDS INITIALIZER\n");
|
Print(" REQUIRES INSTANCE FIELDS INITIALIZER\n");
|
||||||
}
|
}
|
||||||
PrintParameters(program->scope());
|
PrintParameters(program->scope());
|
||||||
@ -1036,16 +1036,16 @@ void AstPrinter::VisitClassLiteral(ClassLiteral* node) {
|
|||||||
PrintIndentedVisit("STATIC FIELDS INITIALIZER",
|
PrintIndentedVisit("STATIC FIELDS INITIALIZER",
|
||||||
node->static_fields_initializer());
|
node->static_fields_initializer());
|
||||||
}
|
}
|
||||||
if (node->instance_fields_initializer_function() != nullptr) {
|
if (node->instance_members_initializer_function() != nullptr) {
|
||||||
PrintIndentedVisit("INSTANCE FIELDS INITIALIZER",
|
PrintIndentedVisit("INSTANCE ELEMENTS INITIALIZER",
|
||||||
node->instance_fields_initializer_function());
|
node->instance_members_initializer_function());
|
||||||
}
|
}
|
||||||
PrintClassProperties(node->properties());
|
PrintClassProperties(node->properties());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AstPrinter::VisitInitializeClassFieldsStatement(
|
void AstPrinter::VisitInitializeClassMembersStatement(
|
||||||
InitializeClassFieldsStatement* node) {
|
InitializeClassMembersStatement* node) {
|
||||||
IndentedScope indent(this, "INITIALIZE CLASS FIELDS", node->position());
|
IndentedScope indent(this, "INITIALIZE CLASS ELEMENTS", node->position());
|
||||||
PrintClassProperties(node->fields());
|
PrintClassProperties(node->fields());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1502,9 +1502,9 @@ void DeclarationScope::AnalyzePartially(AstNodeFactory* ast_node_factory) {
|
|||||||
ResolveScopesThenForEachVariable(
|
ResolveScopesThenForEachVariable(
|
||||||
this, [=, &new_unresolved_list](VariableProxy* proxy) {
|
this, [=, &new_unresolved_list](VariableProxy* proxy) {
|
||||||
// Don't copy unresolved references to the script scope, unless it's a
|
// Don't copy unresolved references to the script scope, unless it's a
|
||||||
// reference to a private field. In that case keep it so we can fail
|
// reference to a private name or method. In that case keep it so we
|
||||||
// later.
|
// can fail later.
|
||||||
if (!outer_scope_->is_script_scope() || proxy->is_private_field()) {
|
if (!outer_scope_->is_script_scope() || proxy->is_private_name()) {
|
||||||
VariableProxy* copy = ast_node_factory->CopyVariableProxy(proxy);
|
VariableProxy* copy = ast_node_factory->CopyVariableProxy(proxy);
|
||||||
new_unresolved_list.AddFront(copy);
|
new_unresolved_list.AddFront(copy);
|
||||||
}
|
}
|
||||||
@ -1801,7 +1801,7 @@ Variable* Scope::LookupRecursive(ParseInfo* info, VariableProxy* proxy,
|
|||||||
// declare them in the outer scope.
|
// declare them in the outer scope.
|
||||||
if (!is_script_scope()) return nullptr;
|
if (!is_script_scope()) return nullptr;
|
||||||
|
|
||||||
if (proxy->is_private_field()) {
|
if (proxy->is_private_name()) {
|
||||||
info->pending_error_handler()->ReportMessageAt(
|
info->pending_error_handler()->ReportMessageAt(
|
||||||
proxy->position(), proxy->position() + 1,
|
proxy->position(), proxy->position() + 1,
|
||||||
MessageTemplate::kInvalidPrivateFieldAccess, proxy->raw_name(),
|
MessageTemplate::kInvalidPrivateFieldAccess, proxy->raw_name(),
|
||||||
@ -1878,7 +1878,7 @@ bool Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy) {
|
|||||||
DCHECK(!proxy->is_resolved());
|
DCHECK(!proxy->is_resolved());
|
||||||
Variable* var = LookupRecursive(info, proxy, nullptr);
|
Variable* var = LookupRecursive(info, proxy, nullptr);
|
||||||
if (var == nullptr) {
|
if (var == nullptr) {
|
||||||
DCHECK(proxy->is_private_field());
|
DCHECK(proxy->is_private_name());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ResolveTo(info, proxy, var);
|
ResolveTo(info, proxy, var);
|
||||||
@ -1988,7 +1988,7 @@ bool Scope::ResolveVariablesRecursively(ParseInfo* info) {
|
|||||||
for (VariableProxy* proxy : unresolved_list_) {
|
for (VariableProxy* proxy : unresolved_list_) {
|
||||||
Variable* var = outer_scope()->LookupRecursive(info, proxy, nullptr);
|
Variable* var = outer_scope()->LookupRecursive(info, proxy, nullptr);
|
||||||
if (var == nullptr) {
|
if (var == nullptr) {
|
||||||
DCHECK(proxy->is_private_field());
|
DCHECK(proxy->is_private_name());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!var->is_dynamic()) {
|
if (!var->is_dynamic()) {
|
||||||
|
@ -708,7 +708,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
|
|||||||
void set_asm_module();
|
void set_asm_module();
|
||||||
|
|
||||||
bool should_ban_arguments() const {
|
bool should_ban_arguments() const {
|
||||||
return IsClassFieldsInitializerFunction(function_kind());
|
return IsClassMembersInitializerFunction(function_kind());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclareThis(AstValueFactory* ast_value_factory);
|
void DeclareThis(AstValueFactory* ast_value_factory);
|
||||||
@ -864,7 +864,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
|
|||||||
// scope only contains the single lazily compiled function, so this
|
// scope only contains the single lazily compiled function, so this
|
||||||
// doesn't re-allocate variables repeatedly.
|
// doesn't re-allocate variables repeatedly.
|
||||||
//
|
//
|
||||||
// Returns false if private fields can not be resolved and
|
// Returns false if private names can not be resolved and
|
||||||
// ParseInfo's pending_error_handler will be populated with an
|
// ParseInfo's pending_error_handler will be populated with an
|
||||||
// error. Otherwise, returns true.
|
// error. Otherwise, returns true.
|
||||||
V8_WARN_UNUSED_RESULT
|
V8_WARN_UNUSED_RESULT
|
||||||
@ -947,7 +947,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
|
|||||||
// parameter is the context in which eval was called. In all other
|
// parameter is the context in which eval was called. In all other
|
||||||
// cases the context parameter is an empty handle.
|
// cases the context parameter is an empty handle.
|
||||||
//
|
//
|
||||||
// Returns false if private fields can not be resolved.
|
// Returns false if private names can not be resolved.
|
||||||
bool AllocateVariables(ParseInfo* info);
|
bool AllocateVariables(ParseInfo* info);
|
||||||
|
|
||||||
void SetDefaults();
|
void SetDefaults();
|
||||||
|
@ -97,7 +97,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ScopeIterator::Option option) {
|
|||||||
// Class fields initializer functions don't have any scope
|
// Class fields initializer functions don't have any scope
|
||||||
// information. We short circuit the parsing of the class literal
|
// information. We short circuit the parsing of the class literal
|
||||||
// and return an empty context here.
|
// and return an empty context here.
|
||||||
if (IsClassFieldsInitializerFunction(shared_info->kind())) {
|
if (IsClassMembersInitializerFunction(shared_info->kind())) {
|
||||||
current_scope_ = closure_scope_ = nullptr;
|
current_scope_ = closure_scope_ = nullptr;
|
||||||
context_ = Handle<Context>();
|
context_ = Handle<Context>();
|
||||||
function_ = Handle<JSFunction>();
|
function_ = Handle<JSFunction>();
|
||||||
|
@ -1121,7 +1121,7 @@ enum FunctionKind : uint8_t {
|
|||||||
kSetterFunction,
|
kSetterFunction,
|
||||||
kAsyncFunction,
|
kAsyncFunction,
|
||||||
kModule,
|
kModule,
|
||||||
kClassFieldsInitializerFunction,
|
kClassMembersInitializerFunction,
|
||||||
|
|
||||||
kDefaultBaseConstructor,
|
kDefaultBaseConstructor,
|
||||||
kDefaultDerivedConstructor,
|
kDefaultDerivedConstructor,
|
||||||
@ -1170,7 +1170,7 @@ inline bool IsConciseMethod(FunctionKind kind) {
|
|||||||
kind == FunctionKind::kConciseGeneratorMethod ||
|
kind == FunctionKind::kConciseGeneratorMethod ||
|
||||||
kind == FunctionKind::kAsyncConciseMethod ||
|
kind == FunctionKind::kAsyncConciseMethod ||
|
||||||
kind == FunctionKind::kAsyncConciseGeneratorMethod ||
|
kind == FunctionKind::kAsyncConciseGeneratorMethod ||
|
||||||
kind == FunctionKind::kClassFieldsInitializerFunction;
|
kind == FunctionKind::kClassMembersInitializerFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool IsGetterFunction(FunctionKind kind) {
|
inline bool IsGetterFunction(FunctionKind kind) {
|
||||||
@ -1206,8 +1206,8 @@ inline bool IsClassConstructor(FunctionKind kind) {
|
|||||||
return IsBaseConstructor(kind) || IsDerivedConstructor(kind);
|
return IsBaseConstructor(kind) || IsDerivedConstructor(kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool IsClassFieldsInitializerFunction(FunctionKind kind) {
|
inline bool IsClassMembersInitializerFunction(FunctionKind kind) {
|
||||||
return kind == FunctionKind::kClassFieldsInitializerFunction;
|
return kind == FunctionKind::kClassMembersInitializerFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool IsConstructable(FunctionKind kind) {
|
inline bool IsConstructable(FunctionKind kind) {
|
||||||
@ -1241,8 +1241,8 @@ inline std::ostream& operator<<(std::ostream& os, FunctionKind kind) {
|
|||||||
return os << "AsyncFunction";
|
return os << "AsyncFunction";
|
||||||
case FunctionKind::kModule:
|
case FunctionKind::kModule:
|
||||||
return os << "Module";
|
return os << "Module";
|
||||||
case FunctionKind::kClassFieldsInitializerFunction:
|
case FunctionKind::kClassMembersInitializerFunction:
|
||||||
return os << "ClassFieldsInitializerFunction";
|
return os << "ClassMembersInitializerFunction";
|
||||||
case FunctionKind::kDefaultBaseConstructor:
|
case FunctionKind::kDefaultBaseConstructor:
|
||||||
return os << "DefaultBaseConstructor";
|
return os << "DefaultBaseConstructor";
|
||||||
case FunctionKind::kDefaultDerivedConstructor:
|
case FunctionKind::kDefaultDerivedConstructor:
|
||||||
|
@ -1343,9 +1343,9 @@ Handle<Symbol> Factory::NewPrivateSymbol(PretenureFlag flag) {
|
|||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle<Symbol> Factory::NewPrivateFieldSymbol() {
|
Handle<Symbol> Factory::NewPrivateNameSymbol() {
|
||||||
Handle<Symbol> symbol = NewSymbol();
|
Handle<Symbol> symbol = NewSymbol();
|
||||||
symbol->set_is_private_field();
|
symbol->set_is_private_name();
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ class V8_EXPORT_PRIVATE Factory {
|
|||||||
// Create a symbol in old or read-only space.
|
// Create a symbol in old or read-only space.
|
||||||
Handle<Symbol> NewSymbol(PretenureFlag pretenure = TENURED);
|
Handle<Symbol> NewSymbol(PretenureFlag pretenure = TENURED);
|
||||||
Handle<Symbol> NewPrivateSymbol(PretenureFlag pretenure = TENURED);
|
Handle<Symbol> NewPrivateSymbol(PretenureFlag pretenure = TENURED);
|
||||||
Handle<Symbol> NewPrivateFieldSymbol();
|
Handle<Symbol> NewPrivateNameSymbol();
|
||||||
|
|
||||||
// Create a global (but otherwise uninitialized) context.
|
// Create a global (but otherwise uninitialized) context.
|
||||||
Handle<NativeContext> NewNativeContext();
|
Handle<NativeContext> NewNativeContext();
|
||||||
|
@ -447,7 +447,7 @@ MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<Name> name) {
|
|||||||
LookupForRead(isolate(), &it);
|
LookupForRead(isolate(), &it);
|
||||||
|
|
||||||
if (name->IsPrivate()) {
|
if (name->IsPrivate()) {
|
||||||
if (name->IsPrivateField() && !it.IsFound()) {
|
if (name->IsPrivateName() && !it.IsFound()) {
|
||||||
return TypeError(MessageTemplate::kInvalidPrivateFieldAccess, object,
|
return TypeError(MessageTemplate::kInvalidPrivateFieldAccess, object,
|
||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
@ -1411,7 +1411,7 @@ MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name,
|
|||||||
bool use_ic = FLAG_use_ic;
|
bool use_ic = FLAG_use_ic;
|
||||||
|
|
||||||
if (name->IsPrivate()) {
|
if (name->IsPrivate()) {
|
||||||
if (name->IsPrivateField() && !it.IsFound()) {
|
if (name->IsPrivateName() && !it.IsFound()) {
|
||||||
return TypeError(MessageTemplate::kInvalidPrivateFieldAccess, object,
|
return TypeError(MessageTemplate::kInvalidPrivateFieldAccess, object,
|
||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
@ -2466,7 +2466,7 @@ static bool CanFastCloneObject(Handle<Map> map) {
|
|||||||
PropertyDetails details = descriptors->GetDetails(i);
|
PropertyDetails details = descriptors->GetDetails(i);
|
||||||
Name* key = descriptors->GetKey(i);
|
Name* key = descriptors->GetKey(i);
|
||||||
if (details.kind() != kData || !details.IsEnumerable() ||
|
if (details.kind() != kData || !details.IsEnumerable() ||
|
||||||
key->IsPrivateField()) {
|
key->IsPrivateName()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1112,9 +1112,9 @@ void BytecodeGenerator::GenerateBytecodeBody() {
|
|||||||
|
|
||||||
// The derived constructor case is handled in VisitCallSuper.
|
// The derived constructor case is handled in VisitCallSuper.
|
||||||
if (IsBaseConstructor(function_kind()) &&
|
if (IsBaseConstructor(function_kind()) &&
|
||||||
info()->literal()->requires_instance_fields_initializer()) {
|
info()->literal()->requires_instance_members_initializer()) {
|
||||||
BuildInstanceFieldInitialization(Register::function_closure(),
|
BuildInstanceMemberInitialization(Register::function_closure(),
|
||||||
builder()->Receiver());
|
builder()->Receiver());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visit statements in the function body.
|
// Visit statements in the function body.
|
||||||
@ -1903,10 +1903,10 @@ void BytecodeGenerator::BuildClassLiteral(ClassLiteral* expr, Register name) {
|
|||||||
|
|
||||||
if (property->kind() == ClassLiteral::Property::FIELD) {
|
if (property->kind() == ClassLiteral::Property::FIELD) {
|
||||||
if (property->is_private()) {
|
if (property->is_private()) {
|
||||||
builder()->CallRuntime(Runtime::kCreatePrivateFieldSymbol);
|
builder()->CallRuntime(Runtime::kCreatePrivateNameSymbol);
|
||||||
DCHECK_NOT_NULL(property->private_field_name_var());
|
DCHECK_NOT_NULL(property->private_name_var());
|
||||||
BuildVariableAssignment(property->private_field_name_var(),
|
BuildVariableAssignment(property->private_name_var(), Token::INIT,
|
||||||
Token::INIT, HoleCheckMode::kElided);
|
HoleCheckMode::kElided);
|
||||||
}
|
}
|
||||||
// We don't compute field's value here, but instead do it in the
|
// We don't compute field's value here, but instead do it in the
|
||||||
// initializer function.
|
// initializer function.
|
||||||
@ -1931,12 +1931,12 @@ void BytecodeGenerator::BuildClassLiteral(ClassLiteral* expr, Register name) {
|
|||||||
HoleCheckMode::kElided);
|
HoleCheckMode::kElided);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expr->instance_fields_initializer_function() != nullptr) {
|
if (expr->instance_members_initializer_function() != nullptr) {
|
||||||
Register initializer =
|
Register initializer =
|
||||||
VisitForRegisterValue(expr->instance_fields_initializer_function());
|
VisitForRegisterValue(expr->instance_members_initializer_function());
|
||||||
|
|
||||||
if (FunctionLiteral::NeedsHomeObject(
|
if (FunctionLiteral::NeedsHomeObject(
|
||||||
expr->instance_fields_initializer_function())) {
|
expr->instance_members_initializer_function())) {
|
||||||
FeedbackSlot slot = feedback_spec()->AddStoreICSlot(language_mode());
|
FeedbackSlot slot = feedback_spec()->AddStoreICSlot(language_mode());
|
||||||
builder()->LoadAccumulatorWithRegister(prototype).StoreHomeObjectProperty(
|
builder()->LoadAccumulatorWithRegister(prototype).StoreHomeObjectProperty(
|
||||||
initializer, feedback_index(slot), language_mode());
|
initializer, feedback_index(slot), language_mode());
|
||||||
@ -2004,8 +2004,8 @@ void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr, Register name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BytecodeGenerator::VisitInitializeClassFieldsStatement(
|
void BytecodeGenerator::VisitInitializeClassMembersStatement(
|
||||||
InitializeClassFieldsStatement* stmt) {
|
InitializeClassMembersStatement* stmt) {
|
||||||
RegisterList args = register_allocator()->NewRegisterList(3);
|
RegisterList args = register_allocator()->NewRegisterList(3);
|
||||||
Register constructor = args[0], key = args[1], value = args[2];
|
Register constructor = args[0], key = args[1], value = args[2];
|
||||||
builder()->MoveRegister(builder()->Receiver(), constructor);
|
builder()->MoveRegister(builder()->Receiver(), constructor);
|
||||||
@ -2024,9 +2024,9 @@ void BytecodeGenerator::VisitInitializeClassFieldsStatement(
|
|||||||
builder()->StoreAccumulatorInRegister(key);
|
builder()->StoreAccumulatorInRegister(key);
|
||||||
} else if (property->kind() == ClassLiteral::Property::FIELD &&
|
} else if (property->kind() == ClassLiteral::Property::FIELD &&
|
||||||
property->is_private()) {
|
property->is_private()) {
|
||||||
Variable* private_field_name_var = property->private_field_name_var();
|
Variable* private_name_var = property->private_name_var();
|
||||||
DCHECK_NOT_NULL(private_field_name_var);
|
DCHECK_NOT_NULL(private_name_var);
|
||||||
BuildVariableLoad(private_field_name_var, HoleCheckMode::kElided);
|
BuildVariableLoad(private_name_var, HoleCheckMode::kElided);
|
||||||
builder()->StoreAccumulatorInRegister(key);
|
builder()->StoreAccumulatorInRegister(key);
|
||||||
} else {
|
} else {
|
||||||
BuildLoadPropertyKey(property, key);
|
BuildLoadPropertyKey(property, key);
|
||||||
@ -2045,8 +2045,8 @@ void BytecodeGenerator::VisitInitializeClassFieldsStatement(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BytecodeGenerator::BuildInstanceFieldInitialization(Register constructor,
|
void BytecodeGenerator::BuildInstanceMemberInitialization(Register constructor,
|
||||||
Register instance) {
|
Register instance) {
|
||||||
RegisterList args = register_allocator()->NewRegisterList(1);
|
RegisterList args = register_allocator()->NewRegisterList(1);
|
||||||
Register initializer = register_allocator()->NewRegister();
|
Register initializer = register_allocator()->NewRegister();
|
||||||
|
|
||||||
@ -3840,11 +3840,11 @@ void BytecodeGenerator::VisitCallSuper(Call* expr) {
|
|||||||
// TODO(gsathya): In the future, we could tag nested arrow functions
|
// TODO(gsathya): In the future, we could tag nested arrow functions
|
||||||
// or eval with the correct bit so that we do the load conditionally
|
// or eval with the correct bit so that we do the load conditionally
|
||||||
// if required.
|
// if required.
|
||||||
if (info()->literal()->requires_instance_fields_initializer() ||
|
if (info()->literal()->requires_instance_members_initializer() ||
|
||||||
!IsDerivedConstructor(info()->literal()->kind())) {
|
!IsDerivedConstructor(info()->literal()->kind())) {
|
||||||
Register instance = register_allocator()->NewRegister();
|
Register instance = register_allocator()->NewRegister();
|
||||||
builder()->StoreAccumulatorInRegister(instance);
|
builder()->StoreAccumulatorInRegister(instance);
|
||||||
BuildInstanceFieldInitialization(this_function, instance);
|
BuildInstanceMemberInitialization(this_function, instance);
|
||||||
builder()->LoadAccumulatorWithRegister(instance);
|
builder()->LoadAccumulatorWithRegister(instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,8 +198,8 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
|
|||||||
void VisitClassLiteral(ClassLiteral* expr, Register name);
|
void VisitClassLiteral(ClassLiteral* expr, Register name);
|
||||||
void VisitNewTargetVariable(Variable* variable);
|
void VisitNewTargetVariable(Variable* variable);
|
||||||
void VisitThisFunctionVariable(Variable* variable);
|
void VisitThisFunctionVariable(Variable* variable);
|
||||||
void BuildInstanceFieldInitialization(Register constructor,
|
void BuildInstanceMemberInitialization(Register constructor,
|
||||||
Register instance);
|
Register instance);
|
||||||
void BuildGeneratorObjectVariableInitialization();
|
void BuildGeneratorObjectVariableInitialization();
|
||||||
void VisitBlockDeclarationsAndStatements(Block* stmt);
|
void VisitBlockDeclarationsAndStatements(Block* stmt);
|
||||||
void VisitSetHomeObject(Register value, Register home_object,
|
void VisitSetHomeObject(Register value, Register home_object,
|
||||||
|
@ -497,7 +497,7 @@ void LookupIterator::ReconfigureDataProperty(Handle<Object> value,
|
|||||||
|
|
||||||
Handle<JSReceiver> holder = GetHolder<JSReceiver>();
|
Handle<JSReceiver> holder = GetHolder<JSReceiver>();
|
||||||
|
|
||||||
// Property details can never change for private fields.
|
// Property details can never change for private properties.
|
||||||
if (holder->IsJSProxy()) {
|
if (holder->IsJSProxy()) {
|
||||||
DCHECK(name()->IsPrivate());
|
DCHECK(name()->IsPrivate());
|
||||||
return;
|
return;
|
||||||
@ -700,7 +700,7 @@ void LookupIterator::Delete() {
|
|||||||
ElementsAccessor* accessor = object->GetElementsAccessor();
|
ElementsAccessor* accessor = object->GetElementsAccessor();
|
||||||
accessor->Delete(object, number_);
|
accessor->Delete(object, number_);
|
||||||
} else {
|
} else {
|
||||||
DCHECK(!name()->IsPrivateField());
|
DCHECK(!name()->IsPrivateName());
|
||||||
bool is_prototype_map = holder->map()->is_prototype_map();
|
bool is_prototype_map = holder->map()->is_prototype_map();
|
||||||
RuntimeCallTimerScope stats_scope(
|
RuntimeCallTimerScope stats_scope(
|
||||||
isolate_, is_prototype_map
|
isolate_, is_prototype_map
|
||||||
|
@ -446,7 +446,7 @@ void Symbol::SymbolVerify(Isolate* isolate) {
|
|||||||
CHECK(HasHashCode());
|
CHECK(HasHashCode());
|
||||||
CHECK_GT(Hash(), 0);
|
CHECK_GT(Hash(), 0);
|
||||||
CHECK(name()->IsUndefined(isolate) || name()->IsString());
|
CHECK(name()->IsUndefined(isolate) || name()->IsString());
|
||||||
CHECK_IMPLIES(IsPrivateField(), IsPrivate());
|
CHECK_IMPLIES(IsPrivateName(), IsPrivate());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ByteArray::ByteArrayVerify(Isolate* isolate) { CHECK(IsByteArray()); }
|
void ByteArray::ByteArrayVerify(Isolate* isolate) { CHECK(IsByteArray()); }
|
||||||
|
@ -5321,8 +5321,8 @@ Maybe<bool> Object::RedefineIncompatibleProperty(Isolate* isolate,
|
|||||||
|
|
||||||
Maybe<bool> Object::SetDataProperty(LookupIterator* it, Handle<Object> value) {
|
Maybe<bool> Object::SetDataProperty(LookupIterator* it, Handle<Object> value) {
|
||||||
DCHECK_IMPLIES(it->GetReceiver()->IsJSProxy(),
|
DCHECK_IMPLIES(it->GetReceiver()->IsJSProxy(),
|
||||||
it->GetName()->IsPrivateField());
|
it->GetName()->IsPrivateName());
|
||||||
DCHECK_IMPLIES(!it->IsElement() && it->GetName()->IsPrivateField(),
|
DCHECK_IMPLIES(!it->IsElement() && it->GetName()->IsPrivateName(),
|
||||||
it->state() == LookupIterator::DATA);
|
it->state() == LookupIterator::DATA);
|
||||||
Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(it->GetReceiver());
|
Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(it->GetReceiver());
|
||||||
|
|
||||||
@ -5385,7 +5385,7 @@ Maybe<bool> Object::AddDataProperty(LookupIterator* it, Handle<Object> value,
|
|||||||
// Private symbols should be installed on JSProxy using
|
// Private symbols should be installed on JSProxy using
|
||||||
// JSProxy::SetPrivateSymbol.
|
// JSProxy::SetPrivateSymbol.
|
||||||
if (it->GetReceiver()->IsJSProxy() && it->GetName()->IsPrivate() &&
|
if (it->GetReceiver()->IsJSProxy() && it->GetName()->IsPrivate() &&
|
||||||
!it->GetName()->IsPrivateField()) {
|
!it->GetName()->IsPrivateName()) {
|
||||||
RETURN_FAILURE(it->isolate(), should_throw,
|
RETURN_FAILURE(it->isolate(), should_throw,
|
||||||
NewTypeError(MessageTemplate::kProxyPrivate));
|
NewTypeError(MessageTemplate::kProxyPrivate));
|
||||||
}
|
}
|
||||||
@ -5393,7 +5393,7 @@ Maybe<bool> Object::AddDataProperty(LookupIterator* it, Handle<Object> value,
|
|||||||
DCHECK_NE(LookupIterator::INTEGER_INDEXED_EXOTIC, it->state());
|
DCHECK_NE(LookupIterator::INTEGER_INDEXED_EXOTIC, it->state());
|
||||||
|
|
||||||
Handle<JSReceiver> receiver = it->GetStoreTarget<JSReceiver>();
|
Handle<JSReceiver> receiver = it->GetStoreTarget<JSReceiver>();
|
||||||
DCHECK_IMPLIES(receiver->IsJSProxy(), it->GetName()->IsPrivateField());
|
DCHECK_IMPLIES(receiver->IsJSProxy(), it->GetName()->IsPrivateName());
|
||||||
DCHECK_IMPLIES(receiver->IsJSProxy(),
|
DCHECK_IMPLIES(receiver->IsJSProxy(),
|
||||||
it->state() == LookupIterator::NOT_FOUND);
|
it->state() == LookupIterator::NOT_FOUND);
|
||||||
|
|
||||||
@ -7763,7 +7763,7 @@ Maybe<bool> JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
|||||||
ShouldThrow should_throw) {
|
ShouldThrow should_throw) {
|
||||||
STACK_CHECK(isolate, Nothing<bool>());
|
STACK_CHECK(isolate, Nothing<bool>());
|
||||||
if (key->IsSymbol() && Handle<Symbol>::cast(key)->IsPrivate()) {
|
if (key->IsSymbol() && Handle<Symbol>::cast(key)->IsPrivate()) {
|
||||||
DCHECK(!Handle<Symbol>::cast(key)->IsPrivateField());
|
DCHECK(!Handle<Symbol>::cast(key)->IsPrivateName());
|
||||||
return JSProxy::SetPrivateSymbol(isolate, proxy, Handle<Symbol>::cast(key),
|
return JSProxy::SetPrivateSymbol(isolate, proxy, Handle<Symbol>::cast(key),
|
||||||
desc, should_throw);
|
desc, should_throw);
|
||||||
}
|
}
|
||||||
@ -7873,7 +7873,7 @@ Maybe<bool> JSProxy::SetPrivateSymbol(Isolate* isolate, Handle<JSProxy> proxy,
|
|||||||
Handle<Symbol> private_name,
|
Handle<Symbol> private_name,
|
||||||
PropertyDescriptor* desc,
|
PropertyDescriptor* desc,
|
||||||
ShouldThrow should_throw) {
|
ShouldThrow should_throw) {
|
||||||
DCHECK(!private_name->IsPrivateField());
|
DCHECK(!private_name->IsPrivateName());
|
||||||
// Despite the generic name, this can only add private data properties.
|
// Despite the generic name, this can only add private data properties.
|
||||||
if (!PropertyDescriptor::IsDataDescriptor(desc) ||
|
if (!PropertyDescriptor::IsDataDescriptor(desc) ||
|
||||||
desc->ToAttributes() != DONT_ENUM) {
|
desc->ToAttributes() != DONT_ENUM) {
|
||||||
@ -10189,7 +10189,7 @@ Handle<DescriptorArray> DescriptorArray::CopyForFastObjectClone(
|
|||||||
Name* key = src->GetKey(i);
|
Name* key = src->GetKey(i);
|
||||||
PropertyDetails details = src->GetDetails(i);
|
PropertyDetails details = src->GetDetails(i);
|
||||||
|
|
||||||
DCHECK(!key->IsPrivateField());
|
DCHECK(!key->IsPrivateName());
|
||||||
DCHECK(details.IsEnumerable());
|
DCHECK(details.IsEnumerable());
|
||||||
DCHECK_EQ(details.kind(), kData);
|
DCHECK_EQ(details.kind(), kData);
|
||||||
|
|
||||||
@ -14181,10 +14181,10 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
|
|||||||
// FunctionKind must have already been set.
|
// FunctionKind must have already been set.
|
||||||
DCHECK(lit->kind() == shared_info->kind());
|
DCHECK(lit->kind() == shared_info->kind());
|
||||||
shared_info->set_needs_home_object(lit->scope()->NeedsHomeObject());
|
shared_info->set_needs_home_object(lit->scope()->NeedsHomeObject());
|
||||||
DCHECK_IMPLIES(lit->requires_instance_fields_initializer(),
|
DCHECK_IMPLIES(lit->requires_instance_members_initializer(),
|
||||||
IsClassConstructor(lit->kind()));
|
IsClassConstructor(lit->kind()));
|
||||||
shared_info->set_requires_instance_fields_initializer(
|
shared_info->set_requires_instance_members_initializer(
|
||||||
lit->requires_instance_fields_initializer());
|
lit->requires_instance_members_initializer());
|
||||||
|
|
||||||
shared_info->set_is_toplevel(is_toplevel);
|
shared_info->set_is_toplevel(is_toplevel);
|
||||||
DCHECK(shared_info->outer_scope_info()->IsTheHole());
|
DCHECK(shared_info->outer_scope_info()->IsTheHole());
|
||||||
|
@ -27,17 +27,17 @@ BIT_FIELD_ACCESSORS(Symbol, flags, is_public, Symbol::IsPublicBit)
|
|||||||
BIT_FIELD_ACCESSORS(Symbol, flags, is_interesting_symbol,
|
BIT_FIELD_ACCESSORS(Symbol, flags, is_interesting_symbol,
|
||||||
Symbol::IsInterestingSymbolBit)
|
Symbol::IsInterestingSymbolBit)
|
||||||
|
|
||||||
bool Symbol::is_private_field() const {
|
bool Symbol::is_private_name() const {
|
||||||
bool value = Symbol::IsPrivateFieldBit::decode(flags());
|
bool value = Symbol::IsPrivateNameBit::decode(flags());
|
||||||
DCHECK_IMPLIES(value, is_private());
|
DCHECK_IMPLIES(value, is_private());
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Symbol::set_is_private_field() {
|
void Symbol::set_is_private_name() {
|
||||||
// TODO(gsathya): Re-order the bits to have these next to each other
|
// TODO(gsathya): Re-order the bits to have these next to each other
|
||||||
// and just do the bit shifts once.
|
// and just do the bit shifts once.
|
||||||
set_flags(Symbol::IsPrivateBit::update(flags(), true));
|
set_flags(Symbol::IsPrivateBit::update(flags(), true));
|
||||||
set_flags(Symbol::IsPrivateFieldBit::update(flags(), true));
|
set_flags(Symbol::IsPrivateNameBit::update(flags(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Name::IsUniqueName() const {
|
bool Name::IsUniqueName() const {
|
||||||
@ -98,11 +98,11 @@ bool Name::IsPrivate() {
|
|||||||
return this->IsSymbol() && Symbol::cast(this)->is_private();
|
return this->IsSymbol() && Symbol::cast(this)->is_private();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Name::IsPrivateField() {
|
bool Name::IsPrivateName() {
|
||||||
bool is_private_field =
|
bool is_private_name =
|
||||||
this->IsSymbol() && Symbol::cast(this)->is_private_field();
|
this->IsSymbol() && Symbol::cast(this)->is_private_name();
|
||||||
DCHECK_IMPLIES(is_private_field, IsPrivate());
|
DCHECK_IMPLIES(is_private_name, IsPrivate());
|
||||||
return is_private_field;
|
return is_private_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Name::AsArrayIndex(uint32_t* index) {
|
bool Name::AsArrayIndex(uint32_t* index) {
|
||||||
|
@ -45,9 +45,9 @@ class Name : public HeapObject {
|
|||||||
// If the name is private, it can only name own properties.
|
// If the name is private, it can only name own properties.
|
||||||
inline bool IsPrivate();
|
inline bool IsPrivate();
|
||||||
|
|
||||||
// If the name is a private field, it should behave like a private
|
// If the name is a private name, it should behave like a private
|
||||||
// symbol but also throw on property access miss.
|
// symbol but also throw on property access miss.
|
||||||
inline bool IsPrivateField();
|
inline bool IsPrivateName();
|
||||||
|
|
||||||
inline bool IsUniqueName() const;
|
inline bool IsUniqueName() const;
|
||||||
|
|
||||||
@ -161,13 +161,13 @@ class Symbol : public Name {
|
|||||||
// Symbol.keyFor on such a symbol simply needs to return the attached name.
|
// Symbol.keyFor on such a symbol simply needs to return the attached name.
|
||||||
DECL_BOOLEAN_ACCESSORS(is_public)
|
DECL_BOOLEAN_ACCESSORS(is_public)
|
||||||
|
|
||||||
// [is_private_field]: Whether this is a private field. Private fields
|
// [is_private_name]: Whether this is a private name. Private names
|
||||||
// are the same as private symbols except they throw on missing
|
// are the same as private symbols except they throw on missing
|
||||||
// property access.
|
// property access.
|
||||||
//
|
//
|
||||||
// This also sets the is_private bit.
|
// This also sets the is_private bit.
|
||||||
inline bool is_private_field() const;
|
inline bool is_private_name() const;
|
||||||
inline void set_is_private_field();
|
inline void set_is_private_name();
|
||||||
|
|
||||||
DECL_CAST(Symbol)
|
DECL_CAST(Symbol)
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ class Symbol : public Name {
|
|||||||
V(IsWellKnownSymbolBit, bool, 1, _) \
|
V(IsWellKnownSymbolBit, bool, 1, _) \
|
||||||
V(IsPublicBit, bool, 1, _) \
|
V(IsPublicBit, bool, 1, _) \
|
||||||
V(IsInterestingSymbolBit, bool, 1, _) \
|
V(IsInterestingSymbolBit, bool, 1, _) \
|
||||||
V(IsPrivateFieldBit, bool, 1, _)
|
V(IsPrivateNameBit, bool, 1, _)
|
||||||
|
|
||||||
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
|
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
|
||||||
#undef FLAGS_BIT_FIELDS
|
#undef FLAGS_BIT_FIELDS
|
||||||
|
@ -163,8 +163,8 @@ BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags, native,
|
|||||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags, is_asm_wasm_broken,
|
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags, is_asm_wasm_broken,
|
||||||
SharedFunctionInfo::IsAsmWasmBrokenBit)
|
SharedFunctionInfo::IsAsmWasmBrokenBit)
|
||||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags,
|
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags,
|
||||||
requires_instance_fields_initializer,
|
requires_instance_members_initializer,
|
||||||
SharedFunctionInfo::RequiresInstanceFieldsInitializer)
|
SharedFunctionInfo::RequiresInstanceMembersInitializer)
|
||||||
|
|
||||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags, name_should_print_as_anonymous,
|
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags, name_should_print_as_anonymous,
|
||||||
SharedFunctionInfo::NameShouldPrintAsAnonymousBit)
|
SharedFunctionInfo::NameShouldPrintAsAnonymousBit)
|
||||||
|
@ -475,7 +475,7 @@ class SharedFunctionInfo : public HeapObject, public NeverReadOnlySpaceObject {
|
|||||||
// initializer. This flag is set when creating the
|
// initializer. This flag is set when creating the
|
||||||
// SharedFunctionInfo as a reminder to emit the initializer call
|
// SharedFunctionInfo as a reminder to emit the initializer call
|
||||||
// when generating code later.
|
// when generating code later.
|
||||||
DECL_BOOLEAN_ACCESSORS(requires_instance_fields_initializer)
|
DECL_BOOLEAN_ACCESSORS(requires_instance_members_initializer)
|
||||||
|
|
||||||
// [source code]: Source code for the function.
|
// [source code]: Source code for the function.
|
||||||
bool HasSourceCode() const;
|
bool HasSourceCode() const;
|
||||||
@ -634,7 +634,7 @@ class SharedFunctionInfo : public HeapObject, public NeverReadOnlySpaceObject {
|
|||||||
V(IsAsmWasmBrokenBit, bool, 1, _) \
|
V(IsAsmWasmBrokenBit, bool, 1, _) \
|
||||||
V(FunctionMapIndexBits, int, 5, _) \
|
V(FunctionMapIndexBits, int, 5, _) \
|
||||||
V(DisabledOptimizationReasonBits, BailoutReason, 4, _) \
|
V(DisabledOptimizationReasonBits, BailoutReason, 4, _) \
|
||||||
V(RequiresInstanceFieldsInitializer, bool, 1, _) \
|
V(RequiresInstanceMembersInitializer, bool, 1, _) \
|
||||||
V(ConstructAsBuiltinBit, bool, 1, _) \
|
V(ConstructAsBuiltinBit, bool, 1, _) \
|
||||||
V(IsAnonymousExpressionBit, bool, 1, _) \
|
V(IsAnonymousExpressionBit, bool, 1, _) \
|
||||||
V(NameShouldPrintAsAnonymousBit, bool, 1, _) \
|
V(NameShouldPrintAsAnonymousBit, bool, 1, _) \
|
||||||
|
@ -67,8 +67,8 @@ void ParseInfo::SetFunctionInfo(T function) {
|
|||||||
set_language_mode(function->language_mode());
|
set_language_mode(function->language_mode());
|
||||||
set_function_kind(function->kind());
|
set_function_kind(function->kind());
|
||||||
set_declaration(function->is_declaration());
|
set_declaration(function->is_declaration());
|
||||||
set_requires_instance_fields_initializer(
|
set_requires_instance_members_initializer(
|
||||||
function->requires_instance_fields_initializer());
|
function->requires_instance_members_initializer());
|
||||||
set_toplevel(function->is_toplevel());
|
set_toplevel(function->is_toplevel());
|
||||||
set_wrapped_as_function(function->is_wrapped());
|
set_wrapped_as_function(function->is_wrapped());
|
||||||
}
|
}
|
||||||
|
@ -90,9 +90,9 @@ class V8_EXPORT_PRIVATE ParseInfo {
|
|||||||
set_wrapped_as_function)
|
set_wrapped_as_function)
|
||||||
FLAG_ACCESSOR(kAllowEvalCache, allow_eval_cache, set_allow_eval_cache)
|
FLAG_ACCESSOR(kAllowEvalCache, allow_eval_cache, set_allow_eval_cache)
|
||||||
FLAG_ACCESSOR(kIsDeclaration, is_declaration, set_declaration)
|
FLAG_ACCESSOR(kIsDeclaration, is_declaration, set_declaration)
|
||||||
FLAG_ACCESSOR(kRequiresInstanceFieldsInitializer,
|
FLAG_ACCESSOR(kRequiresInstanceMembersInitializer,
|
||||||
requires_instance_fields_initializer,
|
requires_instance_members_initializer,
|
||||||
set_requires_instance_fields_initializer);
|
set_requires_instance_members_initializer);
|
||||||
#undef FLAG_ACCESSOR
|
#undef FLAG_ACCESSOR
|
||||||
|
|
||||||
void set_parse_restriction(ParseRestriction restriction) {
|
void set_parse_restriction(ParseRestriction restriction) {
|
||||||
@ -283,7 +283,7 @@ class V8_EXPORT_PRIVATE ParseInfo {
|
|||||||
kWrappedAsFunction = 1 << 14, // Implicitly wrapped as function.
|
kWrappedAsFunction = 1 << 14, // Implicitly wrapped as function.
|
||||||
kAllowEvalCache = 1 << 15,
|
kAllowEvalCache = 1 << 15,
|
||||||
kIsDeclaration = 1 << 16,
|
kIsDeclaration = 1 << 16,
|
||||||
kRequiresInstanceFieldsInitializer = 1 << 17,
|
kRequiresInstanceMembersInitializer = 1 << 17,
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------- Inputs to parsing and scope analysis -----------------------
|
//------------- Inputs to parsing and scope analysis -----------------------
|
||||||
|
@ -552,10 +552,10 @@ class ParserBase {
|
|||||||
has_name_static_property(false),
|
has_name_static_property(false),
|
||||||
has_static_computed_names(false),
|
has_static_computed_names(false),
|
||||||
has_static_class_fields(false),
|
has_static_class_fields(false),
|
||||||
has_instance_class_fields(false),
|
has_instance_members(false),
|
||||||
is_anonymous(false),
|
is_anonymous(false),
|
||||||
static_fields_scope(nullptr),
|
static_fields_scope(nullptr),
|
||||||
instance_fields_scope(nullptr),
|
instance_members_scope(nullptr),
|
||||||
computed_field_count(0) {}
|
computed_field_count(0) {}
|
||||||
Variable* variable;
|
Variable* variable;
|
||||||
ExpressionT extends;
|
ExpressionT extends;
|
||||||
@ -568,10 +568,10 @@ class ParserBase {
|
|||||||
bool has_name_static_property;
|
bool has_name_static_property;
|
||||||
bool has_static_computed_names;
|
bool has_static_computed_names;
|
||||||
bool has_static_class_fields;
|
bool has_static_class_fields;
|
||||||
bool has_instance_class_fields;
|
bool has_instance_members;
|
||||||
bool is_anonymous;
|
bool is_anonymous;
|
||||||
DeclarationScope* static_fields_scope;
|
DeclarationScope* static_fields_scope;
|
||||||
DeclarationScope* instance_fields_scope;
|
DeclarationScope* instance_members_scope;
|
||||||
int computed_field_count;
|
int computed_field_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1032,8 +1032,8 @@ class ParserBase {
|
|||||||
IdentifierT* property_name, bool has_extends, bool* is_computed_name,
|
IdentifierT* property_name, bool has_extends, bool* is_computed_name,
|
||||||
ClassLiteralProperty::Kind* property_kind, bool* is_static,
|
ClassLiteralProperty::Kind* property_kind, bool* is_static,
|
||||||
bool* is_private);
|
bool* is_private);
|
||||||
ExpressionT ParseClassFieldInitializer(ClassInfo* class_info, int beg_pos,
|
ExpressionT ParseMemberInitializer(ClassInfo* class_info, int beg_pos,
|
||||||
bool is_static);
|
bool is_static);
|
||||||
ObjectLiteralPropertyT ParseObjectPropertyDefinition(
|
ObjectLiteralPropertyT ParseObjectPropertyDefinition(
|
||||||
ObjectLiteralChecker* checker, bool* is_computed_name,
|
ObjectLiteralChecker* checker, bool* is_computed_name,
|
||||||
bool* is_rest_property);
|
bool* is_rest_property);
|
||||||
@ -1621,7 +1621,7 @@ ParserBase<Impl>::ParseIdentifierNameOrPrivateName() {
|
|||||||
name = impl()->GetSymbol();
|
name = impl()->GetSymbol();
|
||||||
auto key_proxy =
|
auto key_proxy =
|
||||||
impl()->ExpressionFromIdentifier(name, pos, InferName::kNo);
|
impl()->ExpressionFromIdentifier(name, pos, InferName::kNo);
|
||||||
key_proxy->set_is_private_field();
|
key_proxy->set_is_private_name();
|
||||||
key = key_proxy;
|
key = key_proxy;
|
||||||
} else {
|
} else {
|
||||||
name = ParseIdentifierName();
|
name = ParseIdentifierName();
|
||||||
@ -2211,8 +2211,8 @@ ParserBase<Impl>::ParseClassPropertyDefinition(
|
|||||||
if (!*is_computed_name) {
|
if (!*is_computed_name) {
|
||||||
checker->CheckClassFieldName(*is_static);
|
checker->CheckClassFieldName(*is_static);
|
||||||
}
|
}
|
||||||
ExpressionT initializer = ParseClassFieldInitializer(
|
ExpressionT initializer =
|
||||||
class_info, property_beg_pos, *is_static);
|
ParseMemberInitializer(class_info, property_beg_pos, *is_static);
|
||||||
ExpectSemicolon();
|
ExpectSemicolon();
|
||||||
ClassLiteralPropertyT result = factory()->NewClassLiteralProperty(
|
ClassLiteralPropertyT result = factory()->NewClassLiteralProperty(
|
||||||
name_expression, initializer, *property_kind, *is_static,
|
name_expression, initializer, *property_kind, *is_static,
|
||||||
@ -2306,16 +2306,15 @@ ParserBase<Impl>::ParseClassPropertyDefinition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Impl>
|
template <typename Impl>
|
||||||
typename ParserBase<Impl>::ExpressionT
|
typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseMemberInitializer(
|
||||||
ParserBase<Impl>::ParseClassFieldInitializer(ClassInfo* class_info, int beg_pos,
|
ClassInfo* class_info, int beg_pos, bool is_static) {
|
||||||
bool is_static) {
|
DeclarationScope* initializer_scope =
|
||||||
DeclarationScope* initializer_scope = is_static
|
is_static ? class_info->static_fields_scope
|
||||||
? class_info->static_fields_scope
|
: class_info->instance_members_scope;
|
||||||
: class_info->instance_fields_scope;
|
|
||||||
|
|
||||||
if (initializer_scope == nullptr) {
|
if (initializer_scope == nullptr) {
|
||||||
initializer_scope =
|
initializer_scope =
|
||||||
NewFunctionScope(FunctionKind::kClassFieldsInitializerFunction);
|
NewFunctionScope(FunctionKind::kClassMembersInitializerFunction);
|
||||||
// TODO(gsathya): Make scopes be non contiguous.
|
// TODO(gsathya): Make scopes be non contiguous.
|
||||||
initializer_scope->set_start_position(beg_pos);
|
initializer_scope->set_start_position(beg_pos);
|
||||||
initializer_scope->SetLanguageMode(LanguageMode::kStrict);
|
initializer_scope->SetLanguageMode(LanguageMode::kStrict);
|
||||||
@ -2344,8 +2343,8 @@ ParserBase<Impl>::ParseClassFieldInitializer(ClassInfo* class_info, int beg_pos,
|
|||||||
class_info->static_fields_scope = initializer_scope;
|
class_info->static_fields_scope = initializer_scope;
|
||||||
class_info->has_static_class_fields = true;
|
class_info->has_static_class_fields = true;
|
||||||
} else {
|
} else {
|
||||||
class_info->instance_fields_scope = initializer_scope;
|
class_info->instance_members_scope = initializer_scope;
|
||||||
class_info->has_instance_class_fields = true;
|
class_info->has_instance_members = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return initializer;
|
return initializer;
|
||||||
|
@ -868,8 +868,8 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
RETURN_IF_PARSE_ERROR;
|
RETURN_IF_PARSE_ERROR;
|
||||||
result->set_requires_instance_fields_initializer(
|
result->set_requires_instance_members_initializer(
|
||||||
info->requires_instance_fields_initializer());
|
info->requires_instance_members_initializer());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the target stack is empty.
|
// Make sure the target stack is empty.
|
||||||
@ -3140,9 +3140,8 @@ void Parser::DeclareClassProperty(const AstRawString* class_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (kind == ClassLiteralProperty::FIELD && is_private) {
|
if (kind == ClassLiteralProperty::FIELD && is_private) {
|
||||||
Variable* private_field_name_var =
|
Variable* private_name_var = CreateSyntheticContextVariable(property_name);
|
||||||
CreateSyntheticContextVariable(property_name);
|
property->set_private_name_var(private_name_var);
|
||||||
property->set_private_field_name_var(private_field_name_var);
|
|
||||||
class_info->properties->Add(property, zone());
|
class_info->properties->Add(property, zone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3151,11 +3150,11 @@ FunctionLiteral* Parser::CreateInitializerFunction(
|
|||||||
const char* name, DeclarationScope* scope,
|
const char* name, DeclarationScope* scope,
|
||||||
ZonePtrList<ClassLiteral::Property>* fields) {
|
ZonePtrList<ClassLiteral::Property>* fields) {
|
||||||
DCHECK_EQ(scope->function_kind(),
|
DCHECK_EQ(scope->function_kind(),
|
||||||
FunctionKind::kClassFieldsInitializerFunction);
|
FunctionKind::kClassMembersInitializerFunction);
|
||||||
// function() { .. class fields initializer .. }
|
// function() { .. class fields initializer .. }
|
||||||
ScopedPtrList<Statement> statements(pointer_buffer());
|
ScopedPtrList<Statement> statements(pointer_buffer());
|
||||||
InitializeClassFieldsStatement* static_fields =
|
InitializeClassMembersStatement* static_fields =
|
||||||
factory()->NewInitializeClassFieldsStatement(fields, kNoSourcePosition);
|
factory()->NewInitializeClassMembersStatement(fields, kNoSourcePosition);
|
||||||
statements.Add(static_fields);
|
statements.Add(static_fields);
|
||||||
return factory()->NewFunctionLiteral(
|
return factory()->NewFunctionLiteral(
|
||||||
ast_value_factory()->GetOneByteString(name), scope, statements, 0, 0, 0,
|
ast_value_factory()->GetOneByteString(name), scope, statements, 0, 0, 0,
|
||||||
@ -3200,18 +3199,18 @@ Expression* Parser::RewriteClassLiteral(Scope* block_scope,
|
|||||||
class_info->static_fields);
|
class_info->static_fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionLiteral* instance_fields_initializer_function = nullptr;
|
FunctionLiteral* instance_members_initializer_function = nullptr;
|
||||||
if (class_info->has_instance_class_fields) {
|
if (class_info->has_instance_members) {
|
||||||
instance_fields_initializer_function = CreateInitializerFunction(
|
instance_members_initializer_function = CreateInitializerFunction(
|
||||||
"<instance_fields_initializer>", class_info->instance_fields_scope,
|
"<instance_members_initializer>", class_info->instance_members_scope,
|
||||||
class_info->instance_fields);
|
class_info->instance_fields);
|
||||||
class_info->constructor->set_requires_instance_fields_initializer(true);
|
class_info->constructor->set_requires_instance_members_initializer(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassLiteral* class_literal = factory()->NewClassLiteral(
|
ClassLiteral* class_literal = factory()->NewClassLiteral(
|
||||||
block_scope, class_info->variable, class_info->extends,
|
block_scope, class_info->variable, class_info->extends,
|
||||||
class_info->constructor, class_info->properties,
|
class_info->constructor, class_info->properties,
|
||||||
static_fields_initializer, instance_fields_initializer_function, pos,
|
static_fields_initializer, instance_members_initializer_function, pos,
|
||||||
end_pos, class_info->has_name_static_property,
|
end_pos, class_info->has_name_static_property,
|
||||||
class_info->has_static_computed_names, class_info->is_anonymous);
|
class_info->has_static_computed_names, class_info->is_anonymous);
|
||||||
|
|
||||||
@ -3240,7 +3239,7 @@ bool Parser::IsPropertyWithPrivateFieldKey(Expression* expression) {
|
|||||||
if (!property->key()->IsVariableProxy()) return false;
|
if (!property->key()->IsVariableProxy()) return false;
|
||||||
VariableProxy* key = property->key()->AsVariableProxy();
|
VariableProxy* key = property->key()->AsVariableProxy();
|
||||||
|
|
||||||
return key->is_private_field();
|
return key->is_private_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::InsertShadowingVarBindingInitializers(Block* inner_block) {
|
void Parser::InsertShadowingVarBindingInitializers(Block* inner_block) {
|
||||||
|
@ -752,7 +752,7 @@ NOT_A_PATTERN(WithStatement)
|
|||||||
NOT_A_PATTERN(Yield)
|
NOT_A_PATTERN(Yield)
|
||||||
NOT_A_PATTERN(YieldStar)
|
NOT_A_PATTERN(YieldStar)
|
||||||
NOT_A_PATTERN(Await)
|
NOT_A_PATTERN(Await)
|
||||||
NOT_A_PATTERN(InitializeClassFieldsStatement)
|
NOT_A_PATTERN(InitializeClassMembersStatement)
|
||||||
|
|
||||||
#undef NOT_A_PATTERN
|
#undef NOT_A_PATTERN
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
@ -299,12 +299,12 @@ class PreParserExpression {
|
|||||||
// and PreParser.
|
// and PreParser.
|
||||||
PreParserExpression* operator->() { return this; }
|
PreParserExpression* operator->() { return this; }
|
||||||
|
|
||||||
void set_is_private_field() {
|
void set_is_private_name() {
|
||||||
if (variables_ != nullptr) {
|
if (variables_ != nullptr) {
|
||||||
DCHECK(IsIdentifier());
|
DCHECK(IsIdentifier());
|
||||||
DCHECK(AsIdentifier().IsPrivateName());
|
DCHECK(AsIdentifier().IsPrivateName());
|
||||||
DCHECK_EQ(1, variables_->LengthForTest());
|
DCHECK_EQ(1, variables_->LengthForTest());
|
||||||
variables_->first()->set_is_private_field();
|
variables_->first()->set_is_private_name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1233,7 +1233,7 @@ class PreParser : public ParserBase<PreParser> {
|
|||||||
if (class_info->has_static_class_fields) {
|
if (class_info->has_static_class_fields) {
|
||||||
GetNextFunctionLiteralId();
|
GetNextFunctionLiteralId();
|
||||||
}
|
}
|
||||||
if (class_info->has_instance_class_fields) {
|
if (class_info->has_instance_members) {
|
||||||
GetNextFunctionLiteralId();
|
GetNextFunctionLiteralId();
|
||||||
}
|
}
|
||||||
return PreParserExpression::Default();
|
return PreParserExpression::Default();
|
||||||
|
@ -337,8 +337,8 @@ void Processor::VisitDebuggerStatement(DebuggerStatement* node) {
|
|||||||
replacement_ = node;
|
replacement_ = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Processor::VisitInitializeClassFieldsStatement(
|
void Processor::VisitInitializeClassMembersStatement(
|
||||||
InitializeClassFieldsStatement* node) {
|
InitializeClassMembersStatement* node) {
|
||||||
replacement_ = node;
|
replacement_ = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
|
|||||||
if (is_found_out) *is_found_out = it.IsFound();
|
if (is_found_out) *is_found_out = it.IsFound();
|
||||||
|
|
||||||
if (!it.IsFound() && key->IsSymbol() &&
|
if (!it.IsFound() && key->IsSymbol() &&
|
||||||
Symbol::cast(*key)->is_private_field()) {
|
Symbol::cast(*key)->is_private_name()) {
|
||||||
THROW_NEW_ERROR(
|
THROW_NEW_ERROR(
|
||||||
isolate,
|
isolate,
|
||||||
NewTypeError(MessageTemplate::kInvalidPrivateFieldAccess, key, object),
|
NewTypeError(MessageTemplate::kInvalidPrivateFieldAccess, key, object),
|
||||||
@ -358,7 +358,7 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
|
|||||||
if (!success) return MaybeHandle<Object>();
|
if (!success) return MaybeHandle<Object>();
|
||||||
|
|
||||||
if (!it.IsFound() && key->IsSymbol() &&
|
if (!it.IsFound() && key->IsSymbol() &&
|
||||||
Symbol::cast(*key)->is_private_field()) {
|
Symbol::cast(*key)->is_private_name()) {
|
||||||
THROW_NEW_ERROR(
|
THROW_NEW_ERROR(
|
||||||
isolate,
|
isolate,
|
||||||
NewTypeError(MessageTemplate::kInvalidPrivateFieldAccess, key, object),
|
NewTypeError(MessageTemplate::kInvalidPrivateFieldAccess, key, object),
|
||||||
@ -1215,7 +1215,7 @@ RUNTIME_FUNCTION(Runtime_AddPrivateField) {
|
|||||||
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, o, 0);
|
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, o, 0);
|
||||||
CONVERT_ARG_HANDLE_CHECKED(Symbol, key, 1);
|
CONVERT_ARG_HANDLE_CHECKED(Symbol, key, 1);
|
||||||
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
|
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
|
||||||
DCHECK(key->is_private_field());
|
DCHECK(key->is_private_name());
|
||||||
|
|
||||||
LookupIterator it =
|
LookupIterator it =
|
||||||
LookupIterator::PropertyOrElement(isolate, o, key, LookupIterator::OWN);
|
LookupIterator::PropertyOrElement(isolate, o, key, LookupIterator::OWN);
|
||||||
|
@ -23,10 +23,10 @@ RUNTIME_FUNCTION(Runtime_CreatePrivateSymbol) {
|
|||||||
return *symbol;
|
return *symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
RUNTIME_FUNCTION(Runtime_CreatePrivateFieldSymbol) {
|
RUNTIME_FUNCTION(Runtime_CreatePrivateNameSymbol) {
|
||||||
HandleScope scope(isolate);
|
HandleScope scope(isolate);
|
||||||
DCHECK_EQ(0, args.length());
|
DCHECK_EQ(0, args.length());
|
||||||
Handle<Symbol> symbol = isolate->factory()->NewPrivateFieldSymbol();
|
Handle<Symbol> symbol = isolate->factory()->NewPrivateNameSymbol();
|
||||||
return *symbol;
|
return *symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ bool Runtime::NeedsExactContext(FunctionId id) {
|
|||||||
case Runtime::kAddPrivateField:
|
case Runtime::kAddPrivateField:
|
||||||
case Runtime::kCopyDataProperties:
|
case Runtime::kCopyDataProperties:
|
||||||
case Runtime::kCreateDataProperty:
|
case Runtime::kCreateDataProperty:
|
||||||
case Runtime::kCreatePrivateFieldSymbol:
|
case Runtime::kCreatePrivateNameSymbol:
|
||||||
case Runtime::kReThrow:
|
case Runtime::kReThrow:
|
||||||
case Runtime::kThrow:
|
case Runtime::kThrow:
|
||||||
case Runtime::kThrowApplyNonFunction:
|
case Runtime::kThrowApplyNonFunction:
|
||||||
|
@ -433,7 +433,7 @@ namespace internal {
|
|||||||
F(StringTrim, 2, 1)
|
F(StringTrim, 2, 1)
|
||||||
|
|
||||||
#define FOR_EACH_INTRINSIC_SYMBOL(F, I) \
|
#define FOR_EACH_INTRINSIC_SYMBOL(F, I) \
|
||||||
F(CreatePrivateFieldSymbol, 0, 1) \
|
F(CreatePrivateNameSymbol, 0, 1) \
|
||||||
F(CreatePrivateSymbol, -1 /* <= 1 */, 1) \
|
F(CreatePrivateSymbol, -1 /* <= 1 */, 1) \
|
||||||
F(SymbolDescriptiveString, 1, 1) \
|
F(SymbolDescriptiveString, 1, 1) \
|
||||||
F(SymbolIsPrivate, 1, 1)
|
F(SymbolIsPrivate, 1, 1)
|
||||||
|
@ -38,7 +38,7 @@ bytecodes: [
|
|||||||
B(Star), R(5),
|
B(Star), R(5),
|
||||||
B(LdaConstant), U8(1),
|
B(LdaConstant), U8(1),
|
||||||
B(Star), R(6),
|
B(Star), R(6),
|
||||||
B(CallRuntime), U16(Runtime::kCreatePrivateFieldSymbol), R(0), U8(0),
|
B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(0), U8(0),
|
||||||
B(StaCurrentContextSlot), U8(4),
|
B(StaCurrentContextSlot), U8(4),
|
||||||
B(Mov), R(5), R(7),
|
B(Mov), R(5), R(7),
|
||||||
B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(3),
|
B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(3),
|
||||||
@ -59,7 +59,7 @@ bytecodes: [
|
|||||||
B(Star), R(5),
|
B(Star), R(5),
|
||||||
B(LdaConstant), U8(6),
|
B(LdaConstant), U8(6),
|
||||||
B(Star), R(6),
|
B(Star), R(6),
|
||||||
B(CallRuntime), U16(Runtime::kCreatePrivateFieldSymbol), R(0), U8(0),
|
B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(0), U8(0),
|
||||||
B(StaCurrentContextSlot), U8(4),
|
B(StaCurrentContextSlot), U8(4),
|
||||||
B(Mov), R(5), R(7),
|
B(Mov), R(5), R(7),
|
||||||
B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(3),
|
B(CallRuntime), U16(Runtime::kDefineClass), R(6), U8(3),
|
||||||
@ -148,7 +148,7 @@ bytecodes: [
|
|||||||
B(Star), R(7),
|
B(Star), R(7),
|
||||||
B(LdaConstant), U8(1),
|
B(LdaConstant), U8(1),
|
||||||
B(Star), R(8),
|
B(Star), R(8),
|
||||||
B(CallRuntime), U16(Runtime::kCreatePrivateFieldSymbol), R(0), U8(0),
|
B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(0), U8(0),
|
||||||
B(StaCurrentContextSlot), U8(4),
|
B(StaCurrentContextSlot), U8(4),
|
||||||
B(Mov), R(7), R(9),
|
B(Mov), R(7), R(9),
|
||||||
B(Mov), R(13), R(10),
|
B(Mov), R(13), R(10),
|
||||||
@ -179,9 +179,9 @@ bytecodes: [
|
|||||||
B(Star), R(7),
|
B(Star), R(7),
|
||||||
B(LdaConstant), U8(8),
|
B(LdaConstant), U8(8),
|
||||||
B(Star), R(8),
|
B(Star), R(8),
|
||||||
B(CallRuntime), U16(Runtime::kCreatePrivateFieldSymbol), R(0), U8(0),
|
B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(0), U8(0),
|
||||||
B(StaCurrentContextSlot), U8(4),
|
B(StaCurrentContextSlot), U8(4),
|
||||||
B(CallRuntime), U16(Runtime::kCreatePrivateFieldSymbol), R(0), U8(0),
|
B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(0), U8(0),
|
||||||
B(StaCurrentContextSlot), U8(5),
|
B(StaCurrentContextSlot), U8(5),
|
||||||
B(CreateClosure), U8(12), U8(7), U8(2),
|
B(CreateClosure), U8(12), U8(7), U8(2),
|
||||||
B(Star), R(11),
|
B(Star), R(11),
|
||||||
@ -205,7 +205,7 @@ bytecodes: [
|
|||||||
B(Star), R(7),
|
B(Star), R(7),
|
||||||
B(LdaConstant), U8(16),
|
B(LdaConstant), U8(16),
|
||||||
B(Star), R(8),
|
B(Star), R(8),
|
||||||
B(CallRuntime), U16(Runtime::kCreatePrivateFieldSymbol), R(0), U8(0),
|
B(CallRuntime), U16(Runtime::kCreatePrivateNameSymbol), R(0), U8(0),
|
||||||
B(StaCurrentContextSlot), U8(4),
|
B(StaCurrentContextSlot), U8(4),
|
||||||
B(Mov), R(7), R(9),
|
B(Mov), R(7), R(9),
|
||||||
B(Mov), R(1), R(10),
|
B(Mov), R(1), R(10),
|
||||||
|
@ -187,7 +187,7 @@ Running test: testScopesPaused
|
|||||||
lineNumber : 12
|
lineNumber : 12
|
||||||
scriptId : <scriptId>
|
scriptId : <scriptId>
|
||||||
}
|
}
|
||||||
functionName : <instance_fields_initializer>
|
functionName : <instance_members_initializer>
|
||||||
location : {
|
location : {
|
||||||
columnNumber : 8
|
columnNumber : 8
|
||||||
lineNumber : 12
|
lineNumber : 12
|
||||||
@ -368,7 +368,7 @@ Running test: testScopesPaused
|
|||||||
lineNumber : 12
|
lineNumber : 12
|
||||||
scriptId : <scriptId>
|
scriptId : <scriptId>
|
||||||
}
|
}
|
||||||
functionName : <instance_fields_initializer>
|
functionName : <instance_members_initializer>
|
||||||
location : {
|
location : {
|
||||||
columnNumber : 14
|
columnNumber : 14
|
||||||
lineNumber : 13
|
lineNumber : 13
|
||||||
@ -549,7 +549,7 @@ Running test: testScopesPaused
|
|||||||
lineNumber : 12
|
lineNumber : 12
|
||||||
scriptId : <scriptId>
|
scriptId : <scriptId>
|
||||||
}
|
}
|
||||||
functionName : <instance_fields_initializer>
|
functionName : <instance_members_initializer>
|
||||||
location : {
|
location : {
|
||||||
columnNumber : 8
|
columnNumber : 8
|
||||||
lineNumber : 14
|
lineNumber : 14
|
||||||
@ -802,7 +802,7 @@ Running test: testScopesPaused
|
|||||||
lineNumber : 12
|
lineNumber : 12
|
||||||
scriptId : <scriptId>
|
scriptId : <scriptId>
|
||||||
}
|
}
|
||||||
functionName : <instance_fields_initializer>
|
functionName : <instance_members_initializer>
|
||||||
location : {
|
location : {
|
||||||
columnNumber : 8
|
columnNumber : 8
|
||||||
lineNumber : 14
|
lineNumber : 14
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
x = foo();
|
x = foo();
|
||||||
^
|
^
|
||||||
ReferenceError: foo is not defined
|
ReferenceError: foo is not defined
|
||||||
at X.<instance_fields_initializer> (*%(basename)s:8:7)
|
at X.<instance_members_initializer> (*%(basename)s:8:7)
|
||||||
at new X (*%(basename)s:7:1)
|
at new X (*%(basename)s:7:1)
|
||||||
at *%(basename)s:11:1
|
at *%(basename)s:11:1
|
@ -75,14 +75,14 @@ function testClassInstantiation() {
|
|||||||
|
|
||||||
// ReferenceError: FAIL is not defined
|
// ReferenceError: FAIL is not defined
|
||||||
// at thrower
|
// at thrower
|
||||||
// at X.<instance_fields_initializer>
|
// at X.<instance_members_initializer>
|
||||||
// at new X
|
// at new X
|
||||||
// at testClassInstantiation
|
// at testClassInstantiation
|
||||||
// at testTrace
|
// at testTrace
|
||||||
testTrace(
|
testTrace(
|
||||||
"during class instantiation",
|
"during class instantiation",
|
||||||
testClassInstantiation,
|
testClassInstantiation,
|
||||||
["thrower", "X.<instance_fields_initializer>", "new X"],
|
["thrower", "X.<instance_members_initializer>", "new X"],
|
||||||
["anonymous"]
|
["anonymous"]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -98,14 +98,14 @@ function testClassInstantiationWithSuper() {
|
|||||||
|
|
||||||
// ReferenceError: FAIL is not defined
|
// ReferenceError: FAIL is not defined
|
||||||
// at thrower
|
// at thrower
|
||||||
// at X.<instance_fields_initializer>
|
// at X.<instance_members_initializer>
|
||||||
// at new X
|
// at new X
|
||||||
// at testClassInstantiation
|
// at testClassInstantiation
|
||||||
// at testTrace
|
// at testTrace
|
||||||
testTrace(
|
testTrace(
|
||||||
"during class instantiation with super",
|
"during class instantiation with super",
|
||||||
testClassInstantiationWithSuper,
|
testClassInstantiationWithSuper,
|
||||||
["thrower", "X.<instance_fields_initializer>", "new X"],
|
["thrower", "X.<instance_members_initializer>", "new X"],
|
||||||
["Base", "anonymous"]
|
["Base", "anonymous"]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -124,14 +124,14 @@ function testClassInstantiationWithSuper2() {
|
|||||||
|
|
||||||
// ReferenceError: FAIL is not defined
|
// ReferenceError: FAIL is not defined
|
||||||
// at thrower
|
// at thrower
|
||||||
// at X.<instance_fields_initializer>
|
// at X.<instance_members_initializer>
|
||||||
// at new X
|
// at new X
|
||||||
// at testClassInstantiation
|
// at testClassInstantiation
|
||||||
// at testTrace
|
// at testTrace
|
||||||
testTrace(
|
testTrace(
|
||||||
"during class instantiation with super2",
|
"during class instantiation with super2",
|
||||||
testClassInstantiationWithSuper2,
|
testClassInstantiationWithSuper2,
|
||||||
["thrower", "X.<instance_fields_initializer>", "new X"],
|
["thrower", "X.<instance_members_initializer>", "new X"],
|
||||||
["Base", "anonymous"]
|
["Base", "anonymous"]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ function testClassInstantiationWithSuper3() {
|
|||||||
|
|
||||||
// ReferenceError: FAIL is not defined
|
// ReferenceError: FAIL is not defined
|
||||||
// at thrower
|
// at thrower
|
||||||
// at X.<instance_fields_initializer>
|
// at X.<instance_members_initializer>
|
||||||
// at new Base
|
// at new Base
|
||||||
// at new X
|
// at new X
|
||||||
// at testClassInstantiationWithSuper3
|
// at testClassInstantiationWithSuper3
|
||||||
@ -159,7 +159,7 @@ function testClassInstantiationWithSuper3() {
|
|||||||
testTrace(
|
testTrace(
|
||||||
"during class instantiation with super3",
|
"during class instantiation with super3",
|
||||||
testClassInstantiationWithSuper3,
|
testClassInstantiationWithSuper3,
|
||||||
["thrower", "X.<instance_fields_initializer>", "new Base", "new X"],
|
["thrower", "X.<instance_members_initializer>", "new Base", "new X"],
|
||||||
["anonymous"]
|
["anonymous"]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user