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

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

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Rebase 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 #include "src/parsing/preparse-data.h" 10 #include "src/parsing/preparse-data.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 static PreParserIdentifier Enum() { 62 static PreParserIdentifier Enum() {
63 return PreParserIdentifier(kEnumIdentifier); 63 return PreParserIdentifier(kEnumIdentifier);
64 } 64 }
65 static PreParserIdentifier Await() { 65 static PreParserIdentifier Await() {
66 return PreParserIdentifier(kAwaitIdentifier); 66 return PreParserIdentifier(kAwaitIdentifier);
67 } 67 }
68 static PreParserIdentifier Async() { 68 static PreParserIdentifier Async() {
69 return PreParserIdentifier(kAsyncIdentifier); 69 return PreParserIdentifier(kAsyncIdentifier);
70 } 70 }
71 static PreParserIdentifier Name() {
72 return PreParserIdentifier(kNameIdentifier);
73 }
71 bool IsEmpty() const { return type_ == kEmptyIdentifier; } 74 bool IsEmpty() const { return type_ == kEmptyIdentifier; }
72 bool IsEval() const { return type_ == kEvalIdentifier; } 75 bool IsEval() const { return type_ == kEvalIdentifier; }
73 bool IsArguments() const { return type_ == kArgumentsIdentifier; } 76 bool IsArguments() const { return type_ == kArgumentsIdentifier; }
74 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); } 77 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); }
75 bool IsUndefined() const { return type_ == kUndefinedIdentifier; } 78 bool IsUndefined() const { return type_ == kUndefinedIdentifier; }
76 bool IsLet() const { return type_ == kLetIdentifier; } 79 bool IsLet() const { return type_ == kLetIdentifier; }
77 bool IsStatic() const { return type_ == kStaticIdentifier; } 80 bool IsStatic() const { return type_ == kStaticIdentifier; }
78 bool IsYield() const { return type_ == kYieldIdentifier; } 81 bool IsYield() const { return type_ == kYieldIdentifier; }
79 bool IsPrototype() const { return type_ == kPrototypeIdentifier; } 82 bool IsPrototype() const { return type_ == kPrototypeIdentifier; }
80 bool IsConstructor() const { return type_ == kConstructorIdentifier; } 83 bool IsConstructor() const { return type_ == kConstructorIdentifier; }
81 bool IsEnum() const { return type_ == kEnumIdentifier; } 84 bool IsEnum() const { return type_ == kEnumIdentifier; }
82 bool IsAwait() const { return type_ == kAwaitIdentifier; } 85 bool IsAwait() const { return type_ == kAwaitIdentifier; }
86 bool IsName() const { return type_ == kNameIdentifier; }
83 87
84 // Allow identifier->name()[->length()] to work. The preparser 88 // Allow identifier->name()[->length()] to work. The preparser
85 // does not need the actual positions/lengths of the identifiers. 89 // does not need the actual positions/lengths of the identifiers.
86 const PreParserIdentifier* operator->() const { return this; } 90 const PreParserIdentifier* operator->() const { return this; }
87 const PreParserIdentifier raw_name() const { return *this; } 91 const PreParserIdentifier raw_name() const { return *this; }
88 92
89 int position() const { return 0; } 93 int position() const { return 0; }
90 int length() const { return 0; } 94 int length() const { return 0; }
91 95
92 private: 96 private:
93 enum Type { 97 enum Type {
94 kEmptyIdentifier, 98 kEmptyIdentifier,
95 kUnknownIdentifier, 99 kUnknownIdentifier,
96 kFutureReservedIdentifier, 100 kFutureReservedIdentifier,
97 kFutureStrictReservedIdentifier, 101 kFutureStrictReservedIdentifier,
98 kLetIdentifier, 102 kLetIdentifier,
99 kStaticIdentifier, 103 kStaticIdentifier,
100 kYieldIdentifier, 104 kYieldIdentifier,
101 kEvalIdentifier, 105 kEvalIdentifier,
102 kArgumentsIdentifier, 106 kArgumentsIdentifier,
103 kUndefinedIdentifier, 107 kUndefinedIdentifier,
104 kPrototypeIdentifier, 108 kPrototypeIdentifier,
105 kConstructorIdentifier, 109 kConstructorIdentifier,
106 kEnumIdentifier, 110 kEnumIdentifier,
107 kAwaitIdentifier, 111 kAwaitIdentifier,
108 kAsyncIdentifier 112 kAsyncIdentifier,
113 kNameIdentifier
109 }; 114 };
110 115
111 explicit PreParserIdentifier(Type type) : type_(type), string_(nullptr) {} 116 explicit PreParserIdentifier(Type type) : type_(type), string_(nullptr) {}
112 Type type_; 117 Type type_;
113 // Only non-nullptr when PreParser.track_unresolved_variables_ is true. 118 // Only non-nullptr when PreParser.track_unresolved_variables_ is true.
114 const AstRawString* string_; 119 const AstRawString* string_;
115 friend class PreParserExpression; 120 friend class PreParserExpression;
116 friend class PreParser; 121 friend class PreParser;
117 friend class PreParserFactory; 122 friend class PreParserFactory;
118 }; 123 };
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 } 1140 }
1136 1141
1137 V8_INLINE bool IsPrototype(PreParserIdentifier identifier) const { 1142 V8_INLINE bool IsPrototype(PreParserIdentifier identifier) const {
1138 return identifier.IsPrototype(); 1143 return identifier.IsPrototype();
1139 } 1144 }
1140 1145
1141 V8_INLINE bool IsConstructor(PreParserIdentifier identifier) const { 1146 V8_INLINE bool IsConstructor(PreParserIdentifier identifier) const {
1142 return identifier.IsConstructor(); 1147 return identifier.IsConstructor();
1143 } 1148 }
1144 1149
1150 V8_INLINE bool IsName(PreParserIdentifier identifier) const {
1151 return identifier.IsName();
1152 }
1153
1145 V8_INLINE static bool IsBoilerplateProperty(PreParserExpression property) { 1154 V8_INLINE static bool IsBoilerplateProperty(PreParserExpression property) {
1146 // PreParser doesn't count boilerplate properties. 1155 // PreParser doesn't count boilerplate properties.
1147 return false; 1156 return false;
1148 } 1157 }
1149 1158
1150 V8_INLINE bool IsNative(PreParserExpression expr) const { 1159 V8_INLINE bool IsNative(PreParserExpression expr) const {
1151 // Preparsing is disabled for extensions (because the extension 1160 // Preparsing is disabled for extensions (because the extension
1152 // details aren't passed to lazily compiled functions), so we 1161 // details aren't passed to lazily compiled functions), so we
1153 // don't accept "native function" in the preparser and there is 1162 // don't accept "native function" in the preparser and there is
1154 // no need to keep track of "native". 1163 // no need to keep track of "native".
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 function_state_->NextMaterializedLiteralIndex(); 1557 function_state_->NextMaterializedLiteralIndex();
1549 function_state_->NextMaterializedLiteralIndex(); 1558 function_state_->NextMaterializedLiteralIndex();
1550 } 1559 }
1551 return EmptyExpression(); 1560 return EmptyExpression();
1552 } 1561 }
1553 1562
1554 } // namespace internal 1563 } // namespace internal
1555 } // namespace v8 1564 } // namespace v8
1556 1565
1557 #endif // V8_PARSING_PREPARSER_H 1566 #endif // V8_PARSING_PREPARSER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698