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

Side by Side Diff: lib/runtime/dart/core.js

Issue 1348453004: fix some errors in our SDK, mostly around numbers (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « lib/runtime/dart/convert.js ('k') | lib/runtime/dart/js.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 dart_library.library('dart/core', null, /* Imports */[ 1 dart_library.library('dart/core', null, /* Imports */[
2 "dart_runtime/dart" 2 "dart_runtime/dart"
3 ], /* Lazy imports */[ 3 ], /* Lazy imports */[
4 'dart/_js_helper', 4 'dart/_js_helper',
5 'dart/_internal', 5 'dart/_internal',
6 'dart/collection', 6 'dart/collection',
7 'dart/_interceptors', 7 'dart/_interceptors',
8 'dart/convert' 8 'dart/convert'
9 ], function(exports, dart, _js_helper, _internal, collection, _interceptors, con vert) { 9 ], function(exports, dart, _js_helper, _internal, collection, _interceptors, con vert) {
10 'use strict'; 10 'use strict';
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 dart.fn(sixDigits, String, [int]); 543 dart.fn(sixDigits, String, [int]);
544 function twoDigits(n) { 544 function twoDigits(n) {
545 if (dart.notNull(n) >= 10) 545 if (dart.notNull(n) >= 10)
546 return `${n}`; 546 return `${n}`;
547 return `0${n}`; 547 return `0${n}`;
548 } 548 }
549 dart.fn(twoDigits, String, [int]); 549 dart.fn(twoDigits, String, [int]);
550 if (dart.notNull(this.inMicroseconds) < 0) { 550 if (dart.notNull(this.inMicroseconds) < 0) {
551 return `-${this['unary-']()}`; 551 return `-${this['unary-']()}`;
552 } 552 }
553 let twoDigitMinutes = twoDigits(this.inMinutes[dartx.remainder](Duration.M INUTES_PER_HOUR)); 553 let twoDigitMinutes = twoDigits(dart.asInt(this.inMinutes[dartx.remainder] (Duration.MINUTES_PER_HOUR)));
554 let twoDigitSeconds = twoDigits(this.inSeconds[dartx.remainder](Duration.S ECONDS_PER_MINUTE)); 554 let twoDigitSeconds = twoDigits(dart.asInt(this.inSeconds[dartx.remainder] (Duration.SECONDS_PER_MINUTE)));
555 let sixDigitUs = sixDigits(this.inMicroseconds[dartx.remainder](Duration.M ICROSECONDS_PER_SECOND)); 555 let sixDigitUs = sixDigits(dart.asInt(this.inMicroseconds[dartx.remainder] (Duration.MICROSECONDS_PER_SECOND)));
556 return `${this.inHours}:${twoDigitMinutes}:${twoDigitSeconds}.${sixDigitUs }`; 556 return `${this.inHours}:${twoDigitMinutes}:${twoDigitSeconds}.${sixDigitUs }`;
557 } 557 }
558 get isNegative() { 558 get isNegative() {
559 return dart.notNull(this[_duration]) < 0; 559 return dart.notNull(this[_duration]) < 0;
560 } 560 }
561 abs() { 561 abs() {
562 return new Duration._microseconds(this[_duration][dartx.abs]()); 562 return new Duration._microseconds(this[_duration][dartx.abs]());
563 } 563 }
564 ['unary-']() { 564 ['unary-']() {
565 return new Duration._microseconds(-dart.notNull(this[_duration])); 565 return new Duration._microseconds(-dart.notNull(this[_duration]));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 Duration.MILLISECONDS_PER_HOUR = dart.notNull(Duration.MILLISECONDS_PER_MINUTE ) * dart.notNull(Duration.MINUTES_PER_HOUR); 600 Duration.MILLISECONDS_PER_HOUR = dart.notNull(Duration.MILLISECONDS_PER_MINUTE ) * dart.notNull(Duration.MINUTES_PER_HOUR);
601 Duration.MILLISECONDS_PER_DAY = dart.notNull(Duration.MILLISECONDS_PER_HOUR) * dart.notNull(Duration.HOURS_PER_DAY); 601 Duration.MILLISECONDS_PER_DAY = dart.notNull(Duration.MILLISECONDS_PER_HOUR) * dart.notNull(Duration.HOURS_PER_DAY);
602 Duration.SECONDS_PER_HOUR = dart.notNull(Duration.SECONDS_PER_MINUTE) * dart.n otNull(Duration.MINUTES_PER_HOUR); 602 Duration.SECONDS_PER_HOUR = dart.notNull(Duration.SECONDS_PER_MINUTE) * dart.n otNull(Duration.MINUTES_PER_HOUR);
603 Duration.SECONDS_PER_DAY = dart.notNull(Duration.SECONDS_PER_HOUR) * dart.notN ull(Duration.HOURS_PER_DAY); 603 Duration.SECONDS_PER_DAY = dart.notNull(Duration.SECONDS_PER_HOUR) * dart.notN ull(Duration.HOURS_PER_DAY);
604 Duration.MINUTES_PER_DAY = dart.notNull(Duration.MINUTES_PER_HOUR) * dart.notN ull(Duration.HOURS_PER_DAY); 604 Duration.MINUTES_PER_DAY = dart.notNull(Duration.MINUTES_PER_HOUR) * dart.notN ull(Duration.HOURS_PER_DAY);
605 Duration.ZERO = dart.const(new Duration({seconds: 0})); 605 Duration.ZERO = dart.const(new Duration({seconds: 0}));
606 class Error extends Object { 606 class Error extends Object {
607 Error() { 607 Error() {
608 } 608 }
609 static safeToString(object) { 609 static safeToString(object) {
610 if (dart.is(object, num) || typeof object == 'boolean' || null == object) { 610 if (typeof object == 'number' || typeof object == 'boolean' || null == obj ect) {
611 return dart.toString(object); 611 return dart.toString(object);
612 } 612 }
613 if (typeof object == 'string') { 613 if (typeof object == 'string') {
614 return Error._stringToSafeString(object); 614 return Error._stringToSafeString(object);
615 } 615 }
616 return Error._objectToString(object); 616 return Error._objectToString(object);
617 } 617 }
618 static _stringToSafeString(string) { 618 static _stringToSafeString(string) {
619 return _js_helper.jsonEncodeNative(string); 619 return _js_helper.jsonEncodeNative(string);
620 } 620 }
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 return; 1592 return;
1593 this[_start] = Stopwatch._now(); 1593 this[_start] = Stopwatch._now();
1594 if (this[_stop] != null) { 1594 if (this[_stop] != null) {
1595 this[_stop] = this[_start]; 1595 this[_stop] = this[_start];
1596 } 1596 }
1597 } 1597 }
1598 get elapsedTicks() { 1598 get elapsedTicks() {
1599 if (this[_start] == null) { 1599 if (this[_start] == null) {
1600 return 0; 1600 return 0;
1601 } 1601 }
1602 return this[_stop] == null ? dart.notNull(Stopwatch._now()) - dart.notNull (this[_start]) : dart.notNull(this[_stop]) - dart.notNull(this[_start]); 1602 return dart.asInt(this[_stop] == null ? dart.notNull(Stopwatch._now()) - d art.notNull(this[_start]) : dart.notNull(this[_stop]) - dart.notNull(this[_start ]));
1603 } 1603 }
1604 get elapsed() { 1604 get elapsed() {
1605 return new Duration({microseconds: this.elapsedMicroseconds}); 1605 return new Duration({microseconds: this.elapsedMicroseconds});
1606 } 1606 }
1607 get elapsedMicroseconds() { 1607 get elapsedMicroseconds() {
1608 return (dart.notNull(this.elapsedTicks) * 1000000 / dart.notNull(this.freq uency))[dartx.truncate](); 1608 return (dart.notNull(this.elapsedTicks) * 1000000 / dart.notNull(this.freq uency))[dartx.truncate]();
1609 } 1609 }
1610 get elapsedMilliseconds() { 1610 get elapsedMilliseconds() {
1611 return (dart.notNull(this.elapsedTicks) * 1000 / dart.notNull(this.frequen cy))[dartx.truncate](); 1611 return (dart.notNull(this.elapsedTicks) * 1000 / dart.notNull(this.frequen cy))[dartx.truncate]();
1612 } 1612 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 } 1781 }
1782 reset(rawIndex) { 1782 reset(rawIndex) {
1783 if (rawIndex === void 0) 1783 if (rawIndex === void 0)
1784 rawIndex = 0; 1784 rawIndex = 0;
1785 RangeError.checkValueInInterval(rawIndex, 0, this.string[dartx.length], "r awIndex"); 1785 RangeError.checkValueInInterval(rawIndex, 0, this.string[dartx.length], "r awIndex");
1786 this[_checkSplitSurrogate](rawIndex); 1786 this[_checkSplitSurrogate](rawIndex);
1787 this[_position] = this[_nextPosition] = rawIndex; 1787 this[_position] = this[_nextPosition] = rawIndex;
1788 this[_currentCodePoint] = null; 1788 this[_currentCodePoint] = null;
1789 } 1789 }
1790 get current() { 1790 get current() {
1791 return this[_currentCodePoint]; 1791 return dart.asInt(this[_currentCodePoint]);
1792 } 1792 }
1793 get currentSize() { 1793 get currentSize() {
1794 return dart.notNull(this[_nextPosition]) - dart.notNull(this[_position]); 1794 return dart.notNull(this[_nextPosition]) - dart.notNull(this[_position]);
1795 } 1795 }
1796 get currentAsString() { 1796 get currentAsString() {
1797 if (this[_position] == this[_nextPosition]) 1797 if (this[_position] == this[_nextPosition])
1798 return null; 1798 return null;
1799 if (dart.notNull(this[_position]) + 1 == this[_nextPosition]) 1799 if (dart.notNull(this[_position]) + 1 == this[_nextPosition])
1800 return this.string[dartx.get](this[_position]); 1800 return this.string[dartx.get](this[_position]);
1801 return this.string[dartx.substring](this[_position], this[_nextPosition]); 1801 return this.string[dartx.substring](this[_position], this[_nextPosition]);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 if (this[_host] == null) 1964 if (this[_host] == null)
1965 return ""; 1965 return "";
1966 if (dart.notNull(this[_host][dartx.startsWith]('['))) { 1966 if (dart.notNull(this[_host][dartx.startsWith]('['))) {
1967 return this[_host][dartx.substring](1, dart.notNull(this[_host][dartx.le ngth]) - 1); 1967 return this[_host][dartx.substring](1, dart.notNull(this[_host][dartx.le ngth]) - 1);
1968 } 1968 }
1969 return this[_host]; 1969 return this[_host];
1970 } 1970 }
1971 get port() { 1971 get port() {
1972 if (this[_port] == null) 1972 if (this[_port] == null)
1973 return Uri._defaultPort(this.scheme); 1973 return Uri._defaultPort(this.scheme);
1974 return this[_port]; 1974 return dart.asInt(this[_port]);
1975 } 1975 }
1976 static _defaultPort(scheme) { 1976 static _defaultPort(scheme) {
1977 if (scheme == "http") 1977 if (scheme == "http")
1978 return 80; 1978 return 80;
1979 if (scheme == "https") 1979 if (scheme == "https")
1980 return 443; 1980 return 443;
1981 return 0; 1981 return 0;
1982 } 1982 }
1983 get path() { 1983 get path() {
1984 return this[_path]; 1984 return this[_path];
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 } 2363 }
2364 let isFile = scheme == "file"; 2364 let isFile = scheme == "file";
2365 if (userInfo != null) { 2365 if (userInfo != null) {
2366 userInfo = Uri._makeUserInfo(userInfo, 0, userInfo[dartx.length]); 2366 userInfo = Uri._makeUserInfo(userInfo, 0, userInfo[dartx.length]);
2367 } else { 2367 } else {
2368 userInfo = this.userInfo; 2368 userInfo = this.userInfo;
2369 } 2369 }
2370 if (port != null) { 2370 if (port != null) {
2371 port = Uri._makePort(port, scheme); 2371 port = Uri._makePort(port, scheme);
2372 } else { 2372 } else {
2373 port = this[_port]; 2373 port = dart.asInt(this[_port]);
2374 if (dart.notNull(schemeChanged)) { 2374 if (dart.notNull(schemeChanged)) {
2375 port = Uri._makePort(port, scheme); 2375 port = Uri._makePort(port, scheme);
2376 } 2376 }
2377 } 2377 }
2378 if (host != null) { 2378 if (host != null) {
2379 host = Uri._makeHost(host, 0, host[dartx.length], false); 2379 host = Uri._makeHost(host, 0, host[dartx.length], false);
2380 } else if (dart.notNull(this.hasAuthority)) { 2380 } else if (dart.notNull(this.hasAuthority)) {
2381 host = this.host; 2381 host = this.host;
2382 } else if (dart.notNull(userInfo[dartx.isNotEmpty]) || port != null || dar t.notNull(isFile)) { 2382 } else if (dart.notNull(userInfo[dartx.isNotEmpty]) || port != null || dar t.notNull(isFile)) {
2383 host = ""; 2383 host = "";
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 if (dart.notNull(reference.path[dartx.startsWith]("/"))) { 2824 if (dart.notNull(reference.path[dartx.startsWith]("/"))) {
2825 targetPath = this[_removeDotSegments](reference.path); 2825 targetPath = this[_removeDotSegments](reference.path);
2826 } else { 2826 } else {
2827 targetPath = this[_removeDotSegments](this[_merge](this[_path], re ference.path)); 2827 targetPath = this[_removeDotSegments](this[_merge](this[_path], re ference.path));
2828 } 2828 }
2829 if (dart.notNull(reference.hasQuery)) 2829 if (dart.notNull(reference.hasQuery))
2830 targetQuery = reference.query; 2830 targetQuery = reference.query;
2831 } 2831 }
2832 targetUserInfo = this[_userInfo]; 2832 targetUserInfo = this[_userInfo];
2833 targetHost = this[_host]; 2833 targetHost = this[_host];
2834 targetPort = this[_port]; 2834 targetPort = dart.asInt(this[_port]);
2835 } 2835 }
2836 } 2836 }
2837 let fragment = dart.notNull(reference.hasFragment) ? reference.fragment : null; 2837 let fragment = dart.notNull(reference.hasFragment) ? reference.fragment : null;
2838 return new Uri._internal(targetScheme, targetUserInfo, targetHost, targetP ort, targetPath, targetQuery, fragment); 2838 return new Uri._internal(targetScheme, targetUserInfo, targetHost, targetP ort, targetPath, targetQuery, fragment);
2839 } 2839 }
2840 get hasAuthority() { 2840 get hasAuthority() {
2841 return this[_host] != null; 2841 return this[_host] != null;
2842 } 2842 }
2843 get hasPort() { 2843 get hasPort() {
2844 return this[_port] != null; 2844 return this[_port] != null;
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
3366 exports.StackTrace = StackTrace; 3366 exports.StackTrace = StackTrace;
3367 exports.Stopwatch = Stopwatch; 3367 exports.Stopwatch = Stopwatch;
3368 exports.String = String; 3368 exports.String = String;
3369 exports.RuneIterator = RuneIterator; 3369 exports.RuneIterator = RuneIterator;
3370 exports.StringBuffer = StringBuffer; 3370 exports.StringBuffer = StringBuffer;
3371 exports.StringSink = StringSink; 3371 exports.StringSink = StringSink;
3372 exports.Symbol = Symbol; 3372 exports.Symbol = Symbol;
3373 exports.Type = Type; 3373 exports.Type = Type;
3374 exports.Uri = Uri; 3374 exports.Uri = Uri;
3375 }); 3375 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/convert.js ('k') | lib/runtime/dart/js.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698