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

Side by Side Diff: tool/input_sdk/private/js_helper.dart

Issue 1143953004: Fixes for sunflower (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library _js_helper; 5 library _js_helper;
6 6
7 import 'dart:_js_embedded_names' show 7 import 'dart:_js_embedded_names' show
8 ALL_CLASSES, 8 ALL_CLASSES,
9 GET_ISOLATE_TAG, 9 GET_ISOLATE_TAG,
10 INTERCEPTED_NAMES, 10 INTERCEPTED_NAMES,
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 return JS('int', '#', hash); 582 return JS('int', '#', hash);
583 } 583 }
584 584
585 static _throwFormatException(String string) { 585 static _throwFormatException(String string) {
586 throw new FormatException(string); 586 throw new FormatException(string);
587 } 587 }
588 588
589 static int parseInt(String source, 589 static int parseInt(String source,
590 int radix, 590 int radix,
591 int handleError(String source)) { 591 int handleError(String source)) {
592 if (handleError == null) handleError = _throwFormatException; 592 // TODO(vsm): Make _throwFormatException generic and use directly
593 // to avoid closure allocation.
594 if (handleError == null) handleError = (s) => _throwFormatException(s);
593 595
594 checkString(source); 596 checkString(source);
595 var match = JS('JSExtendableArray|Null', 597 var match = JS('JSExtendableArray|Null',
596 r'/^\s*[+-]?((0x[a-f0-9]+)|(\d+)|([a-z0-9]+))\s*$/i.exec(#)', 598 r'/^\s*[+-]?((0x[a-f0-9]+)|(\d+)|([a-z0-9]+))\s*$/i.exec(#)',
597 source); 599 source);
598 int digitsIndex = 1; 600 int digitsIndex = 1;
599 int hexIndex = 2; 601 int hexIndex = 2;
600 int decimalIndex = 3; 602 int decimalIndex = 3;
601 int nonDecimalHexIndex = 4; 603 int nonDecimalHexIndex = 4;
602 if (radix == null) { 604 if (radix == null) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 } 652 }
651 } 653 }
652 } 654 }
653 } 655 }
654 if (match == null) return handleError(source); 656 if (match == null) return handleError(source);
655 return JS('num', r'parseInt(#, #)', source, radix); 657 return JS('num', r'parseInt(#, #)', source, radix);
656 } 658 }
657 659
658 static double parseDouble(String source, double handleError(String source)) { 660 static double parseDouble(String source, double handleError(String source)) {
659 checkString(source); 661 checkString(source);
660 if (handleError == null) handleError = _throwFormatException; 662 // TODO(vsm): Make _throwFormatException generic and use directly
663 // to avoid closure allocation.
664 if (handleError == null) handleError = (s) => _throwFormatException(s);
661 // Notice that JS parseFloat accepts garbage at the end of the string. 665 // Notice that JS parseFloat accepts garbage at the end of the string.
662 // Accept only: 666 // Accept only:
663 // - [+/-]NaN 667 // - [+/-]NaN
664 // - [+/-]Infinity 668 // - [+/-]Infinity
665 // - a Dart double literal 669 // - a Dart double literal
666 // We do allow leading or trailing whitespace. 670 // We do allow leading or trailing whitespace.
667 if (!JS('bool', 671 if (!JS('bool',
668 r'/^\s*[+-]?(?:Infinity|NaN|' 672 r'/^\s*[+-]?(?:Infinity|NaN|'
669 r'(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(#)', 673 r'(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(#)',
670 source)) { 674 source)) {
(...skipping 2784 matching lines...) Expand 10 before | Expand all | Expand 10 after
3455 throw new MainError("No top-level function named 'main'."); 3459 throw new MainError("No top-level function named 'main'.");
3456 } 3460 }
3457 3461
3458 void badMain() { 3462 void badMain() {
3459 throw new MainError("'main' is not a function."); 3463 throw new MainError("'main' is not a function.");
3460 } 3464 }
3461 3465
3462 void mainHasTooManyParameters() { 3466 void mainHasTooManyParameters() {
3463 throw new MainError("'main' expects too many parameters."); 3467 throw new MainError("'main' expects too many parameters.");
3464 } 3468 }
OLDNEW
« no previous file with comments | « test/generated_sdk/lib/_internal/compiler/js_lib/js_helper.dart ('k') | tool/sdk_expected_errors.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698