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

Side by Side Diff: src/token.h

Issue 584993002: ES6: Implement object literal property shorthand (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: git rebase Created 6 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.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_TOKEN_H_ 5 #ifndef V8_TOKEN_H_
6 #define V8_TOKEN_H_ 6 #define V8_TOKEN_H_
7 7
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/globals.h"
9 10
10 namespace v8 { 11 namespace v8 {
11 namespace internal { 12 namespace internal {
12 13
13 // TOKEN_LIST takes a list of 3 macros M, all of which satisfy the 14 // TOKEN_LIST takes a list of 3 macros M, all of which satisfy the
14 // same signature M(name, string, precedence), where name is the 15 // same signature M(name, string, precedence), where name is the
15 // symbolic token name, string is the corresponding syntactic symbol 16 // symbolic token name, string is the corresponding syntactic symbol
16 // (or NULL, for literals), and precedence is the precedence (or 0). 17 // (or NULL, for literals), and precedence is the precedence (or 0).
17 // The parameters are invoked for token categories as follows: 18 // The parameters are invoked for token categories as follows:
18 // 19 //
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 static const char* Name(Value tok) { 181 static const char* Name(Value tok) {
181 DCHECK(tok < NUM_TOKENS); // tok is unsigned 182 DCHECK(tok < NUM_TOKENS); // tok is unsigned
182 return name_[tok]; 183 return name_[tok];
183 } 184 }
184 185
185 // Predicates 186 // Predicates
186 static bool IsKeyword(Value tok) { 187 static bool IsKeyword(Value tok) {
187 return token_type[tok] == 'K'; 188 return token_type[tok] == 'K';
188 } 189 }
189 190
191 static bool IsIdentifier(Value tok, StrictMode strict_mode,
192 bool is_generator) {
193 switch (tok) {
194 case IDENTIFIER:
195 return true;
196 case FUTURE_STRICT_RESERVED_WORD:
197 case LET:
198 case STATIC:
199 return strict_mode == SLOPPY;
200 case YIELD:
201 return !is_generator && strict_mode == SLOPPY;
202 default:
203 return false;
204 }
205 UNREACHABLE();
206 return false;
207 }
208
190 static bool IsAssignmentOp(Value tok) { 209 static bool IsAssignmentOp(Value tok) {
191 return INIT_VAR <= tok && tok <= ASSIGN_MOD; 210 return INIT_VAR <= tok && tok <= ASSIGN_MOD;
192 } 211 }
193 212
194 static bool IsBinaryOp(Value op) { 213 static bool IsBinaryOp(Value op) {
195 return COMMA <= op && op <= MOD; 214 return COMMA <= op && op <= MOD;
196 } 215 }
197 216
198 static bool IsTruncatingBinaryOp(Value op) { 217 static bool IsTruncatingBinaryOp(Value op) {
199 return BIT_OR <= op && op <= ROR; 218 return BIT_OR <= op && op <= ROR;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 private: 307 private:
289 static const char* const name_[NUM_TOKENS]; 308 static const char* const name_[NUM_TOKENS];
290 static const char* const string_[NUM_TOKENS]; 309 static const char* const string_[NUM_TOKENS];
291 static const int8_t precedence_[NUM_TOKENS]; 310 static const int8_t precedence_[NUM_TOKENS];
292 static const char token_type[NUM_TOKENS]; 311 static const char token_type[NUM_TOKENS];
293 }; 312 };
294 313
295 } } // namespace v8::internal 314 } } // namespace v8::internal
296 315
297 #endif // V8_TOKEN_H_ 316 #endif // V8_TOKEN_H_
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698