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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 T(ASSIGN_BIT_XOR, "^=", 2) \ | 59 T(ASSIGN_BIT_XOR, "^=", 2) \ |
60 T(ASSIGN_BIT_AND, "&=", 2) \ | 60 T(ASSIGN_BIT_AND, "&=", 2) \ |
61 T(ASSIGN_SHL, "<<=", 2) \ | 61 T(ASSIGN_SHL, "<<=", 2) \ |
62 T(ASSIGN_SAR, ">>=", 2) \ | 62 T(ASSIGN_SAR, ">>=", 2) \ |
63 T(ASSIGN_SHR, ">>>=", 2) \ | 63 T(ASSIGN_SHR, ">>>=", 2) \ |
64 T(ASSIGN_ADD, "+=", 2) \ | 64 T(ASSIGN_ADD, "+=", 2) \ |
65 T(ASSIGN_SUB, "-=", 2) \ | 65 T(ASSIGN_SUB, "-=", 2) \ |
66 T(ASSIGN_MUL, "*=", 2) \ | 66 T(ASSIGN_MUL, "*=", 2) \ |
67 T(ASSIGN_DIV, "/=", 2) \ | 67 T(ASSIGN_DIV, "/=", 2) \ |
68 T(ASSIGN_MOD, "%=", 2) \ | 68 T(ASSIGN_MOD, "%=", 2) \ |
| 69 T(ASSIGN_EXP, "**=", 2) \ |
69 \ | 70 \ |
70 /* Binary operators sorted by precedence. */ \ | 71 /* Binary operators sorted by precedence. */ \ |
71 /* IsBinaryOp() relies on this block of enum values */ \ | 72 /* IsBinaryOp() relies on this block of enum values */ \ |
72 /* being contiguous and sorted in the same order! */ \ | 73 /* being contiguous and sorted in the same order! */ \ |
73 T(COMMA, ",", 1) \ | 74 T(COMMA, ",", 1) \ |
74 T(OR, "||", 4) \ | 75 T(OR, "||", 4) \ |
75 T(AND, "&&", 5) \ | 76 T(AND, "&&", 5) \ |
76 T(BIT_OR, "|", 6) \ | 77 T(BIT_OR, "|", 6) \ |
77 T(BIT_XOR, "^", 7) \ | 78 T(BIT_XOR, "^", 7) \ |
78 T(BIT_AND, "&", 8) \ | 79 T(BIT_AND, "&", 8) \ |
79 T(SHL, "<<", 11) \ | 80 T(SHL, "<<", 11) \ |
80 T(SAR, ">>", 11) \ | 81 T(SAR, ">>", 11) \ |
81 T(SHR, ">>>", 11) \ | 82 T(SHR, ">>>", 11) \ |
82 T(ROR, "rotate right", 11) /* only used by Crankshaft */ \ | 83 T(ROR, "rotate right", 11) /* only used by Crankshaft */ \ |
83 T(ADD, "+", 12) \ | 84 T(ADD, "+", 12) \ |
84 T(SUB, "-", 12) \ | 85 T(SUB, "-", 12) \ |
85 T(MUL, "*", 13) \ | 86 T(MUL, "*", 13) \ |
86 T(DIV, "/", 13) \ | 87 T(DIV, "/", 13) \ |
87 T(MOD, "%", 13) \ | 88 T(MOD, "%", 13) \ |
| 89 T(EXP, "**", 14) \ |
88 \ | 90 \ |
89 /* Compare operators sorted by precedence. */ \ | 91 /* Compare operators sorted by precedence. */ \ |
90 /* IsCompareOp() relies on this block of enum values */ \ | 92 /* IsCompareOp() relies on this block of enum values */ \ |
91 /* being contiguous and sorted in the same order! */ \ | 93 /* being contiguous and sorted in the same order! */ \ |
92 T(EQ, "==", 9) \ | 94 T(EQ, "==", 9) \ |
93 T(NE, "!=", 9) \ | 95 T(NE, "!=", 9) \ |
94 T(EQ_STRICT, "===", 9) \ | 96 T(EQ_STRICT, "===", 9) \ |
95 T(NE_STRICT, "!==", 9) \ | 97 T(NE_STRICT, "!==", 9) \ |
96 T(LT, "<", 10) \ | 98 T(LT, "<", 10) \ |
97 T(GT, ">", 10) \ | 99 T(GT, ">", 10) \ |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 case YIELD: | 207 case YIELD: |
206 return !is_generator && is_sloppy(language_mode); | 208 return !is_generator && is_sloppy(language_mode); |
207 default: | 209 default: |
208 return false; | 210 return false; |
209 } | 211 } |
210 UNREACHABLE(); | 212 UNREACHABLE(); |
211 return false; | 213 return false; |
212 } | 214 } |
213 | 215 |
214 static bool IsAssignmentOp(Value tok) { | 216 static bool IsAssignmentOp(Value tok) { |
215 return INIT_VAR <= tok && tok <= ASSIGN_MOD; | 217 return INIT_VAR <= tok && tok <= ASSIGN_EXP; |
216 } | 218 } |
217 | 219 |
218 static bool IsBinaryOp(Value op) { | 220 static bool IsBinaryOp(Value op) { |
219 return COMMA <= op && op <= MOD; | 221 return COMMA <= op && op <= EXP; |
220 } | 222 } |
221 | 223 |
222 static bool IsTruncatingBinaryOp(Value op) { | 224 static bool IsTruncatingBinaryOp(Value op) { |
223 return BIT_OR <= op && op <= ROR; | 225 return BIT_OR <= op && op <= ROR; |
224 } | 226 } |
225 | 227 |
226 static bool IsCompareOp(Value op) { | 228 static bool IsCompareOp(Value op) { |
227 return EQ <= op && op <= IN; | 229 return EQ <= op && op <= IN; |
228 } | 230 } |
229 | 231 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 private: | 314 private: |
313 static const char* const name_[NUM_TOKENS]; | 315 static const char* const name_[NUM_TOKENS]; |
314 static const char* const string_[NUM_TOKENS]; | 316 static const char* const string_[NUM_TOKENS]; |
315 static const int8_t precedence_[NUM_TOKENS]; | 317 static const int8_t precedence_[NUM_TOKENS]; |
316 static const char token_type[NUM_TOKENS]; | 318 static const char token_type[NUM_TOKENS]; |
317 }; | 319 }; |
318 | 320 |
319 } } // namespace v8::internal | 321 } } // namespace v8::internal |
320 | 322 |
321 #endif // V8_TOKEN_H_ | 323 #endif // V8_TOKEN_H_ |
OLD | NEW |