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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 } | 241 } |
242 | 242 |
243 static bool IsUnaryOp(Value op) { | 243 static bool IsUnaryOp(Value op) { |
244 return (NOT <= op && op <= VOID) || op == ADD || op == SUB; | 244 return (NOT <= op && op <= VOID) || op == ADD || op == SUB; |
245 } | 245 } |
246 | 246 |
247 static bool IsCountOp(Value op) { | 247 static bool IsCountOp(Value op) { |
248 return op == INC || op == DEC; | 248 return op == INC || op == DEC; |
249 } | 249 } |
250 | 250 |
| 251 static bool IsShiftOp(Value op) { |
| 252 return (SHL <= op) && (op <= SHR); |
| 253 } |
| 254 |
251 // Returns a string corresponding to the JS token string | 255 // Returns a string corresponding to the JS token string |
252 // (.e., "<" for the token LT) or NULL if the token doesn't | 256 // (.e., "<" for the token LT) or NULL if the token doesn't |
253 // have a (unique) string (e.g. an IDENTIFIER). | 257 // have a (unique) string (e.g. an IDENTIFIER). |
254 static const char* String(Value tok) { | 258 static const char* String(Value tok) { |
255 ASSERT(0 <= tok && tok < NUM_TOKENS); | 259 ASSERT(0 <= tok && tok < NUM_TOKENS); |
256 return string_[tok]; | 260 return string_[tok]; |
257 } | 261 } |
258 | 262 |
259 // Returns the precedence > 0 for binary and compare | 263 // Returns the precedence > 0 for binary and compare |
260 // operators; returns 0 otherwise. | 264 // operators; returns 0 otherwise. |
261 static int Precedence(Value tok) { | 265 static int Precedence(Value tok) { |
262 ASSERT(0 <= tok && tok < NUM_TOKENS); | 266 ASSERT(0 <= tok && tok < NUM_TOKENS); |
263 return precedence_[tok]; | 267 return precedence_[tok]; |
264 } | 268 } |
265 | 269 |
266 private: | 270 private: |
267 static const char* name_[NUM_TOKENS]; | 271 static const char* name_[NUM_TOKENS]; |
268 static const char* string_[NUM_TOKENS]; | 272 static const char* string_[NUM_TOKENS]; |
269 static int8_t precedence_[NUM_TOKENS]; | 273 static int8_t precedence_[NUM_TOKENS]; |
270 static const char token_type[NUM_TOKENS]; | 274 static const char token_type[NUM_TOKENS]; |
271 }; | 275 }; |
272 | 276 |
273 } } // namespace v8::internal | 277 } } // namespace v8::internal |
274 | 278 |
275 #endif // V8_TOKEN_H_ | 279 #endif // V8_TOKEN_H_ |
OLD | NEW |