| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/token.h" | 5 #include "vm/token.h" |
| 6 | 6 |
| 7 #include "vm/object.h" | 7 #include "vm/object.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #define TOKEN_PRECEDENCE(t, s, p, a) p, | 21 #define TOKEN_PRECEDENCE(t, s, p, a) p, |
| 22 const uint8_t Token::precedence_[] = {DART_TOKEN_LIST(TOKEN_PRECEDENCE) | 22 const uint8_t Token::precedence_[] = {DART_TOKEN_LIST(TOKEN_PRECEDENCE) |
| 23 DART_KEYWORD_LIST(TOKEN_PRECEDENCE)}; | 23 DART_KEYWORD_LIST(TOKEN_PRECEDENCE)}; |
| 24 #undef TOKEN_PRECEDENCE | 24 #undef TOKEN_PRECEDENCE |
| 25 | 25 |
| 26 #define TOKEN_ATTRIBUTE(t, s, p, a) a, | 26 #define TOKEN_ATTRIBUTE(t, s, p, a) a, |
| 27 const Token::Attribute Token::attributes_[] = { | 27 const Token::Attribute Token::attributes_[] = { |
| 28 DART_TOKEN_LIST(TOKEN_ATTRIBUTE) DART_KEYWORD_LIST(TOKEN_ATTRIBUTE)}; | 28 DART_TOKEN_LIST(TOKEN_ATTRIBUTE) DART_KEYWORD_LIST(TOKEN_ATTRIBUTE)}; |
| 29 #undef TOKEN_ATTRIBUTE | 29 #undef TOKEN_ATTRIBUTE |
| 30 | 30 |
| 31 | |
| 32 bool Token::IsBinaryOperator(Token::Kind token) { | 31 bool Token::IsBinaryOperator(Token::Kind token) { |
| 33 switch (token) { | 32 switch (token) { |
| 34 case Token::kOR: | 33 case Token::kOR: |
| 35 case Token::kAND: | 34 case Token::kAND: |
| 36 return true; | 35 return true; |
| 37 default: | 36 default: |
| 38 return IsBinaryArithmeticOperator(token); | 37 return IsBinaryArithmeticOperator(token); |
| 39 } | 38 } |
| 40 } | 39 } |
| 41 | 40 |
| 42 | |
| 43 bool Token::IsUnaryOperator(Token::Kind token) { | 41 bool Token::IsUnaryOperator(Token::Kind token) { |
| 44 return (token == kNOT) || IsUnaryArithmeticOperator(token); | 42 return (token == kNOT) || IsUnaryArithmeticOperator(token); |
| 45 } | 43 } |
| 46 | 44 |
| 47 | |
| 48 bool Token::IsBinaryArithmeticOperator(Token::Kind token) { | 45 bool Token::IsBinaryArithmeticOperator(Token::Kind token) { |
| 49 switch (token) { | 46 switch (token) { |
| 50 case Token::kADD: | 47 case Token::kADD: |
| 51 case Token::kSUB: | 48 case Token::kSUB: |
| 52 case Token::kMUL: | 49 case Token::kMUL: |
| 53 case Token::kDIV: | 50 case Token::kDIV: |
| 54 case Token::kTRUNCDIV: | 51 case Token::kTRUNCDIV: |
| 55 case Token::kMOD: | 52 case Token::kMOD: |
| 56 case Token::kBIT_OR: | 53 case Token::kBIT_OR: |
| 57 case Token::kBIT_XOR: | 54 case Token::kBIT_XOR: |
| 58 case Token::kBIT_AND: | 55 case Token::kBIT_AND: |
| 59 case Token::kSHL: | 56 case Token::kSHL: |
| 60 case Token::kSHR: | 57 case Token::kSHR: |
| 61 return true; | 58 return true; |
| 62 default: | 59 default: |
| 63 return false; | 60 return false; |
| 64 } | 61 } |
| 65 } | 62 } |
| 66 | 63 |
| 67 | |
| 68 bool Token::IsUnaryArithmeticOperator(Token::Kind token) { | 64 bool Token::IsUnaryArithmeticOperator(Token::Kind token) { |
| 69 return (token == kBIT_NOT) || (token == kNEGATE); | 65 return (token == kBIT_NOT) || (token == kNEGATE); |
| 70 } | 66 } |
| 71 | 67 |
| 72 | |
| 73 bool Token::IsBinaryBitwiseOperator(Token::Kind token) { | 68 bool Token::IsBinaryBitwiseOperator(Token::Kind token) { |
| 74 switch (token) { | 69 switch (token) { |
| 75 case Token::kBIT_OR: | 70 case Token::kBIT_OR: |
| 76 case Token::kBIT_XOR: | 71 case Token::kBIT_XOR: |
| 77 case Token::kBIT_AND: | 72 case Token::kBIT_AND: |
| 78 case Token::kSHL: | 73 case Token::kSHL: |
| 79 case Token::kSHR: | 74 case Token::kSHR: |
| 80 return true; | 75 return true; |
| 81 default: | 76 default: |
| 82 return false; | 77 return false; |
| 83 } | 78 } |
| 84 } | 79 } |
| 85 | 80 |
| 86 } // namespace dart | 81 } // namespace dart |
| OLD | NEW |