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

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

Issue 1178523004: fixes #215, removes special case for length (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: 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 dart.library('dart/core', null, /* Imports */[ 1 dart.library('dart/core', null, /* Imports */[
2 ], /* Lazy imports */[ 2 ], /* Lazy imports */[
3 'dart/_js_helper', 3 'dart/_js_helper',
4 'dart/_internal', 4 'dart/_internal',
5 'dart/collection', 5 'dart/collection',
6 'dart/_interceptors', 6 'dart/_interceptors',
7 'dart/convert' 7 'dart/convert'
8 ], function(exports, _js_helper, _internal, collection, _interceptors, convert) { 8 ], function(exports, _js_helper, _internal, collection, _interceptors, convert) {
9 'use strict'; 9 'use strict';
10 class Object { 10 class Object {
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 this[_memberName] = memberName; 881 this[_memberName] = memberName;
882 this[_arguments] = positionalArguments; 882 this[_arguments] = positionalArguments;
883 this[_namedArguments] = namedArguments; 883 this[_namedArguments] = namedArguments;
884 this[_existingArgumentNames] = existingArgumentNames; 884 this[_existingArgumentNames] = existingArgumentNames;
885 super.Error(); 885 super.Error();
886 } 886 }
887 toString() { 887 toString() {
888 let sb = new StringBuffer(); 888 let sb = new StringBuffer();
889 let i = 0; 889 let i = 0;
890 if (this[_arguments] != null) { 890 if (this[_arguments] != null) {
891 for (; dart.notNull(i) < dart.notNull(this[_arguments].length); i = dart .notNull(i) + 1) { 891 for (; dart.notNull(i) < dart.notNull(this[_arguments][dartx.length]); i = dart.notNull(i) + 1) {
892 if (dart.notNull(i) > 0) { 892 if (dart.notNull(i) > 0) {
893 sb.write(", "); 893 sb.write(", ");
894 } 894 }
895 sb.write(Error.safeToString(this[_arguments][dartx.get](i))); 895 sb.write(Error.safeToString(this[_arguments][dartx.get](i)));
896 } 896 }
897 } 897 }
898 if (this[_namedArguments] != null) { 898 if (this[_namedArguments] != null) {
899 this[_namedArguments].forEach(dart.fn((key, value) => { 899 this[_namedArguments].forEach(dart.fn((key, value) => {
900 if (dart.notNull(i) > 0) { 900 if (dart.notNull(i) > 0) {
901 sb.write(", "); 901 sb.write(", ");
902 } 902 }
903 sb.write(_symbolToString(key)); 903 sb.write(_symbolToString(key));
904 sb.write(": "); 904 sb.write(": ");
905 sb.write(Error.safeToString(value)); 905 sb.write(Error.safeToString(value));
906 i = dart.notNull(i) + 1; 906 i = dart.notNull(i) + 1;
907 }, Object, [Symbol, Object])); 907 }, Object, [Symbol, Object]));
908 } 908 }
909 if (this[_existingArgumentNames] == null) { 909 if (this[_existingArgumentNames] == null) {
910 return `NoSuchMethodError : method not found: '${this[_memberName]}'\n` + `Receiver: ${Error.safeToString(this[_receiver])}\n` + `Arguments: [${sb}]`; 910 return `NoSuchMethodError : method not found: '${this[_memberName]}'\n` + `Receiver: ${Error.safeToString(this[_receiver])}\n` + `Arguments: [${sb}]`;
911 } else { 911 } else {
912 let actualParameters = dart.toString(sb); 912 let actualParameters = dart.toString(sb);
913 sb = new StringBuffer(); 913 sb = new StringBuffer();
914 for (let i = 0; dart.notNull(i) < dart.notNull(this[_existingArgumentNam es].length); i = dart.notNull(i) + 1) { 914 for (let i = 0; dart.notNull(i) < dart.notNull(this[_existingArgumentNam es][dartx.length]); i = dart.notNull(i) + 1) {
915 if (dart.notNull(i) > 0) { 915 if (dart.notNull(i) > 0) {
916 sb.write(", "); 916 sb.write(", ");
917 } 917 }
918 sb.write(this[_existingArgumentNames][dartx.get](i)); 918 sb.write(this[_existingArgumentNames][dartx.get](i));
919 } 919 }
920 let formalParameters = dart.toString(sb); 920 let formalParameters = dart.toString(sb);
921 return "NoSuchMethodError: incorrect number of arguments passed to " + ` method named '${this[_memberName]}'\n` + `Receiver: ${Error.safeToString(this[_r eceiver])}\n` + `Tried calling: ${this[_memberName]}(${actualParameters})\n` + ` Found: ${this[_memberName]}(${formalParameters})`; 921 return "NoSuchMethodError: incorrect number of arguments passed to " + ` method named '${this[_memberName]}'\n` + `Receiver: ${Error.safeToString(this[_r eceiver])}\n` + `Tried calling: ${this[_memberName]}(${actualParameters})\n` + ` Found: ${this[_memberName]}(${formalParameters})`;
922 } 922 }
923 } 923 }
924 } 924 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 if (offset != -1) { 1071 if (offset != -1) {
1072 report = dart.notNull(report) + ` (at offset ${offset})`; 1072 report = dart.notNull(report) + ` (at offset ${offset})`;
1073 } 1073 }
1074 return report; 1074 return report;
1075 } 1075 }
1076 if (offset != -1 && (dart.notNull(offset) < 0 || dart.notNull(offset) > da rt.notNull(dart.as(dart.dload(this.source, 'length'), num)))) { 1076 if (offset != -1 && (dart.notNull(offset) < 0 || dart.notNull(offset) > da rt.notNull(dart.as(dart.dload(this.source, 'length'), num)))) {
1077 offset = -1; 1077 offset = -1;
1078 } 1078 }
1079 if (offset == -1) { 1079 if (offset == -1) {
1080 let source = dart.as(this.source, String); 1080 let source = dart.as(this.source, String);
1081 if (dart.notNull(source.length) > 78) { 1081 if (dart.notNull(source[dartx.length]) > 78) {
1082 source = dart.notNull(source[dartx.substring](0, 75)) + "..."; 1082 source = dart.notNull(source[dartx.substring](0, 75)) + "...";
1083 } 1083 }
1084 return `${report}\n${source}`; 1084 return `${report}\n${source}`;
1085 } 1085 }
1086 let lineNum = 1; 1086 let lineNum = 1;
1087 let lineStart = 0; 1087 let lineStart = 0;
1088 let lastWasCR = null; 1088 let lastWasCR = null;
1089 for (let i = 0; dart.notNull(i) < dart.notNull(offset); i = dart.notNull(i ) + 1) { 1089 for (let i = 0; dart.notNull(i) < dart.notNull(offset); i = dart.notNull(i ) + 1) {
1090 let char = dart.as(dart.dsend(this.source, 'codeUnitAt', i), int); 1090 let char = dart.as(dart.dsend(this.source, 'codeUnitAt', i), int);
1091 if (char == 10) { 1091 if (char == 10) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 } else if (dart.notNull(end) - dart.notNull(offset) < 75) { 1126 } else if (dart.notNull(end) - dart.notNull(offset) < 75) {
1127 start = dart.notNull(end) - 75; 1127 start = dart.notNull(end) - 75;
1128 prefix = "..."; 1128 prefix = "...";
1129 } else { 1129 } else {
1130 start = dart.notNull(offset) - 36; 1130 start = dart.notNull(offset) - 36;
1131 end = dart.notNull(offset) + 36; 1131 end = dart.notNull(offset) + 36;
1132 prefix = postfix = "..."; 1132 prefix = postfix = "...";
1133 } 1133 }
1134 } 1134 }
1135 let slice = dart.as(dart.dsend(this.source, 'substring', start, end), Stri ng); 1135 let slice = dart.as(dart.dsend(this.source, 'substring', start, end), Stri ng);
1136 let markOffset = dart.notNull(offset) - dart.notNull(start) + dart.notNull (prefix.length); 1136 let markOffset = dart.notNull(offset) - dart.notNull(start) + dart.notNull (prefix[dartx.length]);
1137 return `${report}${prefix}${slice}${postfix}\n${" "[dartx['*']](markOffset )}^\n`; 1137 return `${report}${prefix}${slice}${postfix}\n${" "[dartx['*']](markOffset )}^\n`;
1138 } 1138 }
1139 } 1139 }
1140 FormatException[dart.implements] = () => [Exception]; 1140 FormatException[dart.implements] = () => [Exception];
1141 dart.setSignature(FormatException, { 1141 dart.setSignature(FormatException, {
1142 constructors: () => ({FormatException: [FormatException, [], [String, Object , int]]}) 1142 constructors: () => ({FormatException: [FormatException, [], [String, Object , int]]})
1143 }); 1143 });
1144 class IntegerDivisionByZeroException extends Object { 1144 class IntegerDivisionByZeroException extends Object {
1145 IntegerDivisionByZeroException() { 1145 IntegerDivisionByZeroException() {
1146 } 1146 }
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 if (!(typeof length == 'number') || dart.notNull(length) < 0) { 1408 if (!(typeof length == 'number') || dart.notNull(length) < 0) {
1409 throw new ArgumentError(`Length must be a non-negative integer: ${le ngth}`); 1409 throw new ArgumentError(`Length must be a non-negative integer: ${le ngth}`);
1410 } 1410 }
1411 list = _interceptors.JSArray.markFixedList(dart.as(new Array(length), List$())); 1411 list = _interceptors.JSArray.markFixedList(dart.as(new Array(length), List$()));
1412 } 1412 }
1413 return _interceptors.JSArray$(E).typed(list); 1413 return _interceptors.JSArray$(E).typed(list);
1414 } 1414 }
1415 static filled(length, fill) { 1415 static filled(length, fill) {
1416 let result = List$(E).new(length); 1416 let result = List$(E).new(length);
1417 if (length != 0 && fill != null) { 1417 if (length != 0 && fill != null) {
1418 for (let i = 0; dart.notNull(i) < dart.notNull(result.length); i = dar t.notNull(i) + 1) { 1418 for (let i = 0; dart.notNull(i) < dart.notNull(result[dartx.length]); i = dart.notNull(i) + 1) {
1419 result[dartx.set](i, fill); 1419 result[dartx.set](i, fill);
1420 } 1420 }
1421 } 1421 }
1422 return result; 1422 return result;
1423 } 1423 }
1424 static from(elements, opts) { 1424 static from(elements, opts) {
1425 let growable = opts && 'growable' in opts ? opts.growable : true; 1425 let growable = opts && 'growable' in opts ? opts.growable : true;
1426 let list = List$(E).new(); 1426 let list = List$(E).new();
1427 for (let e of elements) { 1427 for (let e of elements) {
1428 list[dartx.add](dart.as(e, E)); 1428 list[dartx.add](dart.as(e, E));
1429 } 1429 }
1430 if (dart.notNull(growable)) 1430 if (dart.notNull(growable))
1431 return list; 1431 return list;
1432 return dart.as(_internal.makeListFixedLength(list), List$(E)); 1432 return dart.as(_internal.makeListFixedLength(list), List$(E));
1433 } 1433 }
1434 static generate(length, generator, opts) { 1434 static generate(length, generator, opts) {
1435 let growable = opts && 'growable' in opts ? opts.growable : true; 1435 let growable = opts && 'growable' in opts ? opts.growable : true;
1436 let result = null; 1436 let result = null;
1437 if (dart.notNull(growable)) { 1437 if (dart.notNull(growable)) {
1438 result = dart.list([], E); 1438 result = dart.list([], E);
1439 result.length = length; 1439 result[dartx.length] = length;
1440 } else { 1440 } else {
1441 result = List$(E).new(length); 1441 result = List$(E).new(length);
1442 } 1442 }
1443 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) { 1443 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) {
1444 result[dartx.set](i, generator(i)); 1444 result[dartx.set](i, generator(i));
1445 } 1445 }
1446 return result; 1446 return result;
1447 } 1447 }
1448 [dart.JsSymbol.iterator]() { 1448 [dart.JsSymbol.iterator]() {
1449 return new dart.JsIterator(this[dartx.iterator]); 1449 return new dart.JsIterator(this[dartx.iterator]);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 class String extends Object { 1630 class String extends Object {
1631 static fromCharCodes(charCodes, start, end) { 1631 static fromCharCodes(charCodes, start, end) {
1632 if (start === void 0) 1632 if (start === void 0)
1633 start = 0; 1633 start = 0;
1634 if (end === void 0) 1634 if (end === void 0)
1635 end = null; 1635 end = null;
1636 if (!dart.is(charCodes, _interceptors.JSArray)) { 1636 if (!dart.is(charCodes, _interceptors.JSArray)) {
1637 return String._stringFromIterable(charCodes, start, end); 1637 return String._stringFromIterable(charCodes, start, end);
1638 } 1638 }
1639 let list = dart.as(charCodes, List); 1639 let list = dart.as(charCodes, List);
1640 let len = list.length; 1640 let len = list[dartx.length];
1641 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(len)) { 1641 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(len)) {
1642 throw new RangeError.range(start, 0, len); 1642 throw new RangeError.range(start, 0, len);
1643 } 1643 }
1644 if (end == null) { 1644 if (end == null) {
1645 end = len; 1645 end = len;
1646 } else if (dart.notNull(end) < dart.notNull(start) || dart.notNull(end) > dart.notNull(len)) { 1646 } else if (dart.notNull(end) < dart.notNull(start) || dart.notNull(end) > dart.notNull(len)) {
1647 throw new RangeError.range(end, start, len); 1647 throw new RangeError.range(end, start, len);
1648 } 1648 }
1649 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(len)) { 1649 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(len)) {
1650 list = list[dartx.sublist](start, end); 1650 list = list[dartx.sublist](start, end);
1651 } 1651 }
1652 return _js_helper.Primitives.stringFromCharCodes(list); 1652 return _js_helper.Primitives.stringFromCharCodes(list);
1653 } 1653 }
1654 static fromCharCode(charCode) { 1654 static fromCharCode(charCode) {
1655 return _js_helper.Primitives.stringFromCharCode(charCode); 1655 return _js_helper.Primitives.stringFromCharCode(charCode);
1656 } 1656 }
1657 static fromEnvironment(name, opts) { 1657 static fromEnvironment(name, opts) {
1658 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : nu ll; 1658 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : nu ll;
1659 throw new UnsupportedError('String.fromEnvironment can only be used as a c onst constructor'); 1659 throw new UnsupportedError('String.fromEnvironment can only be used as a c onst constructor');
1660 } 1660 }
1661 static _stringFromIterable(charCodes, start, end) { 1661 static _stringFromIterable(charCodes, start, end) {
1662 if (dart.notNull(start) < 0) 1662 if (dart.notNull(start) < 0)
1663 throw new RangeError.range(start, 0, charCodes.length); 1663 throw new RangeError.range(start, 0, charCodes[dartx.length]);
1664 if (end != null && dart.notNull(end) < dart.notNull(start)) { 1664 if (end != null && dart.notNull(end) < dart.notNull(start)) {
1665 throw new RangeError.range(end, start, charCodes.length); 1665 throw new RangeError.range(end, start, charCodes[dartx.length]);
1666 } 1666 }
1667 let it = charCodes[dartx.iterator]; 1667 let it = charCodes[dartx.iterator];
1668 for (let i = 0; dart.notNull(i) < dart.notNull(start); i = dart.notNull(i) + 1) { 1668 for (let i = 0; dart.notNull(i) < dart.notNull(start); i = dart.notNull(i) + 1) {
1669 if (!dart.notNull(it.moveNext())) { 1669 if (!dart.notNull(it.moveNext())) {
1670 throw new RangeError.range(start, 0, i); 1670 throw new RangeError.range(start, 0, i);
1671 } 1671 }
1672 } 1672 }
1673 let list = []; 1673 let list = [];
1674 if (end == null) { 1674 if (end == null) {
1675 while (dart.notNull(it.moveNext())) 1675 while (dart.notNull(it.moveNext()))
(...skipping 23 matching lines...) Expand all
1699 get Runes() { 1699 get Runes() {
1700 class Runes extends collection.IterableBase$(int) { 1700 class Runes extends collection.IterableBase$(int) {
1701 Runes(string) { 1701 Runes(string) {
1702 this.string = string; 1702 this.string = string;
1703 super.IterableBase(); 1703 super.IterableBase();
1704 } 1704 }
1705 get iterator() { 1705 get iterator() {
1706 return new RuneIterator(this.string); 1706 return new RuneIterator(this.string);
1707 } 1707 }
1708 get last() { 1708 get last() {
1709 if (this.string.length == 0) { 1709 if (this.string[dartx.length] == 0) {
1710 throw new StateError('No elements.'); 1710 throw new StateError('No elements.');
1711 } 1711 }
1712 let length = this.string.length; 1712 let length = this.string[dartx.length];
1713 let code = this.string[dartx.codeUnitAt](dart.notNull(length) - 1); 1713 let code = this.string[dartx.codeUnitAt](dart.notNull(length) - 1);
1714 if (dart.notNull(_isTrailSurrogate(code)) && dart.notNull(this.string. length) > 1) { 1714 if (dart.notNull(_isTrailSurrogate(code)) && dart.notNull(this.string[ dartx.length]) > 1) {
1715 let previousCode = this.string[dartx.codeUnitAt](dart.notNull(length ) - 2); 1715 let previousCode = this.string[dartx.codeUnitAt](dart.notNull(length ) - 2);
1716 if (dart.notNull(_isLeadSurrogate(previousCode))) { 1716 if (dart.notNull(_isLeadSurrogate(previousCode))) {
1717 return _combineSurrogatePair(previousCode, code); 1717 return _combineSurrogatePair(previousCode, code);
1718 } 1718 }
1719 } 1719 }
1720 return code; 1720 return code;
1721 } 1721 }
1722 } 1722 }
1723 dart.setSignature(Runes, { 1723 dart.setSignature(Runes, {
1724 constructors: () => ({Runes: [exports.Runes, [String]]}) 1724 constructors: () => ({Runes: [exports.Runes, [String]]})
(...skipping 23 matching lines...) Expand all
1748 this.string = string; 1748 this.string = string;
1749 this[_position] = 0; 1749 this[_position] = 0;
1750 this[_nextPosition] = 0; 1750 this[_nextPosition] = 0;
1751 this[_currentCodePoint] = null; 1751 this[_currentCodePoint] = null;
1752 } 1752 }
1753 at(string, index) { 1753 at(string, index) {
1754 this.string = string; 1754 this.string = string;
1755 this[_position] = index; 1755 this[_position] = index;
1756 this[_nextPosition] = index; 1756 this[_nextPosition] = index;
1757 this[_currentCodePoint] = null; 1757 this[_currentCodePoint] = null;
1758 RangeError.checkValueInInterval(index, 0, string.length); 1758 RangeError.checkValueInInterval(index, 0, string[dartx.length]);
1759 this[_checkSplitSurrogate](index); 1759 this[_checkSplitSurrogate](index);
1760 } 1760 }
1761 [_checkSplitSurrogate](index) { 1761 [_checkSplitSurrogate](index) {
1762 if (dart.notNull(index) > 0 && dart.notNull(index) < dart.notNull(this.str ing.length) && dart.notNull(_isLeadSurrogate(this.string[dartx.codeUnitAt](dart. notNull(index) - 1))) && dart.notNull(_isTrailSurrogate(this.string[dartx.codeUn itAt](index)))) { 1762 if (dart.notNull(index) > 0 && dart.notNull(index) < dart.notNull(this.str ing[dartx.length]) && dart.notNull(_isLeadSurrogate(this.string[dartx.codeUnitAt ](dart.notNull(index) - 1))) && dart.notNull(_isTrailSurrogate(this.string[dartx .codeUnitAt](index)))) {
1763 throw new ArgumentError(`Index inside surrogate pair: ${index}`); 1763 throw new ArgumentError(`Index inside surrogate pair: ${index}`);
1764 } 1764 }
1765 } 1765 }
1766 get rawIndex() { 1766 get rawIndex() {
1767 return this[_position] != this[_nextPosition] ? this[_position] : null; 1767 return this[_position] != this[_nextPosition] ? this[_position] : null;
1768 } 1768 }
1769 set rawIndex(rawIndex) { 1769 set rawIndex(rawIndex) {
1770 RangeError.checkValidIndex(rawIndex, this.string, "rawIndex"); 1770 RangeError.checkValidIndex(rawIndex, this.string, "rawIndex");
1771 this.reset(rawIndex); 1771 this.reset(rawIndex);
1772 this.moveNext(); 1772 this.moveNext();
1773 } 1773 }
1774 reset(rawIndex) { 1774 reset(rawIndex) {
1775 if (rawIndex === void 0) 1775 if (rawIndex === void 0)
1776 rawIndex = 0; 1776 rawIndex = 0;
1777 RangeError.checkValueInInterval(rawIndex, 0, this.string.length, "rawIndex "); 1777 RangeError.checkValueInInterval(rawIndex, 0, this.string[dartx.length], "r awIndex");
1778 this[_checkSplitSurrogate](rawIndex); 1778 this[_checkSplitSurrogate](rawIndex);
1779 this[_position] = this[_nextPosition] = rawIndex; 1779 this[_position] = this[_nextPosition] = rawIndex;
1780 this[_currentCodePoint] = null; 1780 this[_currentCodePoint] = null;
1781 } 1781 }
1782 get current() { 1782 get current() {
1783 return this[_currentCodePoint]; 1783 return this[_currentCodePoint];
1784 } 1784 }
1785 get currentSize() { 1785 get currentSize() {
1786 return dart.notNull(this[_nextPosition]) - dart.notNull(this[_position]); 1786 return dart.notNull(this[_nextPosition]) - dart.notNull(this[_position]);
1787 } 1787 }
1788 get currentAsString() { 1788 get currentAsString() {
1789 if (this[_position] == this[_nextPosition]) 1789 if (this[_position] == this[_nextPosition])
1790 return null; 1790 return null;
1791 if (dart.notNull(this[_position]) + 1 == this[_nextPosition]) 1791 if (dart.notNull(this[_position]) + 1 == this[_nextPosition])
1792 return this.string[dartx.get](this[_position]); 1792 return this.string[dartx.get](this[_position]);
1793 return this.string[dartx.substring](this[_position], this[_nextPosition]); 1793 return this.string[dartx.substring](this[_position], this[_nextPosition]);
1794 } 1794 }
1795 moveNext() { 1795 moveNext() {
1796 this[_position] = this[_nextPosition]; 1796 this[_position] = this[_nextPosition];
1797 if (this[_position] == this.string.length) { 1797 if (this[_position] == this.string[dartx.length]) {
1798 this[_currentCodePoint] = null; 1798 this[_currentCodePoint] = null;
1799 return false; 1799 return false;
1800 } 1800 }
1801 let codeUnit = this.string[dartx.codeUnitAt](this[_position]); 1801 let codeUnit = this.string[dartx.codeUnitAt](this[_position]);
1802 let nextPosition = dart.notNull(this[_position]) + 1; 1802 let nextPosition = dart.notNull(this[_position]) + 1;
1803 if (dart.notNull(_isLeadSurrogate(codeUnit)) && dart.notNull(nextPosition) < dart.notNull(this.string.length)) { 1803 if (dart.notNull(_isLeadSurrogate(codeUnit)) && dart.notNull(nextPosition) < dart.notNull(this.string[dartx.length])) {
1804 let nextCodeUnit = this.string[dartx.codeUnitAt](nextPosition); 1804 let nextCodeUnit = this.string[dartx.codeUnitAt](nextPosition);
1805 if (dart.notNull(_isTrailSurrogate(nextCodeUnit))) { 1805 if (dart.notNull(_isTrailSurrogate(nextCodeUnit))) {
1806 this[_nextPosition] = dart.notNull(nextPosition) + 1; 1806 this[_nextPosition] = dart.notNull(nextPosition) + 1;
1807 this[_currentCodePoint] = _combineSurrogatePair(codeUnit, nextCodeUnit ); 1807 this[_currentCodePoint] = _combineSurrogatePair(codeUnit, nextCodeUnit );
1808 return true; 1808 return true;
1809 } 1809 }
1810 } 1810 }
1811 this[_nextPosition] = nextPosition; 1811 this[_nextPosition] = nextPosition;
1812 this[_currentCodePoint] = codeUnit; 1812 this[_currentCodePoint] = codeUnit;
1813 return true; 1813 return true;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 }); 1849 });
1850 let _contents = dart.JsSymbol('_contents'); 1850 let _contents = dart.JsSymbol('_contents');
1851 let _writeString = dart.JsSymbol('_writeString'); 1851 let _writeString = dart.JsSymbol('_writeString');
1852 class StringBuffer extends Object { 1852 class StringBuffer extends Object {
1853 StringBuffer(content) { 1853 StringBuffer(content) {
1854 if (content === void 0) 1854 if (content === void 0)
1855 content = ""; 1855 content = "";
1856 this[_contents] = `${content}`; 1856 this[_contents] = `${content}`;
1857 } 1857 }
1858 get length() { 1858 get length() {
1859 return this[_contents].length; 1859 return this[_contents][dartx.length];
1860 } 1860 }
1861 get isEmpty() { 1861 get isEmpty() {
1862 return this.length == 0; 1862 return this.length == 0;
1863 } 1863 }
1864 get isNotEmpty() { 1864 get isNotEmpty() {
1865 return !dart.notNull(this.isEmpty); 1865 return !dart.notNull(this.isEmpty);
1866 } 1866 }
1867 write(obj) { 1867 write(obj) {
1868 this[_writeString](`${obj}`); 1868 this[_writeString](`${obj}`);
1869 } 1869 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 this[_writeAuthority](sb); 1949 this[_writeAuthority](sb);
1950 return dart.toString(sb); 1950 return dart.toString(sb);
1951 } 1951 }
1952 get userInfo() { 1952 get userInfo() {
1953 return this[_userInfo]; 1953 return this[_userInfo];
1954 } 1954 }
1955 get host() { 1955 get host() {
1956 if (this[_host] == null) 1956 if (this[_host] == null)
1957 return ""; 1957 return "";
1958 if (dart.notNull(this[_host][dartx.startsWith]('['))) { 1958 if (dart.notNull(this[_host][dartx.startsWith]('['))) {
1959 return this[_host][dartx.substring](1, dart.notNull(this[_host].length) - 1); 1959 return this[_host][dartx.substring](1, dart.notNull(this[_host][dartx.le ngth]) - 1);
1960 } 1960 }
1961 return this[_host]; 1961 return this[_host];
1962 } 1962 }
1963 get port() { 1963 get port() {
1964 if (this[_port] == null) 1964 if (this[_port] == null)
1965 return Uri._defaultPort(this.scheme); 1965 return Uri._defaultPort(this.scheme);
1966 return this[_port]; 1966 return this[_port];
1967 } 1967 }
1968 static _defaultPort(scheme) { 1968 static _defaultPort(scheme) {
1969 if (scheme == "http") 1969 if (scheme == "http")
(...skipping 21 matching lines...) Expand all
1991 let userinfo = ""; 1991 let userinfo = "";
1992 let host = null; 1992 let host = null;
1993 let port = null; 1993 let port = null;
1994 let path = null; 1994 let path = null;
1995 let query = null; 1995 let query = null;
1996 let fragment = null; 1996 let fragment = null;
1997 let index = 0; 1997 let index = 0;
1998 let pathStart = 0; 1998 let pathStart = 0;
1999 let char = EOI; 1999 let char = EOI;
2000 let parseAuth = () => { 2000 let parseAuth = () => {
2001 if (index == uri.length) { 2001 if (index == uri[dartx.length]) {
2002 char = EOI; 2002 char = EOI;
2003 return; 2003 return;
2004 } 2004 }
2005 let authStart = index; 2005 let authStart = index;
2006 let lastColon = -1; 2006 let lastColon = -1;
2007 let lastAt = -1; 2007 let lastAt = -1;
2008 char = uri[dartx.codeUnitAt](index); 2008 char = uri[dartx.codeUnitAt](index);
2009 while (dart.notNull(index) < dart.notNull(uri.length)) { 2009 while (dart.notNull(index) < dart.notNull(uri[dartx.length])) {
2010 char = uri[dartx.codeUnitAt](index); 2010 char = uri[dartx.codeUnitAt](index);
2011 if (char == Uri._SLASH || char == Uri._QUESTION || char == Uri._NUMBER _SIGN) { 2011 if (char == Uri._SLASH || char == Uri._QUESTION || char == Uri._NUMBER _SIGN) {
2012 break; 2012 break;
2013 } 2013 }
2014 if (char == Uri._AT_SIGN) { 2014 if (char == Uri._AT_SIGN) {
2015 lastAt = index; 2015 lastAt = index;
2016 lastColon = -1; 2016 lastColon = -1;
2017 } else if (char == Uri._COLON) { 2017 } else if (char == Uri._COLON) {
2018 lastColon = index; 2018 lastColon = index;
2019 } else if (char == Uri._LEFT_BRACKET) { 2019 } else if (char == Uri._LEFT_BRACKET) {
2020 lastColon = -1; 2020 lastColon = -1;
2021 let endBracket = uri[dartx.indexOf](']', dart.notNull(index) + 1); 2021 let endBracket = uri[dartx.indexOf](']', dart.notNull(index) + 1);
2022 if (endBracket == -1) { 2022 if (endBracket == -1) {
2023 index = uri.length; 2023 index = uri[dartx.length];
2024 char = EOI; 2024 char = EOI;
2025 break; 2025 break;
2026 } else { 2026 } else {
2027 index = endBracket; 2027 index = endBracket;
2028 } 2028 }
2029 } 2029 }
2030 index = dart.notNull(index) + 1; 2030 index = dart.notNull(index) + 1;
2031 char = EOI; 2031 char = EOI;
2032 } 2032 }
2033 let hostStart = authStart; 2033 let hostStart = authStart;
(...skipping 11 matching lines...) Expand all
2045 if (dart.notNull(Uri._ZERO) > dart.notNull(digit) || dart.notNull( Uri._NINE) < dart.notNull(digit)) { 2045 if (dart.notNull(Uri._ZERO) > dart.notNull(digit) || dart.notNull( Uri._NINE) < dart.notNull(digit)) {
2046 Uri._fail(uri, i, "Invalid port number"); 2046 Uri._fail(uri, i, "Invalid port number");
2047 } 2047 }
2048 portNumber = dart.notNull(portNumber) * 10 + (dart.notNull(digit) - dart.notNull(Uri._ZERO)); 2048 portNumber = dart.notNull(portNumber) * 10 + (dart.notNull(digit) - dart.notNull(Uri._ZERO));
2049 } 2049 }
2050 } 2050 }
2051 port = Uri._makePort(portNumber, scheme); 2051 port = Uri._makePort(portNumber, scheme);
2052 hostEnd = lastColon; 2052 hostEnd = lastColon;
2053 } 2053 }
2054 host = Uri._makeHost(uri, hostStart, hostEnd, true); 2054 host = Uri._makeHost(uri, hostStart, hostEnd, true);
2055 if (dart.notNull(index) < dart.notNull(uri.length)) { 2055 if (dart.notNull(index) < dart.notNull(uri[dartx.length])) {
2056 char = uri[dartx.codeUnitAt](index); 2056 char = uri[dartx.codeUnitAt](index);
2057 } 2057 }
2058 }; 2058 };
2059 dart.fn(parseAuth, dart.void, []); 2059 dart.fn(parseAuth, dart.void, []);
2060 let NOT_IN_PATH = 0; 2060 let NOT_IN_PATH = 0;
2061 let IN_PATH = 1; 2061 let IN_PATH = 1;
2062 let ALLOW_AUTH = 2; 2062 let ALLOW_AUTH = 2;
2063 let state = NOT_IN_PATH; 2063 let state = NOT_IN_PATH;
2064 let i = index; 2064 let i = index;
2065 while (dart.notNull(i) < dart.notNull(uri.length)) { 2065 while (dart.notNull(i) < dart.notNull(uri[dartx.length])) {
2066 char = uri[dartx.codeUnitAt](i); 2066 char = uri[dartx.codeUnitAt](i);
2067 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN) { 2067 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN) {
2068 state = NOT_IN_PATH; 2068 state = NOT_IN_PATH;
2069 break; 2069 break;
2070 } 2070 }
2071 if (char == Uri._SLASH) { 2071 if (char == Uri._SLASH) {
2072 state = i == 0 ? ALLOW_AUTH : IN_PATH; 2072 state = i == 0 ? ALLOW_AUTH : IN_PATH;
2073 break; 2073 break;
2074 } 2074 }
2075 if (char == Uri._COLON) { 2075 if (char == Uri._COLON) {
2076 if (i == 0) 2076 if (i == 0)
2077 Uri._fail(uri, 0, "Invalid empty scheme"); 2077 Uri._fail(uri, 0, "Invalid empty scheme");
2078 scheme = Uri._makeScheme(uri, i); 2078 scheme = Uri._makeScheme(uri, i);
2079 i = dart.notNull(i) + 1; 2079 i = dart.notNull(i) + 1;
2080 pathStart = i; 2080 pathStart = i;
2081 if (i == uri.length) { 2081 if (i == uri[dartx.length]) {
2082 char = EOI; 2082 char = EOI;
2083 state = NOT_IN_PATH; 2083 state = NOT_IN_PATH;
2084 } else { 2084 } else {
2085 char = uri[dartx.codeUnitAt](i); 2085 char = uri[dartx.codeUnitAt](i);
2086 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN) { 2086 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN) {
2087 state = NOT_IN_PATH; 2087 state = NOT_IN_PATH;
2088 } else if (char == Uri._SLASH) { 2088 } else if (char == Uri._SLASH) {
2089 state = ALLOW_AUTH; 2089 state = ALLOW_AUTH;
2090 } else { 2090 } else {
2091 state = IN_PATH; 2091 state = IN_PATH;
2092 } 2092 }
2093 } 2093 }
2094 break; 2094 break;
2095 } 2095 }
2096 i = dart.notNull(i) + 1; 2096 i = dart.notNull(i) + 1;
2097 char = EOI; 2097 char = EOI;
2098 } 2098 }
2099 index = i; 2099 index = i;
2100 if (state == ALLOW_AUTH) { 2100 if (state == ALLOW_AUTH) {
2101 dart.assert(char == Uri._SLASH); 2101 dart.assert(char == Uri._SLASH);
2102 index = dart.notNull(index) + 1; 2102 index = dart.notNull(index) + 1;
2103 if (index == uri.length) { 2103 if (index == uri[dartx.length]) {
2104 char = EOI; 2104 char = EOI;
2105 state = NOT_IN_PATH; 2105 state = NOT_IN_PATH;
2106 } else { 2106 } else {
2107 char = uri[dartx.codeUnitAt](index); 2107 char = uri[dartx.codeUnitAt](index);
2108 if (char == Uri._SLASH) { 2108 if (char == Uri._SLASH) {
2109 index = dart.notNull(index) + 1; 2109 index = dart.notNull(index) + 1;
2110 parseAuth(); 2110 parseAuth();
2111 pathStart = index; 2111 pathStart = index;
2112 } 2112 }
2113 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN || char == EOI) { 2113 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN || char == EOI) {
2114 state = NOT_IN_PATH; 2114 state = NOT_IN_PATH;
2115 } else { 2115 } else {
2116 state = IN_PATH; 2116 state = IN_PATH;
2117 } 2117 }
2118 } 2118 }
2119 } 2119 }
2120 dart.assert(state == IN_PATH || state == NOT_IN_PATH); 2120 dart.assert(state == IN_PATH || state == NOT_IN_PATH);
2121 if (state == IN_PATH) { 2121 if (state == IN_PATH) {
2122 while ((index = dart.notNull(index) + 1) < dart.notNull(uri.length)) { 2122 while ((index = dart.notNull(index) + 1) < dart.notNull(uri[dartx.length ])) {
2123 char = uri[dartx.codeUnitAt](index); 2123 char = uri[dartx.codeUnitAt](index);
2124 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN) { 2124 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN) {
2125 break; 2125 break;
2126 } 2126 }
2127 char = EOI; 2127 char = EOI;
2128 } 2128 }
2129 state = NOT_IN_PATH; 2129 state = NOT_IN_PATH;
2130 } 2130 }
2131 dart.assert(state == NOT_IN_PATH); 2131 dart.assert(state == NOT_IN_PATH);
2132 let isFile = scheme == "file"; 2132 let isFile = scheme == "file";
2133 let ensureLeadingSlash = host != null; 2133 let ensureLeadingSlash = host != null;
2134 path = Uri._makePath(uri, pathStart, index, null, ensureLeadingSlash, isFi le); 2134 path = Uri._makePath(uri, pathStart, index, null, ensureLeadingSlash, isFi le);
2135 if (char == Uri._QUESTION) { 2135 if (char == Uri._QUESTION) {
2136 let numberSignIndex = uri[dartx.indexOf]('#', dart.notNull(index) + 1); 2136 let numberSignIndex = uri[dartx.indexOf]('#', dart.notNull(index) + 1);
2137 if (dart.notNull(numberSignIndex) < 0) { 2137 if (dart.notNull(numberSignIndex) < 0) {
2138 query = Uri._makeQuery(uri, dart.notNull(index) + 1, uri.length, null) ; 2138 query = Uri._makeQuery(uri, dart.notNull(index) + 1, uri[dartx.length] , null);
2139 } else { 2139 } else {
2140 query = Uri._makeQuery(uri, dart.notNull(index) + 1, numberSignIndex, null); 2140 query = Uri._makeQuery(uri, dart.notNull(index) + 1, numberSignIndex, null);
2141 fragment = Uri._makeFragment(uri, dart.notNull(numberSignIndex) + 1, u ri.length); 2141 fragment = Uri._makeFragment(uri, dart.notNull(numberSignIndex) + 1, u ri[dartx.length]);
2142 } 2142 }
2143 } else if (char == Uri._NUMBER_SIGN) { 2143 } else if (char == Uri._NUMBER_SIGN) {
2144 fragment = Uri._makeFragment(uri, dart.notNull(index) + 1, uri.length); 2144 fragment = Uri._makeFragment(uri, dart.notNull(index) + 1, uri[dartx.len gth]);
2145 } 2145 }
2146 return new Uri._internal(scheme, userinfo, host, port, path, query, fragme nt); 2146 return new Uri._internal(scheme, userinfo, host, port, path, query, fragme nt);
2147 } 2147 }
2148 static _fail(uri, index, message) { 2148 static _fail(uri, index, message) {
2149 throw new FormatException(message, uri, index); 2149 throw new FormatException(message, uri, index);
2150 } 2150 }
2151 _internal(scheme, userInfo, host, port, path, query, fragment) { 2151 _internal(scheme, userInfo, host, port, path, query, fragment) {
2152 this.scheme = scheme; 2152 this.scheme = scheme;
2153 this[_userInfo] = userInfo; 2153 this[_userInfo] = userInfo;
2154 this[_host] = host; 2154 this[_host] = host;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 queryParameters = null; 2195 queryParameters = null;
2196 return Uri._makeHttpUri("https", authority, unencodedPath, queryParameters ); 2196 return Uri._makeHttpUri("https", authority, unencodedPath, queryParameters );
2197 } 2197 }
2198 static _makeHttpUri(scheme, authority, unencodedPath, queryParameters) { 2198 static _makeHttpUri(scheme, authority, unencodedPath, queryParameters) {
2199 let userInfo = ""; 2199 let userInfo = "";
2200 let host = null; 2200 let host = null;
2201 let port = null; 2201 let port = null;
2202 if (authority != null && dart.notNull(authority[dartx.isNotEmpty])) { 2202 if (authority != null && dart.notNull(authority[dartx.isNotEmpty])) {
2203 let hostStart = 0; 2203 let hostStart = 0;
2204 let hasUserInfo = false; 2204 let hasUserInfo = false;
2205 for (let i = 0; dart.notNull(i) < dart.notNull(authority.length); i = da rt.notNull(i) + 1) { 2205 for (let i = 0; dart.notNull(i) < dart.notNull(authority[dartx.length]); i = dart.notNull(i) + 1) {
2206 if (authority[dartx.codeUnitAt](i) == Uri._AT_SIGN) { 2206 if (authority[dartx.codeUnitAt](i) == Uri._AT_SIGN) {
2207 hasUserInfo = true; 2207 hasUserInfo = true;
2208 userInfo = authority[dartx.substring](0, i); 2208 userInfo = authority[dartx.substring](0, i);
2209 hostStart = dart.notNull(i) + 1; 2209 hostStart = dart.notNull(i) + 1;
2210 break; 2210 break;
2211 } 2211 }
2212 } 2212 }
2213 let hostEnd = hostStart; 2213 let hostEnd = hostStart;
2214 if (dart.notNull(hostStart) < dart.notNull(authority.length) && authorit y[dartx.codeUnitAt](hostStart) == Uri._LEFT_BRACKET) { 2214 if (dart.notNull(hostStart) < dart.notNull(authority[dartx.length]) && a uthority[dartx.codeUnitAt](hostStart) == Uri._LEFT_BRACKET) {
2215 for (; dart.notNull(hostEnd) < dart.notNull(authority.length); hostEnd = dart.notNull(hostEnd) + 1) { 2215 for (; dart.notNull(hostEnd) < dart.notNull(authority[dartx.length]); hostEnd = dart.notNull(hostEnd) + 1) {
2216 if (authority[dartx.codeUnitAt](hostEnd) == Uri._RIGHT_BRACKET) 2216 if (authority[dartx.codeUnitAt](hostEnd) == Uri._RIGHT_BRACKET)
2217 break; 2217 break;
2218 } 2218 }
2219 if (hostEnd == authority.length) { 2219 if (hostEnd == authority[dartx.length]) {
2220 throw new FormatException("Invalid IPv6 host entry.", authority, hos tStart); 2220 throw new FormatException("Invalid IPv6 host entry.", authority, hos tStart);
2221 } 2221 }
2222 Uri.parseIPv6Address(authority, dart.notNull(hostStart) + 1, hostEnd); 2222 Uri.parseIPv6Address(authority, dart.notNull(hostStart) + 1, hostEnd);
2223 hostEnd = dart.notNull(hostEnd) + 1; 2223 hostEnd = dart.notNull(hostEnd) + 1;
2224 if (hostEnd != authority.length && authority[dartx.codeUnitAt](hostEnd ) != Uri._COLON) { 2224 if (hostEnd != authority[dartx.length] && authority[dartx.codeUnitAt]( hostEnd) != Uri._COLON) {
2225 throw new FormatException("Invalid end of authority", authority, hos tEnd); 2225 throw new FormatException("Invalid end of authority", authority, hos tEnd);
2226 } 2226 }
2227 } 2227 }
2228 let hasPort = false; 2228 let hasPort = false;
2229 for (; dart.notNull(hostEnd) < dart.notNull(authority.length); hostEnd = dart.notNull(hostEnd) + 1) { 2229 for (; dart.notNull(hostEnd) < dart.notNull(authority[dartx.length]); ho stEnd = dart.notNull(hostEnd) + 1) {
2230 if (authority[dartx.codeUnitAt](hostEnd) == Uri._COLON) { 2230 if (authority[dartx.codeUnitAt](hostEnd) == Uri._COLON) {
2231 let portString = authority[dartx.substring](dart.notNull(hostEnd) + 1); 2231 let portString = authority[dartx.substring](dart.notNull(hostEnd) + 1);
2232 if (dart.notNull(portString[dartx.isNotEmpty])) 2232 if (dart.notNull(portString[dartx.isNotEmpty]))
2233 port = int.parse(portString); 2233 port = int.parse(portString);
2234 break; 2234 break;
2235 } 2235 }
2236 } 2236 }
2237 host = authority[dartx.substring](hostStart, hostEnd); 2237 host = authority[dartx.substring](hostStart, hostEnd);
2238 } 2238 }
2239 return Uri.new({scheme: scheme, userInfo: userInfo, host: dart.as(host, St ring), port: dart.as(port, int), pathSegments: unencodedPath[dartx.split]("/"), queryParameters: queryParameters}); 2239 return Uri.new({scheme: scheme, userInfo: userInfo, host: dart.as(host, St ring), port: dart.as(port, int), pathSegments: unencodedPath[dartx.split]("/"), queryParameters: queryParameters});
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 } else { 2293 } else {
2294 return Uri.new({pathSegments: path[dartx.split](sep)}); 2294 return Uri.new({pathSegments: path[dartx.split](sep)});
2295 } 2295 }
2296 } 2296 }
2297 static _makeWindowsFileUrl(path) { 2297 static _makeWindowsFileUrl(path) {
2298 if (dart.notNull(path[dartx.startsWith]("\\\\?\\"))) { 2298 if (dart.notNull(path[dartx.startsWith]("\\\\?\\"))) {
2299 if (dart.notNull(path[dartx.startsWith]("\\\\?\\UNC\\"))) { 2299 if (dart.notNull(path[dartx.startsWith]("\\\\?\\UNC\\"))) {
2300 path = `\\${path[dartx.substring](7)}`; 2300 path = `\\${path[dartx.substring](7)}`;
2301 } else { 2301 } else {
2302 path = path[dartx.substring](4); 2302 path = path[dartx.substring](4);
2303 if (dart.notNull(path.length) < 3 || path[dartx.codeUnitAt](1) != Uri. _COLON || path[dartx.codeUnitAt](2) != Uri._BACKSLASH) { 2303 if (dart.notNull(path[dartx.length]) < 3 || path[dartx.codeUnitAt](1) != Uri._COLON || path[dartx.codeUnitAt](2) != Uri._BACKSLASH) {
2304 throw new ArgumentError("Windows paths with \\\\?\\ prefix must be a bsolute"); 2304 throw new ArgumentError("Windows paths with \\\\?\\ prefix must be a bsolute");
2305 } 2305 }
2306 } 2306 }
2307 } else { 2307 } else {
2308 path = path[dartx.replaceAll]("/", "\\"); 2308 path = path[dartx.replaceAll]("/", "\\");
2309 } 2309 }
2310 let sep = "\\"; 2310 let sep = "\\";
2311 if (dart.notNull(path.length) > 1 && path[dartx.get](1) == ":") { 2311 if (dart.notNull(path[dartx.length]) > 1 && path[dartx.get](1) == ":") {
2312 Uri._checkWindowsDriveLetter(path[dartx.codeUnitAt](0), true); 2312 Uri._checkWindowsDriveLetter(path[dartx.codeUnitAt](0), true);
2313 if (path.length == 2 || path[dartx.codeUnitAt](2) != Uri._BACKSLASH) { 2313 if (path[dartx.length] == 2 || path[dartx.codeUnitAt](2) != Uri._BACKSLA SH) {
2314 throw new ArgumentError("Windows paths with drive letter must be absol ute"); 2314 throw new ArgumentError("Windows paths with drive letter must be absol ute");
2315 } 2315 }
2316 let pathSegments = path[dartx.split](sep); 2316 let pathSegments = path[dartx.split](sep);
2317 Uri._checkWindowsPathReservedCharacters(pathSegments, true, 1); 2317 Uri._checkWindowsPathReservedCharacters(pathSegments, true, 1);
2318 return Uri.new({scheme: "file", pathSegments: pathSegments}); 2318 return Uri.new({scheme: "file", pathSegments: pathSegments});
2319 } 2319 }
2320 if (dart.notNull(path.length) > 0 && path[dartx.get](0) == sep) { 2320 if (dart.notNull(path[dartx.length]) > 0 && path[dartx.get](0) == sep) {
2321 if (dart.notNull(path.length) > 1 && path[dartx.get](1) == sep) { 2321 if (dart.notNull(path[dartx.length]) > 1 && path[dartx.get](1) == sep) {
2322 let pathStart = path[dartx.indexOf]("\\", 2); 2322 let pathStart = path[dartx.indexOf]("\\", 2);
2323 let hostPart = pathStart == -1 ? path[dartx.substring](2) : path[dartx .substring](2, pathStart); 2323 let hostPart = pathStart == -1 ? path[dartx.substring](2) : path[dartx .substring](2, pathStart);
2324 let pathPart = pathStart == -1 ? "" : path[dartx.substring](dart.notNu ll(pathStart) + 1); 2324 let pathPart = pathStart == -1 ? "" : path[dartx.substring](dart.notNu ll(pathStart) + 1);
2325 let pathSegments = pathPart[dartx.split](sep); 2325 let pathSegments = pathPart[dartx.split](sep);
2326 Uri._checkWindowsPathReservedCharacters(pathSegments, true); 2326 Uri._checkWindowsPathReservedCharacters(pathSegments, true);
2327 return Uri.new({scheme: "file", host: hostPart, pathSegments: pathSegm ents}); 2327 return Uri.new({scheme: "file", host: hostPart, pathSegments: pathSegm ents});
2328 } else { 2328 } else {
2329 let pathSegments = path[dartx.split](sep); 2329 let pathSegments = path[dartx.split](sep);
2330 Uri._checkWindowsPathReservedCharacters(pathSegments, true); 2330 Uri._checkWindowsPathReservedCharacters(pathSegments, true);
2331 return Uri.new({scheme: "file", pathSegments: pathSegments}); 2331 return Uri.new({scheme: "file", pathSegments: pathSegments});
2332 } 2332 }
2333 } else { 2333 } else {
2334 let pathSegments = path[dartx.split](sep); 2334 let pathSegments = path[dartx.split](sep);
2335 Uri._checkWindowsPathReservedCharacters(pathSegments, true); 2335 Uri._checkWindowsPathReservedCharacters(pathSegments, true);
2336 return Uri.new({pathSegments: pathSegments}); 2336 return Uri.new({pathSegments: pathSegments});
2337 } 2337 }
2338 } 2338 }
2339 replace(opts) { 2339 replace(opts) {
2340 let scheme = opts && 'scheme' in opts ? opts.scheme : null; 2340 let scheme = opts && 'scheme' in opts ? opts.scheme : null;
2341 let userInfo = opts && 'userInfo' in opts ? opts.userInfo : null; 2341 let userInfo = opts && 'userInfo' in opts ? opts.userInfo : null;
2342 let host = opts && 'host' in opts ? opts.host : null; 2342 let host = opts && 'host' in opts ? opts.host : null;
2343 let port = opts && 'port' in opts ? opts.port : null; 2343 let port = opts && 'port' in opts ? opts.port : null;
2344 let path = opts && 'path' in opts ? opts.path : null; 2344 let path = opts && 'path' in opts ? opts.path : null;
2345 let pathSegments = opts && 'pathSegments' in opts ? opts.pathSegments : nu ll; 2345 let pathSegments = opts && 'pathSegments' in opts ? opts.pathSegments : nu ll;
2346 let query = opts && 'query' in opts ? opts.query : null; 2346 let query = opts && 'query' in opts ? opts.query : null;
2347 let queryParameters = opts && 'queryParameters' in opts ? opts.queryParame ters : null; 2347 let queryParameters = opts && 'queryParameters' in opts ? opts.queryParame ters : null;
2348 let fragment = opts && 'fragment' in opts ? opts.fragment : null; 2348 let fragment = opts && 'fragment' in opts ? opts.fragment : null;
2349 let schemeChanged = false; 2349 let schemeChanged = false;
2350 if (scheme != null) { 2350 if (scheme != null) {
2351 scheme = Uri._makeScheme(scheme, scheme.length); 2351 scheme = Uri._makeScheme(scheme, scheme[dartx.length]);
2352 schemeChanged = true; 2352 schemeChanged = true;
2353 } else { 2353 } else {
2354 scheme = this.scheme; 2354 scheme = this.scheme;
2355 } 2355 }
2356 let isFile = scheme == "file"; 2356 let isFile = scheme == "file";
2357 if (userInfo != null) { 2357 if (userInfo != null) {
2358 userInfo = Uri._makeUserInfo(userInfo, 0, userInfo.length); 2358 userInfo = Uri._makeUserInfo(userInfo, 0, userInfo[dartx.length]);
2359 } else { 2359 } else {
2360 userInfo = this.userInfo; 2360 userInfo = this.userInfo;
2361 } 2361 }
2362 if (port != null) { 2362 if (port != null) {
2363 port = Uri._makePort(port, scheme); 2363 port = Uri._makePort(port, scheme);
2364 } else { 2364 } else {
2365 port = this[_port]; 2365 port = this[_port];
2366 if (dart.notNull(schemeChanged)) { 2366 if (dart.notNull(schemeChanged)) {
2367 port = Uri._makePort(port, scheme); 2367 port = Uri._makePort(port, scheme);
2368 } 2368 }
2369 } 2369 }
2370 if (host != null) { 2370 if (host != null) {
2371 host = Uri._makeHost(host, 0, host.length, false); 2371 host = Uri._makeHost(host, 0, host[dartx.length], false);
2372 } else if (dart.notNull(this.hasAuthority)) { 2372 } else if (dart.notNull(this.hasAuthority)) {
2373 host = this.host; 2373 host = this.host;
2374 } else if (dart.notNull(userInfo[dartx.isNotEmpty]) || port != null || dar t.notNull(isFile)) { 2374 } else if (dart.notNull(userInfo[dartx.isNotEmpty]) || port != null || dar t.notNull(isFile)) {
2375 host = ""; 2375 host = "";
2376 } 2376 }
2377 let ensureLeadingSlash = host != null; 2377 let ensureLeadingSlash = host != null;
2378 if (path != null || pathSegments != null) { 2378 if (path != null || pathSegments != null) {
2379 path = Uri._makePath(path, 0, Uri._stringOrNullLength(path), pathSegment s, ensureLeadingSlash, isFile); 2379 path = Uri._makePath(path, 0, Uri._stringOrNullLength(path), pathSegment s, ensureLeadingSlash, isFile);
2380 } else { 2380 } else {
2381 path = this.path; 2381 path = this.path;
2382 if ((dart.notNull(isFile) || dart.notNull(ensureLeadingSlash) && !dart.n otNull(path[dartx.isEmpty])) && !dart.notNull(path[dartx.startsWith]('/'))) { 2382 if ((dart.notNull(isFile) || dart.notNull(ensureLeadingSlash) && !dart.n otNull(path[dartx.isEmpty])) && !dart.notNull(path[dartx.startsWith]('/'))) {
2383 path = `/${path}`; 2383 path = `/${path}`;
2384 } 2384 }
2385 } 2385 }
2386 if (query != null || queryParameters != null) { 2386 if (query != null || queryParameters != null) {
2387 query = Uri._makeQuery(query, 0, Uri._stringOrNullLength(query), queryPa rameters); 2387 query = Uri._makeQuery(query, 0, Uri._stringOrNullLength(query), queryPa rameters);
2388 } else if (dart.notNull(this.hasQuery)) { 2388 } else if (dart.notNull(this.hasQuery)) {
2389 query = this.query; 2389 query = this.query;
2390 } 2390 }
2391 if (fragment != null) { 2391 if (fragment != null) {
2392 fragment = Uri._makeFragment(fragment, 0, fragment.length); 2392 fragment = Uri._makeFragment(fragment, 0, fragment[dartx.length]);
2393 } else if (dart.notNull(this.hasFragment)) { 2393 } else if (dart.notNull(this.hasFragment)) {
2394 fragment = this.fragment; 2394 fragment = this.fragment;
2395 } 2395 }
2396 return new Uri._internal(scheme, userInfo, host, port, path, query, fragme nt); 2396 return new Uri._internal(scheme, userInfo, host, port, path, query, fragme nt);
2397 } 2397 }
2398 get pathSegments() { 2398 get pathSegments() {
2399 if (this[_pathSegments] == null) { 2399 if (this[_pathSegments] == null) {
2400 let pathToSplit = !dart.notNull(this.path[dartx.isEmpty]) && this.path[d artx.codeUnitAt](0) == Uri._SLASH ? this.path[dartx.substring](1) : this.path; 2400 let pathToSplit = !dart.notNull(this.path[dartx.isEmpty]) && this.path[d artx.codeUnitAt](0) == Uri._SLASH ? this.path[dartx.substring](1) : this.path;
2401 this[_pathSegments] = new (collection.UnmodifiableListView$(String))(pat hToSplit == "" ? dart.const(dart.list([], String)) : List$(String).from(pathToSp lit[dartx.split]("/")[dartx.map](Uri.decodeComponent), {growable: false})); 2401 this[_pathSegments] = new (collection.UnmodifiableListView$(String))(pat hToSplit == "" ? dart.const(dart.list([], String)) : List$(String).from(pathToSp lit[dartx.split]("/")[dartx.map](Uri.decodeComponent), {growable: false}));
2402 } 2402 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 } 2580 }
2581 })); 2581 }));
2582 return dart.toString(result); 2582 return dart.toString(result);
2583 } 2583 }
2584 static _makeFragment(fragment, start, end) { 2584 static _makeFragment(fragment, start, end) {
2585 if (fragment == null) 2585 if (fragment == null)
2586 return null; 2586 return null;
2587 return Uri._normalize(fragment, start, end, dart.as(Uri._queryCharTable, L ist$(int))); 2587 return Uri._normalize(fragment, start, end, dart.as(Uri._queryCharTable, L ist$(int)));
2588 } 2588 }
2589 static _stringOrNullLength(s) { 2589 static _stringOrNullLength(s) {
2590 return s == null ? 0 : s.length; 2590 return s == null ? 0 : s[dartx.length];
2591 } 2591 }
2592 static _isHexDigit(char) { 2592 static _isHexDigit(char) {
2593 if (dart.notNull(Uri._NINE) >= dart.notNull(char)) 2593 if (dart.notNull(Uri._NINE) >= dart.notNull(char))
2594 return dart.notNull(Uri._ZERO) <= dart.notNull(char); 2594 return dart.notNull(Uri._ZERO) <= dart.notNull(char);
2595 char = dart.notNull(char) | 32; 2595 char = dart.notNull(char) | 32;
2596 return dart.notNull(Uri._LOWER_CASE_A) <= dart.notNull(char) && dart.notNu ll(Uri._LOWER_CASE_F) >= dart.notNull(char); 2596 return dart.notNull(Uri._LOWER_CASE_A) <= dart.notNull(char) && dart.notNu ll(Uri._LOWER_CASE_F) >= dart.notNull(char);
2597 } 2597 }
2598 static _hexValue(char) { 2598 static _hexValue(char) {
2599 dart.assert(Uri._isHexDigit(char)); 2599 dart.assert(Uri._isHexDigit(char));
2600 if (dart.notNull(Uri._NINE) >= dart.notNull(char)) 2600 if (dart.notNull(Uri._NINE) >= dart.notNull(char))
2601 return dart.notNull(char) - dart.notNull(Uri._ZERO); 2601 return dart.notNull(char) - dart.notNull(Uri._ZERO);
2602 char = dart.notNull(char) | 32; 2602 char = dart.notNull(char) | 32;
2603 return dart.notNull(char) - (dart.notNull(Uri._LOWER_CASE_A) - 10); 2603 return dart.notNull(char) - (dart.notNull(Uri._LOWER_CASE_A) - 10);
2604 } 2604 }
2605 static _normalizeEscape(source, index, lowerCase) { 2605 static _normalizeEscape(source, index, lowerCase) {
2606 dart.assert(source[dartx.codeUnitAt](index) == Uri._PERCENT); 2606 dart.assert(source[dartx.codeUnitAt](index) == Uri._PERCENT);
2607 if (dart.notNull(index) + 2 >= dart.notNull(source.length)) { 2607 if (dart.notNull(index) + 2 >= dart.notNull(source[dartx.length])) {
2608 return "%"; 2608 return "%";
2609 } 2609 }
2610 let firstDigit = source[dartx.codeUnitAt](dart.notNull(index) + 1); 2610 let firstDigit = source[dartx.codeUnitAt](dart.notNull(index) + 1);
2611 let secondDigit = source[dartx.codeUnitAt](dart.notNull(index) + 2); 2611 let secondDigit = source[dartx.codeUnitAt](dart.notNull(index) + 2);
2612 if (!dart.notNull(Uri._isHexDigit(firstDigit)) || !dart.notNull(Uri._isHex Digit(secondDigit))) { 2612 if (!dart.notNull(Uri._isHexDigit(firstDigit)) || !dart.notNull(Uri._isHex Digit(secondDigit))) {
2613 return "%"; 2613 return "%";
2614 } 2614 }
2615 let value = dart.notNull(Uri._hexValue(firstDigit)) * 16 + dart.notNull(Ur i._hexValue(secondDigit)); 2615 let value = dart.notNull(Uri._hexValue(firstDigit)) * 16 + dart.notNull(Ur i._hexValue(secondDigit));
2616 if (dart.notNull(Uri._isUnreservedChar(value))) { 2616 if (dart.notNull(Uri._isUnreservedChar(value))) {
2617 if (dart.notNull(lowerCase) && dart.notNull(Uri._UPPER_CASE_A) <= dart.n otNull(value) && dart.notNull(Uri._UPPER_CASE_Z) >= dart.notNull(value)) { 2617 if (dart.notNull(lowerCase) && dart.notNull(Uri._UPPER_CASE_A) <= dart.n otNull(value) && dart.notNull(Uri._UPPER_CASE_Z) >= dart.notNull(value)) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2741 let delta = dart.notNull(baseEnd) - dart.notNull(newEnd); 2741 let delta = dart.notNull(baseEnd) - dart.notNull(newEnd);
2742 if ((delta == 2 || delta == 3) && base[dartx.codeUnitAt](dart.notNull(ne wEnd) + 1) == Uri._DOT && (delta == 2 || base[dartx.codeUnitAt](dart.notNull(new End) + 2) == Uri._DOT)) { 2742 if ((delta == 2 || delta == 3) && base[dartx.codeUnitAt](dart.notNull(ne wEnd) + 1) == Uri._DOT && (delta == 2 || base[dartx.codeUnitAt](dart.notNull(new End) + 2) == Uri._DOT)) {
2743 break; 2743 break;
2744 } 2744 }
2745 baseEnd = newEnd; 2745 baseEnd = newEnd;
2746 backCount = dart.notNull(backCount) - 1; 2746 backCount = dart.notNull(backCount) - 1;
2747 } 2747 }
2748 return dart.notNull(base[dartx.substring](0, dart.notNull(baseEnd) + 1)) + dart.notNull(reference[dartx.substring](dart.notNull(refStart) - 3 * dart.notNu ll(backCount))); 2748 return dart.notNull(base[dartx.substring](0, dart.notNull(baseEnd) + 1)) + dart.notNull(reference[dartx.substring](dart.notNull(refStart) - 3 * dart.notNu ll(backCount)));
2749 } 2749 }
2750 [_hasDotSegments](path) { 2750 [_hasDotSegments](path) {
2751 if (dart.notNull(path.length) > 0 && path[dartx.codeUnitAt](0) == Uri._DOT ) 2751 if (dart.notNull(path[dartx.length]) > 0 && path[dartx.codeUnitAt](0) == U ri._DOT)
2752 return true; 2752 return true;
2753 let index = path[dartx.indexOf]("/."); 2753 let index = path[dartx.indexOf]("/.");
2754 return index != -1; 2754 return index != -1;
2755 } 2755 }
2756 [_removeDotSegments](path) { 2756 [_removeDotSegments](path) {
2757 if (!dart.notNull(this[_hasDotSegments](path))) 2757 if (!dart.notNull(this[_hasDotSegments](path)))
2758 return path; 2758 return path;
2759 let output = dart.list([], String); 2759 let output = dart.list([], String);
2760 let appendSlash = false; 2760 let appendSlash = false;
2761 for (let segment of path[dartx.split]("/")) { 2761 for (let segment of path[dartx.split]("/")) {
2762 appendSlash = false; 2762 appendSlash = false;
2763 if (segment == "..") { 2763 if (segment == "..") {
2764 if (!dart.notNull(output[dartx.isEmpty]) && (output.length != 1 || out put[dartx.get](0) != "")) 2764 if (!dart.notNull(output[dartx.isEmpty]) && (output[dartx.length] != 1 || output[dartx.get](0) != ""))
2765 output[dartx.removeLast](); 2765 output[dartx.removeLast]();
2766 appendSlash = true; 2766 appendSlash = true;
2767 } else if ("." == segment) { 2767 } else if ("." == segment) {
2768 appendSlash = true; 2768 appendSlash = true;
2769 } else { 2769 } else {
2770 output[dartx.add](segment); 2770 output[dartx.add](segment);
2771 } 2771 }
2772 } 2772 }
2773 if (dart.notNull(appendSlash)) 2773 if (dart.notNull(appendSlash))
2774 output[dartx.add](""); 2774 output[dartx.add]("");
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2874 Uri._checkNonWindowsPathReservedCharacters(this.pathSegments, false); 2874 Uri._checkNonWindowsPathReservedCharacters(this.pathSegments, false);
2875 let result = new StringBuffer(); 2875 let result = new StringBuffer();
2876 if (dart.notNull(this[_isPathAbsolute])) 2876 if (dart.notNull(this[_isPathAbsolute]))
2877 result.write("/"); 2877 result.write("/");
2878 result.writeAll(this.pathSegments, "/"); 2878 result.writeAll(this.pathSegments, "/");
2879 return dart.toString(result); 2879 return dart.toString(result);
2880 } 2880 }
2881 [_toWindowsFilePath]() { 2881 [_toWindowsFilePath]() {
2882 let hasDriveLetter = false; 2882 let hasDriveLetter = false;
2883 let segments = this.pathSegments; 2883 let segments = this.pathSegments;
2884 if (dart.notNull(segments.length) > 0 && segments[dartx.get](0).length == 2 && segments[dartx.get](0)[dartx.codeUnitAt](1) == Uri._COLON) { 2884 if (dart.notNull(segments[dartx.length]) > 0 && segments[dartx.get](0)[dar tx.length] == 2 && segments[dartx.get](0)[dartx.codeUnitAt](1) == Uri._COLON) {
2885 Uri._checkWindowsDriveLetter(segments[dartx.get](0)[dartx.codeUnitAt](0) , false); 2885 Uri._checkWindowsDriveLetter(segments[dartx.get](0)[dartx.codeUnitAt](0) , false);
2886 Uri._checkWindowsPathReservedCharacters(segments, false, 1); 2886 Uri._checkWindowsPathReservedCharacters(segments, false, 1);
2887 hasDriveLetter = true; 2887 hasDriveLetter = true;
2888 } else { 2888 } else {
2889 Uri._checkWindowsPathReservedCharacters(segments, false); 2889 Uri._checkWindowsPathReservedCharacters(segments, false);
2890 } 2890 }
2891 let result = new StringBuffer(); 2891 let result = new StringBuffer();
2892 if (dart.notNull(this[_isPathAbsolute]) && !dart.notNull(hasDriveLetter)) 2892 if (dart.notNull(this[_isPathAbsolute]) && !dart.notNull(hasDriveLetter))
2893 result.write("\\"); 2893 result.write("\\");
2894 if (this.host != "") { 2894 if (this.host != "") {
2895 result.write("\\"); 2895 result.write("\\");
2896 result.write(this.host); 2896 result.write(this.host);
2897 result.write("\\"); 2897 result.write("\\");
2898 } 2898 }
2899 result.writeAll(segments, "\\"); 2899 result.writeAll(segments, "\\");
2900 if (dart.notNull(hasDriveLetter) && segments.length == 1) 2900 if (dart.notNull(hasDriveLetter) && segments[dartx.length] == 1)
2901 result.write("\\"); 2901 result.write("\\");
2902 return dart.toString(result); 2902 return dart.toString(result);
2903 } 2903 }
2904 get [_isPathAbsolute]() { 2904 get [_isPathAbsolute]() {
2905 if (this.path == null || dart.notNull(this.path[dartx.isEmpty])) 2905 if (this.path == null || dart.notNull(this.path[dartx.isEmpty]))
2906 return false; 2906 return false;
2907 return this.path[dartx.startsWith]('/'); 2907 return this.path[dartx.startsWith]('/');
2908 } 2908 }
2909 [_writeAuthority](ss) { 2909 [_writeAuthority](ss) {
2910 if (dart.notNull(this[_userInfo][dartx.isNotEmpty])) { 2910 if (dart.notNull(this[_userInfo][dartx.isNotEmpty])) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2990 } 2990 }
2991 return map; 2991 return map;
2992 })), Map$(String, String)); 2992 })), Map$(String, String));
2993 } 2993 }
2994 static parseIPv4Address(host) { 2994 static parseIPv4Address(host) {
2995 let error = msg => { 2995 let error = msg => {
2996 throw new FormatException(`Illegal IPv4 address, ${msg}`); 2996 throw new FormatException(`Illegal IPv4 address, ${msg}`);
2997 }; 2997 };
2998 dart.fn(error, dart.void, [String]); 2998 dart.fn(error, dart.void, [String]);
2999 let bytes = host[dartx.split]('.'); 2999 let bytes = host[dartx.split]('.');
3000 if (bytes.length != 4) { 3000 if (bytes[dartx.length] != 4) {
3001 error('IPv4 address should contain exactly 4 parts'); 3001 error('IPv4 address should contain exactly 4 parts');
3002 } 3002 }
3003 return dart.as(bytes[dartx.map](dart.fn(byteString => { 3003 return dart.as(bytes[dartx.map](dart.fn(byteString => {
3004 let byte = int.parse(dart.as(byteString, String)); 3004 let byte = int.parse(dart.as(byteString, String));
3005 if (dart.notNull(byte) < 0 || dart.notNull(byte) > 255) { 3005 if (dart.notNull(byte) < 0 || dart.notNull(byte) > 255) {
3006 error('each part must be in the range of `0..255`'); 3006 error('each part must be in the range of `0..255`');
3007 } 3007 }
3008 return byte; 3008 return byte;
3009 }))[dartx.toList](), List$(int)); 3009 }))[dartx.toList](), List$(int));
3010 } 3010 }
3011 static parseIPv6Address(host, start, end) { 3011 static parseIPv6Address(host, start, end) {
3012 if (start === void 0) 3012 if (start === void 0)
3013 start = 0; 3013 start = 0;
3014 if (end === void 0) 3014 if (end === void 0)
3015 end = null; 3015 end = null;
3016 if (end == null) 3016 if (end == null)
3017 end = host.length; 3017 end = host[dartx.length];
3018 let error = (msg, position) => { 3018 let error = (msg, position) => {
3019 if (position === void 0) 3019 if (position === void 0)
3020 position = null; 3020 position = null;
3021 throw new FormatException(`Illegal IPv6 address, ${msg}`, host, dart.as( position, int)); 3021 throw new FormatException(`Illegal IPv6 address, ${msg}`, host, dart.as( position, int));
3022 }; 3022 };
3023 dart.fn(error, dart.void, [String], [Object]); 3023 dart.fn(error, dart.void, [String], [Object]);
3024 let parseHex = (start, end) => { 3024 let parseHex = (start, end) => {
3025 if (dart.notNull(end) - dart.notNull(start) > 4) { 3025 if (dart.notNull(end) - dart.notNull(start) > 4) {
3026 error('an IPv6 part can only contain a maximum of 4 hex digits', start ); 3026 error('an IPv6 part can only contain a maximum of 4 hex digits', start );
3027 } 3027 }
3028 let value = int.parse(host[dartx.substring](start, end), {radix: 16}); 3028 let value = int.parse(host[dartx.substring](start, end), {radix: 16});
3029 if (dart.notNull(value) < 0 || dart.notNull(value) > (1 << 16) - 1) { 3029 if (dart.notNull(value) < 0 || dart.notNull(value) > (1 << 16) - 1) {
3030 error('each part must be in the range of `0x0..0xFFFF`', start); 3030 error('each part must be in the range of `0x0..0xFFFF`', start);
3031 } 3031 }
3032 return value; 3032 return value;
3033 }; 3033 };
3034 dart.fn(parseHex, int, [int, int]); 3034 dart.fn(parseHex, int, [int, int]);
3035 if (dart.notNull(host.length) < 2) 3035 if (dart.notNull(host[dartx.length]) < 2)
3036 error('address is too short'); 3036 error('address is too short');
3037 let parts = dart.list([], int); 3037 let parts = dart.list([], int);
3038 let wildcardSeen = false; 3038 let wildcardSeen = false;
3039 let partStart = start; 3039 let partStart = start;
3040 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 3040 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
3041 if (host[dartx.codeUnitAt](i) == Uri._COLON) { 3041 if (host[dartx.codeUnitAt](i) == Uri._COLON) {
3042 if (i == start) { 3042 if (i == start) {
3043 i = dart.notNull(i) + 1; 3043 i = dart.notNull(i) + 1;
3044 if (host[dartx.codeUnitAt](i) != Uri._COLON) { 3044 if (host[dartx.codeUnitAt](i) != Uri._COLON) {
3045 error('invalid start colon.', i); 3045 error('invalid start colon.', i);
3046 } 3046 }
3047 partStart = i; 3047 partStart = i;
3048 } 3048 }
3049 if (i == partStart) { 3049 if (i == partStart) {
3050 if (dart.notNull(wildcardSeen)) { 3050 if (dart.notNull(wildcardSeen)) {
3051 error('only one wildcard `::` is allowed', i); 3051 error('only one wildcard `::` is allowed', i);
3052 } 3052 }
3053 wildcardSeen = true; 3053 wildcardSeen = true;
3054 parts[dartx.add](-1); 3054 parts[dartx.add](-1);
3055 } else { 3055 } else {
3056 parts[dartx.add](parseHex(partStart, i)); 3056 parts[dartx.add](parseHex(partStart, i));
3057 } 3057 }
3058 partStart = dart.notNull(i) + 1; 3058 partStart = dart.notNull(i) + 1;
3059 } 3059 }
3060 } 3060 }
3061 if (parts.length == 0) 3061 if (parts[dartx.length] == 0)
3062 error('too few parts'); 3062 error('too few parts');
3063 let atEnd = partStart == end; 3063 let atEnd = partStart == end;
3064 let isLastWildcard = parts[dartx.last] == -1; 3064 let isLastWildcard = parts[dartx.last] == -1;
3065 if (dart.notNull(atEnd) && !dart.notNull(isLastWildcard)) { 3065 if (dart.notNull(atEnd) && !dart.notNull(isLastWildcard)) {
3066 error('expected a part after last `:`', end); 3066 error('expected a part after last `:`', end);
3067 } 3067 }
3068 if (!dart.notNull(atEnd)) { 3068 if (!dart.notNull(atEnd)) {
3069 try { 3069 try {
3070 parts[dartx.add](parseHex(partStart, end)); 3070 parts[dartx.add](parseHex(partStart, end));
3071 } catch (e) { 3071 } catch (e) {
3072 try { 3072 try {
3073 let last = Uri.parseIPv4Address(host[dartx.substring](partStart, end )); 3073 let last = Uri.parseIPv4Address(host[dartx.substring](partStart, end ));
3074 parts[dartx.add](dart.notNull(last[dartx.get](0)) << 8 | dart.notNul l(last[dartx.get](1))); 3074 parts[dartx.add](dart.notNull(last[dartx.get](0)) << 8 | dart.notNul l(last[dartx.get](1)));
3075 parts[dartx.add](dart.notNull(last[dartx.get](2)) << 8 | dart.notNul l(last[dartx.get](3))); 3075 parts[dartx.add](dart.notNull(last[dartx.get](2)) << 8 | dart.notNul l(last[dartx.get](3)));
3076 } catch (e) { 3076 } catch (e) {
3077 error('invalid end of IPv6 address.', partStart); 3077 error('invalid end of IPv6 address.', partStart);
3078 } 3078 }
3079 3079
3080 } 3080 }
3081 3081
3082 } 3082 }
3083 if (dart.notNull(wildcardSeen)) { 3083 if (dart.notNull(wildcardSeen)) {
3084 if (dart.notNull(parts.length) > 7) { 3084 if (dart.notNull(parts[dartx.length]) > 7) {
3085 error('an address with a wildcard must have less than 7 parts'); 3085 error('an address with a wildcard must have less than 7 parts');
3086 } 3086 }
3087 } else if (parts.length != 8) { 3087 } else if (parts[dartx.length] != 8) {
3088 error('an address without a wildcard must contain exactly 8 parts'); 3088 error('an address without a wildcard must contain exactly 8 parts');
3089 } 3089 }
3090 let bytes = List$(int).new(16); 3090 let bytes = List$(int).new(16);
3091 for (let i = 0, index = 0; dart.notNull(i) < dart.notNull(parts.length); i = dart.notNull(i) + 1) { 3091 for (let i = 0, index = 0; dart.notNull(i) < dart.notNull(parts[dartx.leng th]); i = dart.notNull(i) + 1) {
3092 let value = parts[dartx.get](i); 3092 let value = parts[dartx.get](i);
3093 if (value == -1) { 3093 if (value == -1) {
3094 let wildCardLength = 9 - dart.notNull(parts.length); 3094 let wildCardLength = 9 - dart.notNull(parts[dartx.length]);
3095 for (let j = 0; dart.notNull(j) < dart.notNull(wildCardLength); j = da rt.notNull(j) + 1) { 3095 for (let j = 0; dart.notNull(j) < dart.notNull(wildCardLength); j = da rt.notNull(j) + 1) {
3096 bytes[dartx.set](index, 0); 3096 bytes[dartx.set](index, 0);
3097 bytes[dartx.set](dart.notNull(index) + 1, 0); 3097 bytes[dartx.set](dart.notNull(index) + 1, 0);
3098 index = dart.notNull(index) + 2; 3098 index = dart.notNull(index) + 2;
3099 } 3099 }
3100 } else { 3100 } else {
3101 bytes[dartx.set](index, dart.notNull(value) >> 8); 3101 bytes[dartx.set](index, dart.notNull(value) >> 8);
3102 bytes[dartx.set](dart.notNull(index) + 1, dart.notNull(value) & 255); 3102 bytes[dartx.set](dart.notNull(index) + 1, dart.notNull(value) & 255);
3103 index = dart.notNull(index) + 2; 3103 index = dart.notNull(index) + 2;
3104 } 3104 }
3105 } 3105 }
3106 return dart.as(bytes, List$(int)); 3106 return dart.as(bytes, List$(int));
3107 } 3107 }
3108 static _uriEncode(canonicalTable, text, opts) { 3108 static _uriEncode(canonicalTable, text, opts) {
3109 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8; 3109 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8;
3110 let spaceToPlus = opts && 'spaceToPlus' in opts ? opts.spaceToPlus : false ; 3110 let spaceToPlus = opts && 'spaceToPlus' in opts ? opts.spaceToPlus : false ;
3111 let byteToHex = (byte, buffer) => { 3111 let byteToHex = (byte, buffer) => {
3112 let hex = '0123456789ABCDEF'; 3112 let hex = '0123456789ABCDEF';
3113 dart.dsend(buffer, 'writeCharCode', hex[dartx.codeUnitAt](dart.as(dart.d send(byte, '>>', 4), int))); 3113 dart.dsend(buffer, 'writeCharCode', hex[dartx.codeUnitAt](dart.as(dart.d send(byte, '>>', 4), int)));
3114 dart.dsend(buffer, 'writeCharCode', hex[dartx.codeUnitAt](dart.as(dart.d send(byte, '&', 15), int))); 3114 dart.dsend(buffer, 'writeCharCode', hex[dartx.codeUnitAt](dart.as(dart.d send(byte, '&', 15), int)));
3115 }; 3115 };
3116 dart.fn(byteToHex); 3116 dart.fn(byteToHex);
3117 let result = new StringBuffer(); 3117 let result = new StringBuffer();
3118 let bytes = encoding.encode(text); 3118 let bytes = encoding.encode(text);
3119 for (let i = 0; dart.notNull(i) < dart.notNull(bytes.length); i = dart.not Null(i) + 1) { 3119 for (let i = 0; dart.notNull(i) < dart.notNull(bytes[dartx.length]); i = d art.notNull(i) + 1) {
3120 let byte = bytes[dartx.get](i); 3120 let byte = bytes[dartx.get](i);
3121 if (dart.notNull(byte) < 128 && (dart.notNull(canonicalTable[dartx.get]( dart.notNull(byte) >> 4)) & 1 << (dart.notNull(byte) & 15)) != 0) { 3121 if (dart.notNull(byte) < 128 && (dart.notNull(canonicalTable[dartx.get]( dart.notNull(byte) >> 4)) & 1 << (dart.notNull(byte) & 15)) != 0) {
3122 result.writeCharCode(byte); 3122 result.writeCharCode(byte);
3123 } else if (dart.notNull(spaceToPlus) && byte == Uri._SPACE) { 3123 } else if (dart.notNull(spaceToPlus) && byte == Uri._SPACE) {
3124 result.writeCharCode(Uri._PLUS); 3124 result.writeCharCode(Uri._PLUS);
3125 } else { 3125 } else {
3126 result.writeCharCode(Uri._PERCENT); 3126 result.writeCharCode(Uri._PERCENT);
3127 byteToHex(byte, result); 3127 byteToHex(byte, result);
3128 } 3128 }
3129 } 3129 }
(...skipping 13 matching lines...) Expand all
3143 throw new ArgumentError("Invalid URL encoding"); 3143 throw new ArgumentError("Invalid URL encoding");
3144 } 3144 }
3145 } 3145 }
3146 } 3146 }
3147 return byte; 3147 return byte;
3148 } 3148 }
3149 static _uriDecode(text, opts) { 3149 static _uriDecode(text, opts) {
3150 let plusToSpace = opts && 'plusToSpace' in opts ? opts.plusToSpace : false ; 3150 let plusToSpace = opts && 'plusToSpace' in opts ? opts.plusToSpace : false ;
3151 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8; 3151 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8;
3152 let simple = true; 3152 let simple = true;
3153 for (let i = 0; dart.notNull(i) < dart.notNull(text.length) && dart.notNul l(simple); i = dart.notNull(i) + 1) { 3153 for (let i = 0; dart.notNull(i) < dart.notNull(text[dartx.length]) && dart .notNull(simple); i = dart.notNull(i) + 1) {
3154 let codeUnit = text[dartx.codeUnitAt](i); 3154 let codeUnit = text[dartx.codeUnitAt](i);
3155 simple = codeUnit != Uri._PERCENT && codeUnit != Uri._PLUS; 3155 simple = codeUnit != Uri._PERCENT && codeUnit != Uri._PLUS;
3156 } 3156 }
3157 let bytes = null; 3157 let bytes = null;
3158 if (dart.notNull(simple)) { 3158 if (dart.notNull(simple)) {
3159 if (dart.equals(encoding, convert.UTF8) || dart.equals(encoding, convert .LATIN1)) { 3159 if (dart.equals(encoding, convert.UTF8) || dart.equals(encoding, convert .LATIN1)) {
3160 return text; 3160 return text;
3161 } else { 3161 } else {
3162 bytes = text[dartx.codeUnits]; 3162 bytes = text[dartx.codeUnits];
3163 } 3163 }
3164 } else { 3164 } else {
3165 bytes = List$(int).new(); 3165 bytes = List$(int).new();
3166 for (let i = 0; dart.notNull(i) < dart.notNull(text.length); i = dart.no tNull(i) + 1) { 3166 for (let i = 0; dart.notNull(i) < dart.notNull(text[dartx.length]); i = dart.notNull(i) + 1) {
3167 let codeUnit = text[dartx.codeUnitAt](i); 3167 let codeUnit = text[dartx.codeUnitAt](i);
3168 if (dart.notNull(codeUnit) > 127) { 3168 if (dart.notNull(codeUnit) > 127) {
3169 throw new ArgumentError("Illegal percent encoding in URI"); 3169 throw new ArgumentError("Illegal percent encoding in URI");
3170 } 3170 }
3171 if (codeUnit == Uri._PERCENT) { 3171 if (codeUnit == Uri._PERCENT) {
3172 if (dart.notNull(i) + 3 > dart.notNull(text.length)) { 3172 if (dart.notNull(i) + 3 > dart.notNull(text[dartx.length])) {
3173 throw new ArgumentError('Truncated URI'); 3173 throw new ArgumentError('Truncated URI');
3174 } 3174 }
3175 bytes[dartx.add](Uri._hexCharPairToByte(text, dart.notNull(i) + 1)); 3175 bytes[dartx.add](Uri._hexCharPairToByte(text, dart.notNull(i) + 1));
3176 i = dart.notNull(i) + 2; 3176 i = dart.notNull(i) + 2;
3177 } else if (dart.notNull(plusToSpace) && codeUnit == Uri._PLUS) { 3177 } else if (dart.notNull(plusToSpace) && codeUnit == Uri._PLUS) {
3178 bytes[dartx.add](Uri._SPACE); 3178 bytes[dartx.add](Uri._SPACE);
3179 } else { 3179 } else {
3180 bytes[dartx.add](codeUnit); 3180 bytes[dartx.add](codeUnit);
3181 } 3181 }
3182 } 3182 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3358 exports.StackTrace = StackTrace; 3358 exports.StackTrace = StackTrace;
3359 exports.Stopwatch = Stopwatch; 3359 exports.Stopwatch = Stopwatch;
3360 exports.String = String; 3360 exports.String = String;
3361 exports.RuneIterator = RuneIterator; 3361 exports.RuneIterator = RuneIterator;
3362 exports.StringBuffer = StringBuffer; 3362 exports.StringBuffer = StringBuffer;
3363 exports.StringSink = StringSink; 3363 exports.StringSink = StringSink;
3364 exports.Symbol = Symbol; 3364 exports.Symbol = Symbol;
3365 exports.Type = Type; 3365 exports.Type = Type;
3366 exports.Uri = Uri; 3366 exports.Uri = Uri;
3367 }); 3367 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698