| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } | 231 } |
| 232 | 232 |
| 233 static bool IsBinaryOp(Value op) { | 233 static bool IsBinaryOp(Value op) { |
| 234 return COMMA <= op && op <= MOD; | 234 return COMMA <= op && op <= MOD; |
| 235 } | 235 } |
| 236 | 236 |
| 237 static bool IsCompareOp(Value op) { | 237 static bool IsCompareOp(Value op) { |
| 238 return EQ <= op && op <= IN; | 238 return EQ <= op && op <= IN; |
| 239 } | 239 } |
| 240 | 240 |
| 241 static bool IsOrderedCompareOp(Value op) { |
| 242 return op == LT || op == LTE || op == GT || op == GTE; |
| 243 } |
| 244 |
| 245 static Value NegateCompareOp(Value op) { |
| 246 ASSERT(IsCompareOp(op)); |
| 247 switch (op) { |
| 248 case EQ: return NE; |
| 249 case NE: return EQ; |
| 250 case EQ_STRICT: return NE_STRICT; |
| 251 case LT: return GTE; |
| 252 case GT: return LTE; |
| 253 case LTE: return GT; |
| 254 case GTE: return LT; |
| 255 default: |
| 256 return op; |
| 257 } |
| 258 } |
| 259 |
| 260 static Value InvertCompareOp(Value op) { |
| 261 ASSERT(IsCompareOp(op)); |
| 262 switch (op) { |
| 263 case EQ: return NE; |
| 264 case NE: return EQ; |
| 265 case EQ_STRICT: return NE_STRICT; |
| 266 case LT: return GT; |
| 267 case GT: return LT; |
| 268 case LTE: return GTE; |
| 269 case GTE: return LTE; |
| 270 default: |
| 271 return op; |
| 272 } |
| 273 } |
| 274 |
| 241 static bool IsBitOp(Value op) { | 275 static bool IsBitOp(Value op) { |
| 242 return (BIT_OR <= op && op <= SHR) || op == BIT_NOT; | 276 return (BIT_OR <= op && op <= SHR) || op == BIT_NOT; |
| 243 } | 277 } |
| 244 | 278 |
| 245 static bool IsUnaryOp(Value op) { | 279 static bool IsUnaryOp(Value op) { |
| 246 return (NOT <= op && op <= VOID) || op == ADD || op == SUB; | 280 return (NOT <= op && op <= VOID) || op == ADD || op == SUB; |
| 247 } | 281 } |
| 248 | 282 |
| 249 static bool IsCountOp(Value op) { | 283 static bool IsCountOp(Value op) { |
| 250 return op == INC || op == DEC; | 284 return op == INC || op == DEC; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 272 private: | 306 private: |
| 273 static const char* const name_[NUM_TOKENS]; | 307 static const char* const name_[NUM_TOKENS]; |
| 274 static const char* const string_[NUM_TOKENS]; | 308 static const char* const string_[NUM_TOKENS]; |
| 275 static const int8_t precedence_[NUM_TOKENS]; | 309 static const int8_t precedence_[NUM_TOKENS]; |
| 276 static const char token_type[NUM_TOKENS]; | 310 static const char token_type[NUM_TOKENS]; |
| 277 }; | 311 }; |
| 278 | 312 |
| 279 } } // namespace v8::internal | 313 } } // namespace v8::internal |
| 280 | 314 |
| 281 #endif // V8_TOKEN_H_ | 315 #endif // V8_TOKEN_H_ |
| OLD | NEW |