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

Unified Diff: runtime/vm/token.cc

Issue 10440082: Fix a bug in ia32 shift left , implemented more inlined binary operations in x64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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') | tests/language/bit_operations_test.dart » ('j') | 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 8116)
+++ runtime/vm/token.cc (working copy)
@@ -4,6 +4,8 @@
#include "vm/token.h"
+#include "vm/object.h"
+
namespace dart {
#define TOKEN_NAME(t, s, p, a) #t,
@@ -35,4 +37,33 @@
#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.
+ }
+ }
+ 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;
+}
+
+
} // namespace dart
« no previous file with comments | « runtime/vm/token.h ('k') | tests/language/bit_operations_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698