OLD | NEW |
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 #include "src/globals.h" |
10 | 10 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 static const char* Name(Value tok) { | 186 static const char* Name(Value tok) { |
187 DCHECK(tok < NUM_TOKENS); // tok is unsigned | 187 DCHECK(tok < NUM_TOKENS); // tok is unsigned |
188 return name_[tok]; | 188 return name_[tok]; |
189 } | 189 } |
190 | 190 |
191 // Predicates | 191 // Predicates |
192 static bool IsKeyword(Value tok) { | 192 static bool IsKeyword(Value tok) { |
193 return token_type[tok] == 'K'; | 193 return token_type[tok] == 'K'; |
194 } | 194 } |
195 | 195 |
196 static bool IsIdentifier(Value tok, StrictMode strict_mode, | 196 static bool IsIdentifier(Value tok, LanguageMode language_mode, |
197 bool is_generator) { | 197 bool is_generator) { |
198 switch (tok) { | 198 switch (tok) { |
199 case IDENTIFIER: | 199 case IDENTIFIER: |
200 return true; | 200 return true; |
201 case FUTURE_STRICT_RESERVED_WORD: | 201 case FUTURE_STRICT_RESERVED_WORD: |
202 case LET: | 202 case LET: |
203 case STATIC: | 203 case STATIC: |
204 return strict_mode == SLOPPY; | 204 return is_sloppy(language_mode); |
205 case YIELD: | 205 case YIELD: |
206 return !is_generator && strict_mode == SLOPPY; | 206 return !is_generator && is_sloppy(language_mode); |
207 default: | 207 default: |
208 return false; | 208 return false; |
209 } | 209 } |
210 UNREACHABLE(); | 210 UNREACHABLE(); |
211 return false; | 211 return false; |
212 } | 212 } |
213 | 213 |
214 static bool IsAssignmentOp(Value tok) { | 214 static bool IsAssignmentOp(Value tok) { |
215 return INIT_VAR <= tok && tok <= ASSIGN_MOD; | 215 return INIT_VAR <= tok && tok <= ASSIGN_MOD; |
216 } | 216 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 private: | 312 private: |
313 static const char* const name_[NUM_TOKENS]; | 313 static const char* const name_[NUM_TOKENS]; |
314 static const char* const string_[NUM_TOKENS]; | 314 static const char* const string_[NUM_TOKENS]; |
315 static const int8_t precedence_[NUM_TOKENS]; | 315 static const int8_t precedence_[NUM_TOKENS]; |
316 static const char token_type[NUM_TOKENS]; | 316 static const char token_type[NUM_TOKENS]; |
317 }; | 317 }; |
318 | 318 |
319 } } // namespace v8::internal | 319 } } // namespace v8::internal |
320 | 320 |
321 #endif // V8_TOKEN_H_ | 321 #endif // V8_TOKEN_H_ |
OLD | NEW |