Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/parsing/preparser.h

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Check for 'name' properties at parse-time Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PREPARSER_H 5 #ifndef V8_PARSING_PREPARSER_H
6 #define V8_PARSING_PREPARSER_H 6 #define V8_PARSING_PREPARSER_H
7 7
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/parsing/parser-base.h" 9 #include "src/parsing/parser-base.h"
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 static PreParserIdentifier Enum() { 61 static PreParserIdentifier Enum() {
62 return PreParserIdentifier(kEnumIdentifier); 62 return PreParserIdentifier(kEnumIdentifier);
63 } 63 }
64 static PreParserIdentifier Await() { 64 static PreParserIdentifier Await() {
65 return PreParserIdentifier(kAwaitIdentifier); 65 return PreParserIdentifier(kAwaitIdentifier);
66 } 66 }
67 static PreParserIdentifier Async() { 67 static PreParserIdentifier Async() {
68 return PreParserIdentifier(kAsyncIdentifier); 68 return PreParserIdentifier(kAsyncIdentifier);
69 } 69 }
70 static PreParserIdentifier Name() {
71 return PreParserIdentifier(kNameIdentifier);
72 }
70 bool IsEmpty() const { return type_ == kEmptyIdentifier; } 73 bool IsEmpty() const { return type_ == kEmptyIdentifier; }
71 bool IsEval() const { return type_ == kEvalIdentifier; } 74 bool IsEval() const { return type_ == kEvalIdentifier; }
72 bool IsArguments() const { return type_ == kArgumentsIdentifier; } 75 bool IsArguments() const { return type_ == kArgumentsIdentifier; }
73 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); } 76 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); }
74 bool IsUndefined() const { return type_ == kUndefinedIdentifier; } 77 bool IsUndefined() const { return type_ == kUndefinedIdentifier; }
75 bool IsLet() const { return type_ == kLetIdentifier; } 78 bool IsLet() const { return type_ == kLetIdentifier; }
76 bool IsStatic() const { return type_ == kStaticIdentifier; } 79 bool IsStatic() const { return type_ == kStaticIdentifier; }
77 bool IsYield() const { return type_ == kYieldIdentifier; } 80 bool IsYield() const { return type_ == kYieldIdentifier; }
78 bool IsPrototype() const { return type_ == kPrototypeIdentifier; } 81 bool IsPrototype() const { return type_ == kPrototypeIdentifier; }
79 bool IsConstructor() const { return type_ == kConstructorIdentifier; } 82 bool IsConstructor() const { return type_ == kConstructorIdentifier; }
80 bool IsEnum() const { return type_ == kEnumIdentifier; } 83 bool IsEnum() const { return type_ == kEnumIdentifier; }
81 bool IsAwait() const { return type_ == kAwaitIdentifier; } 84 bool IsAwait() const { return type_ == kAwaitIdentifier; }
85 bool IsName() const { return type_ == kNameIdentifier; }
82 bool IsFutureStrictReserved() const { 86 bool IsFutureStrictReserved() const {
83 return type_ == kFutureStrictReservedIdentifier || 87 return type_ == kFutureStrictReservedIdentifier ||
84 type_ == kLetIdentifier || type_ == kStaticIdentifier || 88 type_ == kLetIdentifier || type_ == kStaticIdentifier ||
85 type_ == kYieldIdentifier; 89 type_ == kYieldIdentifier;
86 } 90 }
87 91
88 // Allow identifier->name()[->length()] to work. The preparser 92 // Allow identifier->name()[->length()] to work. The preparser
89 // does not need the actual positions/lengths of the identifiers. 93 // does not need the actual positions/lengths of the identifiers.
90 const PreParserIdentifier* operator->() const { return this; } 94 const PreParserIdentifier* operator->() const { return this; }
91 const PreParserIdentifier raw_name() const { return *this; } 95 const PreParserIdentifier raw_name() const { return *this; }
(...skipping 10 matching lines...) Expand all
102 kLetIdentifier, 106 kLetIdentifier,
103 kStaticIdentifier, 107 kStaticIdentifier,
104 kYieldIdentifier, 108 kYieldIdentifier,
105 kEvalIdentifier, 109 kEvalIdentifier,
106 kArgumentsIdentifier, 110 kArgumentsIdentifier,
107 kUndefinedIdentifier, 111 kUndefinedIdentifier,
108 kPrototypeIdentifier, 112 kPrototypeIdentifier,
109 kConstructorIdentifier, 113 kConstructorIdentifier,
110 kEnumIdentifier, 114 kEnumIdentifier,
111 kAwaitIdentifier, 115 kAwaitIdentifier,
112 kAsyncIdentifier 116 kAsyncIdentifier,
117 kNameIdentifier
113 }; 118 };
114 119
115 explicit PreParserIdentifier(Type type) : type_(type), string_(nullptr) {} 120 explicit PreParserIdentifier(Type type) : type_(type), string_(nullptr) {}
116 Type type_; 121 Type type_;
117 // Only non-nullptr when PreParser.track_unresolved_variables_ is true. 122 // Only non-nullptr when PreParser.track_unresolved_variables_ is true.
118 const AstRawString* string_; 123 const AstRawString* string_;
119 friend class PreParserExpression; 124 friend class PreParserExpression;
120 friend class PreParser; 125 friend class PreParser;
121 friend class PreParserFactory; 126 friend class PreParserFactory;
122 }; 127 };
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 } 1129 }
1125 1130
1126 V8_INLINE bool IsPrototype(PreParserIdentifier identifier) const { 1131 V8_INLINE bool IsPrototype(PreParserIdentifier identifier) const {
1127 return identifier.IsPrototype(); 1132 return identifier.IsPrototype();
1128 } 1133 }
1129 1134
1130 V8_INLINE bool IsConstructor(PreParserIdentifier identifier) const { 1135 V8_INLINE bool IsConstructor(PreParserIdentifier identifier) const {
1131 return identifier.IsConstructor(); 1136 return identifier.IsConstructor();
1132 } 1137 }
1133 1138
1139 V8_INLINE bool IsName(PreParserIdentifier identifier) const {
1140 return identifier.IsName();
1141 }
1142
1134 V8_INLINE bool IsDirectEvalCall(PreParserExpression expression) const { 1143 V8_INLINE bool IsDirectEvalCall(PreParserExpression expression) const {
1135 return expression.IsDirectEvalCall(); 1144 return expression.IsDirectEvalCall();
1136 } 1145 }
1137 1146
1138 V8_INLINE static bool IsBoilerplateProperty(PreParserExpression property) { 1147 V8_INLINE static bool IsBoilerplateProperty(PreParserExpression property) {
1139 // PreParser doesn't count boilerplate properties. 1148 // PreParser doesn't count boilerplate properties.
1140 return false; 1149 return false;
1141 } 1150 }
1142 1151
1143 V8_INLINE bool IsNative(PreParserExpression expr) const { 1152 V8_INLINE bool IsNative(PreParserExpression expr) const {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 function_state_->NextMaterializedLiteralIndex(); 1549 function_state_->NextMaterializedLiteralIndex();
1541 function_state_->NextMaterializedLiteralIndex(); 1550 function_state_->NextMaterializedLiteralIndex();
1542 } 1551 }
1543 return EmptyExpression(); 1552 return EmptyExpression();
1544 } 1553 }
1545 1554
1546 } // namespace internal 1555 } // namespace internal
1547 } // namespace v8 1556 } // namespace v8
1548 1557
1549 #endif // V8_PARSING_PREPARSER_H 1558 #endif // V8_PARSING_PREPARSER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698