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

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

Issue 1484263002: Use destructuring assignments for named parameters (#180) (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years 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/isolate.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" 2 "dart/_runtime"
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 } 67 }
68 dart.setSignature(_Proxy, { 68 dart.setSignature(_Proxy, {
69 constructors: () => ({_Proxy: [_Proxy, []]}) 69 constructors: () => ({_Proxy: [_Proxy, []]})
70 }); 70 });
71 const proxy = dart.const(new _Proxy()); 71 const proxy = dart.const(new _Proxy());
72 dart.defineExtensionNames([ 72 dart.defineExtensionNames([
73 'toString' 73 'toString'
74 ]); 74 ]);
75 class bool extends Object { 75 class bool extends Object {
76 static fromEnvironment(name, opts) { 76 static fromEnvironment(name, {defaultValue = false} = {}) {
77 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : fa lse;
78 dart.throw(new UnsupportedError('bool.fromEnvironment can only be used as a const constructor')); 77 dart.throw(new UnsupportedError('bool.fromEnvironment can only be used as a const constructor'));
79 } 78 }
80 toString() { 79 toString() {
81 return this ? "true" : "false"; 80 return this ? "true" : "false";
82 } 81 }
83 } 82 }
84 dart.setSignature(bool, { 83 dart.setSignature(bool, {
85 constructors: () => ({fromEnvironment: [bool, [String], {defaultValue: bool} ]}) 84 constructors: () => ({fromEnvironment: [bool, [String], {defaultValue: bool} ]})
86 }); 85 });
87 const Comparator$ = dart.generic(function(T) { 86 const Comparator$ = dart.generic(function(T) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 dart.throw(new FormatException("Time out of range", formattedString)); 179 dart.throw(new FormatException("Time out of range", formattedString));
181 } 180 }
182 if (dart.notNull(addOneMillisecond)) { 181 if (dart.notNull(addOneMillisecond)) {
183 millisecondsSinceEpoch = dart.notNull(millisecondsSinceEpoch) + 1; 182 millisecondsSinceEpoch = dart.notNull(millisecondsSinceEpoch) + 1;
184 } 183 }
185 return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, { isUtc: isUtc}); 184 return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, { isUtc: isUtc});
186 } else { 185 } else {
187 dart.throw(new FormatException("Invalid date format", formattedString)); 186 dart.throw(new FormatException("Invalid date format", formattedString));
188 } 187 }
189 } 188 }
190 fromMillisecondsSinceEpoch(millisecondsSinceEpoch, opts) { 189 fromMillisecondsSinceEpoch(millisecondsSinceEpoch, {isUtc = false} = {}) {
191 let isUtc = opts && 'isUtc' in opts ? opts.isUtc : false;
192 this.millisecondsSinceEpoch = millisecondsSinceEpoch; 190 this.millisecondsSinceEpoch = millisecondsSinceEpoch;
193 this.isUtc = isUtc; 191 this.isUtc = isUtc;
194 if (dart.notNull(millisecondsSinceEpoch[dartx.abs]()) > dart.notNull(DateT ime._MAX_MILLISECONDS_SINCE_EPOCH)) { 192 if (dart.notNull(millisecondsSinceEpoch[dartx.abs]()) > dart.notNull(DateT ime._MAX_MILLISECONDS_SINCE_EPOCH)) {
195 dart.throw(new ArgumentError(millisecondsSinceEpoch)); 193 dart.throw(new ArgumentError(millisecondsSinceEpoch));
196 } 194 }
197 if (isUtc == null) 195 if (isUtc == null)
198 dart.throw(new ArgumentError(isUtc)); 196 dart.throw(new ArgumentError(isUtc));
199 } 197 }
200 ['=='](other) { 198 ['=='](other) {
201 if (!dart.is(other, DateTime)) 199 if (!dart.is(other, DateTime))
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 statics: () => ({parse: [double, [String], [dart.functionType(double, [Strin g])]]}), 450 statics: () => ({parse: [double, [String], [dart.functionType(double, [Strin g])]]}),
453 names: ['parse'] 451 names: ['parse']
454 }); 452 });
455 double.NAN = 0.0 / 0.0; 453 double.NAN = 0.0 / 0.0;
456 double.INFINITY = 1.0 / 0.0; 454 double.INFINITY = 1.0 / 0.0;
457 double.NEGATIVE_INFINITY = -dart.notNull(double.INFINITY); 455 double.NEGATIVE_INFINITY = -dart.notNull(double.INFINITY);
458 double.MIN_POSITIVE = 5e-324; 456 double.MIN_POSITIVE = 5e-324;
459 double.MAX_FINITE = 1.7976931348623157e+308; 457 double.MAX_FINITE = 1.7976931348623157e+308;
460 const _duration = dart.JsSymbol('_duration'); 458 const _duration = dart.JsSymbol('_duration');
461 class Duration extends Object { 459 class Duration extends Object {
462 Duration(opts) { 460 Duration({days = 0, hours = 0, minutes = 0, seconds = 0, milliseconds = 0, m icroseconds = 0} = {}) {
463 let days = opts && 'days' in opts ? opts.days : 0;
464 let hours = opts && 'hours' in opts ? opts.hours : 0;
465 let minutes = opts && 'minutes' in opts ? opts.minutes : 0;
466 let seconds = opts && 'seconds' in opts ? opts.seconds : 0;
467 let milliseconds = opts && 'milliseconds' in opts ? opts.milliseconds : 0;
468 let microseconds = opts && 'microseconds' in opts ? opts.microseconds : 0;
469 this._microseconds(dart.notNull(days) * dart.notNull(Duration.MICROSECONDS _PER_DAY) + dart.notNull(hours) * dart.notNull(Duration.MICROSECONDS_PER_HOUR) + dart.notNull(minutes) * dart.notNull(Duration.MICROSECONDS_PER_MINUTE) + dart.n otNull(seconds) * dart.notNull(Duration.MICROSECONDS_PER_SECOND) + dart.notNull( milliseconds) * dart.notNull(Duration.MICROSECONDS_PER_MILLISECOND) + dart.notNu ll(microseconds)); 461 this._microseconds(dart.notNull(days) * dart.notNull(Duration.MICROSECONDS _PER_DAY) + dart.notNull(hours) * dart.notNull(Duration.MICROSECONDS_PER_HOUR) + dart.notNull(minutes) * dart.notNull(Duration.MICROSECONDS_PER_MINUTE) + dart.n otNull(seconds) * dart.notNull(Duration.MICROSECONDS_PER_SECOND) + dart.notNull( milliseconds) * dart.notNull(Duration.MICROSECONDS_PER_MILLISECOND) + dart.notNu ll(microseconds));
470 } 462 }
471 _microseconds(duration) { 463 _microseconds(duration) {
472 this[_duration] = duration; 464 this[_duration] = duration;
473 } 465 }
474 ['+'](other) { 466 ['+'](other) {
475 return new Duration._microseconds(dart.notNull(this[_duration]) + dart.not Null(other[_duration])); 467 return new Duration._microseconds(dart.notNull(this[_duration]) + dart.not Null(other[_duration]));
476 } 468 }
477 ['-'](other) { 469 ['-'](other) {
478 return new Duration._microseconds(dart.notNull(this[_duration]) - dart.not Null(other[_duration])); 470 return new Duration._microseconds(dart.notNull(this[_duration]) - dart.not Null(other[_duration]));
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 }); 1223 });
1232 function identical(a, b) { 1224 function identical(a, b) {
1233 return _js_helper.Primitives.identicalImplementation(a, b); 1225 return _js_helper.Primitives.identicalImplementation(a, b);
1234 } 1226 }
1235 dart.fn(identical, bool, [Object, Object]); 1227 dart.fn(identical, bool, [Object, Object]);
1236 function identityHashCode(object) { 1228 function identityHashCode(object) {
1237 return _js_helper.objectHashCode(object); 1229 return _js_helper.objectHashCode(object);
1238 } 1230 }
1239 dart.fn(identityHashCode, () => dart.definiteFunctionType(int, [Object])); 1231 dart.fn(identityHashCode, () => dart.definiteFunctionType(int, [Object]));
1240 class int extends num { 1232 class int extends num {
1241 static fromEnvironment(name, opts) { 1233 static fromEnvironment(name, {defaultValue = null} = {}) {
1242 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : nu ll;
1243 dart.throw(new UnsupportedError('int.fromEnvironment can only be used as a const constructor')); 1234 dart.throw(new UnsupportedError('int.fromEnvironment can only be used as a const constructor'));
1244 } 1235 }
1245 static parse(source, opts) { 1236 static parse(source, {radix = null, onError = null} = {}) {
1246 let radix = opts && 'radix' in opts ? opts.radix : null;
1247 let onError = opts && 'onError' in opts ? opts.onError : null;
1248 return _js_helper.Primitives.parseInt(source, radix, onError); 1237 return _js_helper.Primitives.parseInt(source, radix, onError);
1249 } 1238 }
1250 } 1239 }
1251 dart.setSignature(int, { 1240 dart.setSignature(int, {
1252 constructors: () => ({fromEnvironment: [int, [String], {defaultValue: int}]} ), 1241 constructors: () => ({fromEnvironment: [int, [String], {defaultValue: int}]} ),
1253 statics: () => ({parse: [int, [String], {radix: int, onError: dart.functionT ype(int, [String])}]}), 1242 statics: () => ({parse: [int, [String], {radix: int, onError: dart.functionT ype(int, [String])}]}),
1254 names: ['parse'] 1243 names: ['parse']
1255 }); 1244 });
1256 class Invocation extends Object { 1245 class Invocation extends Object {
1257 get isAccessor() { 1246 get isAccessor() {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 } 1411 }
1423 static filled(length, fill) { 1412 static filled(length, fill) {
1424 let result = List$(E).new(length); 1413 let result = List$(E).new(length);
1425 if (length != 0 && fill != null) { 1414 if (length != 0 && fill != null) {
1426 for (let i = 0; dart.notNull(i) < dart.notNull(result[dartx.length]); i = dart.notNull(i) + 1) { 1415 for (let i = 0; dart.notNull(i) < dart.notNull(result[dartx.length]); i = dart.notNull(i) + 1) {
1427 result[dartx.set](i, fill); 1416 result[dartx.set](i, fill);
1428 } 1417 }
1429 } 1418 }
1430 return result; 1419 return result;
1431 } 1420 }
1432 static from(elements, opts) { 1421 static from(elements, {growable = true} = {}) {
1433 let growable = opts && 'growable' in opts ? opts.growable : true;
1434 let list = List$(E).new(); 1422 let list = List$(E).new();
1435 for (let e of elements) { 1423 for (let e of elements) {
1436 list[dartx.add](dart.as(e, E)); 1424 list[dartx.add](dart.as(e, E));
1437 } 1425 }
1438 if (dart.notNull(growable)) 1426 if (dart.notNull(growable))
1439 return list; 1427 return list;
1440 return dart.as(_internal.makeListFixedLength(list), List$(E)); 1428 return dart.as(_internal.makeListFixedLength(list), List$(E));
1441 } 1429 }
1442 static generate(length, generator, opts) { 1430 static generate(length, generator, {growable = true} = {}) {
1443 let growable = opts && 'growable' in opts ? opts.growable : true;
1444 let result = null; 1431 let result = null;
1445 if (dart.notNull(growable)) { 1432 if (dart.notNull(growable)) {
1446 result = dart.list([], E); 1433 result = dart.list([], E);
1447 result[dartx.length] = length; 1434 result[dartx.length] = length;
1448 } else { 1435 } else {
1449 result = List$(E).new(length); 1436 result = List$(E).new(length);
1450 } 1437 }
1451 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) { 1438 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) {
1452 result[dartx.set](i, generator(i)); 1439 result[dartx.set](i, generator(i));
1453 } 1440 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 let line = `${object}`; 1503 let line = `${object}`;
1517 if (_internal.printToZone == null) { 1504 if (_internal.printToZone == null) {
1518 _internal.printToConsole(line); 1505 _internal.printToConsole(line);
1519 } else { 1506 } else {
1520 dart.dcall(_internal.printToZone, line); 1507 dart.dcall(_internal.printToZone, line);
1521 } 1508 }
1522 } 1509 }
1523 dart.fn(print, dart.void, [Object]); 1510 dart.fn(print, dart.void, [Object]);
1524 class Match extends Object {} 1511 class Match extends Object {}
1525 class RegExp extends Object { 1512 class RegExp extends Object {
1526 static new(source, opts) { 1513 static new(source, {multiLine = false, caseSensitive = true} = {}) {
1527 let multiLine = opts && 'multiLine' in opts ? opts.multiLine : false;
1528 let caseSensitive = opts && 'caseSensitive' in opts ? opts.caseSensitive : true;
1529 return new _js_helper.JSSyntaxRegExp(source, {multiLine: multiLine, caseSe nsitive: caseSensitive}); 1514 return new _js_helper.JSSyntaxRegExp(source, {multiLine: multiLine, caseSe nsitive: caseSensitive});
1530 } 1515 }
1531 } 1516 }
1532 RegExp[dart.implements] = () => [Pattern]; 1517 RegExp[dart.implements] = () => [Pattern];
1533 dart.setSignature(RegExp, { 1518 dart.setSignature(RegExp, {
1534 constructors: () => ({new: [RegExp, [String], {multiLine: bool, caseSensitiv e: bool}]}) 1519 constructors: () => ({new: [RegExp, [String], {multiLine: bool, caseSensitiv e: bool}]})
1535 }); 1520 });
1536 const Set$ = dart.generic(function(E) { 1521 const Set$ = dart.generic(function(E) {
1537 class Set extends collection.IterableBase$(E) { 1522 class Set extends collection.IterableBase$(E) {
1538 static new() { 1523 static new() {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 dart.throw(new RangeError.range(end, start, len)); 1640 dart.throw(new RangeError.range(end, start, len));
1656 } 1641 }
1657 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(len)) { 1642 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(len)) {
1658 list = list[dartx.sublist](start, end); 1643 list = list[dartx.sublist](start, end);
1659 } 1644 }
1660 return _js_helper.Primitives.stringFromCharCodes(list); 1645 return _js_helper.Primitives.stringFromCharCodes(list);
1661 } 1646 }
1662 static fromCharCode(charCode) { 1647 static fromCharCode(charCode) {
1663 return _js_helper.Primitives.stringFromCharCode(charCode); 1648 return _js_helper.Primitives.stringFromCharCode(charCode);
1664 } 1649 }
1665 static fromEnvironment(name, opts) { 1650 static fromEnvironment(name, {defaultValue = null} = {}) {
1666 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : nu ll;
1667 dart.throw(new UnsupportedError('String.fromEnvironment can only be used a s a const constructor')); 1651 dart.throw(new UnsupportedError('String.fromEnvironment can only be used a s a const constructor'));
1668 } 1652 }
1669 static _stringFromIterable(charCodes, start, end) { 1653 static _stringFromIterable(charCodes, start, end) {
1670 if (dart.notNull(start) < 0) 1654 if (dart.notNull(start) < 0)
1671 dart.throw(new RangeError.range(start, 0, charCodes[dartx.length])); 1655 dart.throw(new RangeError.range(start, 0, charCodes[dartx.length]));
1672 if (end != null && dart.notNull(end) < dart.notNull(start)) { 1656 if (end != null && dart.notNull(end) < dart.notNull(start)) {
1673 dart.throw(new RangeError.range(end, start, charCodes[dartx.length])); 1657 dart.throw(new RangeError.range(end, start, charCodes[dartx.length]));
1674 } 1658 }
1675 let it = charCodes[dartx.iterator]; 1659 let it = charCodes[dartx.iterator];
1676 for (let i = 0; dart.notNull(i) < dart.notNull(start); i = dart.notNull(i) + 1) { 1660 for (let i = 0; dart.notNull(i) < dart.notNull(start); i = dart.notNull(i) + 1) {
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 this.scheme = scheme; 2144 this.scheme = scheme;
2161 this[_userInfo] = userInfo; 2145 this[_userInfo] = userInfo;
2162 this[_host] = host; 2146 this[_host] = host;
2163 this[_port] = port; 2147 this[_port] = port;
2164 this[_path] = path; 2148 this[_path] = path;
2165 this[_query] = query; 2149 this[_query] = query;
2166 this[_fragment] = fragment; 2150 this[_fragment] = fragment;
2167 this[_pathSegments] = null; 2151 this[_pathSegments] = null;
2168 this[_queryParameters] = null; 2152 this[_queryParameters] = null;
2169 } 2153 }
2170 static new(opts) { 2154 static new({scheme = "", userInfo = "", host = null, port = null, path = nul l, pathSegments = null, query = null, queryParameters = null, fragment = null} = {}) {
2171 let scheme = opts && 'scheme' in opts ? opts.scheme : "";
2172 let userInfo = opts && 'userInfo' in opts ? opts.userInfo : "";
2173 let host = opts && 'host' in opts ? opts.host : null;
2174 let port = opts && 'port' in opts ? opts.port : null;
2175 let path = opts && 'path' in opts ? opts.path : null;
2176 let pathSegments = opts && 'pathSegments' in opts ? opts.pathSegments : nu ll;
2177 let query = opts && 'query' in opts ? opts.query : null;
2178 let queryParameters = opts && 'queryParameters' in opts ? opts.queryParame ters : null;
2179 let fragment = opts && 'fragment' in opts ? opts.fragment : null;
2180 scheme = Uri._makeScheme(scheme, Uri._stringOrNullLength(scheme)); 2155 scheme = Uri._makeScheme(scheme, Uri._stringOrNullLength(scheme));
2181 userInfo = Uri._makeUserInfo(userInfo, 0, Uri._stringOrNullLength(userInfo )); 2156 userInfo = Uri._makeUserInfo(userInfo, 0, Uri._stringOrNullLength(userInfo ));
2182 host = Uri._makeHost(host, 0, Uri._stringOrNullLength(host), false); 2157 host = Uri._makeHost(host, 0, Uri._stringOrNullLength(host), false);
2183 if (query == "") 2158 if (query == "")
2184 query = null; 2159 query = null;
2185 query = Uri._makeQuery(query, 0, Uri._stringOrNullLength(query), queryPara meters); 2160 query = Uri._makeQuery(query, 0, Uri._stringOrNullLength(query), queryPara meters);
2186 fragment = Uri._makeFragment(fragment, 0, Uri._stringOrNullLength(fragment )); 2161 fragment = Uri._makeFragment(fragment, 0, Uri._stringOrNullLength(fragment ));
2187 port = Uri._makePort(port, scheme); 2162 port = Uri._makePort(port, scheme);
2188 let isFile = scheme == "file"; 2163 let isFile = scheme == "file";
2189 if (host == null && (dart.notNull(userInfo[dartx.isNotEmpty]) || port != n ull || dart.notNull(isFile))) { 2164 if (host == null && (dart.notNull(userInfo[dartx.isNotEmpty]) || port != n ull || dart.notNull(isFile))) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 let portString = authority[dartx.substring](dart.notNull(hostEnd) + 1); 2214 let portString = authority[dartx.substring](dart.notNull(hostEnd) + 1);
2240 if (dart.notNull(portString[dartx.isNotEmpty])) 2215 if (dart.notNull(portString[dartx.isNotEmpty]))
2241 port = int.parse(portString); 2216 port = int.parse(portString);
2242 break; 2217 break;
2243 } 2218 }
2244 } 2219 }
2245 host = authority[dartx.substring](hostStart, hostEnd); 2220 host = authority[dartx.substring](hostStart, hostEnd);
2246 } 2221 }
2247 return Uri.new({scheme: scheme, userInfo: userInfo, host: dart.as(host, St ring), port: dart.as(port, int), pathSegments: unencodedPath[dartx.split]("/"), queryParameters: queryParameters}); 2222 return Uri.new({scheme: scheme, userInfo: userInfo, host: dart.as(host, St ring), port: dart.as(port, int), pathSegments: unencodedPath[dartx.split]("/"), queryParameters: queryParameters});
2248 } 2223 }
2249 static file(path, opts) { 2224 static file(path, {windows = null} = {}) {
2250 let windows = opts && 'windows' in opts ? opts.windows : null;
2251 windows = windows == null ? Uri._isWindows : windows; 2225 windows = windows == null ? Uri._isWindows : windows;
2252 return dart.notNull(windows) ? dart.as(Uri._makeWindowsFileUrl(path), Uri) : dart.as(Uri._makeFileUri(path), Uri); 2226 return dart.notNull(windows) ? dart.as(Uri._makeWindowsFileUrl(path), Uri) : dart.as(Uri._makeFileUri(path), Uri);
2253 } 2227 }
2254 static get base() { 2228 static get base() {
2255 let uri = _js_helper.Primitives.currentUri(); 2229 let uri = _js_helper.Primitives.currentUri();
2256 if (uri != null) 2230 if (uri != null)
2257 return Uri.parse(uri); 2231 return Uri.parse(uri);
2258 dart.throw(new UnsupportedError("'Uri.base' is not supported")); 2232 dart.throw(new UnsupportedError("'Uri.base' is not supported"));
2259 } 2233 }
2260 static get _isWindows() { 2234 static get _isWindows() {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 let pathSegments = path[dartx.split](sep); 2311 let pathSegments = path[dartx.split](sep);
2338 Uri._checkWindowsPathReservedCharacters(pathSegments, true); 2312 Uri._checkWindowsPathReservedCharacters(pathSegments, true);
2339 return Uri.new({scheme: "file", pathSegments: pathSegments}); 2313 return Uri.new({scheme: "file", pathSegments: pathSegments});
2340 } 2314 }
2341 } else { 2315 } else {
2342 let pathSegments = path[dartx.split](sep); 2316 let pathSegments = path[dartx.split](sep);
2343 Uri._checkWindowsPathReservedCharacters(pathSegments, true); 2317 Uri._checkWindowsPathReservedCharacters(pathSegments, true);
2344 return Uri.new({pathSegments: pathSegments}); 2318 return Uri.new({pathSegments: pathSegments});
2345 } 2319 }
2346 } 2320 }
2347 replace(opts) { 2321 replace({scheme = null, userInfo = null, host = null, port = null, path = nu ll, pathSegments = null, query = null, queryParameters = null, fragment = null} = {}) {
2348 let scheme = opts && 'scheme' in opts ? opts.scheme : null;
2349 let userInfo = opts && 'userInfo' in opts ? opts.userInfo : null;
2350 let host = opts && 'host' in opts ? opts.host : null;
2351 let port = opts && 'port' in opts ? opts.port : null;
2352 let path = opts && 'path' in opts ? opts.path : null;
2353 let pathSegments = opts && 'pathSegments' in opts ? opts.pathSegments : nu ll;
2354 let query = opts && 'query' in opts ? opts.query : null;
2355 let queryParameters = opts && 'queryParameters' in opts ? opts.queryParame ters : null;
2356 let fragment = opts && 'fragment' in opts ? opts.fragment : null;
2357 let schemeChanged = false; 2322 let schemeChanged = false;
2358 if (scheme != null) { 2323 if (scheme != null) {
2359 scheme = Uri._makeScheme(scheme, scheme[dartx.length]); 2324 scheme = Uri._makeScheme(scheme, scheme[dartx.length]);
2360 schemeChanged = true; 2325 schemeChanged = true;
2361 } else { 2326 } else {
2362 scheme = this.scheme; 2327 scheme = this.scheme;
2363 } 2328 }
2364 let isFile = scheme == "file"; 2329 let isFile = scheme == "file";
2365 if (userInfo != null) { 2330 if (userInfo != null) {
2366 userInfo = Uri._makeUserInfo(userInfo, 0, userInfo[dartx.length]); 2331 userInfo = Uri._makeUserInfo(userInfo, 0, userInfo[dartx.length]);
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 if (this.scheme == "" || this[_host] == null || this[_host] == "") { 2818 if (this.scheme == "" || this[_host] == null || this[_host] == "") {
2854 dart.throw(new StateError(`Cannot use origin without a scheme: ${this}`) ); 2819 dart.throw(new StateError(`Cannot use origin without a scheme: ${this}`) );
2855 } 2820 }
2856 if (this.scheme != "http" && this.scheme != "https") { 2821 if (this.scheme != "http" && this.scheme != "https") {
2857 dart.throw(new StateError(`Origin is only applicable schemes http and ht tps: ${this}`)); 2822 dart.throw(new StateError(`Origin is only applicable schemes http and ht tps: ${this}`));
2858 } 2823 }
2859 if (this[_port] == null) 2824 if (this[_port] == null)
2860 return `${this.scheme}://${this[_host]}`; 2825 return `${this.scheme}://${this[_host]}`;
2861 return `${this.scheme}://${this[_host]}:${this[_port]}`; 2826 return `${this.scheme}://${this[_host]}:${this[_port]}`;
2862 } 2827 }
2863 toFilePath(opts) { 2828 toFilePath({windows = null} = {}) {
2864 let windows = opts && 'windows' in opts ? opts.windows : null;
2865 if (this.scheme != "" && this.scheme != "file") { 2829 if (this.scheme != "" && this.scheme != "file") {
2866 dart.throw(new UnsupportedError(`Cannot extract a file path from a ${thi s.scheme} URI`)); 2830 dart.throw(new UnsupportedError(`Cannot extract a file path from a ${thi s.scheme} URI`));
2867 } 2831 }
2868 if (this.query != "") { 2832 if (this.query != "") {
2869 dart.throw(new UnsupportedError("Cannot extract a file path from a URI w ith a query component")); 2833 dart.throw(new UnsupportedError("Cannot extract a file path from a URI w ith a query component"));
2870 } 2834 }
2871 if (this.fragment != "") { 2835 if (this.fragment != "") {
2872 dart.throw(new UnsupportedError("Cannot extract a file path from a URI w ith a fragment component")); 2836 dart.throw(new UnsupportedError("Cannot extract a file path from a URI w ith a fragment component"));
2873 } 2837 }
2874 if (windows == null) 2838 if (windows == null)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2959 } 2923 }
2960 static _addIfNonEmpty(sb, test, first, second) { 2924 static _addIfNonEmpty(sb, test, first, second) {
2961 if ("" != test) { 2925 if ("" != test) {
2962 sb.write(first); 2926 sb.write(first);
2963 sb.write(second); 2927 sb.write(second);
2964 } 2928 }
2965 } 2929 }
2966 static encodeComponent(component) { 2930 static encodeComponent(component) {
2967 return Uri._uriEncode(dart.as(Uri._unreserved2396Table, List$(int)), compo nent); 2931 return Uri._uriEncode(dart.as(Uri._unreserved2396Table, List$(int)), compo nent);
2968 } 2932 }
2969 static encodeQueryComponent(component, opts) { 2933 static encodeQueryComponent(component, {encoding = convert.UTF8} = {}) {
2970 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8;
2971 return Uri._uriEncode(dart.as(Uri._unreservedTable, List$(int)), component , {encoding: encoding, spaceToPlus: true}); 2934 return Uri._uriEncode(dart.as(Uri._unreservedTable, List$(int)), component , {encoding: encoding, spaceToPlus: true});
2972 } 2935 }
2973 static decodeComponent(encodedComponent) { 2936 static decodeComponent(encodedComponent) {
2974 return Uri._uriDecode(encodedComponent); 2937 return Uri._uriDecode(encodedComponent);
2975 } 2938 }
2976 static decodeQueryComponent(encodedComponent, opts) { 2939 static decodeQueryComponent(encodedComponent, {encoding = convert.UTF8} = {} ) {
2977 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8;
2978 return Uri._uriDecode(encodedComponent, {plusToSpace: true, encoding: enco ding}); 2940 return Uri._uriDecode(encodedComponent, {plusToSpace: true, encoding: enco ding});
2979 } 2941 }
2980 static encodeFull(uri) { 2942 static encodeFull(uri) {
2981 return Uri._uriEncode(dart.as(Uri._encodeFullTable, List$(int)), uri); 2943 return Uri._uriEncode(dart.as(Uri._encodeFullTable, List$(int)), uri);
2982 } 2944 }
2983 static decodeFull(uri) { 2945 static decodeFull(uri) {
2984 return Uri._uriDecode(uri); 2946 return Uri._uriDecode(uri);
2985 } 2947 }
2986 static splitQueryString(query, opts) { 2948 static splitQueryString(query, {encoding = convert.UTF8} = {}) {
2987 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8;
2988 return dart.as(query[dartx.split]("&")[dartx.fold](dart.map(), dart.fn((ma p, element) => { 2949 return dart.as(query[dartx.split]("&")[dartx.fold](dart.map(), dart.fn((ma p, element) => {
2989 let index = dart.as(dart.dsend(element, 'indexOf', "="), int); 2950 let index = dart.as(dart.dsend(element, 'indexOf', "="), int);
2990 if (index == -1) { 2951 if (index == -1) {
2991 if (!dart.equals(element, "")) { 2952 if (!dart.equals(element, "")) {
2992 dart.dsetindex(map, Uri.decodeQueryComponent(dart.as(element, String ), {encoding: encoding}), ""); 2953 dart.dsetindex(map, Uri.decodeQueryComponent(dart.as(element, String ), {encoding: encoding}), "");
2993 } 2954 }
2994 } else if (index != 0) { 2955 } else if (index != 0) {
2995 let key = dart.dsend(element, 'substring', 0, index); 2956 let key = dart.dsend(element, 'substring', 0, index);
2996 let value = dart.dsend(element, 'substring', dart.notNull(index) + 1); 2957 let value = dart.dsend(element, 'substring', dart.notNull(index) + 1);
2997 dart.dsetindex(map, Uri.decodeQueryComponent(dart.as(key, String), {en coding: encoding}), Uri.decodeQueryComponent(dart.as(value, String), {encoding: encoding})); 2958 dart.dsetindex(map, Uri.decodeQueryComponent(dart.as(key, String), {en coding: encoding}), Uri.decodeQueryComponent(dart.as(value, String), {encoding: encoding}));
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3106 index = dart.notNull(index) + 2; 3067 index = dart.notNull(index) + 2;
3107 } 3068 }
3108 } else { 3069 } else {
3109 bytes[dartx.set](index, dart.notNull(value) >> 8); 3070 bytes[dartx.set](index, dart.notNull(value) >> 8);
3110 bytes[dartx.set](dart.notNull(index) + 1, dart.notNull(value) & 255); 3071 bytes[dartx.set](dart.notNull(index) + 1, dart.notNull(value) & 255);
3111 index = dart.notNull(index) + 2; 3072 index = dart.notNull(index) + 2;
3112 } 3073 }
3113 } 3074 }
3114 return dart.as(bytes, List$(int)); 3075 return dart.as(bytes, List$(int));
3115 } 3076 }
3116 static _uriEncode(canonicalTable, text, opts) { 3077 static _uriEncode(canonicalTable, text, {encoding = convert.UTF8, spaceToPlu s = false} = {}) {
3117 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8;
3118 let spaceToPlus = opts && 'spaceToPlus' in opts ? opts.spaceToPlus : false ;
3119 function byteToHex(byte, buffer) { 3078 function byteToHex(byte, buffer) {
3120 let hex = '0123456789ABCDEF'; 3079 let hex = '0123456789ABCDEF';
3121 dart.dsend(buffer, 'writeCharCode', hex[dartx.codeUnitAt](dart.as(dart.d send(byte, '>>', 4), int))); 3080 dart.dsend(buffer, 'writeCharCode', hex[dartx.codeUnitAt](dart.as(dart.d send(byte, '>>', 4), int)));
3122 dart.dsend(buffer, 'writeCharCode', hex[dartx.codeUnitAt](dart.as(dart.d send(byte, '&', 15), int))); 3081 dart.dsend(buffer, 'writeCharCode', hex[dartx.codeUnitAt](dart.as(dart.d send(byte, '&', 15), int)));
3123 } 3082 }
3124 dart.fn(byteToHex); 3083 dart.fn(byteToHex);
3125 let result = new StringBuffer(); 3084 let result = new StringBuffer();
3126 let bytes = encoding.encode(text); 3085 let bytes = encoding.encode(text);
3127 for (let i = 0; dart.notNull(i) < dart.notNull(bytes[dartx.length]); i = d art.notNull(i) + 1) { 3086 for (let i = 0; dart.notNull(i) < dart.notNull(bytes[dartx.length]); i = d art.notNull(i) + 1) {
3128 let byte = bytes[dartx.get](i); 3087 let byte = bytes[dartx.get](i);
(...skipping 18 matching lines...) Expand all
3147 charCode = dart.notNull(charCode) | 32; 3106 charCode = dart.notNull(charCode) | 32;
3148 if (97 <= dart.notNull(charCode) && dart.notNull(charCode) <= 102) { 3107 if (97 <= dart.notNull(charCode) && dart.notNull(charCode) <= 102) {
3149 byte = dart.notNull(byte) * 16 + dart.notNull(charCode) - 87; 3108 byte = dart.notNull(byte) * 16 + dart.notNull(charCode) - 87;
3150 } else { 3109 } else {
3151 dart.throw(new ArgumentError("Invalid URL encoding")); 3110 dart.throw(new ArgumentError("Invalid URL encoding"));
3152 } 3111 }
3153 } 3112 }
3154 } 3113 }
3155 return byte; 3114 return byte;
3156 } 3115 }
3157 static _uriDecode(text, opts) { 3116 static _uriDecode(text, {plusToSpace = false, encoding = convert.UTF8} = {}) {
3158 let plusToSpace = opts && 'plusToSpace' in opts ? opts.plusToSpace : false ;
3159 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8;
3160 let simple = true; 3117 let simple = true;
3161 for (let i = 0; dart.notNull(i) < dart.notNull(text[dartx.length]) && dart .notNull(simple); i = dart.notNull(i) + 1) { 3118 for (let i = 0; dart.notNull(i) < dart.notNull(text[dartx.length]) && dart .notNull(simple); i = dart.notNull(i) + 1) {
3162 let codeUnit = text[dartx.codeUnitAt](i); 3119 let codeUnit = text[dartx.codeUnitAt](i);
3163 simple = codeUnit != Uri._PERCENT && codeUnit != Uri._PLUS; 3120 simple = codeUnit != Uri._PERCENT && codeUnit != Uri._PLUS;
3164 } 3121 }
3165 let bytes = null; 3122 let bytes = null;
3166 if (dart.notNull(simple)) { 3123 if (dart.notNull(simple)) {
3167 if (dart.equals(encoding, convert.UTF8) || dart.equals(encoding, convert .LATIN1)) { 3124 if (dart.equals(encoding, convert.UTF8) || dart.equals(encoding, convert .LATIN1)) {
3168 return text; 3125 return text;
3169 } else { 3126 } else {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
3366 exports.StackTrace = StackTrace; 3323 exports.StackTrace = StackTrace;
3367 exports.Stopwatch = Stopwatch; 3324 exports.Stopwatch = Stopwatch;
3368 exports.String = String; 3325 exports.String = String;
3369 exports.RuneIterator = RuneIterator; 3326 exports.RuneIterator = RuneIterator;
3370 exports.StringBuffer = StringBuffer; 3327 exports.StringBuffer = StringBuffer;
3371 exports.StringSink = StringSink; 3328 exports.StringSink = StringSink;
3372 exports.Symbol = Symbol; 3329 exports.Symbol = Symbol;
3373 exports.Type = Type; 3330 exports.Type = Type;
3374 exports.Uri = Uri; 3331 exports.Uri = Uri;
3375 }); 3332 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/convert.js ('k') | lib/runtime/dart/isolate.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698