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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 T(ELLIPSIS, "...", 0) \ | 43 T(ELLIPSIS, "...", 0) \ |
44 T(CONDITIONAL, "?", 3) \ | 44 T(CONDITIONAL, "?", 3) \ |
45 T(INC, "++", 0) \ | 45 T(INC, "++", 0) \ |
46 T(DEC, "--", 0) \ | 46 T(DEC, "--", 0) \ |
47 T(ARROW, "=>", 0) \ | 47 T(ARROW, "=>", 0) \ |
48 \ | 48 \ |
49 /* Assignment operators. */ \ | 49 /* Assignment operators. */ \ |
50 /* IsAssignmentOp() and Assignment::is_compound() relies on */ \ | 50 /* IsAssignmentOp() and Assignment::is_compound() relies on */ \ |
51 /* this block of enum values being contiguous and sorted in the */ \ | 51 /* this block of enum values being contiguous and sorted in the */ \ |
52 /* same order! */ \ | 52 /* same order! */ \ |
53 T(INIT_VAR, "=init_var", 2) /* AST-use only. */ \ | 53 T(INIT, "=init", 2) /* AST-use only. */ \ |
54 T(INIT_LET, "=init_let", 2) /* AST-use only. */ \ | |
55 T(INIT_CONST, "=init_const", 2) /* AST-use only. */ \ | |
56 T(INIT_CONST_LEGACY, "=init_const_legacy", 2) /* AST-use only. */ \ | |
57 T(ASSIGN, "=", 2) \ | 54 T(ASSIGN, "=", 2) \ |
58 T(ASSIGN_BIT_OR, "|=", 2) \ | 55 T(ASSIGN_BIT_OR, "|=", 2) \ |
59 T(ASSIGN_BIT_XOR, "^=", 2) \ | 56 T(ASSIGN_BIT_XOR, "^=", 2) \ |
60 T(ASSIGN_BIT_AND, "&=", 2) \ | 57 T(ASSIGN_BIT_AND, "&=", 2) \ |
61 T(ASSIGN_SHL, "<<=", 2) \ | 58 T(ASSIGN_SHL, "<<=", 2) \ |
62 T(ASSIGN_SAR, ">>=", 2) \ | 59 T(ASSIGN_SAR, ">>=", 2) \ |
63 T(ASSIGN_SHR, ">>>=", 2) \ | 60 T(ASSIGN_SHR, ">>>=", 2) \ |
64 T(ASSIGN_ADD, "+=", 2) \ | 61 T(ASSIGN_ADD, "+=", 2) \ |
65 T(ASSIGN_SUB, "-=", 2) \ | 62 T(ASSIGN_SUB, "-=", 2) \ |
66 T(ASSIGN_MUL, "*=", 2) \ | 63 T(ASSIGN_MUL, "*=", 2) \ |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 case YIELD: | 204 case YIELD: |
208 return !is_generator && is_sloppy(language_mode); | 205 return !is_generator && is_sloppy(language_mode); |
209 default: | 206 default: |
210 return false; | 207 return false; |
211 } | 208 } |
212 UNREACHABLE(); | 209 UNREACHABLE(); |
213 return false; | 210 return false; |
214 } | 211 } |
215 | 212 |
216 static bool IsAssignmentOp(Value tok) { | 213 static bool IsAssignmentOp(Value tok) { |
217 return INIT_VAR <= tok && tok <= ASSIGN_MOD; | 214 return INIT <= tok && tok <= ASSIGN_MOD; |
218 } | 215 } |
219 | 216 |
220 static bool IsBinaryOp(Value op) { | 217 static bool IsBinaryOp(Value op) { |
221 return COMMA <= op && op <= MOD; | 218 return COMMA <= op && op <= MOD; |
222 } | 219 } |
223 | 220 |
224 static bool IsTruncatingBinaryOp(Value op) { | 221 static bool IsTruncatingBinaryOp(Value op) { |
225 return BIT_OR <= op && op <= ROR; | 222 return BIT_OR <= op && op <= ROR; |
226 } | 223 } |
227 | 224 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 static const char* const name_[NUM_TOKENS]; | 312 static const char* const name_[NUM_TOKENS]; |
316 static const char* const string_[NUM_TOKENS]; | 313 static const char* const string_[NUM_TOKENS]; |
317 static const int8_t precedence_[NUM_TOKENS]; | 314 static const int8_t precedence_[NUM_TOKENS]; |
318 static const char token_type[NUM_TOKENS]; | 315 static const char token_type[NUM_TOKENS]; |
319 }; | 316 }; |
320 | 317 |
321 } // namespace internal | 318 } // namespace internal |
322 } // namespace v8 | 319 } // namespace v8 |
323 | 320 |
324 #endif // V8_TOKEN_H_ | 321 #endif // V8_TOKEN_H_ |
OLD | NEW |