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_PARSING_TOKEN_H_ | 5 #ifndef V8_PARSING_TOKEN_H_ |
6 #define V8_PARSING_TOKEN_H_ | 6 #define V8_PARSING_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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 case LT: return GT; | 273 case LT: return GT; |
274 case GT: return LT; | 274 case GT: return LT; |
275 case LTE: return GTE; | 275 case LTE: return GTE; |
276 case GTE: return LTE; | 276 case GTE: return LTE; |
277 default: | 277 default: |
278 UNREACHABLE(); | 278 UNREACHABLE(); |
279 return op; | 279 return op; |
280 } | 280 } |
281 } | 281 } |
282 | 282 |
| 283 static bool EvalComparison(Value op, double op1, double op2) { |
| 284 DCHECK(IsArithmeticCompareOp(op)); |
| 285 switch (op) { |
| 286 case Token::EQ: |
| 287 case Token::EQ_STRICT: return (op1 == op2); |
| 288 case Token::NE: return (op1 != op2); |
| 289 case Token::LT: return (op1 < op2); |
| 290 case Token::GT: return (op1 > op2); |
| 291 case Token::LTE: return (op1 <= op2); |
| 292 case Token::GTE: return (op1 >= op2); |
| 293 default: |
| 294 UNREACHABLE(); |
| 295 return false; |
| 296 } |
| 297 } |
| 298 |
283 static bool IsBitOp(Value op) { | 299 static bool IsBitOp(Value op) { |
284 return (BIT_OR <= op && op <= SHR) || op == BIT_NOT; | 300 return (BIT_OR <= op && op <= SHR) || op == BIT_NOT; |
285 } | 301 } |
286 | 302 |
287 static bool IsUnaryOp(Value op) { | 303 static bool IsUnaryOp(Value op) { |
288 return (NOT <= op && op <= VOID) || op == ADD || op == SUB; | 304 return (NOT <= op && op <= VOID) || op == ADD || op == SUB; |
289 } | 305 } |
290 | 306 |
291 static bool IsCountOp(Value op) { | 307 static bool IsCountOp(Value op) { |
292 return op == INC || op == DEC; | 308 return op == INC || op == DEC; |
(...skipping 22 matching lines...) Expand all Loading... |
315 static const char* const name_[NUM_TOKENS]; | 331 static const char* const name_[NUM_TOKENS]; |
316 static const char* const string_[NUM_TOKENS]; | 332 static const char* const string_[NUM_TOKENS]; |
317 static const int8_t precedence_[NUM_TOKENS]; | 333 static const int8_t precedence_[NUM_TOKENS]; |
318 static const char token_type[NUM_TOKENS]; | 334 static const char token_type[NUM_TOKENS]; |
319 }; | 335 }; |
320 | 336 |
321 } // namespace internal | 337 } // namespace internal |
322 } // namespace v8 | 338 } // namespace v8 |
323 | 339 |
324 #endif // V8_PARSING_TOKEN_H_ | 340 #endif // V8_PARSING_TOKEN_H_ |
OLD | NEW |