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

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

Issue 1069493002: implement opassign, fix bugs in pre/postfix, introduce a let* helper (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/runtime/dart/convert.js ('k') | lib/runtime/dart/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 var core; 1 var core;
2 (function(exports) { 2 (function(exports) {
3 'use strict'; 3 'use strict';
4 class Object { 4 class Object {
5 constructor() { 5 constructor() {
6 let name = this.constructor.name; 6 let name = this.constructor.name;
7 let init = this[name]; 7 let init = this[name];
8 let result = void 0; 8 let result = void 0;
9 if (init) 9 if (init)
10 result = init.apply(this, arguments); 10 result = init.apply(this, arguments);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 addOneMillisecond = true; 170 addOneMillisecond = true;
171 millisecond = 999; 171 millisecond = 999;
172 } 172 }
173 let isUtc = false; 173 let isUtc = false;
174 if (match.get(8) != null) { 174 if (match.get(8) != null) {
175 isUtc = true; 175 isUtc = true;
176 if (match.get(9) != null) { 176 if (match.get(9) != null) {
177 let sign = match.get(9) == '-' ? -1 : 1; 177 let sign = match.get(9) == '-' ? -1 : 1;
178 let hourDifference = int.parse(match.get(10)); 178 let hourDifference = int.parse(match.get(10));
179 let minuteDifference = parseIntOrZero(match.get(11)); 179 let minuteDifference = parseIntOrZero(match.get(11));
180 minuteDifference = 60 * dart.notNull(hourDifference); 180 minuteDifference = dart.notNull(minuteDifference) + 60 * dart.notNul l(hourDifference);
181 minute = dart.notNull(sign) * dart.notNull(minuteDifference); 181 minute = dart.notNull(minute) - dart.notNull(sign) * dart.notNull(mi nuteDifference);
182 } 182 }
183 } 183 }
184 let millisecondsSinceEpoch = DateTime[_brokenDownDateToMillisecondsSince Epoch](years, month, day, hour, minute, second, millisecond, isUtc); 184 let millisecondsSinceEpoch = DateTime[_brokenDownDateToMillisecondsSince Epoch](years, month, day, hour, minute, second, millisecond, isUtc);
185 if (millisecondsSinceEpoch == null) { 185 if (millisecondsSinceEpoch == null) {
186 throw new FormatException("Time out of range", formattedString); 186 throw new FormatException("Time out of range", formattedString);
187 } 187 }
188 if (addOneMillisecond) 188 if (addOneMillisecond) {
189 millisecondsSinceEpoch = dart.notNull(millisecondsSinceEpoch) + 1; 189 millisecondsSinceEpoch = dart.notNull(millisecondsSinceEpoch) + 1;
190 }
190 return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, { isUtc: isUtc}); 191 return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, { isUtc: isUtc});
191 } else { 192 } else {
192 throw new FormatException("Invalid date format", formattedString); 193 throw new FormatException("Invalid date format", formattedString);
193 } 194 }
194 } 195 }
195 fromMillisecondsSinceEpoch(millisecondsSinceEpoch, opts) { 196 fromMillisecondsSinceEpoch(millisecondsSinceEpoch, opts) {
196 let isUtc = opts && 'isUtc' in opts ? opts.isUtc : false; 197 let isUtc = opts && 'isUtc' in opts ? opts.isUtc : false;
197 this.millisecondsSinceEpoch = millisecondsSinceEpoch; 198 this.millisecondsSinceEpoch = millisecondsSinceEpoch;
198 this.isUtc = isUtc; 199 this.isUtc = isUtc;
199 if (dart.notNull(millisecondsSinceEpoch.abs()) > dart.notNull(DateTime[_MA X_MILLISECONDS_SINCE_EPOCH])) { 200 if (dart.notNull(millisecondsSinceEpoch.abs()) > dart.notNull(DateTime[_MA X_MILLISECONDS_SINCE_EPOCH])) {
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 this.offset = offset; 935 this.offset = offset;
935 } 936 }
936 toString() { 937 toString() {
937 let report = "FormatException"; 938 let report = "FormatException";
938 if (dart.notNull(this.message != null) && dart.notNull("" != this.message) ) { 939 if (dart.notNull(this.message != null) && dart.notNull("" != this.message) ) {
939 report = `${report}: ${this.message}`; 940 report = `${report}: ${this.message}`;
940 } 941 }
941 let offset = this.offset; 942 let offset = this.offset;
942 if (!(typeof this.source == 'string')) { 943 if (!(typeof this.source == 'string')) {
943 if (offset != -1) { 944 if (offset != -1) {
944 report = ` (at offset ${offset})`; 945 report = String['+'](report, ` (at offset ${offset})`);
945 } 946 }
946 return report; 947 return report;
947 } 948 }
948 if (offset != -1 && (dart.notNull(offset) < 0 || offset['>'](dart.dload(th is.source, 'length')))) { 949 if (offset != -1 && (dart.notNull(offset) < 0 || offset['>'](dart.dload(th is.source, 'length')))) {
949 offset = -1; 950 offset = -1;
950 } 951 }
951 if (offset == -1) { 952 if (offset == -1) {
952 let source = dart.as(this.source, String); 953 let source = dart.as(this.source, String);
953 if (dart.notNull(source.length) > 78) { 954 if (dart.notNull(source.length) > 78) {
954 source = String['+'](source.substring(0, 75), "..."); 955 source = String['+'](source.substring(0, 75), "...");
(...skipping 11 matching lines...) Expand all
966 } 967 }
967 lineStart = dart.notNull(i) + 1; 968 lineStart = dart.notNull(i) + 1;
968 lastWasCR = false; 969 lastWasCR = false;
969 } else if (char == 13) { 970 } else if (char == 13) {
970 lineNum = dart.notNull(lineNum) + 1; 971 lineNum = dart.notNull(lineNum) + 1;
971 lineStart = dart.notNull(i) + 1; 972 lineStart = dart.notNull(i) + 1;
972 lastWasCR = true; 973 lastWasCR = true;
973 } 974 }
974 } 975 }
975 if (dart.notNull(lineNum) > 1) { 976 if (dart.notNull(lineNum) > 1) {
976 report = ` (at line ${lineNum}, character ${dart.notNull(offset) - dart. notNull(lineStart) + 1})\n`; 977 report = String['+'](report, ` (at line ${lineNum}, character ${dart.not Null(offset) - dart.notNull(lineStart) + 1})\n`);
977 } else { 978 } else {
978 report = ` (at character ${dart.notNull(offset) + 1})\n`; 979 report = String['+'](report, ` (at character ${dart.notNull(offset) + 1} )\n`);
979 } 980 }
980 let lineEnd = dart.as(dart.dload(this.source, 'length'), int); 981 let lineEnd = dart.as(dart.dload(this.source, 'length'), int);
981 for (let i = offset; i['<'](dart.dload(this.source, 'length')); i = dart.n otNull(i) + 1) { 982 for (let i = offset; i['<'](dart.dload(this.source, 'length')); i = dart.n otNull(i) + 1) {
982 let char = dart.as(dart.dinvoke(this.source, 'codeUnitAt', i), int); 983 let char = dart.as(dart.dinvoke(this.source, 'codeUnitAt', i), int);
983 if (char == 10 || char == 13) { 984 if (char == 10 || char == 13) {
984 lineEnd = i; 985 lineEnd = i;
985 break; 986 break;
986 } 987 }
987 } 988 }
988 let length = dart.notNull(lineEnd) - dart.notNull(lineStart); 989 let length = dart.notNull(lineEnd) - dart.notNull(lineStart);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 let values = _js_helper.Primitives.getProperty(object, Expando[_EXPANDO_ PROPERTY_NAME]); 1041 let values = _js_helper.Primitives.getProperty(object, Expando[_EXPANDO_ PROPERTY_NAME]);
1041 if (values == null) { 1042 if (values == null) {
1042 values = new Object(); 1043 values = new Object();
1043 _js_helper.Primitives.setProperty(object, Expando[_EXPANDO_PROPERTY_NA ME], values); 1044 _js_helper.Primitives.setProperty(object, Expando[_EXPANDO_PROPERTY_NA ME], values);
1044 } 1045 }
1045 _js_helper.Primitives.setProperty(values, this[_getKey](), value); 1046 _js_helper.Primitives.setProperty(values, this[_getKey](), value);
1046 } 1047 }
1047 [_getKey]() { 1048 [_getKey]() {
1048 let key = dart.as(_js_helper.Primitives.getProperty(this, Expando[_KEY_P ROPERTY_NAME]), String); 1049 let key = dart.as(_js_helper.Primitives.getProperty(this, Expando[_KEY_P ROPERTY_NAME]), String);
1049 if (key == null) { 1050 if (key == null) {
1050 key = `expando$key$${((x) => Expando[_keyCount] = dart.notNull(x) + 1, x)(Expando[_keyCount])}`; 1051 key = `expando$key$${(() => {
1052 let x = Expando[_keyCount];
1053 Expando[_keyCount] = dart.notNull(x) + 1;
1054 return x;
1055 })()}`;
1051 _js_helper.Primitives.setProperty(this, Expando[_KEY_PROPERTY_NAME], k ey); 1056 _js_helper.Primitives.setProperty(this, Expando[_KEY_PROPERTY_NAME], k ey);
1052 } 1057 }
1053 return key; 1058 return key;
1054 } 1059 }
1055 } 1060 }
1056 Expando._KEY_PROPERTY_NAME = 'expando$key'; 1061 Expando._KEY_PROPERTY_NAME = 'expando$key';
1057 Expando._EXPANDO_PROPERTY_NAME = 'expando$values'; 1062 Expando._EXPANDO_PROPERTY_NAME = 'expando$values';
1058 Expando._keyCount = 0; 1063 Expando._keyCount = 0;
1059 return Expando; 1064 return Expando;
1060 }); 1065 });
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 return dart.as(result, List$(E)); 1241 return dart.as(result, List$(E));
1237 } 1242 }
1238 from(elements, opts) { 1243 from(elements, opts) {
1239 let growable = opts && 'growable' in opts ? opts.growable : true; 1244 let growable = opts && 'growable' in opts ? opts.growable : true;
1240 return null; 1245 return null;
1241 } 1246 }
1242 generate(length, generator, opts) { 1247 generate(length, generator, opts) {
1243 let growable = opts && 'growable' in opts ? opts.growable : true; 1248 let growable = opts && 'growable' in opts ? opts.growable : true;
1244 let result = null; 1249 let result = null;
1245 if (growable) { 1250 if (growable) {
1246 result = ((_$) => { 1251 result = new List$(E).from([]);
1247 _$[exports.$length] = length; 1252 result[exports.$length] = length;
1248 return _$;
1249 })(new List$(E).from([]));
1250 } else { 1253 } else {
1251 result = new (List$(E))(length); 1254 result = new (List$(E))(length);
1252 } 1255 }
1253 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) { 1256 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) {
1254 result[exports.$set](i, generator(i)); 1257 result[exports.$set](i, generator(i));
1255 } 1258 }
1256 return result; 1259 return result;
1257 } 1260 }
1258 } 1261 }
1259 List[dart.implements] = () => [Iterable$(E), _internal.EfficientLength]; 1262 List[dart.implements] = () => [Iterable$(E), _internal.EfficientLength];
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 static get base() { 2052 static get base() {
2050 let uri = _js_helper.Primitives.currentUri(); 2053 let uri = _js_helper.Primitives.currentUri();
2051 if (uri != null) 2054 if (uri != null)
2052 return Uri.parse(uri); 2055 return Uri.parse(uri);
2053 throw new UnsupportedError("'Uri.base' is not supported"); 2056 throw new UnsupportedError("'Uri.base' is not supported");
2054 } 2057 }
2055 static get [_isWindows]() { 2058 static get [_isWindows]() {
2056 return false; 2059 return false;
2057 } 2060 }
2058 static [_checkNonWindowsPathReservedCharacters](segments, argumentError) { 2061 static [_checkNonWindowsPathReservedCharacters](segments, argumentError) {
2059 segments[exports.$forEach](dart.as((segment) => { 2062 segments[exports.$forEach](dart.as(segment => {
2060 if (dart.dinvoke(segment, 'contains', "/")) { 2063 if (dart.dinvoke(segment, 'contains', "/")) {
2061 if (argumentError) { 2064 if (argumentError) {
2062 throw new ArgumentError(`Illegal path character ${segment}`); 2065 throw new ArgumentError(`Illegal path character ${segment}`);
2063 } else { 2066 } else {
2064 throw new UnsupportedError(`Illegal path character ${segment}`); 2067 throw new UnsupportedError(`Illegal path character ${segment}`);
2065 } 2068 }
2066 } 2069 }
2067 }, dart.throw_("Unimplemented type (String) → void"))); 2070 }, dart.throw_("Unimplemented type (String) → void")));
2068 } 2071 }
2069 static [_checkWindowsPathReservedCharacters](segments, argumentError, firstS egment) { 2072 static [_checkWindowsPathReservedCharacters](segments, argumentError, firstS egment) {
2070 if (firstSegment === void 0) 2073 if (firstSegment === void 0)
2071 firstSegment = 0; 2074 firstSegment = 0;
2072 segments[exports.$skip](firstSegment)[exports.$forEach](dart.as((segment) => { 2075 segments[exports.$skip](firstSegment)[exports.$forEach](dart.as(segment => {
2073 if (dart.dinvoke(segment, 'contains', new RegExp('["*/:<>?\\\\|]'))) { 2076 if (dart.dinvoke(segment, 'contains', new RegExp('["*/:<>?\\\\|]'))) {
2074 if (argumentError) { 2077 if (argumentError) {
2075 throw new ArgumentError("Illegal character in path"); 2078 throw new ArgumentError("Illegal character in path");
2076 } else { 2079 } else {
2077 throw new UnsupportedError("Illegal character in path"); 2080 throw new UnsupportedError("Illegal character in path");
2078 } 2081 }
2079 } 2082 }
2080 }, dart.throw_("Unimplemented type (String) → void"))); 2083 }, dart.throw_("Unimplemented type (String) → void")));
2081 } 2084 }
2082 static [_checkWindowsDriveLetter](charCode, argumentError) { 2085 static [_checkWindowsDriveLetter](charCode, argumentError) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 static [_normalizeRegName](host, start, end) { 2247 static [_normalizeRegName](host, start, end) {
2245 let buffer = null; 2248 let buffer = null;
2246 let sectionStart = start; 2249 let sectionStart = start;
2247 let index = start; 2250 let index = start;
2248 let isNormalized = true; 2251 let isNormalized = true;
2249 while (dart.notNull(index) < dart.notNull(end)) { 2252 while (dart.notNull(index) < dart.notNull(end)) {
2250 let char = host.codeUnitAt(index); 2253 let char = host.codeUnitAt(index);
2251 if (char == Uri[_PERCENT]) { 2254 if (char == Uri[_PERCENT]) {
2252 let replacement = Uri[_normalizeEscape](host, index, true); 2255 let replacement = Uri[_normalizeEscape](host, index, true);
2253 if (dart.notNull(replacement == null) && dart.notNull(isNormalized)) { 2256 if (dart.notNull(replacement == null) && dart.notNull(isNormalized)) {
2254 index = 3; 2257 index = dart.notNull(index) + 3;
2255 continue; 2258 continue;
2256 } 2259 }
2257 if (buffer == null) 2260 if (buffer == null)
2258 buffer = new StringBuffer(); 2261 buffer = new StringBuffer();
2259 let slice = host.substring(sectionStart, index); 2262 let slice = host.substring(sectionStart, index);
2260 if (!dart.notNull(isNormalized)) 2263 if (!dart.notNull(isNormalized))
2261 slice = slice.toLowerCase(); 2264 slice = slice.toLowerCase();
2262 buffer.write(slice); 2265 buffer.write(slice);
2263 let sourceLength = 3; 2266 let sourceLength = 3;
2264 if (replacement == null) { 2267 if (replacement == null) {
2265 replacement = host.substring(index, dart.notNull(index) + 3); 2268 replacement = host.substring(index, dart.notNull(index) + 3);
2266 } else if (replacement == "%") { 2269 } else if (replacement == "%") {
2267 replacement = "%25"; 2270 replacement = "%25";
2268 sourceLength = 1; 2271 sourceLength = 1;
2269 } 2272 }
2270 buffer.write(replacement); 2273 buffer.write(replacement);
2271 index = sourceLength; 2274 index = dart.notNull(index) + dart.notNull(sourceLength);
2272 sectionStart = index; 2275 sectionStart = index;
2273 isNormalized = true; 2276 isNormalized = true;
2274 } else if (Uri[_isRegNameChar](char)) { 2277 } else if (Uri[_isRegNameChar](char)) {
2275 if (dart.notNull(isNormalized) && dart.notNull(Uri[_UPPER_CASE_A]) <= dart.notNull(char) && dart.notNull(Uri[_UPPER_CASE_Z]) >= dart.notNull(char)) { 2278 if (dart.notNull(isNormalized) && dart.notNull(Uri[_UPPER_CASE_A]) <= dart.notNull(char) && dart.notNull(Uri[_UPPER_CASE_Z]) >= dart.notNull(char)) {
2276 if (buffer == null) 2279 if (buffer == null)
2277 buffer = new StringBuffer(); 2280 buffer = new StringBuffer();
2278 if (dart.notNull(sectionStart) < dart.notNull(index)) { 2281 if (dart.notNull(sectionStart) < dart.notNull(index)) {
2279 buffer.write(host.substring(sectionStart, index)); 2282 buffer.write(host.substring(sectionStart, index));
2280 sectionStart = index; 2283 sectionStart = index;
2281 } 2284 }
(...skipping 11 matching lines...) Expand all
2293 sourceLength = 2; 2296 sourceLength = 2;
2294 } 2297 }
2295 } 2298 }
2296 if (buffer == null) 2299 if (buffer == null)
2297 buffer = new StringBuffer(); 2300 buffer = new StringBuffer();
2298 let slice = host.substring(sectionStart, index); 2301 let slice = host.substring(sectionStart, index);
2299 if (!dart.notNull(isNormalized)) 2302 if (!dart.notNull(isNormalized))
2300 slice = slice.toLowerCase(); 2303 slice = slice.toLowerCase();
2301 buffer.write(slice); 2304 buffer.write(slice);
2302 buffer.write(Uri[_escapeChar](char)); 2305 buffer.write(Uri[_escapeChar](char));
2303 index = sourceLength; 2306 index = dart.notNull(index) + dart.notNull(sourceLength);
2304 sectionStart = index; 2307 sectionStart = index;
2305 } 2308 }
2306 } 2309 }
2307 if (buffer == null) 2310 if (buffer == null)
2308 return host.substring(start, end); 2311 return host.substring(start, end);
2309 if (dart.notNull(sectionStart) < dart.notNull(end)) { 2312 if (dart.notNull(sectionStart) < dart.notNull(end)) {
2310 let slice = host.substring(sectionStart, end); 2313 let slice = host.substring(sectionStart, end);
2311 if (!dart.notNull(isNormalized)) 2314 if (!dart.notNull(isNormalized))
2312 slice = slice.toLowerCase(); 2315 slice = slice.toLowerCase();
2313 buffer.write(slice); 2316 buffer.write(slice);
(...skipping 30 matching lines...) Expand all
2344 static [_makePath](path, start, end, pathSegments, ensureLeadingSlash, isFil e) { 2347 static [_makePath](path, start, end, pathSegments, ensureLeadingSlash, isFil e) {
2345 if (dart.notNull(path == null) && dart.notNull(pathSegments == null)) 2348 if (dart.notNull(path == null) && dart.notNull(pathSegments == null))
2346 return isFile ? "/" : ""; 2349 return isFile ? "/" : "";
2347 if (dart.notNull(path != null) && dart.notNull(pathSegments != null)) { 2350 if (dart.notNull(path != null) && dart.notNull(pathSegments != null)) {
2348 throw new ArgumentError('Both path and pathSegments specified'); 2351 throw new ArgumentError('Both path and pathSegments specified');
2349 } 2352 }
2350 let result = null; 2353 let result = null;
2351 if (path != null) { 2354 if (path != null) {
2352 result = Uri[_normalize](path, start, end, dart.as(Uri[_pathCharOrSlashT able], List$(int))); 2355 result = Uri[_normalize](path, start, end, dart.as(Uri[_pathCharOrSlashT able], List$(int)));
2353 } else { 2356 } else {
2354 result = pathSegments[exports.$map](dart.as((s) => Uri[_uriEncode](dart. as(Uri[_pathCharTable], List$(int)), dart.as(s, String)), dart.throw_("Unimpleme nted type (String) → dynamic")))[exports.$join]("/"); 2357 result = pathSegments[exports.$map](dart.as(s => Uri[_uriEncode](dart.as (Uri[_pathCharTable], List$(int)), dart.as(s, String)), dart.throw_("Unimplement ed type (String) → dynamic")))[exports.$join]("/");
2355 } 2358 }
2356 if (dart.dload(result, 'isEmpty')) { 2359 if (dart.dload(result, 'isEmpty')) {
2357 if (isFile) 2360 if (isFile)
2358 return "/"; 2361 return "/";
2359 } else if ((dart.notNull(isFile) || dart.notNull(ensureLeadingSlash)) && d art.notNull(!dart.equals(dart.dinvoke(result, 'codeUnitAt', 0), Uri[_SLASH]))) { 2362 } else if ((dart.notNull(isFile) || dart.notNull(ensureLeadingSlash)) && d art.notNull(!dart.equals(dart.dinvoke(result, 'codeUnitAt', 0), Uri[_SLASH]))) {
2360 return `/${result}`; 2363 return `/${result}`;
2361 } 2364 }
2362 return dart.as(result, String); 2365 return dart.as(result, String);
2363 } 2366 }
2364 static [_makeQuery](query, start, end, queryParameters) { 2367 static [_makeQuery](query, start, end, queryParameters) {
(...skipping 23 matching lines...) Expand all
2388 if (fragment == null) 2391 if (fragment == null)
2389 return null; 2392 return null;
2390 return Uri[_normalize](fragment, start, end, dart.as(Uri[_queryCharTable], List$(int))); 2393 return Uri[_normalize](fragment, start, end, dart.as(Uri[_queryCharTable], List$(int)));
2391 } 2394 }
2392 static [_stringOrNullLength](s) { 2395 static [_stringOrNullLength](s) {
2393 return s == null ? 0 : s.length; 2396 return s == null ? 0 : s.length;
2394 } 2397 }
2395 static [_isHexDigit](char) { 2398 static [_isHexDigit](char) {
2396 if (dart.notNull(Uri[_NINE]) >= dart.notNull(char)) 2399 if (dart.notNull(Uri[_NINE]) >= dart.notNull(char))
2397 return dart.notNull(Uri[_ZERO]) <= dart.notNull(char); 2400 return dart.notNull(Uri[_ZERO]) <= dart.notNull(char);
2398 char = 32; 2401 char = dart.notNull(char) | 32;
2399 return dart.notNull(Uri[_LOWER_CASE_A]) <= dart.notNull(char) && dart.notN ull(Uri[_LOWER_CASE_F]) >= dart.notNull(char); 2402 return dart.notNull(Uri[_LOWER_CASE_A]) <= dart.notNull(char) && dart.notN ull(Uri[_LOWER_CASE_F]) >= dart.notNull(char);
2400 } 2403 }
2401 static [_hexValue](char) { 2404 static [_hexValue](char) {
2402 dart.assert(Uri[_isHexDigit](char)); 2405 dart.assert(Uri[_isHexDigit](char));
2403 if (dart.notNull(Uri[_NINE]) >= dart.notNull(char)) 2406 if (dart.notNull(Uri[_NINE]) >= dart.notNull(char))
2404 return dart.notNull(char) - dart.notNull(Uri[_ZERO]); 2407 return dart.notNull(char) - dart.notNull(Uri[_ZERO]);
2405 char = 32; 2408 char = dart.notNull(char) | 32;
2406 return dart.notNull(char) - (dart.notNull(Uri[_LOWER_CASE_A]) - 10); 2409 return dart.notNull(char) - (dart.notNull(Uri[_LOWER_CASE_A]) - 10);
2407 } 2410 }
2408 static [_normalizeEscape](source, index, lowerCase) { 2411 static [_normalizeEscape](source, index, lowerCase) {
2409 dart.assert(source.codeUnitAt(index) == Uri[_PERCENT]); 2412 dart.assert(source.codeUnitAt(index) == Uri[_PERCENT]);
2410 if (dart.notNull(index) + 2 >= dart.notNull(source.length)) { 2413 if (dart.notNull(index) + 2 >= dart.notNull(source.length)) {
2411 return "%"; 2414 return "%";
2412 } 2415 }
2413 let firstDigit = source.codeUnitAt(dart.notNull(index) + 1); 2416 let firstDigit = source.codeUnitAt(dart.notNull(index) + 1);
2414 let secondDigit = source.codeUnitAt(dart.notNull(index) + 2); 2417 let secondDigit = source.codeUnitAt(dart.notNull(index) + 2);
2415 if (!dart.notNull(Uri[_isHexDigit](firstDigit)) || !dart.notNull(Uri[_isHe xDigit](secondDigit))) { 2418 if (!dart.notNull(Uri[_isHexDigit](firstDigit)) || !dart.notNull(Uri[_isHe xDigit](secondDigit))) {
2416 return "%"; 2419 return "%";
2417 } 2420 }
2418 let value = dart.notNull(Uri[_hexValue](firstDigit)) * 16 + dart.notNull(U ri[_hexValue](secondDigit)); 2421 let value = dart.notNull(Uri[_hexValue](firstDigit)) * 16 + dart.notNull(U ri[_hexValue](secondDigit));
2419 if (Uri[_isUnreservedChar](value)) { 2422 if (Uri[_isUnreservedChar](value)) {
2420 if (dart.notNull(lowerCase) && dart.notNull(Uri[_UPPER_CASE_A]) <= dart. notNull(value) && dart.notNull(Uri[_UPPER_CASE_Z]) >= dart.notNull(value)) { 2423 if (dart.notNull(lowerCase) && dart.notNull(Uri[_UPPER_CASE_A]) <= dart. notNull(value) && dart.notNull(Uri[_UPPER_CASE_Z]) >= dart.notNull(value)) {
2421 value = 32; 2424 value = dart.notNull(value) | 32;
2422 } 2425 }
2423 return new String.fromCharCode(value); 2426 return new String.fromCharCode(value);
2424 } 2427 }
2425 if (dart.notNull(firstDigit) >= dart.notNull(Uri[_LOWER_CASE_A]) || dart.n otNull(secondDigit) >= dart.notNull(Uri[_LOWER_CASE_A])) { 2428 if (dart.notNull(firstDigit) >= dart.notNull(Uri[_LOWER_CASE_A]) || dart.n otNull(secondDigit) >= dart.notNull(Uri[_LOWER_CASE_A])) {
2426 return source.substring(index, dart.notNull(index) + 3).toUpperCase(); 2429 return source.substring(index, dart.notNull(index) + 3).toUpperCase();
2427 } 2430 }
2428 return null; 2431 return null;
2429 } 2432 }
2430 static [_isUnreservedChar](ch) { 2433 static [_isUnreservedChar](ch) {
2431 return dart.notNull(ch) < 127 && dart.notNull(!dart.equals(dart.dbinary(Ur i[_unreservedTable][exports.$get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNul l(ch) & 15)), 0)); 2434 return dart.notNull(ch) < 127 && dart.notNull(!dart.equals(dart.dbinary(Ur i[_unreservedTable][exports.$get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNul l(ch) & 15)), 0));
(...skipping 18 matching lines...) Expand all
2450 flag = 240; 2453 flag = 240;
2451 } 2454 }
2452 } 2455 }
2453 codeUnits = new List(3 * dart.notNull(encodedBytes)); 2456 codeUnits = new List(3 * dart.notNull(encodedBytes));
2454 let index = 0; 2457 let index = 0;
2455 while ((encodedBytes = dart.notNull(encodedBytes) - 1) >= 0) { 2458 while ((encodedBytes = dart.notNull(encodedBytes) - 1) >= 0) {
2456 let byte = dart.as(dart.dbinary(dart.dbinary(dart.dbinary(char, '>>', 6 * dart.notNull(encodedBytes)), '&', 63), '|', flag), int); 2459 let byte = dart.as(dart.dbinary(dart.dbinary(dart.dbinary(char, '>>', 6 * dart.notNull(encodedBytes)), '&', 63), '|', flag), int);
2457 codeUnits[exports.$set](index, Uri[_PERCENT]); 2460 codeUnits[exports.$set](index, Uri[_PERCENT]);
2458 codeUnits[exports.$set](dart.notNull(index) + 1, hexDigits.codeUnitAt( dart.notNull(byte) >> 4)); 2461 codeUnits[exports.$set](dart.notNull(index) + 1, hexDigits.codeUnitAt( dart.notNull(byte) >> 4));
2459 codeUnits[exports.$set](dart.notNull(index) + 2, hexDigits.codeUnitAt( dart.notNull(byte) & 15)); 2462 codeUnits[exports.$set](dart.notNull(index) + 2, hexDigits.codeUnitAt( dart.notNull(byte) & 15));
2460 index = 3; 2463 index = dart.notNull(index) + 3;
2461 flag = 128; 2464 flag = 128;
2462 } 2465 }
2463 } 2466 }
2464 return new String.fromCharCodes(dart.as(codeUnits, Iterable$(int))); 2467 return new String.fromCharCodes(dart.as(codeUnits, Iterable$(int)));
2465 } 2468 }
2466 static [_normalize](component, start, end, charTable) { 2469 static [_normalize](component, start, end, charTable) {
2467 let buffer = null; 2470 let buffer = null;
2468 let sectionStart = start; 2471 let sectionStart = start;
2469 let index = start; 2472 let index = start;
2470 while (dart.notNull(index) < dart.notNull(end)) { 2473 while (dart.notNull(index) < dart.notNull(end)) {
2471 let char = component.codeUnitAt(index); 2474 let char = component.codeUnitAt(index);
2472 if (dart.notNull(char) < 127 && (dart.notNull(charTable[exports.$get](da rt.notNull(char) >> 4)) & 1 << (dart.notNull(char) & 15)) != 0) { 2475 if (dart.notNull(char) < 127 && (dart.notNull(charTable[exports.$get](da rt.notNull(char) >> 4)) & 1 << (dart.notNull(char) & 15)) != 0) {
2473 index = dart.notNull(index) + 1; 2476 index = dart.notNull(index) + 1;
2474 } else { 2477 } else {
2475 let replacement = null; 2478 let replacement = null;
2476 let sourceLength = null; 2479 let sourceLength = null;
2477 if (char == Uri[_PERCENT]) { 2480 if (char == Uri[_PERCENT]) {
2478 replacement = Uri[_normalizeEscape](component, index, false); 2481 replacement = Uri[_normalizeEscape](component, index, false);
2479 if (replacement == null) { 2482 if (replacement == null) {
2480 index = 3; 2483 index = dart.notNull(index) + 3;
2481 continue; 2484 continue;
2482 } 2485 }
2483 if ("%" == replacement) { 2486 if ("%" == replacement) {
2484 replacement = "%25"; 2487 replacement = "%25";
2485 sourceLength = 1; 2488 sourceLength = 1;
2486 } else { 2489 } else {
2487 sourceLength = 3; 2490 sourceLength = 3;
2488 } 2491 }
2489 } else if (Uri[_isGeneralDelimiter](char)) { 2492 } else if (Uri[_isGeneralDelimiter](char)) {
2490 Uri[_fail](component, index, "Invalid character"); 2493 Uri[_fail](component, index, "Invalid character");
2491 } else { 2494 } else {
2492 sourceLength = 1; 2495 sourceLength = 1;
2493 if ((dart.notNull(char) & 64512) == 55296) { 2496 if ((dart.notNull(char) & 64512) == 55296) {
2494 if (dart.notNull(index) + 1 < dart.notNull(end)) { 2497 if (dart.notNull(index) + 1 < dart.notNull(end)) {
2495 let tail = component.codeUnitAt(dart.notNull(index) + 1); 2498 let tail = component.codeUnitAt(dart.notNull(index) + 1);
2496 if ((dart.notNull(tail) & 64512) == 56320) { 2499 if ((dart.notNull(tail) & 64512) == 56320) {
2497 sourceLength = 2; 2500 sourceLength = 2;
2498 char = 65536 | (dart.notNull(char) & 1023) << 10 | dart.notNul l(tail) & 1023; 2501 char = 65536 | (dart.notNull(char) & 1023) << 10 | dart.notNul l(tail) & 1023;
2499 } 2502 }
2500 } 2503 }
2501 } 2504 }
2502 replacement = Uri[_escapeChar](char); 2505 replacement = Uri[_escapeChar](char);
2503 } 2506 }
2504 if (buffer == null) 2507 if (buffer == null)
2505 buffer = new StringBuffer(); 2508 buffer = new StringBuffer();
2506 buffer.write(component.substring(sectionStart, index)); 2509 buffer.write(component.substring(sectionStart, index));
2507 buffer.write(replacement); 2510 buffer.write(replacement);
2508 index = sourceLength; 2511 index = dart.notNull(index) + dart.notNull(sourceLength);
2509 sectionStart = index; 2512 sectionStart = index;
2510 } 2513 }
2511 } 2514 }
2512 if (buffer == null) { 2515 if (buffer == null) {
2513 return component.substring(start, end); 2516 return component.substring(start, end);
2514 } 2517 }
2515 if (dart.notNull(sectionStart) < dart.notNull(end)) { 2518 if (dart.notNull(sectionStart) < dart.notNull(end)) {
2516 buffer.write(component.substring(sectionStart, end)); 2519 buffer.write(component.substring(sectionStart, end));
2517 } 2520 }
2518 return buffer.toString(); 2521 return buffer.toString();
2519 } 2522 }
2520 static [_isSchemeCharacter](ch) { 2523 static [_isSchemeCharacter](ch) {
2521 return dart.notNull(ch) < 128 && dart.notNull(!dart.equals(dart.dbinary(Ur i[_schemeTable][exports.$get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNull(ch ) & 15)), 0)); 2524 return dart.notNull(ch) < 128 && dart.notNull(!dart.equals(dart.dbinary(Ur i[_schemeTable][exports.$get](dart.notNull(ch) >> 4), '&', 1 << (dart.notNull(ch ) & 15)), 0));
2522 } 2525 }
2523 static [_isGeneralDelimiter](ch) { 2526 static [_isGeneralDelimiter](ch) {
2524 return dart.notNull(ch) <= dart.notNull(Uri[_RIGHT_BRACKET]) && dart.notNu ll(!dart.equals(dart.dbinary(Uri[_genDelimitersTable][exports.$get](dart.notNull (ch) >> 4), '&', 1 << (dart.notNull(ch) & 15)), 0)); 2527 return dart.notNull(ch) <= dart.notNull(Uri[_RIGHT_BRACKET]) && dart.notNu ll(!dart.equals(dart.dbinary(Uri[_genDelimitersTable][exports.$get](dart.notNull (ch) >> 4), '&', 1 << (dart.notNull(ch) & 15)), 0));
2525 } 2528 }
2526 get isAbsolute() { 2529 get isAbsolute() {
2527 return dart.notNull(this.scheme != "") && dart.notNull(this.fragment == "" ); 2530 return dart.notNull(this.scheme != "") && dart.notNull(this.fragment == "" );
2528 } 2531 }
2529 [_merge](base, reference) { 2532 [_merge](base, reference) {
2530 if (base.isEmpty) 2533 if (base.isEmpty)
2531 return `/${reference}`; 2534 return `/${reference}`;
2532 let backCount = 0; 2535 let backCount = 0;
2533 let refStart = 0; 2536 let refStart = 0;
2534 while (reference.startsWith("../", refStart)) { 2537 while (reference.startsWith("../", refStart)) {
2535 refStart = 3; 2538 refStart = dart.notNull(refStart) + 3;
2536 backCount = dart.notNull(backCount) + 1; 2539 backCount = dart.notNull(backCount) + 1;
2537 } 2540 }
2538 let baseEnd = base.lastIndexOf('/'); 2541 let baseEnd = base.lastIndexOf('/');
2539 while (dart.notNull(baseEnd) > 0 && dart.notNull(backCount) > 0) { 2542 while (dart.notNull(baseEnd) > 0 && dart.notNull(backCount) > 0) {
2540 let newEnd = base.lastIndexOf('/', dart.notNull(baseEnd) - 1); 2543 let newEnd = base.lastIndexOf('/', dart.notNull(baseEnd) - 1);
2541 if (dart.notNull(newEnd) < 0) { 2544 if (dart.notNull(newEnd) < 0) {
2542 break; 2545 break;
2543 } 2546 }
2544 let delta = dart.notNull(baseEnd) - dart.notNull(newEnd); 2547 let delta = dart.notNull(baseEnd) - dart.notNull(newEnd);
2545 if ((delta == 2 || delta == 3) && base.codeUnitAt(dart.notNull(newEnd) + 1) == Uri[_DOT] && (delta == 2 || base.codeUnitAt(dart.notNull(newEnd) + 2) == Uri[_DOT])) { 2548 if ((delta == 2 || delta == 3) && base.codeUnitAt(dart.notNull(newEnd) + 1) == Uri[_DOT] && (delta == 2 || base.codeUnitAt(dart.notNull(newEnd) + 2) == Uri[_DOT])) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 } 2799 }
2797 static parseIPv4Address(host) { 2800 static parseIPv4Address(host) {
2798 // Function error: (String) → void 2801 // Function error: (String) → void
2799 function error(msg) { 2802 function error(msg) {
2800 throw new FormatException(`Illegal IPv4 address, ${msg}`); 2803 throw new FormatException(`Illegal IPv4 address, ${msg}`);
2801 } 2804 }
2802 let bytes = host.split('.'); 2805 let bytes = host.split('.');
2803 if (bytes[exports.$length] != 4) { 2806 if (bytes[exports.$length] != 4) {
2804 error('IPv4 address should contain exactly 4 parts'); 2807 error('IPv4 address should contain exactly 4 parts');
2805 } 2808 }
2806 return dart.as(bytes[exports.$map](dart.as((byteString) => { 2809 return dart.as(bytes[exports.$map](dart.as(byteString => {
2807 let byte = int.parse(dart.as(byteString, String)); 2810 let byte = int.parse(dart.as(byteString, String));
2808 if (dart.notNull(byte) < 0 || dart.notNull(byte) > 255) { 2811 if (dart.notNull(byte) < 0 || dart.notNull(byte) > 255) {
2809 error('each part must be in the range of `0..255`'); 2812 error('each part must be in the range of `0..255`');
2810 } 2813 }
2811 return byte; 2814 return byte;
2812 }, dart.throw_("Unimplemented type (String) → dynamic")))[exports.$toList] (), List$(int)); 2815 }, dart.throw_("Unimplemented type (String) → dynamic")))[exports.$toList] (), List$(int));
2813 } 2816 }
2814 static parseIPv6Address(host, start, end) { 2817 static parseIPv6Address(host, start, end) {
2815 if (start === void 0) 2818 if (start === void 0)
2816 start = 0; 2819 start = 0;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2891 error('an address without a wildcard must contain exactly 8 parts'); 2894 error('an address without a wildcard must contain exactly 8 parts');
2892 } 2895 }
2893 let bytes = new (List$(int))(16); 2896 let bytes = new (List$(int))(16);
2894 for (let i = 0, index = 0; dart.notNull(i) < dart.notNull(parts[exports.$l ength]); i = dart.notNull(i) + 1) { 2897 for (let i = 0, index = 0; dart.notNull(i) < dart.notNull(parts[exports.$l ength]); i = dart.notNull(i) + 1) {
2895 let value = parts[exports.$get](i); 2898 let value = parts[exports.$get](i);
2896 if (value == -1) { 2899 if (value == -1) {
2897 let wildCardLength = 9 - dart.notNull(parts[exports.$length]); 2900 let wildCardLength = 9 - dart.notNull(parts[exports.$length]);
2898 for (let j = 0; dart.notNull(j) < dart.notNull(wildCardLength); j = da rt.notNull(j) + 1) { 2901 for (let j = 0; dart.notNull(j) < dart.notNull(wildCardLength); j = da rt.notNull(j) + 1) {
2899 bytes[exports.$set](index, 0); 2902 bytes[exports.$set](index, 0);
2900 bytes[exports.$set](dart.notNull(index) + 1, 0); 2903 bytes[exports.$set](dart.notNull(index) + 1, 0);
2901 index = 2; 2904 index = dart.notNull(index) + 2;
2902 } 2905 }
2903 } else { 2906 } else {
2904 bytes[exports.$set](index, dart.notNull(value) >> 8); 2907 bytes[exports.$set](index, dart.notNull(value) >> 8);
2905 bytes[exports.$set](dart.notNull(index) + 1, dart.notNull(value) & 255 ); 2908 bytes[exports.$set](dart.notNull(index) + 1, dart.notNull(value) & 255 );
2906 index = 2; 2909 index = dart.notNull(index) + 2;
2907 } 2910 }
2908 } 2911 }
2909 return dart.as(bytes, List$(int)); 2912 return dart.as(bytes, List$(int));
2910 } 2913 }
2911 static [_uriEncode](canonicalTable, text, opts) { 2914 static [_uriEncode](canonicalTable, text, opts) {
2912 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8; 2915 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8;
2913 let spaceToPlus = opts && 'spaceToPlus' in opts ? opts.spaceToPlus : false ; 2916 let spaceToPlus = opts && 'spaceToPlus' in opts ? opts.spaceToPlus : false ;
2914 // Function byteToHex: (dynamic, dynamic) → dynamic 2917 // Function byteToHex: (dynamic, dynamic) → dynamic
2915 function byteToHex(byte, buffer) { 2918 function byteToHex(byte, buffer) {
2916 let hex = '0123456789ABCDEF'; 2919 let hex = '0123456789ABCDEF';
(...skipping 15 matching lines...) Expand all
2932 } 2935 }
2933 return result.toString(); 2936 return result.toString();
2934 } 2937 }
2935 static [_hexCharPairToByte](s, pos) { 2938 static [_hexCharPairToByte](s, pos) {
2936 let byte = 0; 2939 let byte = 0;
2937 for (let i = 0; dart.notNull(i) < 2; i = dart.notNull(i) + 1) { 2940 for (let i = 0; dart.notNull(i) < 2; i = dart.notNull(i) + 1) {
2938 let charCode = s.codeUnitAt(dart.notNull(pos) + dart.notNull(i)); 2941 let charCode = s.codeUnitAt(dart.notNull(pos) + dart.notNull(i));
2939 if (48 <= dart.notNull(charCode) && dart.notNull(charCode) <= 57) { 2942 if (48 <= dart.notNull(charCode) && dart.notNull(charCode) <= 57) {
2940 byte = dart.notNull(byte) * 16 + dart.notNull(charCode) - 48; 2943 byte = dart.notNull(byte) * 16 + dart.notNull(charCode) - 48;
2941 } else { 2944 } else {
2942 charCode = 32; 2945 charCode = dart.notNull(charCode) | 32;
2943 if (97 <= dart.notNull(charCode) && dart.notNull(charCode) <= 102) { 2946 if (97 <= dart.notNull(charCode) && dart.notNull(charCode) <= 102) {
2944 byte = dart.notNull(byte) * 16 + dart.notNull(charCode) - 87; 2947 byte = dart.notNull(byte) * 16 + dart.notNull(charCode) - 87;
2945 } else { 2948 } else {
2946 throw new ArgumentError("Invalid URL encoding"); 2949 throw new ArgumentError("Invalid URL encoding");
2947 } 2950 }
2948 } 2951 }
2949 } 2952 }
2950 return byte; 2953 return byte;
2951 } 2954 }
2952 static [_uriDecode](text, opts) { 2955 static [_uriDecode](text, opts) {
(...skipping 16 matching lines...) Expand all
2969 for (let i = 0; dart.notNull(i) < dart.notNull(text.length); i = dart.no tNull(i) + 1) { 2972 for (let i = 0; dart.notNull(i) < dart.notNull(text.length); i = dart.no tNull(i) + 1) {
2970 let codeUnit = text.codeUnitAt(i); 2973 let codeUnit = text.codeUnitAt(i);
2971 if (dart.notNull(codeUnit) > 127) { 2974 if (dart.notNull(codeUnit) > 127) {
2972 throw new ArgumentError("Illegal percent encoding in URI"); 2975 throw new ArgumentError("Illegal percent encoding in URI");
2973 } 2976 }
2974 if (codeUnit == Uri[_PERCENT]) { 2977 if (codeUnit == Uri[_PERCENT]) {
2975 if (dart.notNull(i) + 3 > dart.notNull(text.length)) { 2978 if (dart.notNull(i) + 3 > dart.notNull(text.length)) {
2976 throw new ArgumentError('Truncated URI'); 2979 throw new ArgumentError('Truncated URI');
2977 } 2980 }
2978 bytes[exports.$add](Uri[_hexCharPairToByte](text, dart.notNull(i) + 1)); 2981 bytes[exports.$add](Uri[_hexCharPairToByte](text, dart.notNull(i) + 1));
2979 i = 2; 2982 i = dart.notNull(i) + 2;
2980 } else if (dart.notNull(plusToSpace) && codeUnit == Uri[_PLUS]) { 2983 } else if (dart.notNull(plusToSpace) && codeUnit == Uri[_PLUS]) {
2981 bytes[exports.$add](Uri[_SPACE]); 2984 bytes[exports.$add](Uri[_SPACE]);
2982 } else { 2985 } else {
2983 bytes[exports.$add](codeUnit); 2986 bytes[exports.$add](codeUnit);
2984 } 2987 }
2985 } 2988 }
2986 } 2989 }
2987 return encoding.decode(bytes); 2990 return encoding.decode(bytes);
2988 } 2991 }
2989 static [_isAlphabeticCharacter](codeUnit) { 2992 static [_isAlphabeticCharacter](codeUnit) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
3122 exports.Stopwatch = Stopwatch; 3125 exports.Stopwatch = Stopwatch;
3123 exports.String = String; 3126 exports.String = String;
3124 exports.$last = $last; 3127 exports.$last = $last;
3125 exports.RuneIterator = RuneIterator; 3128 exports.RuneIterator = RuneIterator;
3126 exports.StringBuffer = StringBuffer; 3129 exports.StringBuffer = StringBuffer;
3127 exports.StringSink = StringSink; 3130 exports.StringSink = StringSink;
3128 exports.Symbol = Symbol; 3131 exports.Symbol = Symbol;
3129 exports.Type = Type; 3132 exports.Type = Type;
3130 exports.Uri = Uri; 3133 exports.Uri = Uri;
3131 })(core || (core = {})); 3134 })(core || (core = {}));
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