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

Unified Diff: lib/compiler/implementation/lib/js_helper.dart

Issue 10343002: Make bit-operations return a positive result. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cache unsigned shift precedences. Created 8 years, 8 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 | « no previous file | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/js_helper.dart
diff --git a/lib/compiler/implementation/lib/js_helper.dart b/lib/compiler/implementation/lib/js_helper.dart
index f818cdba5b875e159a95e8c5a23ceac6c00d8374..55d645e9da43e686465f0772d58aa2050ff57a80 100644
--- a/lib/compiler/implementation/lib/js_helper.dart
+++ b/lib/compiler/implementation/lib/js_helper.dart
@@ -163,7 +163,7 @@ shl(var a, var b) {
// TODO(floitsch): inputs must be integers.
if (checkNumbers(a, b)) {
if (b < 0) throw new IllegalArgumentException(b);
- return JS('num', @'# << #', a, b);
+ return JS('num', @'(# << #) >>> 0', a, b);
}
return UNINTERCEPTED(a << b);
}
@@ -172,7 +172,7 @@ shr(var a, var b) {
// TODO(floitsch): inputs must be integers.
if (checkNumbers(a, b)) {
if (b < 0) throw new IllegalArgumentException(b);
- return JS('num', @'# >> #', a, b);
+ return JS('num', @'# >>> #', a, b);
}
return UNINTERCEPTED(a >> b);
}
@@ -180,7 +180,7 @@ shr(var a, var b) {
and(var a, var b) {
// TODO(floitsch): inputs must be integers.
if (checkNumbers(a, b)) {
- return JS('num', @'# & #', a, b);
+ return JS('num', @'(# & #) >>> 0', a, b);
}
return UNINTERCEPTED(a & b);
}
@@ -188,7 +188,7 @@ and(var a, var b) {
or(var a, var b) {
// TODO(floitsch): inputs must be integers.
if (checkNumbers(a, b)) {
- return JS('num', @'# | #', a, b);
+ return JS('num', @'(# | #) >>> 0', a, b);
}
return UNINTERCEPTED(a | b);
}
@@ -196,13 +196,15 @@ or(var a, var b) {
xor(var a, var b) {
// TODO(floitsch): inputs must be integers.
if (checkNumbers(a, b)) {
- return JS('num', @'# ^ #', a, b);
+ return JS('num', @'(# ^ #) >>> 0', a, b);
}
return UNINTERCEPTED(a ^ b);
}
not(var a) {
- if (JS('bool', @'typeof # === "number"', a)) return JS('num', @'~#', a);
+ if (JS('bool', @'typeof # === "number"', a)) {
+ return JS('num', @'(~#) >>> 0', a);
+ }
return UNINTERCEPTED(~a);
}
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698