OLD | NEW |
| (Empty) |
1 dart_library.library('dart/core', null, /* Imports */[ | |
2 'dart/_runtime' | |
3 ], /* Lazy imports */[ | |
4 'dart/_js_helper', | |
5 'dart/_internal', | |
6 'dart/collection', | |
7 'dart/_interceptors', | |
8 'dart/convert' | |
9 ], function(exports, dart, _js_helper, _internal, collection, _interceptors, con
vert) { | |
10 'use strict'; | |
11 let dartx = dart.dartx; | |
12 class Object { | |
13 constructor() { | |
14 let name = this.constructor.name; | |
15 let result = void 0; | |
16 if (name in this) result = this[name](...arguments); | |
17 return result === void 0 ? this : result; | |
18 } | |
19 ['=='](other) { | |
20 return identical(this, other); | |
21 } | |
22 get hashCode() { | |
23 return _js_helper.Primitives.objectHashCode(this); | |
24 } | |
25 toString() { | |
26 return _js_helper.Primitives.objectToString(this); | |
27 } | |
28 noSuchMethod(invocation) { | |
29 dart.throw(new NoSuchMethodError(this, invocation.memberName, invocation.p
ositionalArguments, invocation.namedArguments)); | |
30 } | |
31 get runtimeType() { | |
32 return dart.realRuntimeType(this); | |
33 } | |
34 } | |
35 dart.setSignature(Object, { | |
36 constructors: () => ({Object: [Object, []]}), | |
37 methods: () => ({ | |
38 '==': [bool, [dart.dynamic]], | |
39 toString: [String, []], | |
40 noSuchMethod: [dart.dynamic, [Invocation]] | |
41 }) | |
42 }); | |
43 class Deprecated extends Object { | |
44 Deprecated(expires) { | |
45 this.expires = expires; | |
46 } | |
47 toString() { | |
48 return `Deprecated feature. Will be removed ${this.expires}`; | |
49 } | |
50 } | |
51 dart.setSignature(Deprecated, { | |
52 constructors: () => ({Deprecated: [Deprecated, [String]]}) | |
53 }); | |
54 class _Override extends Object { | |
55 _Override() { | |
56 } | |
57 } | |
58 dart.setSignature(_Override, { | |
59 constructors: () => ({_Override: [_Override, []]}) | |
60 }); | |
61 const deprecated = dart.const(new Deprecated("next release")); | |
62 const override = dart.const(new _Override()); | |
63 class _Proxy extends Object { | |
64 _Proxy() { | |
65 } | |
66 } | |
67 dart.setSignature(_Proxy, { | |
68 constructors: () => ({_Proxy: [_Proxy, []]}) | |
69 }); | |
70 const proxy = dart.const(new _Proxy()); | |
71 dart.defineExtensionNames([ | |
72 'toString' | |
73 ]); | |
74 class bool extends Object { | |
75 static fromEnvironment(name, opts) { | |
76 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : fa
lse; | |
77 dart.throw(new UnsupportedError('bool.fromEnvironment can only be used as
a const constructor')); | |
78 } | |
79 toString() { | |
80 return this ? "true" : "false"; | |
81 } | |
82 } | |
83 dart.setSignature(bool, { | |
84 constructors: () => ({fromEnvironment: [bool, [String], {defaultValue: bool}
]}) | |
85 }); | |
86 const Comparator$ = dart.generic(function(T) { | |
87 const Comparator = dart.typedef('Comparator', () => dart.functionType(int, [
T, T])); | |
88 return Comparator; | |
89 }); | |
90 let Comparator = Comparator$(); | |
91 const Comparable$ = dart.generic(function(T) { | |
92 class Comparable extends Object { | |
93 static compare(a, b) { | |
94 return a[dartx.compareTo](b); | |
95 } | |
96 } | |
97 dart.setSignature(Comparable, { | |
98 statics: () => ({compare: [int, [Comparable$(), Comparable$()]]}), | |
99 names: ['compare'] | |
100 }); | |
101 return Comparable; | |
102 }); | |
103 let Comparable = Comparable$(); | |
104 class DateTime extends Object { | |
105 DateTime(year, month, day, hour, minute, second, millisecond) { | |
106 if (month === void 0) month = 1; | |
107 if (day === void 0) day = 1; | |
108 if (hour === void 0) hour = 0; | |
109 if (minute === void 0) minute = 0; | |
110 if (second === void 0) second = 0; | |
111 if (millisecond === void 0) millisecond = 0; | |
112 this._internal(year, month, day, hour, minute, second, millisecond, false)
; | |
113 } | |
114 utc(year, month, day, hour, minute, second, millisecond) { | |
115 if (month === void 0) month = 1; | |
116 if (day === void 0) day = 1; | |
117 if (hour === void 0) hour = 0; | |
118 if (minute === void 0) minute = 0; | |
119 if (second === void 0) second = 0; | |
120 if (millisecond === void 0) millisecond = 0; | |
121 this._internal(year, month, day, hour, minute, second, millisecond, true); | |
122 } | |
123 now() { | |
124 this._now(); | |
125 } | |
126 static parse(formattedString) { | |
127 let re = RegExp.new('^([+-]?\\d{4,6})-?(\\d\\d)-?(\\d\\d)' + '(?:[ T](\\d\
\d)(?::?(\\d\\d)(?::?(\\d\\d)(.\\d{1,6})?)?)?' + '( ?[zZ]| ?([-+])(\\d\\d)(?::?(
\\d\\d))?)?)?$'); | |
128 let match = re.firstMatch(formattedString); | |
129 if (match != null) { | |
130 function parseIntOrZero(matched) { | |
131 if (matched == null) return 0; | |
132 return int.parse(matched); | |
133 } | |
134 dart.fn(parseIntOrZero, int, [String]); | |
135 function parseDoubleOrZero(matched) { | |
136 if (matched == null) return 0.0; | |
137 return double.parse(matched); | |
138 } | |
139 dart.fn(parseDoubleOrZero, double, [String]); | |
140 let years = int.parse(match.get(1)); | |
141 let month = int.parse(match.get(2)); | |
142 let day = int.parse(match.get(3)); | |
143 let hour = parseIntOrZero(match.get(4)); | |
144 let minute = parseIntOrZero(match.get(5)); | |
145 let second = parseIntOrZero(match.get(6)); | |
146 let addOneMillisecond = false; | |
147 let millisecond = (dart.notNull(parseDoubleOrZero(match.get(7))) * 1000)
[dartx.round](); | |
148 if (millisecond == 1000) { | |
149 addOneMillisecond = true; | |
150 millisecond = 999; | |
151 } | |
152 let isUtc = false; | |
153 if (match.get(8) != null) { | |
154 isUtc = true; | |
155 if (match.get(9) != null) { | |
156 let sign = match.get(9) == '-' ? -1 : 1; | |
157 let hourDifference = int.parse(match.get(10)); | |
158 let minuteDifference = parseIntOrZero(match.get(11)); | |
159 minuteDifference = dart.notNull(minuteDifference) + 60 * dart.notNul
l(hourDifference); | |
160 minute = dart.notNull(minute) - sign * dart.notNull(minuteDifference
); | |
161 } | |
162 } | |
163 let millisecondsSinceEpoch = DateTime._brokenDownDateToMillisecondsSince
Epoch(years, month, day, hour, minute, second, millisecond, isUtc); | |
164 if (millisecondsSinceEpoch == null) { | |
165 dart.throw(new FormatException("Time out of range", formattedString)); | |
166 } | |
167 if (addOneMillisecond) { | |
168 millisecondsSinceEpoch = dart.notNull(millisecondsSinceEpoch) + 1; | |
169 } | |
170 return new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch, {
isUtc: isUtc}); | |
171 } else { | |
172 dart.throw(new FormatException("Invalid date format", formattedString)); | |
173 } | |
174 } | |
175 fromMillisecondsSinceEpoch(millisecondsSinceEpoch, opts) { | |
176 let isUtc = opts && 'isUtc' in opts ? opts.isUtc : false; | |
177 this.millisecondsSinceEpoch = millisecondsSinceEpoch; | |
178 this.isUtc = isUtc; | |
179 if (dart.notNull(millisecondsSinceEpoch[dartx.abs]()) > dart.notNull(DateT
ime._MAX_MILLISECONDS_SINCE_EPOCH)) { | |
180 dart.throw(new ArgumentError(millisecondsSinceEpoch)); | |
181 } | |
182 if (isUtc == null) dart.throw(new ArgumentError(isUtc)); | |
183 } | |
184 ['=='](other) { | |
185 if (!dart.is(other, DateTime)) return false; | |
186 return dart.equals(this.millisecondsSinceEpoch, dart.dload(other, 'millise
condsSinceEpoch')) && dart.equals(this.isUtc, dart.dload(other, 'isUtc')); | |
187 } | |
188 isBefore(other) { | |
189 return dart.notNull(this.millisecondsSinceEpoch) < dart.notNull(other.mill
isecondsSinceEpoch); | |
190 } | |
191 isAfter(other) { | |
192 return dart.notNull(this.millisecondsSinceEpoch) > dart.notNull(other.mill
isecondsSinceEpoch); | |
193 } | |
194 isAtSameMomentAs(other) { | |
195 return this.millisecondsSinceEpoch == other.millisecondsSinceEpoch; | |
196 } | |
197 compareTo(other) { | |
198 return this.millisecondsSinceEpoch[dartx.compareTo](other.millisecondsSinc
eEpoch); | |
199 } | |
200 get hashCode() { | |
201 return this.millisecondsSinceEpoch; | |
202 } | |
203 toLocal() { | |
204 if (dart.notNull(this.isUtc)) { | |
205 return new DateTime.fromMillisecondsSinceEpoch(this.millisecondsSinceEpo
ch, {isUtc: false}); | |
206 } | |
207 return this; | |
208 } | |
209 toUtc() { | |
210 if (dart.notNull(this.isUtc)) return this; | |
211 return new DateTime.fromMillisecondsSinceEpoch(this.millisecondsSinceEpoch
, {isUtc: true}); | |
212 } | |
213 static _fourDigits(n) { | |
214 let absN = n[dartx.abs](); | |
215 let sign = dart.notNull(n) < 0 ? "-" : ""; | |
216 if (dart.notNull(absN) >= 1000) return `${n}`; | |
217 if (dart.notNull(absN) >= 100) return `${sign}0${absN}`; | |
218 if (dart.notNull(absN) >= 10) return `${sign}00${absN}`; | |
219 return `${sign}000${absN}`; | |
220 } | |
221 static _sixDigits(n) { | |
222 dart.assert(dart.notNull(n) < -9999 || dart.notNull(n) > 9999); | |
223 let absN = n[dartx.abs](); | |
224 let sign = dart.notNull(n) < 0 ? "-" : "+"; | |
225 if (dart.notNull(absN) >= 100000) return `${sign}${absN}`; | |
226 return `${sign}0${absN}`; | |
227 } | |
228 static _threeDigits(n) { | |
229 if (dart.notNull(n) >= 100) return `${n}`; | |
230 if (dart.notNull(n) >= 10) return `0${n}`; | |
231 return `00${n}`; | |
232 } | |
233 static _twoDigits(n) { | |
234 if (dart.notNull(n) >= 10) return `${n}`; | |
235 return `0${n}`; | |
236 } | |
237 toString() { | |
238 let y = DateTime._fourDigits(this.year); | |
239 let m = DateTime._twoDigits(this.month); | |
240 let d = DateTime._twoDigits(this.day); | |
241 let h = DateTime._twoDigits(this.hour); | |
242 let min = DateTime._twoDigits(this.minute); | |
243 let sec = DateTime._twoDigits(this.second); | |
244 let ms = DateTime._threeDigits(this.millisecond); | |
245 if (dart.notNull(this.isUtc)) { | |
246 return `${y}-${m}-${d} ${h}:${min}:${sec}.${ms}Z`; | |
247 } else { | |
248 return `${y}-${m}-${d} ${h}:${min}:${sec}.${ms}`; | |
249 } | |
250 } | |
251 toIso8601String() { | |
252 let y = dart.notNull(this.year) >= -9999 && dart.notNull(this.year) <= 999
9 ? DateTime._fourDigits(this.year) : DateTime._sixDigits(this.year); | |
253 let m = DateTime._twoDigits(this.month); | |
254 let d = DateTime._twoDigits(this.day); | |
255 let h = DateTime._twoDigits(this.hour); | |
256 let min = DateTime._twoDigits(this.minute); | |
257 let sec = DateTime._twoDigits(this.second); | |
258 let ms = DateTime._threeDigits(this.millisecond); | |
259 if (dart.notNull(this.isUtc)) { | |
260 return `${y}-${m}-${d}T${h}:${min}:${sec}.${ms}Z`; | |
261 } else { | |
262 return `${y}-${m}-${d}T${h}:${min}:${sec}.${ms}`; | |
263 } | |
264 } | |
265 add(duration) { | |
266 let ms = this.millisecondsSinceEpoch; | |
267 return new DateTime.fromMillisecondsSinceEpoch(dart.notNull(ms) + dart.not
Null(duration.inMilliseconds), {isUtc: this.isUtc}); | |
268 } | |
269 subtract(duration) { | |
270 let ms = this.millisecondsSinceEpoch; | |
271 return new DateTime.fromMillisecondsSinceEpoch(dart.notNull(ms) - dart.not
Null(duration.inMilliseconds), {isUtc: this.isUtc}); | |
272 } | |
273 difference(other) { | |
274 let ms = this.millisecondsSinceEpoch; | |
275 let otherMs = other.millisecondsSinceEpoch; | |
276 return new Duration({milliseconds: dart.notNull(ms) - dart.notNull(otherMs
)}); | |
277 } | |
278 _internal(year, month, day, hour, minute, second, millisecond, isUtc) { | |
279 this.isUtc = typeof isUtc == 'boolean' ? isUtc : dart.throw(new ArgumentEr
ror(isUtc)); | |
280 this.millisecondsSinceEpoch = dart.as(_js_helper.checkInt(_js_helper.Primi
tives.valueFromDecomposedDate(year, month, day, hour, minute, second, millisecon
d, isUtc)), int); | |
281 } | |
282 _now() { | |
283 this.isUtc = false; | |
284 this.millisecondsSinceEpoch = _js_helper.Primitives.dateNow(); | |
285 } | |
286 static _brokenDownDateToMillisecondsSinceEpoch(year, month, day, hour, minut
e, second, millisecond, isUtc) { | |
287 return dart.as(_js_helper.Primitives.valueFromDecomposedDate(year, month,
day, hour, minute, second, millisecond, isUtc), int); | |
288 } | |
289 get timeZoneName() { | |
290 if (dart.notNull(this.isUtc)) return "UTC"; | |
291 return _js_helper.Primitives.getTimeZoneName(this); | |
292 } | |
293 get timeZoneOffset() { | |
294 if (dart.notNull(this.isUtc)) return new Duration(); | |
295 return new Duration({minutes: _js_helper.Primitives.getTimeZoneOffsetInMin
utes(this)}); | |
296 } | |
297 get year() { | |
298 return dart.as(_js_helper.Primitives.getYear(this), int); | |
299 } | |
300 get month() { | |
301 return dart.as(_js_helper.Primitives.getMonth(this), int); | |
302 } | |
303 get day() { | |
304 return dart.as(_js_helper.Primitives.getDay(this), int); | |
305 } | |
306 get hour() { | |
307 return dart.as(_js_helper.Primitives.getHours(this), int); | |
308 } | |
309 get minute() { | |
310 return dart.as(_js_helper.Primitives.getMinutes(this), int); | |
311 } | |
312 get second() { | |
313 return dart.as(_js_helper.Primitives.getSeconds(this), int); | |
314 } | |
315 get millisecond() { | |
316 return dart.as(_js_helper.Primitives.getMilliseconds(this), int); | |
317 } | |
318 get weekday() { | |
319 return dart.as(_js_helper.Primitives.getWeekday(this), int); | |
320 } | |
321 } | |
322 DateTime[dart.implements] = () => [Comparable]; | |
323 dart.defineNamedConstructor(DateTime, 'utc'); | |
324 dart.defineNamedConstructor(DateTime, 'now'); | |
325 dart.defineNamedConstructor(DateTime, 'fromMillisecondsSinceEpoch'); | |
326 dart.defineNamedConstructor(DateTime, '_internal'); | |
327 dart.defineNamedConstructor(DateTime, '_now'); | |
328 dart.setSignature(DateTime, { | |
329 constructors: () => ({ | |
330 DateTime: [DateTime, [int], [int, int, int, int, int, int]], | |
331 utc: [DateTime, [int], [int, int, int, int, int, int]], | |
332 now: [DateTime, []], | |
333 fromMillisecondsSinceEpoch: [DateTime, [int], {isUtc: bool}], | |
334 _internal: [DateTime, [int, int, int, int, int, int, int, bool]], | |
335 _now: [DateTime, []] | |
336 }), | |
337 methods: () => ({ | |
338 isBefore: [bool, [DateTime]], | |
339 isAfter: [bool, [DateTime]], | |
340 isAtSameMomentAs: [bool, [DateTime]], | |
341 compareTo: [int, [DateTime]], | |
342 toLocal: [DateTime, []], | |
343 toUtc: [DateTime, []], | |
344 toIso8601String: [String, []], | |
345 add: [DateTime, [Duration]], | |
346 subtract: [DateTime, [Duration]], | |
347 difference: [Duration, [DateTime]] | |
348 }), | |
349 statics: () => ({ | |
350 parse: [DateTime, [String]], | |
351 _fourDigits: [String, [int]], | |
352 _sixDigits: [String, [int]], | |
353 _threeDigits: [String, [int]], | |
354 _twoDigits: [String, [int]], | |
355 _brokenDownDateToMillisecondsSinceEpoch: [int, [int, int, int, int, int, i
nt, int, bool]] | |
356 }), | |
357 names: ['parse', '_fourDigits', '_sixDigits', '_threeDigits', '_twoDigits',
'_brokenDownDateToMillisecondsSinceEpoch'] | |
358 }); | |
359 dart.defineExtensionMembers(DateTime, ['compareTo']); | |
360 DateTime.MONDAY = 1; | |
361 DateTime.TUESDAY = 2; | |
362 DateTime.WEDNESDAY = 3; | |
363 DateTime.THURSDAY = 4; | |
364 DateTime.FRIDAY = 5; | |
365 DateTime.SATURDAY = 6; | |
366 DateTime.SUNDAY = 7; | |
367 DateTime.DAYS_PER_WEEK = 7; | |
368 DateTime.JANUARY = 1; | |
369 DateTime.FEBRUARY = 2; | |
370 DateTime.MARCH = 3; | |
371 DateTime.APRIL = 4; | |
372 DateTime.MAY = 5; | |
373 DateTime.JUNE = 6; | |
374 DateTime.JULY = 7; | |
375 DateTime.AUGUST = 8; | |
376 DateTime.SEPTEMBER = 9; | |
377 DateTime.OCTOBER = 10; | |
378 DateTime.NOVEMBER = 11; | |
379 DateTime.DECEMBER = 12; | |
380 DateTime.MONTHS_PER_YEAR = 12; | |
381 DateTime._MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000; | |
382 class num extends Object { | |
383 static parse(input, onError) { | |
384 if (onError === void 0) onError = null; | |
385 let source = input[dartx.trim](); | |
386 num._parseError = false; | |
387 let result = int.parse(source, {onError: num._onParseErrorInt}); | |
388 if (!dart.notNull(num._parseError)) return result; | |
389 num._parseError = false; | |
390 result = double.parse(source, num._onParseErrorDouble); | |
391 if (!dart.notNull(num._parseError)) return result; | |
392 if (onError == null) dart.throw(new FormatException(input)); | |
393 return onError(input); | |
394 } | |
395 static _onParseErrorInt(_) { | |
396 num._parseError = true; | |
397 return 0; | |
398 } | |
399 static _onParseErrorDouble(_) { | |
400 num._parseError = true; | |
401 return 0.0; | |
402 } | |
403 } | |
404 num[dart.implements] = () => [Comparable$(num)]; | |
405 dart.setSignature(num, { | |
406 statics: () => ({ | |
407 parse: [num, [String], [dart.functionType(num, [String])]], | |
408 _onParseErrorInt: [int, [String]], | |
409 _onParseErrorDouble: [double, [String]] | |
410 }), | |
411 names: ['parse', '_onParseErrorInt', '_onParseErrorDouble'] | |
412 }); | |
413 num._parseError = false; | |
414 class double extends num { | |
415 static parse(source, onError) { | |
416 if (onError === void 0) onError = null; | |
417 return _js_helper.Primitives.parseDouble(source, onError); | |
418 } | |
419 } | |
420 dart.setSignature(double, { | |
421 statics: () => ({parse: [double, [String], [dart.functionType(double, [Strin
g])]]}), | |
422 names: ['parse'] | |
423 }); | |
424 double.NAN = 0.0 / 0.0; | |
425 double.INFINITY = 1.0 / 0.0; | |
426 double.MIN_POSITIVE = 5e-324; | |
427 double.MAX_FINITE = 1.7976931348623157e+308; | |
428 dart.defineLazyProperties(double, { | |
429 get NEGATIVE_INFINITY() { | |
430 return -dart.notNull(double.INFINITY); | |
431 } | |
432 }); | |
433 const _duration = dart.JsSymbol('_duration'); | |
434 class Duration extends Object { | |
435 Duration(opts) { | |
436 let days = opts && 'days' in opts ? opts.days : 0; | |
437 let hours = opts && 'hours' in opts ? opts.hours : 0; | |
438 let minutes = opts && 'minutes' in opts ? opts.minutes : 0; | |
439 let seconds = opts && 'seconds' in opts ? opts.seconds : 0; | |
440 let milliseconds = opts && 'milliseconds' in opts ? opts.milliseconds : 0; | |
441 let microseconds = opts && 'microseconds' in opts ? opts.microseconds : 0; | |
442 this._microseconds(dart.notNull(days) * dart.notNull(Duration.MICROSECONDS
_PER_DAY) + dart.notNull(hours) * dart.notNull(Duration.MICROSECONDS_PER_HOUR) +
dart.notNull(minutes) * dart.notNull(Duration.MICROSECONDS_PER_MINUTE) + dart.n
otNull(seconds) * dart.notNull(Duration.MICROSECONDS_PER_SECOND) + dart.notNull(
milliseconds) * dart.notNull(Duration.MICROSECONDS_PER_MILLISECOND) + dart.notNu
ll(microseconds)); | |
443 } | |
444 _microseconds(duration) { | |
445 this[_duration] = duration; | |
446 } | |
447 ['+'](other) { | |
448 return new Duration._microseconds(dart.notNull(this[_duration]) + dart.not
Null(other[_duration])); | |
449 } | |
450 ['-'](other) { | |
451 return new Duration._microseconds(dart.notNull(this[_duration]) - dart.not
Null(other[_duration])); | |
452 } | |
453 ['*'](factor) { | |
454 return new Duration._microseconds((dart.notNull(this[_duration]) * dart.no
tNull(factor))[dartx.round]()); | |
455 } | |
456 ['~/'](quotient) { | |
457 if (quotient == 0) dart.throw(new IntegerDivisionByZeroException()); | |
458 return new Duration._microseconds((dart.notNull(this[_duration]) / dart.no
tNull(quotient))[dartx.truncate]()); | |
459 } | |
460 ['<'](other) { | |
461 return dart.notNull(this[_duration]) < dart.notNull(other[_duration]); | |
462 } | |
463 ['>'](other) { | |
464 return dart.notNull(this[_duration]) > dart.notNull(other[_duration]); | |
465 } | |
466 ['<='](other) { | |
467 return dart.notNull(this[_duration]) <= dart.notNull(other[_duration]); | |
468 } | |
469 ['>='](other) { | |
470 return dart.notNull(this[_duration]) >= dart.notNull(other[_duration]); | |
471 } | |
472 get inDays() { | |
473 return (dart.notNull(this[_duration]) / dart.notNull(Duration.MICROSECONDS
_PER_DAY))[dartx.truncate](); | |
474 } | |
475 get inHours() { | |
476 return (dart.notNull(this[_duration]) / dart.notNull(Duration.MICROSECONDS
_PER_HOUR))[dartx.truncate](); | |
477 } | |
478 get inMinutes() { | |
479 return (dart.notNull(this[_duration]) / dart.notNull(Duration.MICROSECONDS
_PER_MINUTE))[dartx.truncate](); | |
480 } | |
481 get inSeconds() { | |
482 return (dart.notNull(this[_duration]) / dart.notNull(Duration.MICROSECONDS
_PER_SECOND))[dartx.truncate](); | |
483 } | |
484 get inMilliseconds() { | |
485 return (dart.notNull(this[_duration]) / dart.notNull(Duration.MICROSECONDS
_PER_MILLISECOND))[dartx.truncate](); | |
486 } | |
487 get inMicroseconds() { | |
488 return this[_duration]; | |
489 } | |
490 ['=='](other) { | |
491 if (!dart.is(other, Duration)) return false; | |
492 return dart.equals(this[_duration], dart.dload(other, _duration)); | |
493 } | |
494 get hashCode() { | |
495 return dart.hashCode(this[_duration]); | |
496 } | |
497 compareTo(other) { | |
498 return this[_duration][dartx.compareTo](other[_duration]); | |
499 } | |
500 toString() { | |
501 function sixDigits(n) { | |
502 if (dart.notNull(n) >= 100000) return `${n}`; | |
503 if (dart.notNull(n) >= 10000) return `0${n}`; | |
504 if (dart.notNull(n) >= 1000) return `00${n}`; | |
505 if (dart.notNull(n) >= 100) return `000${n}`; | |
506 if (dart.notNull(n) >= 10) return `0000${n}`; | |
507 return `00000${n}`; | |
508 } | |
509 dart.fn(sixDigits, String, [int]); | |
510 function twoDigits(n) { | |
511 if (dart.notNull(n) >= 10) return `${n}`; | |
512 return `0${n}`; | |
513 } | |
514 dart.fn(twoDigits, String, [int]); | |
515 if (dart.notNull(this.inMicroseconds) < 0) { | |
516 return `-${this['unary-']()}`; | |
517 } | |
518 let twoDigitMinutes = twoDigits(dart.asInt(this.inMinutes[dartx.remainder]
(Duration.MINUTES_PER_HOUR))); | |
519 let twoDigitSeconds = twoDigits(dart.asInt(this.inSeconds[dartx.remainder]
(Duration.SECONDS_PER_MINUTE))); | |
520 let sixDigitUs = sixDigits(dart.asInt(this.inMicroseconds[dartx.remainder]
(Duration.MICROSECONDS_PER_SECOND))); | |
521 return `${this.inHours}:${twoDigitMinutes}:${twoDigitSeconds}.${sixDigitUs
}`; | |
522 } | |
523 get isNegative() { | |
524 return dart.notNull(this[_duration]) < 0; | |
525 } | |
526 abs() { | |
527 return new Duration._microseconds(this[_duration][dartx.abs]()); | |
528 } | |
529 ['unary-']() { | |
530 return new Duration._microseconds(-dart.notNull(this[_duration])); | |
531 } | |
532 } | |
533 Duration[dart.implements] = () => [Comparable$(Duration)]; | |
534 dart.defineNamedConstructor(Duration, '_microseconds'); | |
535 dart.setSignature(Duration, { | |
536 constructors: () => ({ | |
537 Duration: [Duration, [], {days: int, hours: int, minutes: int, seconds: in
t, milliseconds: int, microseconds: int}], | |
538 _microseconds: [Duration, [int]] | |
539 }), | |
540 methods: () => ({ | |
541 '+': [Duration, [Duration]], | |
542 '-': [Duration, [Duration]], | |
543 '*': [Duration, [num]], | |
544 '~/': [Duration, [int]], | |
545 '<': [bool, [Duration]], | |
546 '>': [bool, [Duration]], | |
547 '<=': [bool, [Duration]], | |
548 '>=': [bool, [Duration]], | |
549 compareTo: [int, [Duration]], | |
550 abs: [Duration, []], | |
551 'unary-': [Duration, []] | |
552 }) | |
553 }); | |
554 dart.defineExtensionMembers(Duration, ['compareTo']); | |
555 Duration.MICROSECONDS_PER_MILLISECOND = 1000; | |
556 Duration.MILLISECONDS_PER_SECOND = 1000; | |
557 Duration.SECONDS_PER_MINUTE = 60; | |
558 Duration.MINUTES_PER_HOUR = 60; | |
559 Duration.HOURS_PER_DAY = 24; | |
560 dart.defineLazyProperties(Duration, { | |
561 get MICROSECONDS_PER_SECOND() { | |
562 return dart.notNull(Duration.MICROSECONDS_PER_MILLISECOND) * dart.notNull(
Duration.MILLISECONDS_PER_SECOND); | |
563 }, | |
564 get MICROSECONDS_PER_MINUTE() { | |
565 return dart.notNull(Duration.MICROSECONDS_PER_SECOND) * dart.notNull(Durat
ion.SECONDS_PER_MINUTE); | |
566 }, | |
567 get MICROSECONDS_PER_HOUR() { | |
568 return dart.notNull(Duration.MICROSECONDS_PER_MINUTE) * dart.notNull(Durat
ion.MINUTES_PER_HOUR); | |
569 }, | |
570 get MICROSECONDS_PER_DAY() { | |
571 return dart.notNull(Duration.MICROSECONDS_PER_HOUR) * dart.notNull(Duratio
n.HOURS_PER_DAY); | |
572 }, | |
573 get MILLISECONDS_PER_MINUTE() { | |
574 return dart.notNull(Duration.MILLISECONDS_PER_SECOND) * dart.notNull(Durat
ion.SECONDS_PER_MINUTE); | |
575 }, | |
576 get MILLISECONDS_PER_HOUR() { | |
577 return dart.notNull(Duration.MILLISECONDS_PER_MINUTE) * dart.notNull(Durat
ion.MINUTES_PER_HOUR); | |
578 }, | |
579 get MILLISECONDS_PER_DAY() { | |
580 return dart.notNull(Duration.MILLISECONDS_PER_HOUR) * dart.notNull(Duratio
n.HOURS_PER_DAY); | |
581 }, | |
582 get SECONDS_PER_HOUR() { | |
583 return dart.notNull(Duration.SECONDS_PER_MINUTE) * dart.notNull(Duration.M
INUTES_PER_HOUR); | |
584 }, | |
585 get SECONDS_PER_DAY() { | |
586 return dart.notNull(Duration.SECONDS_PER_HOUR) * dart.notNull(Duration.HOU
RS_PER_DAY); | |
587 }, | |
588 get MINUTES_PER_DAY() { | |
589 return dart.notNull(Duration.MINUTES_PER_HOUR) * dart.notNull(Duration.HOU
RS_PER_DAY); | |
590 }, | |
591 get ZERO() { | |
592 return dart.const(new Duration({seconds: 0})); | |
593 } | |
594 }); | |
595 class Error extends Object { | |
596 Error() { | |
597 } | |
598 static safeToString(object) { | |
599 if (typeof object == 'number' || typeof object == 'boolean' || null == obj
ect) { | |
600 return dart.toString(object); | |
601 } | |
602 if (typeof object == 'string') { | |
603 return Error._stringToSafeString(object); | |
604 } | |
605 return Error._objectToString(object); | |
606 } | |
607 static _stringToSafeString(string) { | |
608 return _js_helper.jsonEncodeNative(string); | |
609 } | |
610 static _objectToString(object) { | |
611 return _js_helper.Primitives.objectToString(object); | |
612 } | |
613 get stackTrace() { | |
614 return _js_helper.Primitives.extractStackTrace(this); | |
615 } | |
616 } | |
617 dart.setSignature(Error, { | |
618 constructors: () => ({Error: [Error, []]}), | |
619 statics: () => ({ | |
620 safeToString: [String, [Object]], | |
621 _stringToSafeString: [String, [String]], | |
622 _objectToString: [String, [Object]] | |
623 }), | |
624 names: ['safeToString', '_stringToSafeString', '_objectToString'] | |
625 }); | |
626 class AssertionError extends Error { | |
627 AssertionError() { | |
628 super.Error(); | |
629 } | |
630 } | |
631 class TypeError extends AssertionError {} | |
632 class CastError extends Error { | |
633 CastError() { | |
634 super.Error(); | |
635 } | |
636 } | |
637 class NullThrownError extends Error { | |
638 NullThrownError() { | |
639 super.Error(); | |
640 } | |
641 toString() { | |
642 return "Throw of null."; | |
643 } | |
644 } | |
645 const _hasValue = dart.JsSymbol('_hasValue'); | |
646 class ArgumentError extends Error { | |
647 ArgumentError(message) { | |
648 if (message === void 0) message = null; | |
649 this.message = message; | |
650 this.invalidValue = null; | |
651 this[_hasValue] = false; | |
652 this.name = null; | |
653 super.Error(); | |
654 } | |
655 value(value, name, message) { | |
656 if (name === void 0) name = null; | |
657 if (message === void 0) message = "Invalid argument"; | |
658 this.name = name; | |
659 this.message = message; | |
660 this.invalidValue = value; | |
661 this[_hasValue] = true; | |
662 super.Error(); | |
663 } | |
664 notNull(name) { | |
665 if (name === void 0) name = null; | |
666 this.value(null, name, "Must not be null"); | |
667 } | |
668 toString() { | |
669 if (!dart.notNull(this[_hasValue])) { | |
670 let result = "Invalid arguments(s)"; | |
671 if (this.message != null) { | |
672 result = `${result}: ${this.message}`; | |
673 } | |
674 return result; | |
675 } | |
676 let nameString = ""; | |
677 if (this.name != null) { | |
678 nameString = ` (${this.name})`; | |
679 } | |
680 return `${this.message}${nameString}: ${Error.safeToString(this.invalidVal
ue)}`; | |
681 } | |
682 } | |
683 dart.defineNamedConstructor(ArgumentError, 'value'); | |
684 dart.defineNamedConstructor(ArgumentError, 'notNull'); | |
685 dart.setSignature(ArgumentError, { | |
686 constructors: () => ({ | |
687 ArgumentError: [ArgumentError, [], [dart.dynamic]], | |
688 value: [ArgumentError, [dart.dynamic], [String, String]], | |
689 notNull: [ArgumentError, [], [String]] | |
690 }) | |
691 }); | |
692 class RangeError extends ArgumentError { | |
693 RangeError(message) { | |
694 this.start = null; | |
695 this.end = null; | |
696 super.ArgumentError(message); | |
697 } | |
698 value(value, name, message) { | |
699 if (name === void 0) name = null; | |
700 if (message === void 0) message = null; | |
701 this.start = null; | |
702 this.end = null; | |
703 super.value(value, name, message != null ? message : "Value not in range")
; | |
704 } | |
705 range(invalidValue, minValue, maxValue, name, message) { | |
706 if (name === void 0) name = null; | |
707 if (message === void 0) message = null; | |
708 this.start = minValue; | |
709 this.end = maxValue; | |
710 super.value(invalidValue, name, message != null ? message : "Invalid value
"); | |
711 } | |
712 static index(index, indexable, name, message, length) { | |
713 return new IndexError(index, indexable, name, message, length); | |
714 } | |
715 static checkValueInInterval(value, minValue, maxValue, name, message) { | |
716 if (name === void 0) name = null; | |
717 if (message === void 0) message = null; | |
718 if (dart.notNull(value) < dart.notNull(minValue) || dart.notNull(value) >
dart.notNull(maxValue)) { | |
719 dart.throw(new RangeError.range(value, minValue, maxValue, name, message
)); | |
720 } | |
721 } | |
722 static checkValidIndex(index, indexable, name, length, message) { | |
723 if (name === void 0) name = null; | |
724 if (length === void 0) length = null; | |
725 if (message === void 0) message = null; | |
726 if (length == null) length = dart.as(dart.dload(indexable, 'length'), int)
; | |
727 if (dart.notNull(index) < 0 || dart.notNull(index) >= dart.notNull(length)
) { | |
728 if (name == null) name = "index"; | |
729 dart.throw(RangeError.index(index, indexable, name, message, length)); | |
730 } | |
731 } | |
732 static checkValidRange(start, end, length, startName, endName, message) { | |
733 if (startName === void 0) startName = null; | |
734 if (endName === void 0) endName = null; | |
735 if (message === void 0) message = null; | |
736 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(length))
{ | |
737 if (startName == null) startName = "start"; | |
738 dart.throw(new RangeError.range(start, 0, length, startName, message)); | |
739 } | |
740 if (end != null && (dart.notNull(end) < dart.notNull(start) || dart.notNul
l(end) > dart.notNull(length))) { | |
741 if (endName == null) endName = "end"; | |
742 dart.throw(new RangeError.range(end, start, length, endName, message)); | |
743 } | |
744 } | |
745 static checkNotNegative(value, name, message) { | |
746 if (name === void 0) name = null; | |
747 if (message === void 0) message = null; | |
748 if (dart.notNull(value) < 0) dart.throw(new RangeError.range(value, 0, nul
l, name, message)); | |
749 } | |
750 toString() { | |
751 if (!dart.notNull(this[_hasValue])) return `RangeError: ${this.message}`; | |
752 let value = Error.safeToString(this.invalidValue); | |
753 let explanation = ""; | |
754 if (this.start == null) { | |
755 if (this.end != null) { | |
756 explanation = `: Not less than or equal to ${this.end}`; | |
757 } | |
758 } else if (this.end == null) { | |
759 explanation = `: Not greater than or equal to ${this.start}`; | |
760 } else if (dart.notNull(this.end) > dart.notNull(this.start)) { | |
761 explanation = `: Not in range ${this.start}..${this.end}, inclusive.`; | |
762 } else if (dart.notNull(this.end) < dart.notNull(this.start)) { | |
763 explanation = ": Valid value range is empty"; | |
764 } else { | |
765 explanation = `: Only valid value is ${this.start}`; | |
766 } | |
767 return `RangeError: ${this.message} (${value})${explanation}`; | |
768 } | |
769 } | |
770 dart.defineNamedConstructor(RangeError, 'value'); | |
771 dart.defineNamedConstructor(RangeError, 'range'); | |
772 dart.setSignature(RangeError, { | |
773 constructors: () => ({ | |
774 RangeError: [RangeError, [dart.dynamic]], | |
775 value: [RangeError, [num], [String, String]], | |
776 range: [RangeError, [num, int, int], [String, String]], | |
777 index: [RangeError, [int, dart.dynamic], [String, String, int]] | |
778 }), | |
779 statics: () => ({ | |
780 checkValueInInterval: [dart.void, [int, int, int], [String, String]], | |
781 checkValidIndex: [dart.void, [int, dart.dynamic], [String, int, String]], | |
782 checkValidRange: [dart.void, [int, int, int], [String, String, String]], | |
783 checkNotNegative: [dart.void, [int], [String, String]] | |
784 }), | |
785 names: ['checkValueInInterval', 'checkValidIndex', 'checkValidRange', 'check
NotNegative'] | |
786 }); | |
787 class IndexError extends ArgumentError { | |
788 IndexError(invalidValue, indexable, name, message, length) { | |
789 if (name === void 0) name = null; | |
790 if (message === void 0) message = null; | |
791 if (length === void 0) length = null; | |
792 this.indexable = indexable; | |
793 this.length = dart.as(length != null ? length : dart.dload(indexable, 'len
gth'), int); | |
794 super.value(invalidValue, name, message != null ? message : "Index out of
range"); | |
795 } | |
796 get start() { | |
797 return 0; | |
798 } | |
799 get end() { | |
800 return dart.notNull(this.length) - 1; | |
801 } | |
802 toString() { | |
803 dart.assert(this[_hasValue]); | |
804 let target = Error.safeToString(this.indexable); | |
805 let explanation = `index should be less than ${this.length}`; | |
806 if (dart.notNull(dart.as(dart.dsend(this.invalidValue, '<', 0), bool))) { | |
807 explanation = "index must not be negative"; | |
808 } | |
809 return `RangeError: ${this.message} (${target}[${this.invalidValue}]): ${e
xplanation}`; | |
810 } | |
811 } | |
812 IndexError[dart.implements] = () => [RangeError]; | |
813 dart.setSignature(IndexError, { | |
814 constructors: () => ({IndexError: [IndexError, [int, dart.dynamic], [String,
String, int]]}) | |
815 }); | |
816 class FallThroughError extends Error { | |
817 FallThroughError() { | |
818 super.Error(); | |
819 } | |
820 } | |
821 dart.setSignature(FallThroughError, { | |
822 constructors: () => ({FallThroughError: [FallThroughError, []]}) | |
823 }); | |
824 const _className = dart.JsSymbol('_className'); | |
825 class AbstractClassInstantiationError extends Error { | |
826 AbstractClassInstantiationError(className) { | |
827 this[_className] = className; | |
828 super.Error(); | |
829 } | |
830 toString() { | |
831 return `Cannot instantiate abstract class: '${this[_className]}'`; | |
832 } | |
833 } | |
834 dart.setSignature(AbstractClassInstantiationError, { | |
835 constructors: () => ({AbstractClassInstantiationError: [AbstractClassInstant
iationError, [String]]}) | |
836 }); | |
837 const _receiver = dart.JsSymbol('_receiver'); | |
838 const _memberName = dart.JsSymbol('_memberName'); | |
839 const _arguments = dart.JsSymbol('_arguments'); | |
840 const _namedArguments = dart.JsSymbol('_namedArguments'); | |
841 const _existingArgumentNames = dart.JsSymbol('_existingArgumentNames'); | |
842 class NoSuchMethodError extends Error { | |
843 NoSuchMethodError(receiver, memberName, positionalArguments, namedArguments,
existingArgumentNames) { | |
844 if (existingArgumentNames === void 0) existingArgumentNames = null; | |
845 this[_receiver] = receiver; | |
846 this[_memberName] = memberName; | |
847 this[_arguments] = positionalArguments; | |
848 this[_namedArguments] = namedArguments; | |
849 this[_existingArgumentNames] = existingArgumentNames; | |
850 super.Error(); | |
851 } | |
852 toString() { | |
853 let sb = new StringBuffer(); | |
854 let i = 0; | |
855 if (this[_arguments] != null) { | |
856 for (; i < dart.notNull(this[_arguments][dartx.length]); i++) { | |
857 if (i > 0) { | |
858 sb.write(", "); | |
859 } | |
860 sb.write(Error.safeToString(this[_arguments][dartx.get](i))); | |
861 } | |
862 } | |
863 if (this[_namedArguments] != null) { | |
864 this[_namedArguments][dartx.forEach](dart.fn((key, value) => { | |
865 if (i > 0) { | |
866 sb.write(", "); | |
867 } | |
868 sb.write(_symbolToString(key)); | |
869 sb.write(": "); | |
870 sb.write(Error.safeToString(value)); | |
871 i++; | |
872 }, dart.void, [Symbol, dart.dynamic])); | |
873 } | |
874 if (this[_existingArgumentNames] == null) { | |
875 return `NoSuchMethodError : method not found: '${this[_memberName]}'\n`
+ `Receiver: ${Error.safeToString(this[_receiver])}\n` + `Arguments: [${sb}]`; | |
876 } else { | |
877 let actualParameters = sb.toString(); | |
878 sb = new StringBuffer(); | |
879 for (let i = 0; i < dart.notNull(this[_existingArgumentNames][dartx.leng
th]); i++) { | |
880 if (i > 0) { | |
881 sb.write(", "); | |
882 } | |
883 sb.write(this[_existingArgumentNames][dartx.get](i)); | |
884 } | |
885 let formalParameters = sb.toString(); | |
886 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})`; | |
887 } | |
888 } | |
889 } | |
890 dart.setSignature(NoSuchMethodError, { | |
891 constructors: () => ({NoSuchMethodError: [NoSuchMethodError, [Object, Symbol
, List, Map$(Symbol, dart.dynamic)], [List]]}) | |
892 }); | |
893 class UnsupportedError extends Error { | |
894 UnsupportedError(message) { | |
895 this.message = message; | |
896 super.Error(); | |
897 } | |
898 toString() { | |
899 return `Unsupported operation: ${this.message}`; | |
900 } | |
901 } | |
902 dart.setSignature(UnsupportedError, { | |
903 constructors: () => ({UnsupportedError: [UnsupportedError, [String]]}) | |
904 }); | |
905 class UnimplementedError extends Error { | |
906 UnimplementedError(message) { | |
907 if (message === void 0) message = null; | |
908 this.message = message; | |
909 super.Error(); | |
910 } | |
911 toString() { | |
912 return this.message != null ? `UnimplementedError: ${this.message}` : "Uni
mplementedError"; | |
913 } | |
914 } | |
915 UnimplementedError[dart.implements] = () => [UnsupportedError]; | |
916 dart.setSignature(UnimplementedError, { | |
917 constructors: () => ({UnimplementedError: [UnimplementedError, [], [String]]
}) | |
918 }); | |
919 class StateError extends Error { | |
920 StateError(message) { | |
921 this.message = message; | |
922 super.Error(); | |
923 } | |
924 toString() { | |
925 return `Bad state: ${this.message}`; | |
926 } | |
927 } | |
928 dart.setSignature(StateError, { | |
929 constructors: () => ({StateError: [StateError, [String]]}) | |
930 }); | |
931 class ConcurrentModificationError extends Error { | |
932 ConcurrentModificationError(modifiedObject) { | |
933 if (modifiedObject === void 0) modifiedObject = null; | |
934 this.modifiedObject = modifiedObject; | |
935 super.Error(); | |
936 } | |
937 toString() { | |
938 if (this.modifiedObject == null) { | |
939 return "Concurrent modification during iteration."; | |
940 } | |
941 return "Concurrent modification during iteration: " + `${Error.safeToStrin
g(this.modifiedObject)}.`; | |
942 } | |
943 } | |
944 dart.setSignature(ConcurrentModificationError, { | |
945 constructors: () => ({ConcurrentModificationError: [ConcurrentModificationEr
ror, [], [Object]]}) | |
946 }); | |
947 class OutOfMemoryError extends Object { | |
948 OutOfMemoryError() { | |
949 } | |
950 toString() { | |
951 return "Out of Memory"; | |
952 } | |
953 get stackTrace() { | |
954 return null; | |
955 } | |
956 } | |
957 OutOfMemoryError[dart.implements] = () => [Error]; | |
958 dart.setSignature(OutOfMemoryError, { | |
959 constructors: () => ({OutOfMemoryError: [OutOfMemoryError, []]}) | |
960 }); | |
961 class StackOverflowError extends Object { | |
962 StackOverflowError() { | |
963 } | |
964 toString() { | |
965 return "Stack Overflow"; | |
966 } | |
967 get stackTrace() { | |
968 return null; | |
969 } | |
970 } | |
971 StackOverflowError[dart.implements] = () => [Error]; | |
972 dart.setSignature(StackOverflowError, { | |
973 constructors: () => ({StackOverflowError: [StackOverflowError, []]}) | |
974 }); | |
975 class CyclicInitializationError extends Error { | |
976 CyclicInitializationError(variableName) { | |
977 if (variableName === void 0) variableName = null; | |
978 this.variableName = variableName; | |
979 super.Error(); | |
980 } | |
981 toString() { | |
982 return this.variableName == null ? "Reading static variable during its ini
tialization" : `Reading static variable '${this.variableName}' during its initia
lization`; | |
983 } | |
984 } | |
985 dart.setSignature(CyclicInitializationError, { | |
986 constructors: () => ({CyclicInitializationError: [CyclicInitializationError,
[], [String]]}) | |
987 }); | |
988 class Exception extends Object { | |
989 static new(message) { | |
990 if (message === void 0) message = null; | |
991 return new _ExceptionImplementation(message); | |
992 } | |
993 } | |
994 dart.setSignature(Exception, { | |
995 constructors: () => ({new: [Exception, [], [dart.dynamic]]}) | |
996 }); | |
997 class _ExceptionImplementation extends Object { | |
998 _ExceptionImplementation(message) { | |
999 if (message === void 0) message = null; | |
1000 this.message = message; | |
1001 } | |
1002 toString() { | |
1003 if (this.message == null) return "Exception"; | |
1004 return `Exception: ${this.message}`; | |
1005 } | |
1006 } | |
1007 _ExceptionImplementation[dart.implements] = () => [Exception]; | |
1008 dart.setSignature(_ExceptionImplementation, { | |
1009 constructors: () => ({_ExceptionImplementation: [_ExceptionImplementation, [
], [dart.dynamic]]}) | |
1010 }); | |
1011 class FormatException extends Object { | |
1012 FormatException(message, source, offset) { | |
1013 if (message === void 0) message = ""; | |
1014 if (source === void 0) source = null; | |
1015 if (offset === void 0) offset = -1; | |
1016 this.message = message; | |
1017 this.source = source; | |
1018 this.offset = offset; | |
1019 } | |
1020 toString() { | |
1021 let report = "FormatException"; | |
1022 if (this.message != null && "" != this.message) { | |
1023 report = `${report}: ${this.message}`; | |
1024 } | |
1025 let offset = this.offset; | |
1026 if (!(typeof this.source == 'string')) { | |
1027 if (offset != -1) { | |
1028 report = report + ` (at offset ${offset})`; | |
1029 } | |
1030 return report; | |
1031 } | |
1032 if (offset != -1 && (dart.notNull(offset) < 0 || dart.notNull(offset) > da
rt.notNull(dart.as(dart.dload(this.source, 'length'), num)))) { | |
1033 offset = -1; | |
1034 } | |
1035 if (offset == -1) { | |
1036 let source = dart.as(this.source, String); | |
1037 if (dart.notNull(source[dartx.length]) > 78) { | |
1038 source = dart.notNull(source[dartx.substring](0, 75)) + "..."; | |
1039 } | |
1040 return `${report}\n${source}`; | |
1041 } | |
1042 let lineNum = 1; | |
1043 let lineStart = 0; | |
1044 let lastWasCR = null; | |
1045 for (let i = 0; i < dart.notNull(offset); i++) { | |
1046 let char = dart.as(dart.dsend(this.source, 'codeUnitAt', i), int); | |
1047 if (char == 10) { | |
1048 if (lineStart != i || !dart.notNull(lastWasCR)) { | |
1049 lineNum++; | |
1050 } | |
1051 lineStart = i + 1; | |
1052 lastWasCR = false; | |
1053 } else if (char == 13) { | |
1054 lineNum++; | |
1055 lineStart = i + 1; | |
1056 lastWasCR = true; | |
1057 } | |
1058 } | |
1059 if (lineNum > 1) { | |
1060 report = report + ` (at line ${lineNum}, character ${dart.notNull(offset
) - lineStart + 1})\n`; | |
1061 } else { | |
1062 report = report + ` (at character ${dart.notNull(offset) + 1})\n`; | |
1063 } | |
1064 let lineEnd = dart.as(dart.dload(this.source, 'length'), int); | |
1065 for (let i = offset; dart.notNull(i) < dart.notNull(dart.as(dart.dload(thi
s.source, 'length'), num)); i = dart.notNull(i) + 1) { | |
1066 let char = dart.as(dart.dsend(this.source, 'codeUnitAt', i), int); | |
1067 if (char == 10 || char == 13) { | |
1068 lineEnd = i; | |
1069 break; | |
1070 } | |
1071 } | |
1072 let length = dart.notNull(lineEnd) - lineStart; | |
1073 let start = lineStart; | |
1074 let end = lineEnd; | |
1075 let prefix = ""; | |
1076 let postfix = ""; | |
1077 if (length > 78) { | |
1078 let index = dart.notNull(offset) - lineStart; | |
1079 if (index < 75) { | |
1080 end = start + 75; | |
1081 postfix = "..."; | |
1082 } else if (dart.notNull(end) - dart.notNull(offset) < 75) { | |
1083 start = dart.notNull(end) - 75; | |
1084 prefix = "..."; | |
1085 } else { | |
1086 start = dart.notNull(offset) - 36; | |
1087 end = dart.notNull(offset) + 36; | |
1088 prefix = postfix = "..."; | |
1089 } | |
1090 } | |
1091 let slice = dart.as(dart.dsend(this.source, 'substring', start, end), Stri
ng); | |
1092 let markOffset = dart.notNull(offset) - start + dart.notNull(prefix[dartx.
length]); | |
1093 return `${report}${prefix}${slice}${postfix}\n${" "[dartx['*']](markOffset
)}^\n`; | |
1094 } | |
1095 } | |
1096 FormatException[dart.implements] = () => [Exception]; | |
1097 dart.setSignature(FormatException, { | |
1098 constructors: () => ({FormatException: [FormatException, [], [String, dart.d
ynamic, int]]}) | |
1099 }); | |
1100 class IntegerDivisionByZeroException extends Object { | |
1101 IntegerDivisionByZeroException() { | |
1102 } | |
1103 toString() { | |
1104 return "IntegerDivisionByZeroException"; | |
1105 } | |
1106 } | |
1107 IntegerDivisionByZeroException[dart.implements] = () => [Exception]; | |
1108 dart.setSignature(IntegerDivisionByZeroException, { | |
1109 constructors: () => ({IntegerDivisionByZeroException: [IntegerDivisionByZero
Exception, []]}) | |
1110 }); | |
1111 const _getKey = dart.JsSymbol('_getKey'); | |
1112 const Expando$ = dart.generic(function(T) { | |
1113 class Expando extends Object { | |
1114 Expando(name) { | |
1115 if (name === void 0) name = null; | |
1116 this.name = name; | |
1117 } | |
1118 toString() { | |
1119 return `Expando:${this.name}`; | |
1120 } | |
1121 get(object) { | |
1122 let values = _js_helper.Primitives.getProperty(object, Expando$()._EXPAN
DO_PROPERTY_NAME); | |
1123 return dart.as(values == null ? null : _js_helper.Primitives.getProperty
(values, this[_getKey]()), T); | |
1124 } | |
1125 set(object, value) { | |
1126 dart.as(value, T); | |
1127 let values = _js_helper.Primitives.getProperty(object, Expando$()._EXPAN
DO_PROPERTY_NAME); | |
1128 if (values == null) { | |
1129 values = new Object(); | |
1130 _js_helper.Primitives.setProperty(object, Expando$()._EXPANDO_PROPERTY
_NAME, values); | |
1131 } | |
1132 _js_helper.Primitives.setProperty(values, this[_getKey](), value); | |
1133 return value; | |
1134 } | |
1135 [_getKey]() { | |
1136 let key = dart.as(_js_helper.Primitives.getProperty(this, Expando$()._KE
Y_PROPERTY_NAME), String); | |
1137 if (key == null) { | |
1138 key = `expando\$key\$${(() => { | |
1139 let x = Expando$()._keyCount; | |
1140 Expando$()._keyCount = dart.notNull(x) + 1; | |
1141 return x; | |
1142 })()}`; | |
1143 _js_helper.Primitives.setProperty(this, Expando$()._KEY_PROPERTY_NAME,
key); | |
1144 } | |
1145 return key; | |
1146 } | |
1147 } | |
1148 dart.setSignature(Expando, { | |
1149 constructors: () => ({Expando: [Expando$(T), [], [String]]}), | |
1150 methods: () => ({ | |
1151 get: [T, [Object]], | |
1152 set: [dart.void, [Object, T]], | |
1153 [_getKey]: [String, []] | |
1154 }) | |
1155 }); | |
1156 Expando._KEY_PROPERTY_NAME = 'expando$key'; | |
1157 Expando._EXPANDO_PROPERTY_NAME = 'expando$values'; | |
1158 Expando._keyCount = 0; | |
1159 return Expando; | |
1160 }); | |
1161 let Expando = Expando$(); | |
1162 class Function extends Object { | |
1163 static apply(f, positionalArguments, namedArguments) { | |
1164 if (namedArguments === void 0) namedArguments = null; | |
1165 return dart.dcall.apply(null, [f].concat(positionalArguments)); | |
1166 } | |
1167 static _toMangledNames(namedArguments) { | |
1168 let result = dart.map(); | |
1169 namedArguments[dartx.forEach](dart.fn((symbol, value) => { | |
1170 result[dartx.set](_symbolToString(symbol), value); | |
1171 }, dart.void, [Symbol, dart.dynamic])); | |
1172 return result; | |
1173 } | |
1174 } | |
1175 dart.setSignature(Function, { | |
1176 statics: () => ({ | |
1177 apply: [dart.dynamic, [Function, List], [Map$(Symbol, dart.dynamic)]], | |
1178 _toMangledNames: [Map$(String, dart.dynamic), [Map$(Symbol, dart.dynamic)]
] | |
1179 }), | |
1180 names: ['apply', '_toMangledNames'] | |
1181 }); | |
1182 function identical(a, b) { | |
1183 return _js_helper.Primitives.identicalImplementation(a, b); | |
1184 } | |
1185 dart.fn(identical, bool, [Object, Object]); | |
1186 function identityHashCode(object) { | |
1187 return _js_helper.objectHashCode(object); | |
1188 } | |
1189 dart.fn(identityHashCode, () => dart.definiteFunctionType(int, [Object])); | |
1190 class int extends num { | |
1191 static fromEnvironment(name, opts) { | |
1192 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : nu
ll; | |
1193 dart.throw(new UnsupportedError('int.fromEnvironment can only be used as a
const constructor')); | |
1194 } | |
1195 static parse(source, opts) { | |
1196 let radix = opts && 'radix' in opts ? opts.radix : null; | |
1197 let onError = opts && 'onError' in opts ? opts.onError : null; | |
1198 return _js_helper.Primitives.parseInt(source, radix, onError); | |
1199 } | |
1200 } | |
1201 dart.setSignature(int, { | |
1202 constructors: () => ({fromEnvironment: [int, [String], {defaultValue: int}]}
), | |
1203 statics: () => ({parse: [int, [String], {radix: int, onError: dart.functionT
ype(int, [String])}]}), | |
1204 names: ['parse'] | |
1205 }); | |
1206 class Invocation extends Object { | |
1207 get isAccessor() { | |
1208 return dart.notNull(this.isGetter) || dart.notNull(this.isSetter); | |
1209 } | |
1210 } | |
1211 const Iterable$ = dart.generic(function(E) { | |
1212 dart.defineExtensionNames([ | |
1213 'join' | |
1214 ]); | |
1215 class Iterable extends Object { | |
1216 Iterable() { | |
1217 } | |
1218 static generate(count, generator) { | |
1219 if (generator === void 0) generator = null; | |
1220 if (dart.notNull(count) <= 0) return new (_internal.EmptyIterable$(E))()
; | |
1221 return new (exports._GeneratorIterable$(E))(count, generator); | |
1222 } | |
1223 [dart.JsSymbol.iterator]() { | |
1224 return new dart.JsIterator(this[dartx.iterator]); | |
1225 } | |
1226 [dartx.join](separator) { | |
1227 if (separator === void 0) separator = ""; | |
1228 let buffer = new StringBuffer(); | |
1229 buffer.writeAll(this, separator); | |
1230 return buffer.toString(); | |
1231 } | |
1232 } | |
1233 dart.setSignature(Iterable, { | |
1234 constructors: () => ({ | |
1235 Iterable: [Iterable$(E), []], | |
1236 generate: [Iterable$(E), [int], [dart.functionType(E, [int])]] | |
1237 }), | |
1238 methods: () => ({[dartx.join]: [String, [], [String]]}) | |
1239 }); | |
1240 return Iterable; | |
1241 }); | |
1242 let Iterable = Iterable$(); | |
1243 const _Generator$ = dart.generic(function(E) { | |
1244 const _Generator = dart.typedef('_Generator', () => dart.functionType(E, [in
t])); | |
1245 return _Generator; | |
1246 }); | |
1247 let _Generator = _Generator$(); | |
1248 const _end = dart.JsSymbol('_end'); | |
1249 const _start = dart.JsSymbol('_start'); | |
1250 const _generator = dart.JsSymbol('_generator'); | |
1251 const _GeneratorIterable$ = dart.generic(function(E) { | |
1252 class _GeneratorIterable extends collection.IterableBase$(E) { | |
1253 _GeneratorIterable(end, generator) { | |
1254 this[_end] = end; | |
1255 this[_start] = 0; | |
1256 this[_generator] = dart.as(generator != null ? generator : exports._Gene
ratorIterable$()._id, _Generator$(E)); | |
1257 super.IterableBase(); | |
1258 } | |
1259 slice(start, end, generator) { | |
1260 this[_start] = start; | |
1261 this[_end] = end; | |
1262 this[_generator] = generator; | |
1263 super.IterableBase(); | |
1264 } | |
1265 get iterator() { | |
1266 return new (_GeneratorIterator$(E))(this[_start], this[_end], this[_gene
rator]); | |
1267 } | |
1268 get length() { | |
1269 return dart.notNull(this[_end]) - dart.notNull(this[_start]); | |
1270 } | |
1271 skip(count) { | |
1272 RangeError.checkNotNegative(count, "count"); | |
1273 if (count == 0) return this; | |
1274 let newStart = dart.notNull(this[_start]) + dart.notNull(count); | |
1275 if (newStart >= dart.notNull(this[_end])) return new (_internal.EmptyIte
rable$(E))(); | |
1276 return new (exports._GeneratorIterable$(E)).slice(newStart, this[_end],
this[_generator]); | |
1277 } | |
1278 take(count) { | |
1279 RangeError.checkNotNegative(count, "count"); | |
1280 if (count == 0) return new (_internal.EmptyIterable$(E))(); | |
1281 let newEnd = dart.notNull(this[_start]) + dart.notNull(count); | |
1282 if (newEnd >= dart.notNull(this[_end])) return this; | |
1283 return new (exports._GeneratorIterable$(E)).slice(this[_start], newEnd,
this[_generator]); | |
1284 } | |
1285 static _id(n) { | |
1286 return n; | |
1287 } | |
1288 } | |
1289 _GeneratorIterable[dart.implements] = () => [_internal.EfficientLength]; | |
1290 dart.defineNamedConstructor(_GeneratorIterable, 'slice'); | |
1291 dart.setSignature(_GeneratorIterable, { | |
1292 constructors: () => ({ | |
1293 _GeneratorIterable: [exports._GeneratorIterable$(E), [int, dart.function
Type(E, [int])]], | |
1294 slice: [exports._GeneratorIterable$(E), [int, int, _Generator$(E)]] | |
1295 }), | |
1296 methods: () => ({ | |
1297 skip: [Iterable$(E), [int]], | |
1298 take: [Iterable$(E), [int]] | |
1299 }), | |
1300 statics: () => ({_id: [int, [int]]}), | |
1301 names: ['_id'] | |
1302 }); | |
1303 dart.defineExtensionMembers(_GeneratorIterable, ['skip', 'take', 'iterator',
'length']); | |
1304 return _GeneratorIterable; | |
1305 }); | |
1306 dart.defineLazyClassGeneric(exports, '_GeneratorIterable', {get: _GeneratorIte
rable$}); | |
1307 const _index = dart.JsSymbol('_index'); | |
1308 const _current = dart.JsSymbol('_current'); | |
1309 const _GeneratorIterator$ = dart.generic(function(E) { | |
1310 class _GeneratorIterator extends Object { | |
1311 _GeneratorIterator(index, end, generator) { | |
1312 this[_index] = index; | |
1313 this[_end] = end; | |
1314 this[_generator] = generator; | |
1315 this[_current] = null; | |
1316 } | |
1317 moveNext() { | |
1318 if (dart.notNull(this[_index]) < dart.notNull(this[_end])) { | |
1319 this[_current] = this[_generator](this[_index]); | |
1320 this[_index] = dart.notNull(this[_index]) + 1; | |
1321 return true; | |
1322 } else { | |
1323 this[_current] = null; | |
1324 return false; | |
1325 } | |
1326 } | |
1327 get current() { | |
1328 return this[_current]; | |
1329 } | |
1330 } | |
1331 _GeneratorIterator[dart.implements] = () => [Iterator$(E)]; | |
1332 dart.setSignature(_GeneratorIterator, { | |
1333 constructors: () => ({_GeneratorIterator: [_GeneratorIterator$(E), [int, i
nt, _Generator$(E)]]}), | |
1334 methods: () => ({moveNext: [bool, []]}) | |
1335 }); | |
1336 return _GeneratorIterator; | |
1337 }); | |
1338 let _GeneratorIterator = _GeneratorIterator$(); | |
1339 const BidirectionalIterator$ = dart.generic(function(E) { | |
1340 class BidirectionalIterator extends Object {} | |
1341 BidirectionalIterator[dart.implements] = () => [Iterator$(E)]; | |
1342 return BidirectionalIterator; | |
1343 }); | |
1344 let BidirectionalIterator = BidirectionalIterator$(); | |
1345 const Iterator$ = dart.generic(function(E) { | |
1346 class Iterator extends Object {} | |
1347 return Iterator; | |
1348 }); | |
1349 let Iterator = Iterator$(); | |
1350 const List$ = dart.generic(function(E) { | |
1351 class List extends Object { | |
1352 static new(length) { | |
1353 if (length === void 0) length = null; | |
1354 let list = null; | |
1355 if (length == null) { | |
1356 list = []; | |
1357 } else { | |
1358 if (!(typeof length == 'number') || dart.notNull(length) < 0) { | |
1359 dart.throw(new ArgumentError(`Length must be a non-negative integer:
${length}`)); | |
1360 } | |
1361 list = _interceptors.JSArray.markFixedList(dart.as(new Array(length),
List$())); | |
1362 } | |
1363 return _interceptors.JSArray$(E).typed(list); | |
1364 } | |
1365 static filled(length, fill) { | |
1366 let result = List$(E).new(length); | |
1367 if (length != 0 && fill != null) { | |
1368 for (let i = 0; i < dart.notNull(result[dartx.length]); i++) { | |
1369 result[dartx.set](i, fill); | |
1370 } | |
1371 } | |
1372 return result; | |
1373 } | |
1374 static from(elements, opts) { | |
1375 let growable = opts && 'growable' in opts ? opts.growable : true; | |
1376 let list = List$(E).new(); | |
1377 for (let e of elements) { | |
1378 list[dartx.add](dart.as(e, E)); | |
1379 } | |
1380 if (dart.notNull(growable)) return list; | |
1381 return dart.as(_internal.makeListFixedLength(list), List$(E)); | |
1382 } | |
1383 static generate(length, generator, opts) { | |
1384 let growable = opts && 'growable' in opts ? opts.growable : true; | |
1385 let result = null; | |
1386 if (dart.notNull(growable)) { | |
1387 result = dart.list([], E); | |
1388 result[dartx.length] = length; | |
1389 } else { | |
1390 result = List$(E).new(length); | |
1391 } | |
1392 for (let i = 0; i < dart.notNull(length); i++) { | |
1393 result[dartx.set](i, generator(i)); | |
1394 } | |
1395 return result; | |
1396 } | |
1397 [dart.JsSymbol.iterator]() { | |
1398 return new dart.JsIterator(this[dartx.iterator]); | |
1399 } | |
1400 } | |
1401 List[dart.implements] = () => [Iterable$(E)]; | |
1402 dart.setSignature(List, { | |
1403 constructors: () => ({ | |
1404 new: [List$(E), [], [int]], | |
1405 filled: [List$(E), [int, E]], | |
1406 from: [List$(E), [Iterable], {growable: bool}], | |
1407 generate: [List$(E), [int, dart.functionType(E, [int])], {growable: bool
}] | |
1408 }) | |
1409 }); | |
1410 return List; | |
1411 }); | |
1412 let List = List$(); | |
1413 const Map$ = dart.generic(function(K, V) { | |
1414 class Map extends Object { | |
1415 static new() { | |
1416 return collection.LinkedHashMap$(K, V).new(); | |
1417 } | |
1418 static from(other) { | |
1419 return collection.LinkedHashMap$(K, V).from(other); | |
1420 } | |
1421 static identity() { | |
1422 return collection.LinkedHashMap$(K, V).identity(); | |
1423 } | |
1424 static fromIterable(iterable, opts) { | |
1425 return collection.LinkedHashMap$(K, V).fromIterable(iterable, opts); | |
1426 } | |
1427 static fromIterables(keys, values) { | |
1428 return collection.LinkedHashMap$(K, V).fromIterables(keys, values); | |
1429 } | |
1430 } | |
1431 dart.setSignature(Map, { | |
1432 constructors: () => ({ | |
1433 new: [Map$(K, V), []], | |
1434 from: [Map$(K, V), [Map$()]], | |
1435 identity: [Map$(K, V), []], | |
1436 fromIterable: [Map$(K, V), [Iterable], {key: dart.functionType(K, [dart.
dynamic]), value: dart.functionType(V, [dart.dynamic])}], | |
1437 fromIterables: [Map$(K, V), [Iterable$(K), Iterable$(V)]] | |
1438 }) | |
1439 }); | |
1440 return Map; | |
1441 }); | |
1442 let Map = Map$(); | |
1443 class Null extends Object { | |
1444 static _uninstantiable() { | |
1445 dart.throw(new UnsupportedError('class Null cannot be instantiated')); | |
1446 } | |
1447 toString() { | |
1448 return "null"; | |
1449 } | |
1450 } | |
1451 dart.setSignature(Null, { | |
1452 constructors: () => ({_uninstantiable: [Null, []]}) | |
1453 }); | |
1454 class Pattern extends Object {} | |
1455 function print(object) { | |
1456 let line = `${object}`; | |
1457 if (_internal.printToZone == null) { | |
1458 _internal.printToConsole(line); | |
1459 } else { | |
1460 dart.dcall(_internal.printToZone, line); | |
1461 } | |
1462 } | |
1463 dart.fn(print, dart.void, [Object]); | |
1464 class Match extends Object {} | |
1465 class RegExp extends Object { | |
1466 static new(source, opts) { | |
1467 let multiLine = opts && 'multiLine' in opts ? opts.multiLine : false; | |
1468 let caseSensitive = opts && 'caseSensitive' in opts ? opts.caseSensitive :
true; | |
1469 return new _js_helper.JSSyntaxRegExp(source, {multiLine: multiLine, caseSe
nsitive: caseSensitive}); | |
1470 } | |
1471 } | |
1472 RegExp[dart.implements] = () => [Pattern]; | |
1473 dart.setSignature(RegExp, { | |
1474 constructors: () => ({new: [RegExp, [String], {multiLine: bool, caseSensitiv
e: bool}]}) | |
1475 }); | |
1476 const Set$ = dart.generic(function(E) { | |
1477 class Set extends collection.IterableBase$(E) { | |
1478 static new() { | |
1479 return collection.LinkedHashSet$(E).new(); | |
1480 } | |
1481 static identity() { | |
1482 return collection.LinkedHashSet$(E).identity(); | |
1483 } | |
1484 static from(elements) { | |
1485 return collection.LinkedHashSet$(E).from(elements); | |
1486 } | |
1487 } | |
1488 Set[dart.implements] = () => [_internal.EfficientLength]; | |
1489 dart.setSignature(Set, { | |
1490 constructors: () => ({ | |
1491 new: [exports.Set$(E), []], | |
1492 identity: [exports.Set$(E), []], | |
1493 from: [exports.Set$(E), [Iterable$(E)]] | |
1494 }) | |
1495 }); | |
1496 return Set; | |
1497 }); | |
1498 dart.defineLazyClassGeneric(exports, 'Set', {get: Set$}); | |
1499 const Sink$ = dart.generic(function(T) { | |
1500 class Sink extends Object {} | |
1501 return Sink; | |
1502 }); | |
1503 let Sink = Sink$(); | |
1504 class StackTrace extends Object { | |
1505 static get current() { | |
1506 let error = new Error(); | |
1507 let stack = error.stack; | |
1508 if (typeof stack == 'string') return new StackTrace.fromString(stack); | |
1509 if (Error.captureStackTrace != null) { | |
1510 Error.captureStackTrace(error); | |
1511 let stack = error.stack; | |
1512 if (typeof stack == 'string') return new StackTrace.fromString(stack); | |
1513 } | |
1514 try { | |
1515 dart.throw(0); | |
1516 } catch (_) { | |
1517 let stackTrace = dart.stackTrace(_); | |
1518 return stackTrace; | |
1519 } | |
1520 | |
1521 } | |
1522 } | |
1523 const _stop = dart.JsSymbol('_stop'); | |
1524 class Stopwatch extends Object { | |
1525 get frequency() { | |
1526 return Stopwatch._frequency; | |
1527 } | |
1528 Stopwatch() { | |
1529 this[_start] = null; | |
1530 this[_stop] = null; | |
1531 Stopwatch._initTicker(); | |
1532 } | |
1533 start() { | |
1534 if (dart.notNull(this.isRunning)) return; | |
1535 if (this[_start] == null) { | |
1536 this[_start] = Stopwatch._now(); | |
1537 } else { | |
1538 this[_start] = dart.notNull(Stopwatch._now()) - (dart.notNull(this[_stop
]) - dart.notNull(this[_start])); | |
1539 this[_stop] = null; | |
1540 } | |
1541 } | |
1542 stop() { | |
1543 if (!dart.notNull(this.isRunning)) return; | |
1544 this[_stop] = Stopwatch._now(); | |
1545 } | |
1546 reset() { | |
1547 if (this[_start] == null) return; | |
1548 this[_start] = Stopwatch._now(); | |
1549 if (this[_stop] != null) { | |
1550 this[_stop] = this[_start]; | |
1551 } | |
1552 } | |
1553 get elapsedTicks() { | |
1554 if (this[_start] == null) { | |
1555 return 0; | |
1556 } | |
1557 return dart.asInt(this[_stop] == null ? dart.notNull(Stopwatch._now()) - d
art.notNull(this[_start]) : dart.notNull(this[_stop]) - dart.notNull(this[_start
])); | |
1558 } | |
1559 get elapsed() { | |
1560 return new Duration({microseconds: this.elapsedMicroseconds}); | |
1561 } | |
1562 get elapsedMicroseconds() { | |
1563 return (dart.notNull(this.elapsedTicks) * 1000000 / dart.notNull(this.freq
uency))[dartx.truncate](); | |
1564 } | |
1565 get elapsedMilliseconds() { | |
1566 return (dart.notNull(this.elapsedTicks) * 1000 / dart.notNull(this.frequen
cy))[dartx.truncate](); | |
1567 } | |
1568 get isRunning() { | |
1569 return this[_start] != null && this[_stop] == null; | |
1570 } | |
1571 static _initTicker() { | |
1572 _js_helper.Primitives.initTicker(); | |
1573 Stopwatch._frequency = _js_helper.Primitives.timerFrequency; | |
1574 } | |
1575 static _now() { | |
1576 return dart.as(dart.dcall(_js_helper.Primitives.timerTicks), int); | |
1577 } | |
1578 } | |
1579 dart.setSignature(Stopwatch, { | |
1580 constructors: () => ({Stopwatch: [Stopwatch, []]}), | |
1581 methods: () => ({ | |
1582 start: [dart.void, []], | |
1583 stop: [dart.void, []], | |
1584 reset: [dart.void, []] | |
1585 }), | |
1586 statics: () => ({ | |
1587 _initTicker: [dart.void, []], | |
1588 _now: [int, []] | |
1589 }), | |
1590 names: ['_initTicker', '_now'] | |
1591 }); | |
1592 Stopwatch._frequency = null; | |
1593 class String extends Object { | |
1594 static fromCharCodes(charCodes, start, end) { | |
1595 if (start === void 0) start = 0; | |
1596 if (end === void 0) end = null; | |
1597 if (!dart.is(charCodes, _interceptors.JSArray)) { | |
1598 return String._stringFromIterable(charCodes, start, end); | |
1599 } | |
1600 let list = dart.as(charCodes, List); | |
1601 let len = list[dartx.length]; | |
1602 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(len)) { | |
1603 dart.throw(new RangeError.range(start, 0, len)); | |
1604 } | |
1605 if (end == null) { | |
1606 end = len; | |
1607 } else if (dart.notNull(end) < dart.notNull(start) || dart.notNull(end) >
dart.notNull(len)) { | |
1608 dart.throw(new RangeError.range(end, start, len)); | |
1609 } | |
1610 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(len)) { | |
1611 list = list[dartx.sublist](start, end); | |
1612 } | |
1613 return _js_helper.Primitives.stringFromCharCodes(list); | |
1614 } | |
1615 static fromCharCode(charCode) { | |
1616 return _js_helper.Primitives.stringFromCharCode(charCode); | |
1617 } | |
1618 static fromEnvironment(name, opts) { | |
1619 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : nu
ll; | |
1620 dart.throw(new UnsupportedError('String.fromEnvironment can only be used a
s a const constructor')); | |
1621 } | |
1622 static _stringFromIterable(charCodes, start, end) { | |
1623 if (dart.notNull(start) < 0) dart.throw(new RangeError.range(start, 0, cha
rCodes[dartx.length])); | |
1624 if (end != null && dart.notNull(end) < dart.notNull(start)) { | |
1625 dart.throw(new RangeError.range(end, start, charCodes[dartx.length])); | |
1626 } | |
1627 let it = charCodes[dartx.iterator]; | |
1628 for (let i = 0; i < dart.notNull(start); i++) { | |
1629 if (!dart.notNull(it.moveNext())) { | |
1630 dart.throw(new RangeError.range(start, 0, i)); | |
1631 } | |
1632 } | |
1633 let list = []; | |
1634 if (end == null) { | |
1635 while (dart.notNull(it.moveNext())) | |
1636 list[dartx.add](it.current); | |
1637 } else { | |
1638 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNul
l(i) + 1) { | |
1639 if (!dart.notNull(it.moveNext())) { | |
1640 dart.throw(new RangeError.range(end, start, i)); | |
1641 } | |
1642 list[dartx.add](it.current); | |
1643 } | |
1644 } | |
1645 return _js_helper.Primitives.stringFromCharCodes(list); | |
1646 } | |
1647 } | |
1648 String[dart.implements] = () => [Comparable$(String), Pattern]; | |
1649 dart.setSignature(String, { | |
1650 constructors: () => ({ | |
1651 fromCharCodes: [String, [Iterable$(int)], [int, int]], | |
1652 fromCharCode: [String, [int]], | |
1653 fromEnvironment: [String, [String], {defaultValue: String}] | |
1654 }), | |
1655 statics: () => ({_stringFromIterable: [String, [Iterable$(int), int, int]]})
, | |
1656 names: ['_stringFromIterable'] | |
1657 }); | |
1658 dart.defineLazyClass(exports, { | |
1659 get Runes() { | |
1660 class Runes extends collection.IterableBase$(int) { | |
1661 Runes(string) { | |
1662 this.string = string; | |
1663 super.IterableBase(); | |
1664 } | |
1665 get iterator() { | |
1666 return new RuneIterator(this.string); | |
1667 } | |
1668 get last() { | |
1669 if (this.string[dartx.length] == 0) { | |
1670 dart.throw(new StateError('No elements.')); | |
1671 } | |
1672 let length = this.string[dartx.length]; | |
1673 let code = this.string[dartx.codeUnitAt](dart.notNull(length) - 1); | |
1674 if (dart.notNull(_isTrailSurrogate(code)) && dart.notNull(this.string[
dartx.length]) > 1) { | |
1675 let previousCode = this.string[dartx.codeUnitAt](dart.notNull(length
) - 2); | |
1676 if (dart.notNull(_isLeadSurrogate(previousCode))) { | |
1677 return _combineSurrogatePair(previousCode, code); | |
1678 } | |
1679 } | |
1680 return code; | |
1681 } | |
1682 } | |
1683 dart.setSignature(Runes, { | |
1684 constructors: () => ({Runes: [exports.Runes, [String]]}) | |
1685 }); | |
1686 dart.defineExtensionMembers(Runes, ['iterator', 'last']); | |
1687 return Runes; | |
1688 } | |
1689 }); | |
1690 function _isLeadSurrogate(code) { | |
1691 return (dart.notNull(code) & 64512) == 55296; | |
1692 } | |
1693 dart.fn(_isLeadSurrogate, bool, [int]); | |
1694 function _isTrailSurrogate(code) { | |
1695 return (dart.notNull(code) & 64512) == 56320; | |
1696 } | |
1697 dart.fn(_isTrailSurrogate, bool, [int]); | |
1698 function _combineSurrogatePair(start, end) { | |
1699 return 65536 + ((dart.notNull(start) & 1023) << 10) + (dart.notNull(end) & 1
023); | |
1700 } | |
1701 dart.fn(_combineSurrogatePair, int, [int, int]); | |
1702 const _position = dart.JsSymbol('_position'); | |
1703 const _nextPosition = dart.JsSymbol('_nextPosition'); | |
1704 const _currentCodePoint = dart.JsSymbol('_currentCodePoint'); | |
1705 const _checkSplitSurrogate = dart.JsSymbol('_checkSplitSurrogate'); | |
1706 class RuneIterator extends Object { | |
1707 RuneIterator(string) { | |
1708 this.string = string; | |
1709 this[_position] = 0; | |
1710 this[_nextPosition] = 0; | |
1711 this[_currentCodePoint] = null; | |
1712 } | |
1713 at(string, index) { | |
1714 this.string = string; | |
1715 this[_position] = index; | |
1716 this[_nextPosition] = index; | |
1717 this[_currentCodePoint] = null; | |
1718 RangeError.checkValueInInterval(index, 0, string[dartx.length]); | |
1719 this[_checkSplitSurrogate](index); | |
1720 } | |
1721 [_checkSplitSurrogate](index) { | |
1722 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)))) { | |
1723 dart.throw(new ArgumentError(`Index inside surrogate pair: ${index}`)); | |
1724 } | |
1725 } | |
1726 get rawIndex() { | |
1727 return this[_position] != this[_nextPosition] ? this[_position] : null; | |
1728 } | |
1729 set rawIndex(rawIndex) { | |
1730 RangeError.checkValidIndex(rawIndex, this.string, "rawIndex"); | |
1731 this.reset(rawIndex); | |
1732 this.moveNext(); | |
1733 } | |
1734 reset(rawIndex) { | |
1735 if (rawIndex === void 0) rawIndex = 0; | |
1736 RangeError.checkValueInInterval(rawIndex, 0, this.string[dartx.length], "r
awIndex"); | |
1737 this[_checkSplitSurrogate](rawIndex); | |
1738 this[_position] = this[_nextPosition] = rawIndex; | |
1739 this[_currentCodePoint] = null; | |
1740 } | |
1741 get current() { | |
1742 return dart.asInt(this[_currentCodePoint]); | |
1743 } | |
1744 get currentSize() { | |
1745 return dart.notNull(this[_nextPosition]) - dart.notNull(this[_position]); | |
1746 } | |
1747 get currentAsString() { | |
1748 if (this[_position] == this[_nextPosition]) return null; | |
1749 if (dart.notNull(this[_position]) + 1 == this[_nextPosition]) return this.
string[dartx.get](this[_position]); | |
1750 return this.string[dartx.substring](this[_position], this[_nextPosition]); | |
1751 } | |
1752 moveNext() { | |
1753 this[_position] = this[_nextPosition]; | |
1754 if (this[_position] == this.string[dartx.length]) { | |
1755 this[_currentCodePoint] = null; | |
1756 return false; | |
1757 } | |
1758 let codeUnit = this.string[dartx.codeUnitAt](this[_position]); | |
1759 let nextPosition = dart.notNull(this[_position]) + 1; | |
1760 if (dart.notNull(_isLeadSurrogate(codeUnit)) && nextPosition < dart.notNul
l(this.string[dartx.length])) { | |
1761 let nextCodeUnit = this.string[dartx.codeUnitAt](nextPosition); | |
1762 if (dart.notNull(_isTrailSurrogate(nextCodeUnit))) { | |
1763 this[_nextPosition] = nextPosition + 1; | |
1764 this[_currentCodePoint] = _combineSurrogatePair(codeUnit, nextCodeUnit
); | |
1765 return true; | |
1766 } | |
1767 } | |
1768 this[_nextPosition] = nextPosition; | |
1769 this[_currentCodePoint] = codeUnit; | |
1770 return true; | |
1771 } | |
1772 movePrevious() { | |
1773 this[_nextPosition] = this[_position]; | |
1774 if (this[_position] == 0) { | |
1775 this[_currentCodePoint] = null; | |
1776 return false; | |
1777 } | |
1778 let position = dart.notNull(this[_position]) - 1; | |
1779 let codeUnit = this.string[dartx.codeUnitAt](position); | |
1780 if (dart.notNull(_isTrailSurrogate(codeUnit)) && position > 0) { | |
1781 let prevCodeUnit = this.string[dartx.codeUnitAt](position - 1); | |
1782 if (dart.notNull(_isLeadSurrogate(prevCodeUnit))) { | |
1783 this[_position] = position - 1; | |
1784 this[_currentCodePoint] = _combineSurrogatePair(prevCodeUnit, codeUnit
); | |
1785 return true; | |
1786 } | |
1787 } | |
1788 this[_position] = position; | |
1789 this[_currentCodePoint] = codeUnit; | |
1790 return true; | |
1791 } | |
1792 } | |
1793 RuneIterator[dart.implements] = () => [BidirectionalIterator$(int)]; | |
1794 dart.defineNamedConstructor(RuneIterator, 'at'); | |
1795 dart.setSignature(RuneIterator, { | |
1796 constructors: () => ({ | |
1797 RuneIterator: [RuneIterator, [String]], | |
1798 at: [RuneIterator, [String, int]] | |
1799 }), | |
1800 methods: () => ({ | |
1801 [_checkSplitSurrogate]: [dart.void, [int]], | |
1802 reset: [dart.void, [], [int]], | |
1803 moveNext: [bool, []], | |
1804 movePrevious: [bool, []] | |
1805 }) | |
1806 }); | |
1807 const _contents = dart.JsSymbol('_contents'); | |
1808 const _writeString = dart.JsSymbol('_writeString'); | |
1809 class StringBuffer extends Object { | |
1810 StringBuffer(content) { | |
1811 if (content === void 0) content = ""; | |
1812 this[_contents] = `${content}`; | |
1813 } | |
1814 get length() { | |
1815 return this[_contents][dartx.length]; | |
1816 } | |
1817 get isEmpty() { | |
1818 return this.length == 0; | |
1819 } | |
1820 get isNotEmpty() { | |
1821 return !dart.notNull(this.isEmpty); | |
1822 } | |
1823 write(obj) { | |
1824 this[_writeString](`${obj}`); | |
1825 } | |
1826 writeCharCode(charCode) { | |
1827 this[_writeString](String.fromCharCode(charCode)); | |
1828 } | |
1829 writeAll(objects, separator) { | |
1830 if (separator === void 0) separator = ""; | |
1831 let iterator = objects[dartx.iterator]; | |
1832 if (!dart.notNull(iterator.moveNext())) return; | |
1833 if (dart.notNull(separator[dartx.isEmpty])) { | |
1834 do { | |
1835 this.write(iterator.current); | |
1836 } while (dart.notNull(iterator.moveNext())); | |
1837 } else { | |
1838 this.write(iterator.current); | |
1839 while (dart.notNull(iterator.moveNext())) { | |
1840 this.write(separator); | |
1841 this.write(iterator.current); | |
1842 } | |
1843 } | |
1844 } | |
1845 writeln(obj) { | |
1846 if (obj === void 0) obj = ""; | |
1847 this.write(obj); | |
1848 this.write("\n"); | |
1849 } | |
1850 clear() { | |
1851 this[_contents] = ""; | |
1852 } | |
1853 toString() { | |
1854 return _js_helper.Primitives.flattenString(this[_contents]); | |
1855 } | |
1856 [_writeString](str) { | |
1857 this[_contents] = _js_helper.Primitives.stringConcatUnchecked(this[_conten
ts], dart.as(str, String)); | |
1858 } | |
1859 } | |
1860 StringBuffer[dart.implements] = () => [StringSink]; | |
1861 dart.setSignature(StringBuffer, { | |
1862 constructors: () => ({StringBuffer: [StringBuffer, [], [Object]]}), | |
1863 methods: () => ({ | |
1864 write: [dart.void, [Object]], | |
1865 writeCharCode: [dart.void, [int]], | |
1866 writeAll: [dart.void, [Iterable], [String]], | |
1867 writeln: [dart.void, [], [Object]], | |
1868 clear: [dart.void, []], | |
1869 [_writeString]: [dart.void, [dart.dynamic]] | |
1870 }) | |
1871 }); | |
1872 class StringSink extends Object {} | |
1873 class Symbol extends Object { | |
1874 static new(name) { | |
1875 return new _internal.Symbol(name); | |
1876 } | |
1877 } | |
1878 dart.setSignature(Symbol, { | |
1879 constructors: () => ({new: [Symbol, [String]]}) | |
1880 }); | |
1881 class Type extends Object {} | |
1882 const _writeAuthority = dart.JsSymbol('_writeAuthority'); | |
1883 const _userInfo = dart.JsSymbol('_userInfo'); | |
1884 const _host = dart.JsSymbol('_host'); | |
1885 const _port = dart.JsSymbol('_port'); | |
1886 const _path = dart.JsSymbol('_path'); | |
1887 const _query = dart.JsSymbol('_query'); | |
1888 const _fragment = dart.JsSymbol('_fragment'); | |
1889 const _pathSegments = dart.JsSymbol('_pathSegments'); | |
1890 const _queryParameters = dart.JsSymbol('_queryParameters'); | |
1891 const _merge = dart.JsSymbol('_merge'); | |
1892 const _hasDotSegments = dart.JsSymbol('_hasDotSegments'); | |
1893 const _removeDotSegments = dart.JsSymbol('_removeDotSegments'); | |
1894 const _toWindowsFilePath = dart.JsSymbol('_toWindowsFilePath'); | |
1895 const _toFilePath = dart.JsSymbol('_toFilePath'); | |
1896 const _isPathAbsolute = dart.JsSymbol('_isPathAbsolute'); | |
1897 class Uri extends Object { | |
1898 get authority() { | |
1899 if (!dart.notNull(this.hasAuthority)) return ""; | |
1900 let sb = new StringBuffer(); | |
1901 this[_writeAuthority](sb); | |
1902 return sb.toString(); | |
1903 } | |
1904 get userInfo() { | |
1905 return this[_userInfo]; | |
1906 } | |
1907 get host() { | |
1908 if (this[_host] == null) return ""; | |
1909 if (dart.notNull(this[_host][dartx.startsWith]('['))) { | |
1910 return this[_host][dartx.substring](1, dart.notNull(this[_host][dartx.le
ngth]) - 1); | |
1911 } | |
1912 return this[_host]; | |
1913 } | |
1914 get port() { | |
1915 if (this[_port] == null) return Uri._defaultPort(this.scheme); | |
1916 return dart.asInt(this[_port]); | |
1917 } | |
1918 static _defaultPort(scheme) { | |
1919 if (scheme == "http") return 80; | |
1920 if (scheme == "https") return 443; | |
1921 return 0; | |
1922 } | |
1923 get path() { | |
1924 return this[_path]; | |
1925 } | |
1926 get query() { | |
1927 return this[_query] == null ? "" : this[_query]; | |
1928 } | |
1929 get fragment() { | |
1930 return this[_fragment] == null ? "" : this[_fragment]; | |
1931 } | |
1932 static parse(uri) { | |
1933 function isRegName(ch) { | |
1934 return dart.notNull(ch) < 128 && (dart.notNull(Uri._regNameTable[dartx.g
et](dart.notNull(ch) >> 4)) & 1 << (dart.notNull(ch) & 15)) != 0; | |
1935 } | |
1936 dart.fn(isRegName, bool, [int]); | |
1937 let EOI = -1; | |
1938 let scheme = ""; | |
1939 let userinfo = ""; | |
1940 let host = null; | |
1941 let port = null; | |
1942 let path = null; | |
1943 let query = null; | |
1944 let fragment = null; | |
1945 let index = 0; | |
1946 let pathStart = 0; | |
1947 let char = EOI; | |
1948 function parseAuth() { | |
1949 if (index == uri[dartx.length]) { | |
1950 char = EOI; | |
1951 return; | |
1952 } | |
1953 let authStart = index; | |
1954 let lastColon = -1; | |
1955 let lastAt = -1; | |
1956 char = uri[dartx.codeUnitAt](index); | |
1957 while (dart.notNull(index) < dart.notNull(uri[dartx.length])) { | |
1958 char = uri[dartx.codeUnitAt](index); | |
1959 if (char == Uri._SLASH || char == Uri._QUESTION || char == Uri._NUMBER
_SIGN) { | |
1960 break; | |
1961 } | |
1962 if (char == Uri._AT_SIGN) { | |
1963 lastAt = index; | |
1964 lastColon = -1; | |
1965 } else if (char == Uri._COLON) { | |
1966 lastColon = index; | |
1967 } else if (char == Uri._LEFT_BRACKET) { | |
1968 lastColon = -1; | |
1969 let endBracket = uri[dartx.indexOf](']', dart.notNull(index) + 1); | |
1970 if (endBracket == -1) { | |
1971 index = uri[dartx.length]; | |
1972 char = EOI; | |
1973 break; | |
1974 } else { | |
1975 index = endBracket; | |
1976 } | |
1977 } | |
1978 index = dart.notNull(index) + 1; | |
1979 char = EOI; | |
1980 } | |
1981 let hostStart = authStart; | |
1982 let hostEnd = index; | |
1983 if (dart.notNull(lastAt) >= 0) { | |
1984 userinfo = Uri._makeUserInfo(uri, authStart, lastAt); | |
1985 hostStart = dart.notNull(lastAt) + 1; | |
1986 } | |
1987 if (dart.notNull(lastColon) >= 0) { | |
1988 let portNumber = null; | |
1989 if (dart.notNull(lastColon) + 1 < dart.notNull(index)) { | |
1990 portNumber = 0; | |
1991 for (let i = dart.notNull(lastColon) + 1; i < dart.notNull(index); i
++) { | |
1992 let digit = uri[dartx.codeUnitAt](i); | |
1993 if (dart.notNull(Uri._ZERO) > dart.notNull(digit) || dart.notNull(
Uri._NINE) < dart.notNull(digit)) { | |
1994 Uri._fail(uri, i, "Invalid port number"); | |
1995 } | |
1996 portNumber = dart.notNull(portNumber) * 10 + (dart.notNull(digit)
- dart.notNull(Uri._ZERO)); | |
1997 } | |
1998 } | |
1999 port = Uri._makePort(portNumber, scheme); | |
2000 hostEnd = lastColon; | |
2001 } | |
2002 host = Uri._makeHost(uri, hostStart, hostEnd, true); | |
2003 if (dart.notNull(index) < dart.notNull(uri[dartx.length])) { | |
2004 char = uri[dartx.codeUnitAt](index); | |
2005 } | |
2006 } | |
2007 dart.fn(parseAuth, dart.void, []); | |
2008 let NOT_IN_PATH = 0; | |
2009 let IN_PATH = 1; | |
2010 let ALLOW_AUTH = 2; | |
2011 let state = NOT_IN_PATH; | |
2012 let i = index; | |
2013 while (dart.notNull(i) < dart.notNull(uri[dartx.length])) { | |
2014 char = uri[dartx.codeUnitAt](i); | |
2015 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN) { | |
2016 state = NOT_IN_PATH; | |
2017 break; | |
2018 } | |
2019 if (char == Uri._SLASH) { | |
2020 state = i == 0 ? ALLOW_AUTH : IN_PATH; | |
2021 break; | |
2022 } | |
2023 if (char == Uri._COLON) { | |
2024 if (i == 0) Uri._fail(uri, 0, "Invalid empty scheme"); | |
2025 scheme = Uri._makeScheme(uri, i); | |
2026 i = dart.notNull(i) + 1; | |
2027 pathStart = i; | |
2028 if (i == uri[dartx.length]) { | |
2029 char = EOI; | |
2030 state = NOT_IN_PATH; | |
2031 } else { | |
2032 char = uri[dartx.codeUnitAt](i); | |
2033 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN) { | |
2034 state = NOT_IN_PATH; | |
2035 } else if (char == Uri._SLASH) { | |
2036 state = ALLOW_AUTH; | |
2037 } else { | |
2038 state = IN_PATH; | |
2039 } | |
2040 } | |
2041 break; | |
2042 } | |
2043 i = dart.notNull(i) + 1; | |
2044 char = EOI; | |
2045 } | |
2046 index = i; | |
2047 if (state == ALLOW_AUTH) { | |
2048 dart.assert(char == Uri._SLASH); | |
2049 index = dart.notNull(index) + 1; | |
2050 if (index == uri[dartx.length]) { | |
2051 char = EOI; | |
2052 state = NOT_IN_PATH; | |
2053 } else { | |
2054 char = uri[dartx.codeUnitAt](index); | |
2055 if (char == Uri._SLASH) { | |
2056 index = dart.notNull(index) + 1; | |
2057 parseAuth(); | |
2058 pathStart = index; | |
2059 } | |
2060 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN || char == EOI)
{ | |
2061 state = NOT_IN_PATH; | |
2062 } else { | |
2063 state = IN_PATH; | |
2064 } | |
2065 } | |
2066 } | |
2067 dart.assert(state == IN_PATH || state == NOT_IN_PATH); | |
2068 if (state == IN_PATH) { | |
2069 while ((index = dart.notNull(index) + 1) < dart.notNull(uri[dartx.length
])) { | |
2070 char = uri[dartx.codeUnitAt](index); | |
2071 if (char == Uri._QUESTION || char == Uri._NUMBER_SIGN) { | |
2072 break; | |
2073 } | |
2074 char = EOI; | |
2075 } | |
2076 state = NOT_IN_PATH; | |
2077 } | |
2078 dart.assert(state == NOT_IN_PATH); | |
2079 let isFile = scheme == "file"; | |
2080 let ensureLeadingSlash = host != null; | |
2081 path = Uri._makePath(uri, pathStart, index, null, ensureLeadingSlash, isFi
le); | |
2082 if (char == Uri._QUESTION) { | |
2083 let numberSignIndex = uri[dartx.indexOf]('#', dart.notNull(index) + 1); | |
2084 if (dart.notNull(numberSignIndex) < 0) { | |
2085 query = Uri._makeQuery(uri, dart.notNull(index) + 1, uri[dartx.length]
, null); | |
2086 } else { | |
2087 query = Uri._makeQuery(uri, dart.notNull(index) + 1, numberSignIndex,
null); | |
2088 fragment = Uri._makeFragment(uri, dart.notNull(numberSignIndex) + 1, u
ri[dartx.length]); | |
2089 } | |
2090 } else if (char == Uri._NUMBER_SIGN) { | |
2091 fragment = Uri._makeFragment(uri, dart.notNull(index) + 1, uri[dartx.len
gth]); | |
2092 } | |
2093 return new Uri._internal(scheme, userinfo, host, port, path, query, fragme
nt); | |
2094 } | |
2095 static _fail(uri, index, message) { | |
2096 dart.throw(new FormatException(message, uri, index)); | |
2097 } | |
2098 _internal(scheme, userInfo, host, port, path, query, fragment) { | |
2099 this.scheme = scheme; | |
2100 this[_userInfo] = userInfo; | |
2101 this[_host] = host; | |
2102 this[_port] = port; | |
2103 this[_path] = path; | |
2104 this[_query] = query; | |
2105 this[_fragment] = fragment; | |
2106 this[_pathSegments] = null; | |
2107 this[_queryParameters] = null; | |
2108 } | |
2109 static new(opts) { | |
2110 let scheme = opts && 'scheme' in opts ? opts.scheme : ""; | |
2111 let userInfo = opts && 'userInfo' in opts ? opts.userInfo : ""; | |
2112 let host = opts && 'host' in opts ? opts.host : null; | |
2113 let port = opts && 'port' in opts ? opts.port : null; | |
2114 let path = opts && 'path' in opts ? opts.path : null; | |
2115 let pathSegments = opts && 'pathSegments' in opts ? opts.pathSegments : nu
ll; | |
2116 let query = opts && 'query' in opts ? opts.query : null; | |
2117 let queryParameters = opts && 'queryParameters' in opts ? opts.queryParame
ters : null; | |
2118 let fragment = opts && 'fragment' in opts ? opts.fragment : null; | |
2119 scheme = Uri._makeScheme(scheme, Uri._stringOrNullLength(scheme)); | |
2120 userInfo = Uri._makeUserInfo(userInfo, 0, Uri._stringOrNullLength(userInfo
)); | |
2121 host = Uri._makeHost(host, 0, Uri._stringOrNullLength(host), false); | |
2122 if (query == "") query = null; | |
2123 query = Uri._makeQuery(query, 0, Uri._stringOrNullLength(query), queryPara
meters); | |
2124 fragment = Uri._makeFragment(fragment, 0, Uri._stringOrNullLength(fragment
)); | |
2125 port = Uri._makePort(port, scheme); | |
2126 let isFile = scheme == "file"; | |
2127 if (host == null && (dart.notNull(userInfo[dartx.isNotEmpty]) || port != n
ull || isFile)) { | |
2128 host = ""; | |
2129 } | |
2130 let ensureLeadingSlash = host != null; | |
2131 path = Uri._makePath(path, 0, Uri._stringOrNullLength(path), pathSegments,
ensureLeadingSlash, isFile); | |
2132 return new Uri._internal(scheme, userInfo, host, port, path, query, fragme
nt); | |
2133 } | |
2134 static http(authority, unencodedPath, queryParameters) { | |
2135 if (queryParameters === void 0) queryParameters = null; | |
2136 return Uri._makeHttpUri("http", authority, unencodedPath, queryParameters)
; | |
2137 } | |
2138 static https(authority, unencodedPath, queryParameters) { | |
2139 if (queryParameters === void 0) queryParameters = null; | |
2140 return Uri._makeHttpUri("https", authority, unencodedPath, queryParameters
); | |
2141 } | |
2142 static _makeHttpUri(scheme, authority, unencodedPath, queryParameters) { | |
2143 let userInfo = ""; | |
2144 let host = null; | |
2145 let port = null; | |
2146 if (authority != null && dart.notNull(authority[dartx.isNotEmpty])) { | |
2147 let hostStart = 0; | |
2148 let hasUserInfo = false; | |
2149 for (let i = 0; i < dart.notNull(authority[dartx.length]); i++) { | |
2150 if (authority[dartx.codeUnitAt](i) == Uri._AT_SIGN) { | |
2151 hasUserInfo = true; | |
2152 userInfo = authority[dartx.substring](0, i); | |
2153 hostStart = i + 1; | |
2154 break; | |
2155 } | |
2156 } | |
2157 let hostEnd = hostStart; | |
2158 if (hostStart < dart.notNull(authority[dartx.length]) && authority[dartx
.codeUnitAt](hostStart) == Uri._LEFT_BRACKET) { | |
2159 for (; hostEnd < dart.notNull(authority[dartx.length]); hostEnd++) { | |
2160 if (authority[dartx.codeUnitAt](hostEnd) == Uri._RIGHT_BRACKET) brea
k; | |
2161 } | |
2162 if (hostEnd == authority[dartx.length]) { | |
2163 dart.throw(new FormatException("Invalid IPv6 host entry.", authority
, hostStart)); | |
2164 } | |
2165 Uri.parseIPv6Address(authority, hostStart + 1, hostEnd); | |
2166 hostEnd++; | |
2167 if (hostEnd != authority[dartx.length] && authority[dartx.codeUnitAt](
hostEnd) != Uri._COLON) { | |
2168 dart.throw(new FormatException("Invalid end of authority", authority
, hostEnd)); | |
2169 } | |
2170 } | |
2171 let hasPort = false; | |
2172 for (; hostEnd < dart.notNull(authority[dartx.length]); hostEnd++) { | |
2173 if (authority[dartx.codeUnitAt](hostEnd) == Uri._COLON) { | |
2174 let portString = authority[dartx.substring](hostEnd + 1); | |
2175 if (dart.notNull(portString[dartx.isNotEmpty])) port = int.parse(por
tString); | |
2176 break; | |
2177 } | |
2178 } | |
2179 host = authority[dartx.substring](hostStart, hostEnd); | |
2180 } | |
2181 return Uri.new({scheme: scheme, userInfo: userInfo, host: dart.as(host, St
ring), port: dart.as(port, int), pathSegments: unencodedPath[dartx.split]("/"),
queryParameters: queryParameters}); | |
2182 } | |
2183 static file(path, opts) { | |
2184 let windows = opts && 'windows' in opts ? opts.windows : null; | |
2185 windows = windows == null ? Uri._isWindows : windows; | |
2186 return dart.as(dart.notNull(windows) ? Uri._makeWindowsFileUrl(path) : Uri
._makeFileUri(path), Uri); | |
2187 } | |
2188 static get base() { | |
2189 let uri = _js_helper.Primitives.currentUri(); | |
2190 if (uri != null) return Uri.parse(uri); | |
2191 dart.throw(new UnsupportedError("'Uri.base' is not supported")); | |
2192 } | |
2193 static get _isWindows() { | |
2194 return false; | |
2195 } | |
2196 static _checkNonWindowsPathReservedCharacters(segments, argumentError) { | |
2197 segments[dartx.forEach](dart.fn(segment => { | |
2198 if (dart.notNull(segment[dartx.contains]("/"))) { | |
2199 if (dart.notNull(argumentError)) { | |
2200 dart.throw(new ArgumentError(`Illegal path character ${segment}`)); | |
2201 } else { | |
2202 dart.throw(new UnsupportedError(`Illegal path character ${segment}`)
); | |
2203 } | |
2204 } | |
2205 }, dart.void, [String])); | |
2206 } | |
2207 static _checkWindowsPathReservedCharacters(segments, argumentError, firstSeg
ment) { | |
2208 if (firstSegment === void 0) firstSegment = 0; | |
2209 segments[dartx.skip](firstSegment)[dartx.forEach](dart.fn(segment => { | |
2210 if (dart.notNull(segment[dartx.contains](RegExp.new('["*/:<>?\\\\|]'))))
{ | |
2211 if (dart.notNull(argumentError)) { | |
2212 dart.throw(new ArgumentError("Illegal character in path")); | |
2213 } else { | |
2214 dart.throw(new UnsupportedError("Illegal character in path")); | |
2215 } | |
2216 } | |
2217 }, dart.void, [String])); | |
2218 } | |
2219 static _checkWindowsDriveLetter(charCode, argumentError) { | |
2220 if (dart.notNull(Uri._UPPER_CASE_A) <= dart.notNull(charCode) && dart.notN
ull(charCode) <= dart.notNull(Uri._UPPER_CASE_Z) || dart.notNull(Uri._LOWER_CASE
_A) <= dart.notNull(charCode) && dart.notNull(charCode) <= dart.notNull(Uri._LOW
ER_CASE_Z)) { | |
2221 return; | |
2222 } | |
2223 if (dart.notNull(argumentError)) { | |
2224 dart.throw(new ArgumentError("Illegal drive letter " + String.fromCharCo
de(charCode))); | |
2225 } else { | |
2226 dart.throw(new UnsupportedError("Illegal drive letter " + String.fromCha
rCode(charCode))); | |
2227 } | |
2228 } | |
2229 static _makeFileUri(path) { | |
2230 let sep = "/"; | |
2231 if (dart.notNull(path[dartx.startsWith](sep))) { | |
2232 return Uri.new({scheme: "file", pathSegments: path[dartx.split](sep)}); | |
2233 } else { | |
2234 return Uri.new({pathSegments: path[dartx.split](sep)}); | |
2235 } | |
2236 } | |
2237 static _makeWindowsFileUrl(path) { | |
2238 if (dart.notNull(path[dartx.startsWith]("\\\\?\\"))) { | |
2239 if (dart.notNull(path[dartx.startsWith]("\\\\?\\UNC\\"))) { | |
2240 path = `\\${path[dartx.substring](7)}`; | |
2241 } else { | |
2242 path = path[dartx.substring](4); | |
2243 if (dart.notNull(path[dartx.length]) < 3 || path[dartx.codeUnitAt](1)
!= Uri._COLON || path[dartx.codeUnitAt](2) != Uri._BACKSLASH) { | |
2244 dart.throw(new ArgumentError("Windows paths with \\\\?\\ prefix must
be absolute")); | |
2245 } | |
2246 } | |
2247 } else { | |
2248 path = path[dartx.replaceAll]("/", "\\"); | |
2249 } | |
2250 let sep = "\\"; | |
2251 if (dart.notNull(path[dartx.length]) > 1 && path[dartx.get](1) == ":") { | |
2252 Uri._checkWindowsDriveLetter(path[dartx.codeUnitAt](0), true); | |
2253 if (path[dartx.length] == 2 || path[dartx.codeUnitAt](2) != Uri._BACKSLA
SH) { | |
2254 dart.throw(new ArgumentError("Windows paths with drive letter must be
absolute")); | |
2255 } | |
2256 let pathSegments = path[dartx.split](sep); | |
2257 Uri._checkWindowsPathReservedCharacters(pathSegments, true, 1); | |
2258 return Uri.new({scheme: "file", pathSegments: pathSegments}); | |
2259 } | |
2260 if (dart.notNull(path[dartx.length]) > 0 && path[dartx.get](0) == sep) { | |
2261 if (dart.notNull(path[dartx.length]) > 1 && path[dartx.get](1) == sep) { | |
2262 let pathStart = path[dartx.indexOf]("\\", 2); | |
2263 let hostPart = pathStart == -1 ? path[dartx.substring](2) : path[dartx
.substring](2, pathStart); | |
2264 let pathPart = pathStart == -1 ? "" : path[dartx.substring](dart.notNu
ll(pathStart) + 1); | |
2265 let pathSegments = pathPart[dartx.split](sep); | |
2266 Uri._checkWindowsPathReservedCharacters(pathSegments, true); | |
2267 return Uri.new({scheme: "file", host: hostPart, pathSegments: pathSegm
ents}); | |
2268 } else { | |
2269 let pathSegments = path[dartx.split](sep); | |
2270 Uri._checkWindowsPathReservedCharacters(pathSegments, true); | |
2271 return Uri.new({scheme: "file", pathSegments: pathSegments}); | |
2272 } | |
2273 } else { | |
2274 let pathSegments = path[dartx.split](sep); | |
2275 Uri._checkWindowsPathReservedCharacters(pathSegments, true); | |
2276 return Uri.new({pathSegments: pathSegments}); | |
2277 } | |
2278 } | |
2279 replace(opts) { | |
2280 let scheme = opts && 'scheme' in opts ? opts.scheme : null; | |
2281 let userInfo = opts && 'userInfo' in opts ? opts.userInfo : null; | |
2282 let host = opts && 'host' in opts ? opts.host : null; | |
2283 let port = opts && 'port' in opts ? opts.port : null; | |
2284 let path = opts && 'path' in opts ? opts.path : null; | |
2285 let pathSegments = opts && 'pathSegments' in opts ? opts.pathSegments : nu
ll; | |
2286 let query = opts && 'query' in opts ? opts.query : null; | |
2287 let queryParameters = opts && 'queryParameters' in opts ? opts.queryParame
ters : null; | |
2288 let fragment = opts && 'fragment' in opts ? opts.fragment : null; | |
2289 let schemeChanged = false; | |
2290 if (scheme != null) { | |
2291 scheme = Uri._makeScheme(scheme, scheme[dartx.length]); | |
2292 schemeChanged = true; | |
2293 } else { | |
2294 scheme = this.scheme; | |
2295 } | |
2296 let isFile = scheme == "file"; | |
2297 if (userInfo != null) { | |
2298 userInfo = Uri._makeUserInfo(userInfo, 0, userInfo[dartx.length]); | |
2299 } else { | |
2300 userInfo = this.userInfo; | |
2301 } | |
2302 if (port != null) { | |
2303 port = Uri._makePort(port, scheme); | |
2304 } else { | |
2305 port = dart.asInt(this[_port]); | |
2306 if (schemeChanged) { | |
2307 port = Uri._makePort(port, scheme); | |
2308 } | |
2309 } | |
2310 if (host != null) { | |
2311 host = Uri._makeHost(host, 0, host[dartx.length], false); | |
2312 } else if (dart.notNull(this.hasAuthority)) { | |
2313 host = this.host; | |
2314 } else if (dart.notNull(userInfo[dartx.isNotEmpty]) || port != null || isF
ile) { | |
2315 host = ""; | |
2316 } | |
2317 let ensureLeadingSlash = host != null; | |
2318 if (path != null || pathSegments != null) { | |
2319 path = Uri._makePath(path, 0, Uri._stringOrNullLength(path), pathSegment
s, ensureLeadingSlash, isFile); | |
2320 } else { | |
2321 path = this.path; | |
2322 if ((isFile || ensureLeadingSlash && !dart.notNull(path[dartx.isEmpty]))
&& !dart.notNull(path[dartx.startsWith]('/'))) { | |
2323 path = `/${path}`; | |
2324 } | |
2325 } | |
2326 if (query != null || queryParameters != null) { | |
2327 query = Uri._makeQuery(query, 0, Uri._stringOrNullLength(query), queryPa
rameters); | |
2328 } else if (dart.notNull(this.hasQuery)) { | |
2329 query = this.query; | |
2330 } | |
2331 if (fragment != null) { | |
2332 fragment = Uri._makeFragment(fragment, 0, fragment[dartx.length]); | |
2333 } else if (dart.notNull(this.hasFragment)) { | |
2334 fragment = this.fragment; | |
2335 } | |
2336 return new Uri._internal(scheme, userInfo, host, port, path, query, fragme
nt); | |
2337 } | |
2338 get pathSegments() { | |
2339 if (this[_pathSegments] == null) { | |
2340 let pathToSplit = !dart.notNull(this.path[dartx.isEmpty]) && this.path[d
artx.codeUnitAt](0) == Uri._SLASH ? this.path[dartx.substring](1) : this.path; | |
2341 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})); | |
2342 } | |
2343 return this[_pathSegments]; | |
2344 } | |
2345 get queryParameters() { | |
2346 if (this[_queryParameters] == null) { | |
2347 this[_queryParameters] = new (collection.UnmodifiableMapView$(String, St
ring))(Uri.splitQueryString(this.query)); | |
2348 } | |
2349 return this[_queryParameters]; | |
2350 } | |
2351 static _makePort(port, scheme) { | |
2352 if (port != null && port == Uri._defaultPort(scheme)) return null; | |
2353 return port; | |
2354 } | |
2355 static _makeHost(host, start, end, strictIPv6) { | |
2356 if (host == null) return null; | |
2357 if (start == end) return ""; | |
2358 if (host[dartx.codeUnitAt](start) == Uri._LEFT_BRACKET) { | |
2359 if (host[dartx.codeUnitAt](dart.notNull(end) - 1) != Uri._RIGHT_BRACKET)
{ | |
2360 Uri._fail(host, start, 'Missing end `]` to match `[` in host'); | |
2361 } | |
2362 Uri.parseIPv6Address(host, dart.notNull(start) + 1, dart.notNull(end) -
1); | |
2363 return host[dartx.substring](start, end)[dartx.toLowerCase](); | |
2364 } | |
2365 if (!dart.notNull(strictIPv6)) { | |
2366 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNul
l(i) + 1) { | |
2367 if (host[dartx.codeUnitAt](i) == Uri._COLON) { | |
2368 Uri.parseIPv6Address(host, start, end); | |
2369 return `[${host}]`; | |
2370 } | |
2371 } | |
2372 } | |
2373 return Uri._normalizeRegName(host, start, end); | |
2374 } | |
2375 static _isRegNameChar(char) { | |
2376 return dart.notNull(char) < 127 && (dart.notNull(Uri._regNameTable[dartx.g
et](dart.notNull(char) >> 4)) & 1 << (dart.notNull(char) & 15)) != 0; | |
2377 } | |
2378 static _normalizeRegName(host, start, end) { | |
2379 let buffer = null; | |
2380 let sectionStart = start; | |
2381 let index = start; | |
2382 let isNormalized = true; | |
2383 while (dart.notNull(index) < dart.notNull(end)) { | |
2384 let char = host[dartx.codeUnitAt](index); | |
2385 if (char == Uri._PERCENT) { | |
2386 let replacement = Uri._normalizeEscape(host, index, true); | |
2387 if (replacement == null && isNormalized) { | |
2388 index = dart.notNull(index) + 3; | |
2389 continue; | |
2390 } | |
2391 if (buffer == null) buffer = new StringBuffer(); | |
2392 let slice = host[dartx.substring](sectionStart, index); | |
2393 if (!isNormalized) slice = slice[dartx.toLowerCase](); | |
2394 buffer.write(slice); | |
2395 let sourceLength = 3; | |
2396 if (replacement == null) { | |
2397 replacement = host[dartx.substring](index, dart.notNull(index) + 3); | |
2398 } else if (replacement == "%") { | |
2399 replacement = "%25"; | |
2400 sourceLength = 1; | |
2401 } | |
2402 buffer.write(replacement); | |
2403 index = dart.notNull(index) + sourceLength; | |
2404 sectionStart = index; | |
2405 isNormalized = true; | |
2406 } else if (dart.notNull(Uri._isRegNameChar(char))) { | |
2407 if (isNormalized && dart.notNull(Uri._UPPER_CASE_A) <= dart.notNull(ch
ar) && dart.notNull(Uri._UPPER_CASE_Z) >= dart.notNull(char)) { | |
2408 if (buffer == null) buffer = new StringBuffer(); | |
2409 if (dart.notNull(sectionStart) < dart.notNull(index)) { | |
2410 buffer.write(host[dartx.substring](sectionStart, index)); | |
2411 sectionStart = index; | |
2412 } | |
2413 isNormalized = false; | |
2414 } | |
2415 index = dart.notNull(index) + 1; | |
2416 } else if (dart.notNull(Uri._isGeneralDelimiter(char))) { | |
2417 Uri._fail(host, index, "Invalid character"); | |
2418 } else { | |
2419 let sourceLength = 1; | |
2420 if ((dart.notNull(char) & 64512) == 55296 && dart.notNull(index) + 1 <
dart.notNull(end)) { | |
2421 let tail = host[dartx.codeUnitAt](dart.notNull(index) + 1); | |
2422 if ((dart.notNull(tail) & 64512) == 56320) { | |
2423 char = 65536 | (dart.notNull(char) & 1023) << 10 | dart.notNull(ta
il) & 1023; | |
2424 sourceLength = 2; | |
2425 } | |
2426 } | |
2427 if (buffer == null) buffer = new StringBuffer(); | |
2428 let slice = host[dartx.substring](sectionStart, index); | |
2429 if (!isNormalized) slice = slice[dartx.toLowerCase](); | |
2430 buffer.write(slice); | |
2431 buffer.write(Uri._escapeChar(char)); | |
2432 index = dart.notNull(index) + sourceLength; | |
2433 sectionStart = index; | |
2434 } | |
2435 } | |
2436 if (buffer == null) return host[dartx.substring](start, end); | |
2437 if (dart.notNull(sectionStart) < dart.notNull(end)) { | |
2438 let slice = host[dartx.substring](sectionStart, end); | |
2439 if (!isNormalized) slice = slice[dartx.toLowerCase](); | |
2440 buffer.write(slice); | |
2441 } | |
2442 return dart.toString(buffer); | |
2443 } | |
2444 static _makeScheme(scheme, end) { | |
2445 if (end == 0) return ""; | |
2446 let firstCodeUnit = scheme[dartx.codeUnitAt](0); | |
2447 if (!dart.notNull(Uri._isAlphabeticCharacter(firstCodeUnit))) { | |
2448 Uri._fail(scheme, 0, "Scheme not starting with alphabetic character"); | |
2449 } | |
2450 let allLowercase = dart.notNull(firstCodeUnit) >= dart.notNull(Uri._LOWER_
CASE_A); | |
2451 for (let i = 0; i < dart.notNull(end); i++) { | |
2452 let codeUnit = scheme[dartx.codeUnitAt](i); | |
2453 if (!dart.notNull(Uri._isSchemeCharacter(codeUnit))) { | |
2454 Uri._fail(scheme, i, "Illegal scheme character"); | |
2455 } | |
2456 if (dart.notNull(codeUnit) < dart.notNull(Uri._LOWER_CASE_A) || dart.not
Null(codeUnit) > dart.notNull(Uri._LOWER_CASE_Z)) { | |
2457 allLowercase = false; | |
2458 } | |
2459 } | |
2460 scheme = scheme[dartx.substring](0, end); | |
2461 if (!allLowercase) scheme = scheme[dartx.toLowerCase](); | |
2462 return scheme; | |
2463 } | |
2464 static _makeUserInfo(userInfo, start, end) { | |
2465 if (userInfo == null) return ""; | |
2466 return Uri._normalize(userInfo, start, end, Uri._userinfoTable); | |
2467 } | |
2468 static _makePath(path, start, end, pathSegments, ensureLeadingSlash, isFile)
{ | |
2469 if (path == null && pathSegments == null) return dart.notNull(isFile) ? "/
" : ""; | |
2470 if (path != null && pathSegments != null) { | |
2471 dart.throw(new ArgumentError('Both path and pathSegments specified')); | |
2472 } | |
2473 let result = null; | |
2474 if (path != null) { | |
2475 result = Uri._normalize(path, start, end, Uri._pathCharOrSlashTable); | |
2476 } else { | |
2477 result = pathSegments[dartx.map](dart.fn(s => Uri._uriEncode(Uri._pathCh
arTable, s), String, [String]))[dartx.join]("/"); | |
2478 } | |
2479 if (dart.notNull(dart.as(dart.dload(result, 'isEmpty'), bool))) { | |
2480 if (dart.notNull(isFile)) return "/"; | |
2481 } else if ((dart.notNull(isFile) || dart.notNull(ensureLeadingSlash)) && !
dart.equals(dart.dsend(result, 'codeUnitAt', 0), Uri._SLASH)) { | |
2482 return `/${result}`; | |
2483 } | |
2484 return dart.as(result, String); | |
2485 } | |
2486 static _makeQuery(query, start, end, queryParameters) { | |
2487 if (query == null && queryParameters == null) return null; | |
2488 if (query != null && queryParameters != null) { | |
2489 dart.throw(new ArgumentError('Both query and queryParameters specified')
); | |
2490 } | |
2491 if (query != null) return Uri._normalize(query, start, end, Uri._queryChar
Table); | |
2492 let result = new StringBuffer(); | |
2493 let first = true; | |
2494 queryParameters[dartx.forEach](dart.fn((key, value) => { | |
2495 if (!first) { | |
2496 result.write("&"); | |
2497 } | |
2498 first = false; | |
2499 result.write(Uri.encodeQueryComponent(key)); | |
2500 if (value != null && !dart.notNull(value[dartx.isEmpty])) { | |
2501 result.write("="); | |
2502 result.write(Uri.encodeQueryComponent(value)); | |
2503 } | |
2504 }, dart.void, [String, String])); | |
2505 return result.toString(); | |
2506 } | |
2507 static _makeFragment(fragment, start, end) { | |
2508 if (fragment == null) return null; | |
2509 return Uri._normalize(fragment, start, end, Uri._queryCharTable); | |
2510 } | |
2511 static _stringOrNullLength(s) { | |
2512 return s == null ? 0 : s[dartx.length]; | |
2513 } | |
2514 static _isHexDigit(char) { | |
2515 if (dart.notNull(Uri._NINE) >= dart.notNull(char)) return dart.notNull(Uri
._ZERO) <= dart.notNull(char); | |
2516 char = dart.notNull(char) | 32; | |
2517 return dart.notNull(Uri._LOWER_CASE_A) <= dart.notNull(char) && dart.notNu
ll(Uri._LOWER_CASE_F) >= dart.notNull(char); | |
2518 } | |
2519 static _hexValue(char) { | |
2520 dart.assert(Uri._isHexDigit(char)); | |
2521 if (dart.notNull(Uri._NINE) >= dart.notNull(char)) return dart.notNull(cha
r) - dart.notNull(Uri._ZERO); | |
2522 char = dart.notNull(char) | 32; | |
2523 return dart.notNull(char) - (dart.notNull(Uri._LOWER_CASE_A) - 10); | |
2524 } | |
2525 static _normalizeEscape(source, index, lowerCase) { | |
2526 dart.assert(source[dartx.codeUnitAt](index) == Uri._PERCENT); | |
2527 if (dart.notNull(index) + 2 >= dart.notNull(source[dartx.length])) { | |
2528 return "%"; | |
2529 } | |
2530 let firstDigit = source[dartx.codeUnitAt](dart.notNull(index) + 1); | |
2531 let secondDigit = source[dartx.codeUnitAt](dart.notNull(index) + 2); | |
2532 if (!dart.notNull(Uri._isHexDigit(firstDigit)) || !dart.notNull(Uri._isHex
Digit(secondDigit))) { | |
2533 return "%"; | |
2534 } | |
2535 let value = dart.notNull(Uri._hexValue(firstDigit)) * 16 + dart.notNull(Ur
i._hexValue(secondDigit)); | |
2536 if (dart.notNull(Uri._isUnreservedChar(value))) { | |
2537 if (dart.notNull(lowerCase) && dart.notNull(Uri._UPPER_CASE_A) <= value
&& dart.notNull(Uri._UPPER_CASE_Z) >= value) { | |
2538 value = value | 32; | |
2539 } | |
2540 return String.fromCharCode(value); | |
2541 } | |
2542 if (dart.notNull(firstDigit) >= dart.notNull(Uri._LOWER_CASE_A) || dart.no
tNull(secondDigit) >= dart.notNull(Uri._LOWER_CASE_A)) { | |
2543 return source[dartx.substring](index, dart.notNull(index) + 3)[dartx.toU
pperCase](); | |
2544 } | |
2545 return null; | |
2546 } | |
2547 static _isUnreservedChar(ch) { | |
2548 return dart.notNull(ch) < 127 && (dart.notNull(Uri._unreservedTable[dartx.
get](dart.notNull(ch) >> 4)) & 1 << (dart.notNull(ch) & 15)) != 0; | |
2549 } | |
2550 static _escapeChar(char) { | |
2551 dart.assert(dart.dsend(char, '<=', 1114111)); | |
2552 let hexDigits = "0123456789ABCDEF"; | |
2553 let codeUnits = null; | |
2554 if (dart.notNull(dart.as(dart.dsend(char, '<', 128), bool))) { | |
2555 codeUnits = List.new(3); | |
2556 codeUnits[dartx.set](0, Uri._PERCENT); | |
2557 codeUnits[dartx.set](1, hexDigits[dartx.codeUnitAt](dart.as(dart.dsend(c
har, '>>', 4), int))); | |
2558 codeUnits[dartx.set](2, hexDigits[dartx.codeUnitAt](dart.as(dart.dsend(c
har, '&', 15), int))); | |
2559 } else { | |
2560 let flag = 192; | |
2561 let encodedBytes = 2; | |
2562 if (dart.notNull(dart.as(dart.dsend(char, '>', 2047), bool))) { | |
2563 flag = 224; | |
2564 encodedBytes = 3; | |
2565 if (dart.notNull(dart.as(dart.dsend(char, '>', 65535), bool))) { | |
2566 encodedBytes = 4; | |
2567 flag = 240; | |
2568 } | |
2569 } | |
2570 codeUnits = List.new(3 * encodedBytes); | |
2571 let index = 0; | |
2572 while (--encodedBytes >= 0) { | |
2573 let byte = dart.as(dart.dsend(dart.dsend(dart.dsend(char, '>>', 6 * en
codedBytes), '&', 63), '|', flag), int); | |
2574 codeUnits[dartx.set](index, Uri._PERCENT); | |
2575 codeUnits[dartx.set](index + 1, hexDigits[dartx.codeUnitAt](dart.notNu
ll(byte) >> 4)); | |
2576 codeUnits[dartx.set](index + 2, hexDigits[dartx.codeUnitAt](dart.notNu
ll(byte) & 15)); | |
2577 index = index + 3; | |
2578 flag = 128; | |
2579 } | |
2580 } | |
2581 return String.fromCharCodes(dart.as(codeUnits, Iterable$(int))); | |
2582 } | |
2583 static _normalize(component, start, end, charTable) { | |
2584 let buffer = null; | |
2585 let sectionStart = start; | |
2586 let index = start; | |
2587 while (dart.notNull(index) < dart.notNull(end)) { | |
2588 let char = component[dartx.codeUnitAt](index); | |
2589 if (dart.notNull(char) < 127 && (dart.notNull(charTable[dartx.get](dart.
notNull(char) >> 4)) & 1 << (dart.notNull(char) & 15)) != 0) { | |
2590 index = dart.notNull(index) + 1; | |
2591 } else { | |
2592 let replacement = null; | |
2593 let sourceLength = null; | |
2594 if (char == Uri._PERCENT) { | |
2595 replacement = Uri._normalizeEscape(component, index, false); | |
2596 if (replacement == null) { | |
2597 index = dart.notNull(index) + 3; | |
2598 continue; | |
2599 } | |
2600 if ("%" == replacement) { | |
2601 replacement = "%25"; | |
2602 sourceLength = 1; | |
2603 } else { | |
2604 sourceLength = 3; | |
2605 } | |
2606 } else if (dart.notNull(Uri._isGeneralDelimiter(char))) { | |
2607 Uri._fail(component, index, "Invalid character"); | |
2608 } else { | |
2609 sourceLength = 1; | |
2610 if ((dart.notNull(char) & 64512) == 55296) { | |
2611 if (dart.notNull(index) + 1 < dart.notNull(end)) { | |
2612 let tail = component[dartx.codeUnitAt](dart.notNull(index) + 1); | |
2613 if ((dart.notNull(tail) & 64512) == 56320) { | |
2614 sourceLength = 2; | |
2615 char = 65536 | (dart.notNull(char) & 1023) << 10 | dart.notNul
l(tail) & 1023; | |
2616 } | |
2617 } | |
2618 } | |
2619 replacement = Uri._escapeChar(char); | |
2620 } | |
2621 if (buffer == null) buffer = new StringBuffer(); | |
2622 buffer.write(component[dartx.substring](sectionStart, index)); | |
2623 buffer.write(replacement); | |
2624 index = dart.notNull(index) + dart.notNull(sourceLength); | |
2625 sectionStart = index; | |
2626 } | |
2627 } | |
2628 if (buffer == null) { | |
2629 return component[dartx.substring](start, end); | |
2630 } | |
2631 if (dart.notNull(sectionStart) < dart.notNull(end)) { | |
2632 buffer.write(component[dartx.substring](sectionStart, end)); | |
2633 } | |
2634 return dart.toString(buffer); | |
2635 } | |
2636 static _isSchemeCharacter(ch) { | |
2637 return dart.notNull(ch) < 128 && (dart.notNull(Uri._schemeTable[dartx.get]
(dart.notNull(ch) >> 4)) & 1 << (dart.notNull(ch) & 15)) != 0; | |
2638 } | |
2639 static _isGeneralDelimiter(ch) { | |
2640 return dart.notNull(ch) <= dart.notNull(Uri._RIGHT_BRACKET) && (dart.notNu
ll(Uri._genDelimitersTable[dartx.get](dart.notNull(ch) >> 4)) & 1 << (dart.notNu
ll(ch) & 15)) != 0; | |
2641 } | |
2642 get isAbsolute() { | |
2643 return this.scheme != "" && this.fragment == ""; | |
2644 } | |
2645 [_merge](base, reference) { | |
2646 if (dart.notNull(base[dartx.isEmpty])) return `/${reference}`; | |
2647 let backCount = 0; | |
2648 let refStart = 0; | |
2649 while (dart.notNull(reference[dartx.startsWith]("../", refStart))) { | |
2650 refStart = refStart + 3; | |
2651 backCount++; | |
2652 } | |
2653 let baseEnd = base[dartx.lastIndexOf]('/'); | |
2654 while (dart.notNull(baseEnd) > 0 && backCount > 0) { | |
2655 let newEnd = base[dartx.lastIndexOf]('/', dart.notNull(baseEnd) - 1); | |
2656 if (dart.notNull(newEnd) < 0) { | |
2657 break; | |
2658 } | |
2659 let delta = dart.notNull(baseEnd) - dart.notNull(newEnd); | |
2660 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)) { | |
2661 break; | |
2662 } | |
2663 baseEnd = newEnd; | |
2664 backCount--; | |
2665 } | |
2666 return dart.notNull(base[dartx.substring](0, dart.notNull(baseEnd) + 1)) +
dart.notNull(reference[dartx.substring](refStart - 3 * backCount)); | |
2667 } | |
2668 [_hasDotSegments](path) { | |
2669 if (dart.notNull(path[dartx.length]) > 0 && path[dartx.codeUnitAt](0) == U
ri._DOT) return true; | |
2670 let index = path[dartx.indexOf]("/."); | |
2671 return index != -1; | |
2672 } | |
2673 [_removeDotSegments](path) { | |
2674 if (!dart.notNull(this[_hasDotSegments](path))) return path; | |
2675 let output = dart.list([], String); | |
2676 let appendSlash = false; | |
2677 for (let segment of path[dartx.split]("/")) { | |
2678 appendSlash = false; | |
2679 if (segment == "..") { | |
2680 if (!dart.notNull(output[dartx.isEmpty]) && (output[dartx.length] != 1
|| output[dartx.get](0) != "")) output[dartx.removeLast](); | |
2681 appendSlash = true; | |
2682 } else if ("." == segment) { | |
2683 appendSlash = true; | |
2684 } else { | |
2685 output[dartx.add](segment); | |
2686 } | |
2687 } | |
2688 if (appendSlash) output[dartx.add](""); | |
2689 return output[dartx.join]("/"); | |
2690 } | |
2691 resolve(reference) { | |
2692 return this.resolveUri(Uri.parse(reference)); | |
2693 } | |
2694 resolveUri(reference) { | |
2695 let targetScheme = null; | |
2696 let targetUserInfo = ""; | |
2697 let targetHost = null; | |
2698 let targetPort = null; | |
2699 let targetPath = null; | |
2700 let targetQuery = null; | |
2701 if (dart.notNull(reference.scheme[dartx.isNotEmpty])) { | |
2702 targetScheme = reference.scheme; | |
2703 if (dart.notNull(reference.hasAuthority)) { | |
2704 targetUserInfo = reference.userInfo; | |
2705 targetHost = reference.host; | |
2706 targetPort = dart.notNull(reference.hasPort) ? reference.port : null; | |
2707 } | |
2708 targetPath = this[_removeDotSegments](reference.path); | |
2709 if (dart.notNull(reference.hasQuery)) { | |
2710 targetQuery = reference.query; | |
2711 } | |
2712 } else { | |
2713 targetScheme = this.scheme; | |
2714 if (dart.notNull(reference.hasAuthority)) { | |
2715 targetUserInfo = reference.userInfo; | |
2716 targetHost = reference.host; | |
2717 targetPort = Uri._makePort(dart.notNull(reference.hasPort) ? reference
.port : null, targetScheme); | |
2718 targetPath = this[_removeDotSegments](reference.path); | |
2719 if (dart.notNull(reference.hasQuery)) targetQuery = reference.query; | |
2720 } else { | |
2721 if (reference.path == "") { | |
2722 targetPath = this[_path]; | |
2723 if (dart.notNull(reference.hasQuery)) { | |
2724 targetQuery = reference.query; | |
2725 } else { | |
2726 targetQuery = this[_query]; | |
2727 } | |
2728 } else { | |
2729 if (dart.notNull(reference.path[dartx.startsWith]("/"))) { | |
2730 targetPath = this[_removeDotSegments](reference.path); | |
2731 } else { | |
2732 targetPath = this[_removeDotSegments](this[_merge](this[_path], re
ference.path)); | |
2733 } | |
2734 if (dart.notNull(reference.hasQuery)) targetQuery = reference.query; | |
2735 } | |
2736 targetUserInfo = this[_userInfo]; | |
2737 targetHost = this[_host]; | |
2738 targetPort = dart.asInt(this[_port]); | |
2739 } | |
2740 } | |
2741 let fragment = dart.notNull(reference.hasFragment) ? reference.fragment :
null; | |
2742 return new Uri._internal(targetScheme, targetUserInfo, targetHost, targetP
ort, targetPath, targetQuery, fragment); | |
2743 } | |
2744 get hasAuthority() { | |
2745 return this[_host] != null; | |
2746 } | |
2747 get hasPort() { | |
2748 return this[_port] != null; | |
2749 } | |
2750 get hasQuery() { | |
2751 return this[_query] != null; | |
2752 } | |
2753 get hasFragment() { | |
2754 return this[_fragment] != null; | |
2755 } | |
2756 get origin() { | |
2757 if (this.scheme == "" || this[_host] == null || this[_host] == "") { | |
2758 dart.throw(new StateError(`Cannot use origin without a scheme: ${this}`)
); | |
2759 } | |
2760 if (this.scheme != "http" && this.scheme != "https") { | |
2761 dart.throw(new StateError(`Origin is only applicable schemes http and ht
tps: ${this}`)); | |
2762 } | |
2763 if (this[_port] == null) return `${this.scheme}://${this[_host]}`; | |
2764 return `${this.scheme}://${this[_host]}:${this[_port]}`; | |
2765 } | |
2766 toFilePath(opts) { | |
2767 let windows = opts && 'windows' in opts ? opts.windows : null; | |
2768 if (this.scheme != "" && this.scheme != "file") { | |
2769 dart.throw(new UnsupportedError(`Cannot extract a file path from a ${thi
s.scheme} URI`)); | |
2770 } | |
2771 if (this.query != "") { | |
2772 dart.throw(new UnsupportedError("Cannot extract a file path from a URI w
ith a query component")); | |
2773 } | |
2774 if (this.fragment != "") { | |
2775 dart.throw(new UnsupportedError("Cannot extract a file path from a URI w
ith a fragment component")); | |
2776 } | |
2777 if (windows == null) windows = Uri._isWindows; | |
2778 return dart.notNull(windows) ? this[_toWindowsFilePath]() : this[_toFilePa
th](); | |
2779 } | |
2780 [_toFilePath]() { | |
2781 if (this.host != "") { | |
2782 dart.throw(new UnsupportedError("Cannot extract a non-Windows file path
from a file URI " + "with an authority")); | |
2783 } | |
2784 Uri._checkNonWindowsPathReservedCharacters(this.pathSegments, false); | |
2785 let result = new StringBuffer(); | |
2786 if (dart.notNull(this[_isPathAbsolute])) result.write("/"); | |
2787 result.writeAll(this.pathSegments, "/"); | |
2788 return result.toString(); | |
2789 } | |
2790 [_toWindowsFilePath]() { | |
2791 let hasDriveLetter = false; | |
2792 let segments = this.pathSegments; | |
2793 if (dart.notNull(segments[dartx.length]) > 0 && segments[dartx.get](0)[dar
tx.length] == 2 && segments[dartx.get](0)[dartx.codeUnitAt](1) == Uri._COLON) { | |
2794 Uri._checkWindowsDriveLetter(segments[dartx.get](0)[dartx.codeUnitAt](0)
, false); | |
2795 Uri._checkWindowsPathReservedCharacters(segments, false, 1); | |
2796 hasDriveLetter = true; | |
2797 } else { | |
2798 Uri._checkWindowsPathReservedCharacters(segments, false); | |
2799 } | |
2800 let result = new StringBuffer(); | |
2801 if (dart.notNull(this[_isPathAbsolute]) && !hasDriveLetter) result.write("
\\"); | |
2802 if (this.host != "") { | |
2803 result.write("\\"); | |
2804 result.write(this.host); | |
2805 result.write("\\"); | |
2806 } | |
2807 result.writeAll(segments, "\\"); | |
2808 if (hasDriveLetter && segments[dartx.length] == 1) result.write("\\"); | |
2809 return result.toString(); | |
2810 } | |
2811 get [_isPathAbsolute]() { | |
2812 if (this.path == null || dart.notNull(this.path[dartx.isEmpty])) return fa
lse; | |
2813 return this.path[dartx.startsWith]('/'); | |
2814 } | |
2815 [_writeAuthority](ss) { | |
2816 if (dart.notNull(this[_userInfo][dartx.isNotEmpty])) { | |
2817 ss.write(this[_userInfo]); | |
2818 ss.write("@"); | |
2819 } | |
2820 if (this[_host] != null) ss.write(this[_host]); | |
2821 if (this[_port] != null) { | |
2822 ss.write(":"); | |
2823 ss.write(this[_port]); | |
2824 } | |
2825 } | |
2826 toString() { | |
2827 let sb = new StringBuffer(); | |
2828 Uri._addIfNonEmpty(sb, this.scheme, this.scheme, ':'); | |
2829 if (dart.notNull(this.hasAuthority) || dart.notNull(this.path[dartx.starts
With]("//")) || this.scheme == "file") { | |
2830 sb.write("//"); | |
2831 this[_writeAuthority](sb); | |
2832 } | |
2833 sb.write(this.path); | |
2834 if (this[_query] != null) { | |
2835 sb.write("?"); | |
2836 sb.write(this[_query]); | |
2837 } | |
2838 if (this[_fragment] != null) { | |
2839 sb.write("#"); | |
2840 sb.write(this[_fragment]); | |
2841 } | |
2842 return sb.toString(); | |
2843 } | |
2844 ['=='](other) { | |
2845 if (!dart.is(other, Uri)) return false; | |
2846 let uri = dart.as(other, Uri); | |
2847 return this.scheme == uri.scheme && this.hasAuthority == uri.hasAuthority
&& this.userInfo == uri.userInfo && this.host == uri.host && this.port == uri.po
rt && this.path == uri.path && this.hasQuery == uri.hasQuery && this.query == ur
i.query && this.hasFragment == uri.hasFragment && this.fragment == uri.fragment; | |
2848 } | |
2849 get hashCode() { | |
2850 function combine(part, current) { | |
2851 return dart.as(dart.dsend(dart.dsend(dart.dsend(current, '*', 31), '+',
dart.hashCode(part)), '&', 1073741823), int); | |
2852 } | |
2853 dart.fn(combine, int, [dart.dynamic, dart.dynamic]); | |
2854 return combine(this.scheme, combine(this.userInfo, combine(this.host, comb
ine(this.port, combine(this.path, combine(this.query, combine(this.fragment, 1))
))))); | |
2855 } | |
2856 static _addIfNonEmpty(sb, test, first, second) { | |
2857 if ("" != test) { | |
2858 sb.write(first); | |
2859 sb.write(second); | |
2860 } | |
2861 } | |
2862 static encodeComponent(component) { | |
2863 return Uri._uriEncode(Uri._unreserved2396Table, component); | |
2864 } | |
2865 static encodeQueryComponent(component, opts) { | |
2866 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8; | |
2867 return Uri._uriEncode(Uri._unreservedTable, component, {encoding: encoding
, spaceToPlus: true}); | |
2868 } | |
2869 static decodeComponent(encodedComponent) { | |
2870 return Uri._uriDecode(encodedComponent); | |
2871 } | |
2872 static decodeQueryComponent(encodedComponent, opts) { | |
2873 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8; | |
2874 return Uri._uriDecode(encodedComponent, {plusToSpace: true, encoding: enco
ding}); | |
2875 } | |
2876 static encodeFull(uri) { | |
2877 return Uri._uriEncode(Uri._encodeFullTable, uri); | |
2878 } | |
2879 static decodeFull(uri) { | |
2880 return Uri._uriDecode(uri); | |
2881 } | |
2882 static splitQueryString(query, opts) { | |
2883 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8; | |
2884 return query[dartx.split]("&")[dartx.fold](dart.map(), dart.fn((map, eleme
nt) => { | |
2885 let index = element[dartx.indexOf]("="); | |
2886 if (index == -1) { | |
2887 if (element != "") { | |
2888 map[dartx.set](Uri.decodeQueryComponent(element, {encoding: encoding
}), ""); | |
2889 } | |
2890 } else if (index != 0) { | |
2891 let key = element[dartx.substring](0, index); | |
2892 let value = element[dartx.substring](dart.notNull(index) + 1); | |
2893 map[dartx.set](Uri.decodeQueryComponent(key, {encoding: encoding}), Ur
i.decodeQueryComponent(value, {encoding: encoding})); | |
2894 } | |
2895 return map; | |
2896 }, Map$(String, String), [Map$(String, String), String])); | |
2897 } | |
2898 static parseIPv4Address(host) { | |
2899 function error(msg) { | |
2900 dart.throw(new FormatException(`Illegal IPv4 address, ${msg}`)); | |
2901 } | |
2902 dart.fn(error, dart.void, [String]); | |
2903 let bytes = host[dartx.split]('.'); | |
2904 if (bytes[dartx.length] != 4) { | |
2905 error('IPv4 address should contain exactly 4 parts'); | |
2906 } | |
2907 return bytes[dartx.map](dart.fn(byteString => { | |
2908 let byte = int.parse(byteString); | |
2909 if (dart.notNull(byte) < 0 || dart.notNull(byte) > 255) { | |
2910 error('each part must be in the range of `0..255`'); | |
2911 } | |
2912 return byte; | |
2913 }, int, [String]))[dartx.toList](); | |
2914 } | |
2915 static parseIPv6Address(host, start, end) { | |
2916 if (start === void 0) start = 0; | |
2917 if (end === void 0) end = null; | |
2918 if (end == null) end = host[dartx.length]; | |
2919 function error(msg, position) { | |
2920 if (position === void 0) position = null; | |
2921 dart.throw(new FormatException(`Illegal IPv6 address, ${msg}`, host, dar
t.as(position, int))); | |
2922 } | |
2923 dart.fn(error, dart.void, [String], [dart.dynamic]); | |
2924 function parseHex(start, end) { | |
2925 if (dart.notNull(end) - dart.notNull(start) > 4) { | |
2926 error('an IPv6 part can only contain a maximum of 4 hex digits', start
); | |
2927 } | |
2928 let value = int.parse(host[dartx.substring](start, end), {radix: 16}); | |
2929 if (dart.notNull(value) < 0 || dart.notNull(value) > (1 << 16) - 1) { | |
2930 error('each part must be in the range of `0x0..0xFFFF`', start); | |
2931 } | |
2932 return value; | |
2933 } | |
2934 dart.fn(parseHex, int, [int, int]); | |
2935 if (dart.notNull(host[dartx.length]) < 2) error('address is too short'); | |
2936 let parts = dart.list([], int); | |
2937 let wildcardSeen = false; | |
2938 let partStart = start; | |
2939 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull(
i) + 1) { | |
2940 if (host[dartx.codeUnitAt](i) == Uri._COLON) { | |
2941 if (i == start) { | |
2942 i = dart.notNull(i) + 1; | |
2943 if (host[dartx.codeUnitAt](i) != Uri._COLON) { | |
2944 error('invalid start colon.', i); | |
2945 } | |
2946 partStart = i; | |
2947 } | |
2948 if (i == partStart) { | |
2949 if (wildcardSeen) { | |
2950 error('only one wildcard `::` is allowed', i); | |
2951 } | |
2952 wildcardSeen = true; | |
2953 parts[dartx.add](-1); | |
2954 } else { | |
2955 parts[dartx.add](parseHex(partStart, i)); | |
2956 } | |
2957 partStart = dart.notNull(i) + 1; | |
2958 } | |
2959 } | |
2960 if (parts[dartx.length] == 0) error('too few parts'); | |
2961 let atEnd = partStart == end; | |
2962 let isLastWildcard = parts[dartx.last] == -1; | |
2963 if (atEnd && !isLastWildcard) { | |
2964 error('expected a part after last `:`', end); | |
2965 } | |
2966 if (!atEnd) { | |
2967 try { | |
2968 parts[dartx.add](parseHex(partStart, end)); | |
2969 } catch (e) { | |
2970 try { | |
2971 let last = Uri.parseIPv4Address(host[dartx.substring](partStart, end
)); | |
2972 parts[dartx.add](dart.notNull(last[dartx.get](0)) << 8 | dart.notNul
l(last[dartx.get](1))); | |
2973 parts[dartx.add](dart.notNull(last[dartx.get](2)) << 8 | dart.notNul
l(last[dartx.get](3))); | |
2974 } catch (e) { | |
2975 error('invalid end of IPv6 address.', partStart); | |
2976 } | |
2977 | |
2978 } | |
2979 | |
2980 } | |
2981 if (wildcardSeen) { | |
2982 if (dart.notNull(parts[dartx.length]) > 7) { | |
2983 error('an address with a wildcard must have less than 7 parts'); | |
2984 } | |
2985 } else if (parts[dartx.length] != 8) { | |
2986 error('an address without a wildcard must contain exactly 8 parts'); | |
2987 } | |
2988 let bytes = List$(int).new(16); | |
2989 for (let i = 0, index = 0; i < dart.notNull(parts[dartx.length]); i++) { | |
2990 let value = parts[dartx.get](i); | |
2991 if (value == -1) { | |
2992 let wildCardLength = 9 - dart.notNull(parts[dartx.length]); | |
2993 for (let j = 0; j < wildCardLength; j++) { | |
2994 bytes[dartx.set](index, 0); | |
2995 bytes[dartx.set](index + 1, 0); | |
2996 index = index + 2; | |
2997 } | |
2998 } else { | |
2999 bytes[dartx.set](index, dart.notNull(value) >> 8); | |
3000 bytes[dartx.set](index + 1, dart.notNull(value) & 255); | |
3001 index = index + 2; | |
3002 } | |
3003 } | |
3004 return dart.as(bytes, List$(int)); | |
3005 } | |
3006 static _uriEncode(canonicalTable, text, opts) { | |
3007 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8; | |
3008 let spaceToPlus = opts && 'spaceToPlus' in opts ? opts.spaceToPlus : false
; | |
3009 function byteToHex(byte, buffer) { | |
3010 let hex = '0123456789ABCDEF'; | |
3011 dart.dsend(buffer, 'writeCharCode', hex[dartx.codeUnitAt](dart.as(dart.d
send(byte, '>>', 4), int))); | |
3012 dart.dsend(buffer, 'writeCharCode', hex[dartx.codeUnitAt](dart.as(dart.d
send(byte, '&', 15), int))); | |
3013 } | |
3014 dart.fn(byteToHex); | |
3015 let result = new StringBuffer(); | |
3016 let bytes = encoding.encode(text); | |
3017 for (let i = 0; i < dart.notNull(bytes[dartx.length]); i++) { | |
3018 let byte = bytes[dartx.get](i); | |
3019 if (dart.notNull(byte) < 128 && (dart.notNull(canonicalTable[dartx.get](
dart.notNull(byte) >> 4)) & 1 << (dart.notNull(byte) & 15)) != 0) { | |
3020 result.writeCharCode(byte); | |
3021 } else if (dart.notNull(spaceToPlus) && byte == Uri._SPACE) { | |
3022 result.writeCharCode(Uri._PLUS); | |
3023 } else { | |
3024 result.writeCharCode(Uri._PERCENT); | |
3025 byteToHex(byte, result); | |
3026 } | |
3027 } | |
3028 return result.toString(); | |
3029 } | |
3030 static _hexCharPairToByte(s, pos) { | |
3031 let byte = 0; | |
3032 for (let i = 0; i < 2; i++) { | |
3033 let charCode = s[dartx.codeUnitAt](dart.notNull(pos) + i); | |
3034 if (48 <= dart.notNull(charCode) && dart.notNull(charCode) <= 57) { | |
3035 byte = byte * 16 + dart.notNull(charCode) - 48; | |
3036 } else { | |
3037 charCode = dart.notNull(charCode) | 32; | |
3038 if (97 <= dart.notNull(charCode) && dart.notNull(charCode) <= 102) { | |
3039 byte = byte * 16 + dart.notNull(charCode) - 87; | |
3040 } else { | |
3041 dart.throw(new ArgumentError("Invalid URL encoding")); | |
3042 } | |
3043 } | |
3044 } | |
3045 return byte; | |
3046 } | |
3047 static _uriDecode(text, opts) { | |
3048 let plusToSpace = opts && 'plusToSpace' in opts ? opts.plusToSpace : false
; | |
3049 let encoding = opts && 'encoding' in opts ? opts.encoding : convert.UTF8; | |
3050 let simple = true; | |
3051 for (let i = 0; i < dart.notNull(text[dartx.length]) && simple; i++) { | |
3052 let codeUnit = text[dartx.codeUnitAt](i); | |
3053 simple = codeUnit != Uri._PERCENT && codeUnit != Uri._PLUS; | |
3054 } | |
3055 let bytes = null; | |
3056 if (simple) { | |
3057 if (dart.equals(encoding, convert.UTF8) || dart.equals(encoding, convert
.LATIN1)) { | |
3058 return text; | |
3059 } else { | |
3060 bytes = text[dartx.codeUnits]; | |
3061 } | |
3062 } else { | |
3063 bytes = List$(int).new(); | |
3064 for (let i = 0; i < dart.notNull(text[dartx.length]); i++) { | |
3065 let codeUnit = text[dartx.codeUnitAt](i); | |
3066 if (dart.notNull(codeUnit) > 127) { | |
3067 dart.throw(new ArgumentError("Illegal percent encoding in URI")); | |
3068 } | |
3069 if (codeUnit == Uri._PERCENT) { | |
3070 if (i + 3 > dart.notNull(text[dartx.length])) { | |
3071 dart.throw(new ArgumentError('Truncated URI')); | |
3072 } | |
3073 bytes[dartx.add](Uri._hexCharPairToByte(text, i + 1)); | |
3074 i = i + 2; | |
3075 } else if (dart.notNull(plusToSpace) && codeUnit == Uri._PLUS) { | |
3076 bytes[dartx.add](Uri._SPACE); | |
3077 } else { | |
3078 bytes[dartx.add](codeUnit); | |
3079 } | |
3080 } | |
3081 } | |
3082 return encoding.decode(bytes); | |
3083 } | |
3084 static _isAlphabeticCharacter(codeUnit) { | |
3085 return dart.notNull(codeUnit) >= dart.notNull(Uri._LOWER_CASE_A) && dart.n
otNull(codeUnit) <= dart.notNull(Uri._LOWER_CASE_Z) || dart.notNull(codeUnit) >=
dart.notNull(Uri._UPPER_CASE_A) && dart.notNull(codeUnit) <= dart.notNull(Uri._
UPPER_CASE_Z); | |
3086 } | |
3087 } | |
3088 dart.defineNamedConstructor(Uri, '_internal'); | |
3089 dart.setSignature(Uri, { | |
3090 constructors: () => ({ | |
3091 _internal: [Uri, [String, String, String, num, String, String, String]], | |
3092 new: [Uri, [], {scheme: String, userInfo: String, host: String, port: int,
path: String, pathSegments: Iterable$(String), query: String, queryParameters:
Map$(String, String), fragment: String}], | |
3093 http: [Uri, [String, String], [Map$(String, String)]], | |
3094 https: [Uri, [String, String], [Map$(String, String)]], | |
3095 file: [Uri, [String], {windows: bool}] | |
3096 }), | |
3097 methods: () => ({ | |
3098 replace: [Uri, [], {scheme: String, userInfo: String, host: String, port:
int, path: String, pathSegments: Iterable$(String), query: String, queryParamete
rs: Map$(String, String), fragment: String}], | |
3099 [_merge]: [String, [String, String]], | |
3100 [_hasDotSegments]: [bool, [String]], | |
3101 [_removeDotSegments]: [String, [String]], | |
3102 resolve: [Uri, [String]], | |
3103 resolveUri: [Uri, [Uri]], | |
3104 toFilePath: [String, [], {windows: bool}], | |
3105 [_toFilePath]: [String, []], | |
3106 [_toWindowsFilePath]: [String, []], | |
3107 [_writeAuthority]: [dart.void, [StringSink]] | |
3108 }), | |
3109 statics: () => ({ | |
3110 _defaultPort: [int, [String]], | |
3111 parse: [Uri, [String]], | |
3112 _fail: [dart.void, [String, int, String]], | |
3113 _makeHttpUri: [Uri, [String, String, String, Map$(String, String)]], | |
3114 _checkNonWindowsPathReservedCharacters: [dart.dynamic, [List$(String), boo
l]], | |
3115 _checkWindowsPathReservedCharacters: [dart.dynamic, [List$(String), bool],
[int]], | |
3116 _checkWindowsDriveLetter: [dart.dynamic, [int, bool]], | |
3117 _makeFileUri: [dart.dynamic, [String]], | |
3118 _makeWindowsFileUrl: [dart.dynamic, [String]], | |
3119 _makePort: [int, [int, String]], | |
3120 _makeHost: [String, [String, int, int, bool]], | |
3121 _isRegNameChar: [bool, [int]], | |
3122 _normalizeRegName: [String, [String, int, int]], | |
3123 _makeScheme: [String, [String, int]], | |
3124 _makeUserInfo: [String, [String, int, int]], | |
3125 _makePath: [String, [String, int, int, Iterable$(String), bool, bool]], | |
3126 _makeQuery: [String, [String, int, int, Map$(String, String)]], | |
3127 _makeFragment: [String, [String, int, int]], | |
3128 _stringOrNullLength: [int, [String]], | |
3129 _isHexDigit: [bool, [int]], | |
3130 _hexValue: [int, [int]], | |
3131 _normalizeEscape: [String, [String, int, bool]], | |
3132 _isUnreservedChar: [bool, [int]], | |
3133 _escapeChar: [String, [dart.dynamic]], | |
3134 _normalize: [String, [String, int, int, List$(int)]], | |
3135 _isSchemeCharacter: [bool, [int]], | |
3136 _isGeneralDelimiter: [bool, [int]], | |
3137 _addIfNonEmpty: [dart.void, [StringBuffer, String, String, String]], | |
3138 encodeComponent: [String, [String]], | |
3139 encodeQueryComponent: [String, [String], {encoding: convert.Encoding}], | |
3140 decodeComponent: [String, [String]], | |
3141 decodeQueryComponent: [String, [String], {encoding: convert.Encoding}], | |
3142 encodeFull: [String, [String]], | |
3143 decodeFull: [String, [String]], | |
3144 splitQueryString: [Map$(String, String), [String], {encoding: convert.Enco
ding}], | |
3145 parseIPv4Address: [List$(int), [String]], | |
3146 parseIPv6Address: [List$(int), [String], [int, int]], | |
3147 _uriEncode: [String, [List$(int), String], {encoding: convert.Encoding, sp
aceToPlus: bool}], | |
3148 _hexCharPairToByte: [int, [String, int]], | |
3149 _uriDecode: [String, [String], {plusToSpace: bool, encoding: convert.Encod
ing}], | |
3150 _isAlphabeticCharacter: [bool, [int]] | |
3151 }), | |
3152 names: ['_defaultPort', 'parse', '_fail', '_makeHttpUri', '_checkNonWindowsP
athReservedCharacters', '_checkWindowsPathReservedCharacters', '_checkWindowsDri
veLetter', '_makeFileUri', '_makeWindowsFileUrl', '_makePort', '_makeHost', '_is
RegNameChar', '_normalizeRegName', '_makeScheme', '_makeUserInfo', '_makePath',
'_makeQuery', '_makeFragment', '_stringOrNullLength', '_isHexDigit', '_hexValue'
, '_normalizeEscape', '_isUnreservedChar', '_escapeChar', '_normalize', '_isSche
meCharacter', '_isGeneralDelimiter', '_addIfNonEmpty', 'encodeComponent', 'encod
eQueryComponent', 'decodeComponent', 'decodeQueryComponent', 'encodeFull', 'deco
deFull', 'splitQueryString', 'parseIPv4Address', 'parseIPv6Address', '_uriEncode
', '_hexCharPairToByte', '_uriDecode', '_isAlphabeticCharacter'] | |
3153 }); | |
3154 Uri._SPACE = 32; | |
3155 Uri._DOUBLE_QUOTE = 34; | |
3156 Uri._NUMBER_SIGN = 35; | |
3157 Uri._PERCENT = 37; | |
3158 Uri._ASTERISK = 42; | |
3159 Uri._PLUS = 43; | |
3160 Uri._DOT = 46; | |
3161 Uri._SLASH = 47; | |
3162 Uri._ZERO = 48; | |
3163 Uri._NINE = 57; | |
3164 Uri._COLON = 58; | |
3165 Uri._LESS = 60; | |
3166 Uri._GREATER = 62; | |
3167 Uri._QUESTION = 63; | |
3168 Uri._AT_SIGN = 64; | |
3169 Uri._UPPER_CASE_A = 65; | |
3170 Uri._UPPER_CASE_F = 70; | |
3171 Uri._UPPER_CASE_Z = 90; | |
3172 Uri._LEFT_BRACKET = 91; | |
3173 Uri._BACKSLASH = 92; | |
3174 Uri._RIGHT_BRACKET = 93; | |
3175 Uri._LOWER_CASE_A = 97; | |
3176 Uri._LOWER_CASE_F = 102; | |
3177 Uri._LOWER_CASE_Z = 122; | |
3178 Uri._BAR = 124; | |
3179 dart.defineLazyProperties(Uri, { | |
3180 get _unreservedTable() { | |
3181 return dart.const(dart.list([0, 0, 24576, 1023, 65534, 34815, 65534, 18431
], int)); | |
3182 }, | |
3183 get _unreserved2396Table() { | |
3184 return dart.const(dart.list([0, 0, 26498, 1023, 65534, 34815, 65534, 18431
], int)); | |
3185 }, | |
3186 get _encodeFullTable() { | |
3187 return dart.const(dart.list([0, 0, 65498, 45055, 65535, 34815, 65534, 1843
1], int)); | |
3188 }, | |
3189 get _schemeTable() { | |
3190 return dart.const(dart.list([0, 0, 26624, 1023, 65534, 2047, 65534, 2047],
int)); | |
3191 }, | |
3192 get _schemeLowerTable() { | |
3193 return dart.const(dart.list([0, 0, 26624, 1023, 0, 0, 65534, 2047], int)); | |
3194 }, | |
3195 get _subDelimitersTable() { | |
3196 return dart.const(dart.list([0, 0, 32722, 11263, 65534, 34815, 65534, 1843
1], int)); | |
3197 }, | |
3198 get _genDelimitersTable() { | |
3199 return dart.const(dart.list([0, 0, 32776, 33792, 1, 10240, 0, 0], int)); | |
3200 }, | |
3201 get _userinfoTable() { | |
3202 return dart.const(dart.list([0, 0, 32722, 12287, 65534, 34815, 65534, 1843
1], int)); | |
3203 }, | |
3204 get _regNameTable() { | |
3205 return dart.const(dart.list([0, 0, 32754, 11263, 65534, 34815, 65534, 1843
1], int)); | |
3206 }, | |
3207 get _pathCharTable() { | |
3208 return dart.const(dart.list([0, 0, 32722, 12287, 65535, 34815, 65534, 1843
1], int)); | |
3209 }, | |
3210 get _pathCharOrSlashTable() { | |
3211 return dart.const(dart.list([0, 0, 65490, 12287, 65535, 34815, 65534, 1843
1], int)); | |
3212 }, | |
3213 get _queryCharTable() { | |
3214 return dart.const(dart.list([0, 0, 65490, 45055, 65535, 34815, 65534, 1843
1], int)); | |
3215 } | |
3216 }); | |
3217 function _symbolToString(symbol) { | |
3218 return _internal.Symbol.getName(dart.as(symbol, _internal.Symbol)); | |
3219 } | |
3220 dart.fn(_symbolToString, String, [Symbol]); | |
3221 // Exports: | |
3222 exports.Object = Object; | |
3223 exports.Deprecated = Deprecated; | |
3224 exports.deprecated = deprecated; | |
3225 exports.override = override; | |
3226 exports.proxy = proxy; | |
3227 exports.bool = bool; | |
3228 exports.Comparator$ = Comparator$; | |
3229 exports.Comparator = Comparator; | |
3230 exports.Comparable$ = Comparable$; | |
3231 exports.Comparable = Comparable; | |
3232 exports.DateTime = DateTime; | |
3233 exports.num = num; | |
3234 exports.double = double; | |
3235 exports.Duration = Duration; | |
3236 exports.Error = Error; | |
3237 exports.AssertionError = AssertionError; | |
3238 exports.TypeError = TypeError; | |
3239 exports.CastError = CastError; | |
3240 exports.NullThrownError = NullThrownError; | |
3241 exports.ArgumentError = ArgumentError; | |
3242 exports.RangeError = RangeError; | |
3243 exports.IndexError = IndexError; | |
3244 exports.FallThroughError = FallThroughError; | |
3245 exports.AbstractClassInstantiationError = AbstractClassInstantiationError; | |
3246 exports.NoSuchMethodError = NoSuchMethodError; | |
3247 exports.UnsupportedError = UnsupportedError; | |
3248 exports.UnimplementedError = UnimplementedError; | |
3249 exports.StateError = StateError; | |
3250 exports.ConcurrentModificationError = ConcurrentModificationError; | |
3251 exports.OutOfMemoryError = OutOfMemoryError; | |
3252 exports.StackOverflowError = StackOverflowError; | |
3253 exports.CyclicInitializationError = CyclicInitializationError; | |
3254 exports.Exception = Exception; | |
3255 exports.FormatException = FormatException; | |
3256 exports.IntegerDivisionByZeroException = IntegerDivisionByZeroException; | |
3257 exports.Expando$ = Expando$; | |
3258 exports.Expando = Expando; | |
3259 exports.Function = Function; | |
3260 exports.identical = identical; | |
3261 exports.identityHashCode = identityHashCode; | |
3262 exports.int = int; | |
3263 exports.Invocation = Invocation; | |
3264 exports.Iterable$ = Iterable$; | |
3265 exports.Iterable = Iterable; | |
3266 exports.BidirectionalIterator$ = BidirectionalIterator$; | |
3267 exports.BidirectionalIterator = BidirectionalIterator; | |
3268 exports.Iterator$ = Iterator$; | |
3269 exports.Iterator = Iterator; | |
3270 exports.List$ = List$; | |
3271 exports.List = List; | |
3272 exports.Map$ = Map$; | |
3273 exports.Map = Map; | |
3274 exports.Null = Null; | |
3275 exports.Pattern = Pattern; | |
3276 exports.print = print; | |
3277 exports.Match = Match; | |
3278 exports.RegExp = RegExp; | |
3279 exports.Set$ = Set$; | |
3280 exports.Sink$ = Sink$; | |
3281 exports.Sink = Sink; | |
3282 exports.StackTrace = StackTrace; | |
3283 exports.Stopwatch = Stopwatch; | |
3284 exports.String = String; | |
3285 exports.RuneIterator = RuneIterator; | |
3286 exports.StringBuffer = StringBuffer; | |
3287 exports.StringSink = StringSink; | |
3288 exports.Symbol = Symbol; | |
3289 exports.Type = Type; | |
3290 exports.Uri = Uri; | |
3291 }); | |
OLD | NEW |