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

Unified Diff: runtime/vm/token.cc

Issue 10536162: Add token kind into InstanceCallComp so that we do not need to extract it from name (addresses vego… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/token.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/token.cc
===================================================================
--- runtime/vm/token.cc (revision 8672)
+++ runtime/vm/token.cc (working copy)
@@ -37,44 +37,30 @@
#undef TOKEN_ATTRIBUTE
-Token::Kind Token::GetBinaryOp(const String& name) {
- if (name.Length() == 1) {
- switch (name.CharAt(0)) {
- case '+' : return Token::kADD;
- case '-' : return Token::kSUB;
- case '*' : return Token::kMUL;
- case '/' : return Token::kDIV;
- case '%' : return Token::kMOD;
- case '|' : return Token::kBIT_OR;
- case '^' : return Token::kBIT_XOR;
- case '&' : return Token::kBIT_AND;
- default: return Token::kILLEGAL; // Not a binary operation.
- }
+bool Token::IsBinaryToken(Token::Kind token) {
+ switch (token) {
+ case Token::kADD:
+ case Token::kSUB:
+ case Token::kMUL:
+ case Token::kDIV:
+ case Token::kTRUNCDIV:
+ case Token::kMOD:
+ case Token::kBIT_OR:
+ case Token::kBIT_XOR:
+ case Token::kBIT_AND:
+ case Token::kOR:
+ case Token::kAND:
+ case Token::kSHL:
+ case Token::kSHR:
+ return true;
+ default:
+ return false;
}
- if (name.Length() == 2) {
- switch (name.CharAt(0)) {
- case '|' : return name.CharAt(1) == '|' ? Token::kOR : Token::kILLEGAL;
- case '&' : return name.CharAt(1) == '&' ? Token::kAND : Token::kILLEGAL;
- case '<' : return name.CharAt(1) == '<' ? Token::kSHL : Token::kILLEGAL;
- case '>' : return name.CharAt(1) == '>' ? Token::kSHR : Token::kILLEGAL;
- case '~' :
- return name.CharAt(1) == '/' ? Token::kTRUNCDIV : Token::kILLEGAL;
- default: return Token::kILLEGAL; // Not a binary operation.
- }
- }
- return Token::kILLEGAL;
}
-Token::Kind Token::GetUnaryOp(const String& name) {
- if (name.Equals(Str(Token::kNEGATE))) {
- return Token::kNEGATE;
- }
- if ((name.Length() == 1) && (name.CharAt(0) == '~')) {
- return Token::kBIT_NOT;
- }
- return Token::kILLEGAL;
+bool Token::IsUnaryToken(Token::Kind token) {
+ return (token == Token::kNEGATE) || (token == kBIT_NOT);
}
-
} // namespace dart
« no previous file with comments | « runtime/vm/token.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698