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

Unified Diff: frog/parser.dart

Issue 8739002: Frog: Fix parsing of hex literals with >31 bits (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: put issue# in comment Created 9 years, 1 month 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 | « frog/frogsh ('k') | tests/language/src/NumberConstantFolding1Test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/parser.dart
diff --git a/frog/parser.dart b/frog/parser.dart
index 18fa60ff73d15052e918aedb681f70d43dbc4caa..4d321dacf044d52ca55b39cb4ee75b62c42457e2 100644
--- a/frog/parser.dart
+++ b/frog/parser.dart
@@ -1334,10 +1334,14 @@ class Parser {
static int parseHex(String hex) {
var result = 0;
- for (int i=0; i < hex.length; i++) {
+ for (int i = 0; i < hex.length; i++) {
var digit = _hexDigit(hex.charCodeAt(i));
assert(digit != -1);
- result = (result << 4) + digit;
+ // Multiply by 16 rather than shift by 4 since that will result in a
+ // correct value for numbers that exceed the 32 bit precision of JS
+ // 'integers'.
+ // TODO: Figure out a better solution to integer truncation. Issue 638.
+ result = (result * 16) + digit;
}
return result;
« no previous file with comments | « frog/frogsh ('k') | tests/language/src/NumberConstantFolding1Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698