Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: runtime/vm/token.cc

Issue 735543003: Range feedback for binary integer operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/token.h ('k') | runtime/vm/unit_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 21 matching lines...) Expand all
32 #define TOKEN_ATTRIBUTE(t, s, p, a) a, 32 #define TOKEN_ATTRIBUTE(t, s, p, a) a,
33 const Token::Attribute Token::attributes_[] = { 33 const Token::Attribute Token::attributes_[] = {
34 DART_TOKEN_LIST(TOKEN_ATTRIBUTE) 34 DART_TOKEN_LIST(TOKEN_ATTRIBUTE)
35 DART_KEYWORD_LIST(TOKEN_ATTRIBUTE) 35 DART_KEYWORD_LIST(TOKEN_ATTRIBUTE)
36 }; 36 };
37 #undef TOKEN_ATTRIBUTE 37 #undef TOKEN_ATTRIBUTE
38 38
39 39
40 bool Token::IsBinaryOperator(Token::Kind token) { 40 bool Token::IsBinaryOperator(Token::Kind token) {
41 switch (token) { 41 switch (token) {
42 case Token::kOR:
43 case Token::kAND:
44 return true;
45 default:
46 return IsBinaryArithmeticOperator(token);
47 }
48 }
49
50
51 bool Token::IsUnaryOperator(Token::Kind token) {
52 return (token == kNOT) || IsUnaryArithmeticOperator(token);
53 }
54
55
56 bool Token::IsBinaryArithmeticOperator(Token::Kind token) {
57 switch (token) {
42 case Token::kADD: 58 case Token::kADD:
43 case Token::kSUB: 59 case Token::kSUB:
44 case Token::kMUL: 60 case Token::kMUL:
45 case Token::kDIV: 61 case Token::kDIV:
46 case Token::kTRUNCDIV: 62 case Token::kTRUNCDIV:
47 case Token::kMOD: 63 case Token::kMOD:
48 case Token::kBIT_OR: 64 case Token::kBIT_OR:
49 case Token::kBIT_XOR: 65 case Token::kBIT_XOR:
50 case Token::kBIT_AND: 66 case Token::kBIT_AND:
51 case Token::kOR:
52 case Token::kAND:
53 case Token::kSHL: 67 case Token::kSHL:
54 case Token::kSHR: 68 case Token::kSHR:
55 return true; 69 return true;
56 default: 70 default:
57 return false; 71 return false;
58 } 72 }
59 } 73 }
60 74
61 75
62 bool Token::IsPrefixOperator(Token::Kind token) { 76 bool Token::IsUnaryArithmeticOperator(Token::Kind token) {
63 return (token == kNOT) || (token == kBIT_NOT) || (token == kNEGATE); 77 return (token == kBIT_NOT) || (token == kNEGATE);
64 } 78 }
65 79
80
66 } // namespace dart 81 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/token.h ('k') | runtime/vm/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698