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

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

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: rebased 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
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 } 1150 }
1146 1151
1147 V8_INLINE bool IsPrototype(PreParserIdentifier identifier) const { 1152 V8_INLINE bool IsPrototype(PreParserIdentifier identifier) const {
1148 return identifier.IsPrototype(); 1153 return identifier.IsPrototype();
1149 } 1154 }
1150 1155
1151 V8_INLINE bool IsConstructor(PreParserIdentifier identifier) const { 1156 V8_INLINE bool IsConstructor(PreParserIdentifier identifier) const {
1152 return identifier.IsConstructor(); 1157 return identifier.IsConstructor();
1153 } 1158 }
1154 1159
1160 V8_INLINE bool IsName(PreParserIdentifier identifier) const {
1161 return identifier.IsName();
1162 }
1163
1155 V8_INLINE static bool IsBoilerplateProperty(PreParserExpression property) { 1164 V8_INLINE static bool IsBoilerplateProperty(PreParserExpression property) {
1156 // PreParser doesn't count boilerplate properties. 1165 // PreParser doesn't count boilerplate properties.
1157 return false; 1166 return false;
1158 } 1167 }
1159 1168
1160 V8_INLINE bool IsNative(PreParserExpression expr) const { 1169 V8_INLINE bool IsNative(PreParserExpression expr) const {
1161 // Preparsing is disabled for extensions (because the extension 1170 // Preparsing is disabled for extensions (because the extension
1162 // details aren't passed to lazily compiled functions), so we 1171 // details aren't passed to lazily compiled functions), so we
1163 // don't accept "native function" in the preparser and there is 1172 // don't accept "native function" in the preparser and there is
1164 // no need to keep track of "native". 1173 // no need to keep track of "native".
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 function_state_->NextMaterializedLiteralIndex(); 1585 function_state_->NextMaterializedLiteralIndex();
1577 function_state_->NextMaterializedLiteralIndex(); 1586 function_state_->NextMaterializedLiteralIndex();
1578 } 1587 }
1579 return EmptyExpression(); 1588 return EmptyExpression();
1580 } 1589 }
1581 1590
1582 } // namespace internal 1591 } // namespace internal
1583 } // namespace v8 1592 } // namespace v8
1584 1593
1585 #endif // V8_PARSING_PREPARSER_H 1594 #endif // V8_PARSING_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698