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

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

Issue 10913271: Move parseInt parseDouble to int/double classes as a static method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make int.parse directly native. Created 8 years, 3 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 | « lib/compiler/implementation/lib/js_helper.dart ('k') | lib/core/core.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/math_patch.dart
diff --git a/lib/compiler/implementation/lib/math_patch.dart b/lib/compiler/implementation/lib/math_patch.dart
index f6be1d835987afaff8407bf0fed4dd563035889a..38a5097624499bc9fe442525aaa01878c1e6e335 100644
--- a/lib/compiler/implementation/lib/math_patch.dart
+++ b/lib/compiler/implementation/lib/math_patch.dart
@@ -7,41 +7,6 @@
// Imports checkNum etc. used below.
#import("js_helper.dart");
-// TODO(lrn): Consider not using the JS function directly, but instead calling
-// helper functions in the "js_helper" library. Then we can stop enabling JS
-// in all patched library files.
-
-patch int parseInt(str) {
- checkString(str);
- if (!JS('bool',
- @'/^\s*[+-]?(?:0[xX][abcdefABCDEF0-9]+|\d+)\s*$/.test(#)',
- str)) {
- throw new FormatException(str);
- }
- var trimmed = str.trim();
- var base = 10;
- if ((trimmed.length > 2 && (trimmed[1] == 'x' || trimmed[1] == 'X')) ||
- (trimmed.length > 3 && (trimmed[2] == 'x' || trimmed[2] == 'X'))) {
- base = 16;
- }
- var ret = JS('num', @'parseInt(#, #)', trimmed, base);
- if (ret.isNaN()) throw new FormatException(str);
- return ret;
-}
-
-patch double parseDouble(String str) {
- checkString(str);
- var ret = JS('num', @'parseFloat(#)', str);
- if (ret == 0 && (str.startsWith("0x") || str.startsWith("0X"))) {
- // TODO(ahe): This is unspecified, but tested by co19.
- ret = JS('num', @'parseInt(#)', str);
- }
- if (ret.isNaN() && str != 'NaN' && str != '-NaN') {
- throw new FormatException(str);
- }
- return ret;
-}
-
patch double sqrt(num value)
=> JS('double', @'Math.sqrt(#)', checkNum(value));
« no previous file with comments | « lib/compiler/implementation/lib/js_helper.dart ('k') | lib/core/core.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698