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

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

Issue 1317933005: Some preliminary support for quasi-generics (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Address comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 dart_library.library('dart/_interceptors', null, /* Imports */[
2 "dart_runtime/dart",
3 'dart/core',
4 'dart/_internal',
5 'dart/collection',
6 'dart/math'
7 ], /* Lazy imports */[
8 'dart/_js_helper'
9 ], function(exports, dart, core, _internal, collection, math, _js_helper) {
10 'use strict';
11 let dartx = dart.dartx;
12 let JSArray$ = dart.generic(function(E) {
13 dart.defineExtensionNames([
14 'checkGrowable',
15 'add',
16 'removeAt',
17 'insert',
18 'insertAll',
19 'setAll',
20 'removeLast',
21 'remove',
22 'removeWhere',
23 'retainWhere',
24 'where',
25 'expand',
26 'addAll',
27 'clear',
28 'forEach',
29 'map',
30 'join',
31 'take',
32 'takeWhile',
33 'skip',
34 'skipWhile',
35 'reduce',
36 'fold',
37 'firstWhere',
38 'lastWhere',
39 'singleWhere',
40 'elementAt',
41 'sublist',
42 'getRange',
43 'first',
44 'last',
45 'single',
46 'removeRange',
47 'setRange',
48 'fillRange',
49 'replaceRange',
50 'any',
51 'every',
52 'reversed',
53 'sort',
54 'shuffle',
55 'indexOf',
56 'lastIndexOf',
57 'contains',
58 'isEmpty',
59 'isNotEmpty',
60 'toString',
61 'toList',
62 'toSet',
63 'iterator',
64 'hashCode',
65 'length',
66 'length',
67 'get',
68 'set',
69 'asMap'
70 ]);
71 class JSArray extends core.Object {
72 JSArray() {
73 }
74 static typed(allocation) {
75 return dart.list(allocation, E);
76 }
77 static markFixed(allocation) {
78 return JSArray$(E).typed(JSArray$().markFixedList(dart.as(allocation, co re.List)));
79 }
80 static markGrowable(allocation) {
81 return JSArray$().typed(allocation);
82 }
83 static markFixedList(list) {
84 list.fixed$length = Array;
85 return list;
86 }
87 [dartx.checkGrowable](reason) {
88 if (this.fixed$length) {
89 dart.throw(new core.UnsupportedError(dart.as(reason, core.String)));
90 }
91 }
92 [dartx.add](value) {
93 dart.as(value, E);
94 this[dartx.checkGrowable]('add');
95 this.push(value);
96 }
97 [dartx.removeAt](index) {
98 if (!(typeof index == 'number'))
99 dart.throw(new core.ArgumentError(index));
100 if (dart.notNull(index) < 0 || dart.notNull(index) >= dart.notNull(this[ dartx.length])) {
101 dart.throw(new core.RangeError.value(index));
102 }
103 this[dartx.checkGrowable]('removeAt');
104 return this.splice(index, 1)[0];
105 }
106 [dartx.insert](index, value) {
107 dart.as(value, E);
108 if (!(typeof index == 'number'))
109 dart.throw(new core.ArgumentError(index));
110 if (dart.notNull(index) < 0 || dart.notNull(index) > dart.notNull(this[d artx.length])) {
111 dart.throw(new core.RangeError.value(index));
112 }
113 this[dartx.checkGrowable]('insert');
114 this.splice(index, 0, value);
115 }
116 [dartx.insertAll](index, iterable) {
117 dart.as(iterable, core.Iterable$(E));
118 this[dartx.checkGrowable]('insertAll');
119 _internal.IterableMixinWorkaround.insertAllList(this, index, iterable);
120 }
121 [dartx.setAll](index, iterable) {
122 dart.as(iterable, core.Iterable$(E));
123 _internal.IterableMixinWorkaround.setAllList(this, index, iterable);
124 }
125 [dartx.removeLast]() {
126 this[dartx.checkGrowable]('removeLast');
127 if (this[dartx.length] == 0)
128 dart.throw(new core.RangeError.value(-1));
129 return dart.as(this.pop(), E);
130 }
131 [dartx.remove](element) {
132 this[dartx.checkGrowable]('remove');
133 for (let i = 0; dart.notNull(i) < dart.notNull(this[dartx.length]); i = dart.notNull(i) + 1) {
134 if (dart.equals(this[dartx.get](i), element)) {
135 this.splice(i, 1);
136 return true;
137 }
138 }
139 return false;
140 }
141 [dartx.removeWhere](test) {
142 dart.as(test, dart.functionType(core.bool, [E]));
143 _internal.IterableMixinWorkaround.removeWhereList(this, test);
144 }
145 [dartx.retainWhere](test) {
146 dart.as(test, dart.functionType(core.bool, [E]));
147 _internal.IterableMixinWorkaround.removeWhereList(this, dart.fn(element => !dart.notNull(test(element)), core.bool, [E]));
148 }
149 [dartx.where](f) {
150 dart.as(f, dart.functionType(core.bool, [E]));
151 return new (_internal.IterableMixinWorkaround$(E))().where(this, f);
152 }
153 [dartx.expand](f) {
154 dart.as(f, dart.functionType(core.Iterable, [E]));
155 return _internal.IterableMixinWorkaround.expand(this, f);
156 }
157 [dartx.addAll](collection) {
158 dart.as(collection, core.Iterable$(E));
159 for (let e of collection) {
160 this[dartx.add](e);
161 }
162 }
163 [dartx.clear]() {
164 this[dartx.length] = 0;
165 }
166 [dartx.forEach](f) {
167 dart.as(f, dart.functionType(dart.void, [E]));
168 let length = this[dartx.length];
169 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull (i) + 1) {
170 f(dart.as(this[i], E));
171 if (length != this[dartx.length]) {
172 dart.throw(new core.ConcurrentModificationError(this));
173 }
174 }
175 }
176 [dartx.map](f) {
177 dart.as(f, dart.functionType(dart.dynamic, [E]));
178 return _internal.IterableMixinWorkaround.mapList(this, f);
179 }
180 [dartx.join](separator) {
181 if (separator === void 0)
182 separator = "";
183 let list = core.List.new(this[dartx.length]);
184 for (let i = 0; dart.notNull(i) < dart.notNull(this[dartx.length]); i = dart.notNull(i) + 1) {
185 list[dartx.set](i, `${this[dartx.get](i)}`);
186 }
187 return list.join(separator);
188 }
189 [dartx.take](n) {
190 return new (_internal.IterableMixinWorkaround$(E))().takeList(this, n);
191 }
192 [dartx.takeWhile](test) {
193 dart.as(test, dart.functionType(core.bool, [E]));
194 return new (_internal.IterableMixinWorkaround$(E))().takeWhile(this, tes t);
195 }
196 [dartx.skip](n) {
197 return new (_internal.IterableMixinWorkaround$(E))().skipList(this, n);
198 }
199 [dartx.skipWhile](test) {
200 dart.as(test, dart.functionType(core.bool, [E]));
201 return new (_internal.IterableMixinWorkaround$(E))().skipWhile(this, tes t);
202 }
203 [dartx.reduce](combine) {
204 dart.as(combine, dart.functionType(E, [E, E]));
205 return dart.as(_internal.IterableMixinWorkaround.reduce(this, combine), E);
206 }
207 [dartx.fold](initialValue, combine) {
208 dart.as(combine, dart.functionType(dart.dynamic, [dart.dynamic, E]));
209 return _internal.IterableMixinWorkaround.fold(this, initialValue, combin e);
210 }
211 [dartx.firstWhere](test, opts) {
212 dart.as(test, dart.functionType(core.bool, [E]));
213 let orElse = opts && 'orElse' in opts ? opts.orElse : null;
214 dart.as(orElse, dart.functionType(E, []));
215 return dart.as(_internal.IterableMixinWorkaround.firstWhere(this, test, orElse), E);
216 }
217 [dartx.lastWhere](test, opts) {
218 dart.as(test, dart.functionType(core.bool, [E]));
219 let orElse = opts && 'orElse' in opts ? opts.orElse : null;
220 dart.as(orElse, dart.functionType(E, []));
221 return dart.as(_internal.IterableMixinWorkaround.lastWhereList(this, tes t, orElse), E);
222 }
223 [dartx.singleWhere](test) {
224 dart.as(test, dart.functionType(core.bool, [E]));
225 return dart.as(_internal.IterableMixinWorkaround.singleWhere(this, test) , E);
226 }
227 [dartx.elementAt](index) {
228 return this[dartx.get](index);
229 }
230 [dartx.sublist](start, end) {
231 if (end === void 0)
232 end = null;
233 _js_helper.checkNull(start);
234 if (!(typeof start == 'number'))
235 dart.throw(new core.ArgumentError(start));
236 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(this[d artx.length])) {
237 dart.throw(new core.RangeError.range(start, 0, this[dartx.length]));
238 }
239 if (end == null) {
240 end = this[dartx.length];
241 } else {
242 if (!(typeof end == 'number'))
243 dart.throw(new core.ArgumentError(end));
244 if (dart.notNull(end) < dart.notNull(start) || dart.notNull(end) > dar t.notNull(this[dartx.length])) {
245 dart.throw(new core.RangeError.range(end, start, this[dartx.length]) );
246 }
247 }
248 if (start == end)
249 return dart.list([], E);
250 return JSArray$(E).typed(this.slice(start, end));
251 }
252 [dartx.getRange](start, end) {
253 return new (_internal.IterableMixinWorkaround$(E))().getRangeList(this, start, end);
254 }
255 get [dartx.first]() {
256 if (dart.notNull(this[dartx.length]) > 0)
257 return this[dartx.get](0);
258 dart.throw(new core.StateError("No elements"));
259 }
260 get [dartx.last]() {
261 if (dart.notNull(this[dartx.length]) > 0)
262 return this[dartx.get](dart.notNull(this[dartx.length]) - 1);
263 dart.throw(new core.StateError("No elements"));
264 }
265 get [dartx.single]() {
266 if (this[dartx.length] == 1)
267 return this[dartx.get](0);
268 if (this[dartx.length] == 0)
269 dart.throw(new core.StateError("No elements"));
270 dart.throw(new core.StateError("More than one element"));
271 }
272 [dartx.removeRange](start, end) {
273 this[dartx.checkGrowable]('removeRange');
274 let receiverLength = this[dartx.length];
275 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(receiv erLength)) {
276 dart.throw(new core.RangeError.range(start, 0, receiverLength));
277 }
278 if (dart.notNull(end) < dart.notNull(start) || dart.notNull(end) > dart. notNull(receiverLength)) {
279 dart.throw(new core.RangeError.range(end, start, receiverLength));
280 }
281 _internal.Lists.copy(this, end, this, start, dart.notNull(receiverLength ) - dart.notNull(end));
282 this[dartx.length] = dart.notNull(receiverLength) - (dart.notNull(end) - dart.notNull(start));
283 }
284 [dartx.setRange](start, end, iterable, skipCount) {
285 dart.as(iterable, core.Iterable$(E));
286 if (skipCount === void 0)
287 skipCount = 0;
288 _internal.IterableMixinWorkaround.setRangeList(this, start, end, iterabl e, skipCount);
289 }
290 [dartx.fillRange](start, end, fillValue) {
291 if (fillValue === void 0)
292 fillValue = null;
293 dart.as(fillValue, E);
294 _internal.IterableMixinWorkaround.fillRangeList(this, start, end, fillVa lue);
295 }
296 [dartx.replaceRange](start, end, iterable) {
297 dart.as(iterable, core.Iterable$(E));
298 _internal.IterableMixinWorkaround.replaceRangeList(this, start, end, ite rable);
299 }
300 [dartx.any](f) {
301 dart.as(f, dart.functionType(core.bool, [E]));
302 return _internal.IterableMixinWorkaround.any(this, f);
303 }
304 [dartx.every](f) {
305 dart.as(f, dart.functionType(core.bool, [E]));
306 return _internal.IterableMixinWorkaround.every(this, f);
307 }
308 get [dartx.reversed]() {
309 return new (_internal.IterableMixinWorkaround$(E))().reversedList(this);
310 }
311 [dartx.sort](compare) {
312 if (compare === void 0)
313 compare = null;
314 dart.as(compare, dart.functionType(core.int, [E, E]));
315 _internal.IterableMixinWorkaround.sortList(this, compare);
316 }
317 [dartx.shuffle](random) {
318 if (random === void 0)
319 random = null;
320 _internal.IterableMixinWorkaround.shuffleList(this, random);
321 }
322 [dartx.indexOf](element, start) {
323 if (start === void 0)
324 start = 0;
325 return _internal.IterableMixinWorkaround.indexOfList(this, element, star t);
326 }
327 [dartx.lastIndexOf](element, start) {
328 if (start === void 0)
329 start = null;
330 return _internal.IterableMixinWorkaround.lastIndexOfList(this, element, start);
331 }
332 [dartx.contains](other) {
333 for (let i = 0; dart.notNull(i) < dart.notNull(this[dartx.length]); i = dart.notNull(i) + 1) {
334 if (dart.equals(this[dartx.get](i), other))
335 return true;
336 }
337 return false;
338 }
339 get [dartx.isEmpty]() {
340 return this[dartx.length] == 0;
341 }
342 get [dartx.isNotEmpty]() {
343 return !dart.notNull(this[dartx.isEmpty]);
344 }
345 toString() {
346 return collection.ListBase.listToString(this);
347 }
348 [dartx.toList](opts) {
349 let growable = opts && 'growable' in opts ? opts.growable : true;
350 let list = this.slice();
351 if (!dart.notNull(growable))
352 JSArray$().markFixedList(dart.as(list, core.List));
353 return JSArray$(E).typed(list);
354 }
355 [dartx.toSet]() {
356 return core.Set$(E).from(this);
357 }
358 get [dartx.iterator]() {
359 return new (_internal.ListIterator$(E))(this);
360 }
361 get hashCode() {
362 return _js_helper.Primitives.objectHashCode(this);
363 }
364 get [dartx.length]() {
365 return dart.as(this.length, core.int);
366 }
367 set [dartx.length](newLength) {
368 if (!(typeof newLength == 'number'))
369 dart.throw(new core.ArgumentError(newLength));
370 if (dart.notNull(newLength) < 0)
371 dart.throw(new core.RangeError.value(newLength));
372 this[dartx.checkGrowable]('set length');
373 this.length = newLength;
374 }
375 [dartx.get](index) {
376 if (!(typeof index == 'number'))
377 dart.throw(new core.ArgumentError(index));
378 if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notN ull(index) < 0)
379 dart.throw(new core.RangeError.value(index));
380 return dart.as(this[index], E);
381 }
382 [dartx.set](index, value) {
383 dart.as(value, E);
384 if (!(typeof index == 'number'))
385 dart.throw(new core.ArgumentError(index));
386 if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notN ull(index) < 0)
387 dart.throw(new core.RangeError.value(index));
388 this[index] = value;
389 return value;
390 }
391 [dartx.asMap]() {
392 return new (_internal.IterableMixinWorkaround$(E))().asMapList(this);
393 }
394 }
395 dart.setBaseClass(JSArray, dart.global.Array);
396 JSArray[dart.implements] = () => [core.List$(E), JSIndexable];
397 dart.setSignature(JSArray, {
398 constructors: () => ({
399 JSArray: [JSArray$(E), []],
400 typed: [JSArray$(E), [dart.dynamic]],
401 markFixed: [JSArray$(E), [dart.dynamic]],
402 markGrowable: [JSArray$(E), [dart.dynamic]]
403 }),
404 methods: () => ({
405 [dartx.checkGrowable]: [dart.dynamic, [dart.dynamic]],
406 [dartx.add]: [dart.void, [E]],
407 [dartx.removeAt]: [E, [core.int]],
408 [dartx.insert]: [dart.void, [core.int, E]],
409 [dartx.insertAll]: [dart.void, [core.int, core.Iterable$(E)]],
410 [dartx.setAll]: [dart.void, [core.int, core.Iterable$(E)]],
411 [dartx.removeLast]: [E, []],
412 [dartx.remove]: [core.bool, [core.Object]],
413 [dartx.removeWhere]: [dart.void, [dart.functionType(core.bool, [E])]],
414 [dartx.retainWhere]: [dart.void, [dart.functionType(core.bool, [E])]],
415 [dartx.where]: [core.Iterable$(E), [dart.functionType(core.bool, [E])]],
416 [dartx.expand]: [core.Iterable, [dart.functionType(core.Iterable, [E])]] ,
417 [dartx.addAll]: [dart.void, [core.Iterable$(E)]],
418 [dartx.clear]: [dart.void, []],
419 [dartx.forEach]: [dart.void, [dart.functionType(dart.void, [E])]],
420 [dartx.map]: [core.Iterable, [dart.functionType(dart.dynamic, [E])]],
421 [dartx.join]: [core.String, [], [core.String]],
422 [dartx.take]: [core.Iterable$(E), [core.int]],
423 [dartx.takeWhile]: [core.Iterable$(E), [dart.functionType(core.bool, [E] )]],
424 [dartx.skip]: [core.Iterable$(E), [core.int]],
425 [dartx.skipWhile]: [core.Iterable$(E), [dart.functionType(core.bool, [E] )]],
426 [dartx.reduce]: [E, [dart.functionType(E, [E, E])]],
427 [dartx.fold]: [dart.dynamic, [dart.dynamic, dart.functionType(dart.dynam ic, [dart.dynamic, E])]],
428 [dartx.firstWhere]: [E, [dart.functionType(core.bool, [E])], {orElse: da rt.functionType(E, [])}],
429 [dartx.lastWhere]: [E, [dart.functionType(core.bool, [E])], {orElse: dar t.functionType(E, [])}],
430 [dartx.singleWhere]: [E, [dart.functionType(core.bool, [E])]],
431 [dartx.elementAt]: [E, [core.int]],
432 [dartx.sublist]: [core.List$(E), [core.int], [core.int]],
433 [dartx.getRange]: [core.Iterable$(E), [core.int, core.int]],
434 [dartx.removeRange]: [dart.void, [core.int, core.int]],
435 [dartx.setRange]: [dart.void, [core.int, core.int, core.Iterable$(E)], [ core.int]],
436 [dartx.fillRange]: [dart.void, [core.int, core.int], [E]],
437 [dartx.replaceRange]: [dart.void, [core.int, core.int, core.Iterable$(E) ]],
438 [dartx.any]: [core.bool, [dart.functionType(core.bool, [E])]],
439 [dartx.every]: [core.bool, [dart.functionType(core.bool, [E])]],
440 [dartx.sort]: [dart.void, [], [dart.functionType(core.int, [E, E])]],
441 [dartx.shuffle]: [dart.void, [], [math.Random]],
442 [dartx.indexOf]: [core.int, [core.Object], [core.int]],
443 [dartx.lastIndexOf]: [core.int, [core.Object], [core.int]],
444 [dartx.contains]: [core.bool, [core.Object]],
445 [dartx.toList]: [core.List$(E), [], {growable: core.bool}],
446 [dartx.toSet]: [core.Set$(E), []],
447 [dartx.get]: [E, [core.int]],
448 [dartx.set]: [dart.void, [core.int, E]],
449 [dartx.asMap]: [core.Map$(core.int, E), []]
450 }),
451 statics: () => ({markFixedList: [core.List, [core.List]]}),
452 names: ['markFixedList']
453 });
454 JSArray[dart.metadata] = () => [dart.const(new _js_helper.JsPeerInterface({n ame: 'Array'}))];
455 return JSArray;
456 });
457 let JSArray = JSArray$();
458 dart.registerExtension(dart.global.Array, JSArray);
459 let JSMutableArray$ = dart.generic(function(E) {
460 class JSMutableArray extends JSArray$(E) {
461 JSMutableArray() {
462 super.JSArray();
463 }
464 }
465 JSMutableArray[dart.implements] = () => [JSMutableIndexable];
466 return JSMutableArray;
467 });
468 let JSMutableArray = JSMutableArray$();
469 let JSFixedArray$ = dart.generic(function(E) {
470 class JSFixedArray extends JSMutableArray$(E) {}
471 return JSFixedArray;
472 });
473 let JSFixedArray = JSFixedArray$();
474 let JSExtendableArray$ = dart.generic(function(E) {
475 class JSExtendableArray extends JSMutableArray$(E) {}
476 return JSExtendableArray;
477 });
478 let JSExtendableArray = JSExtendableArray$();
479 class Interceptor extends core.Object {
480 Interceptor() {
481 }
482 }
483 dart.setSignature(Interceptor, {
484 constructors: () => ({Interceptor: [Interceptor, []]})
485 });
486 let _isInt32 = Symbol('_isInt32');
487 let _tdivFast = Symbol('_tdivFast');
488 let _tdivSlow = Symbol('_tdivSlow');
489 let _shlPositive = Symbol('_shlPositive');
490 let _shrReceiverPositive = Symbol('_shrReceiverPositive');
491 let _shrOtherPositive = Symbol('_shrOtherPositive');
492 let _shrBothPositive = Symbol('_shrBothPositive');
493 dart.defineExtensionNames([
494 'compareTo',
495 'isNegative',
496 'isNaN',
497 'isInfinite',
498 'isFinite',
499 'remainder',
500 'abs',
501 'sign',
502 'toInt',
503 'truncate',
504 'ceil',
505 'floor',
506 'round',
507 'ceilToDouble',
508 'floorToDouble',
509 'roundToDouble',
510 'truncateToDouble',
511 'clamp',
512 'toDouble',
513 'toStringAsFixed',
514 'toStringAsExponential',
515 'toStringAsPrecision',
516 'toRadixString',
517 'toString',
518 'hashCode',
519 'unary-',
520 '+',
521 '-',
522 '/',
523 '*',
524 '%',
525 '~/',
526 '<<',
527 '>>',
528 '&',
529 '|',
530 '^',
531 '<',
532 '>',
533 '<=',
534 '>=',
535 'runtimeType'
536 ]);
537 class JSNumber extends Interceptor {
538 JSNumber() {
539 super.Interceptor();
540 }
541 [dartx.compareTo](b) {
542 if (!dart.is(b, core.num))
543 dart.throw(new core.ArgumentError(b));
544 if (dart.notNull(this[dartx['<']](b))) {
545 return -1;
546 } else if (dart.notNull(this[dartx['>']](b))) {
547 return 1;
548 } else if (dart.equals(this, b)) {
549 if (dart.equals(this, 0)) {
550 let bIsNegative = b[dartx.isNegative];
551 if (this[dartx.isNegative] == bIsNegative)
552 return 0;
553 if (dart.notNull(this[dartx.isNegative]))
554 return -1;
555 return 1;
556 }
557 return 0;
558 } else if (dart.notNull(this[dartx.isNaN])) {
559 if (dart.notNull(b[dartx.isNaN])) {
560 return 0;
561 }
562 return 1;
563 } else {
564 return -1;
565 }
566 }
567 get [dartx.isNegative]() {
568 return dart.equals(this, 0) ? (1)[dartx['/']](this) < 0 : this[dartx['<']] (0);
569 }
570 get [dartx.isNaN]() {
571 return isNaN(this);
572 }
573 get [dartx.isInfinite]() {
574 return this == Infinity || this == -Infinity;
575 }
576 get [dartx.isFinite]() {
577 return isFinite(this);
578 }
579 [dartx.remainder](b) {
580 _js_helper.checkNull(b);
581 if (!dart.is(b, core.num))
582 dart.throw(new core.ArgumentError(b));
583 return this % b;
584 }
585 [dartx.abs]() {
586 return Math.abs(this);
587 }
588 get [dartx.sign]() {
589 return dart.notNull(this[dartx['>']](0)) ? 1 : dart.notNull(this[dartx['<' ]](0)) ? -1 : this;
590 }
591 [dartx.toInt]() {
592 if (dart.notNull(this[dartx['>=']](JSNumber._MIN_INT32)) && dart.notNull(t his[dartx['<=']](JSNumber._MAX_INT32))) {
593 return this | 0;
594 }
595 if (isFinite(this)) {
596 return this[dartx.truncateToDouble]() + 0;
597 }
598 dart.throw(new core.UnsupportedError('' + this));
599 }
600 [dartx.truncate]() {
601 return this[dartx.toInt]();
602 }
603 [dartx.ceil]() {
604 return this[dartx.ceilToDouble]()[dartx.toInt]();
605 }
606 [dartx.floor]() {
607 return this[dartx.floorToDouble]()[dartx.toInt]();
608 }
609 [dartx.round]() {
610 return this[dartx.roundToDouble]()[dartx.toInt]();
611 }
612 [dartx.ceilToDouble]() {
613 return Math.ceil(this);
614 }
615 [dartx.floorToDouble]() {
616 return Math.floor(this);
617 }
618 [dartx.roundToDouble]() {
619 if (dart.notNull(this[dartx['<']](0))) {
620 return -Math.round(-this);
621 } else {
622 return Math.round(this);
623 }
624 }
625 [dartx.truncateToDouble]() {
626 return dart.notNull(this[dartx['<']](0)) ? this[dartx.ceilToDouble]() : th is[dartx.floorToDouble]();
627 }
628 [dartx.clamp](lowerLimit, upperLimit) {
629 if (!dart.is(lowerLimit, core.num))
630 dart.throw(new core.ArgumentError(lowerLimit));
631 if (!dart.is(upperLimit, core.num))
632 dart.throw(new core.ArgumentError(upperLimit));
633 if (dart.notNull(lowerLimit[dartx.compareTo](upperLimit)) > 0) {
634 dart.throw(new core.ArgumentError(lowerLimit));
635 }
636 if (dart.notNull(this[dartx.compareTo](lowerLimit)) < 0)
637 return lowerLimit;
638 if (dart.notNull(this[dartx.compareTo](upperLimit)) > 0)
639 return upperLimit;
640 return this;
641 }
642 [dartx.toDouble]() {
643 return this;
644 }
645 [dartx.toStringAsFixed](fractionDigits) {
646 _js_helper.checkInt(fractionDigits);
647 if (dart.notNull(fractionDigits) < 0 || dart.notNull(fractionDigits) > 20) {
648 dart.throw(new core.RangeError(fractionDigits));
649 }
650 let result = this.toFixed(fractionDigits);
651 if (dart.equals(this, 0) && dart.notNull(this[dartx.isNegative]))
652 return `-${result}`;
653 return result;
654 }
655 [dartx.toStringAsExponential](fractionDigits) {
656 if (fractionDigits === void 0)
657 fractionDigits = null;
658 let result = null;
659 if (fractionDigits != null) {
660 _js_helper.checkInt(fractionDigits);
661 if (dart.notNull(fractionDigits) < 0 || dart.notNull(fractionDigits) > 2 0) {
662 dart.throw(new core.RangeError(fractionDigits));
663 }
664 result = this.toExponential(fractionDigits);
665 } else {
666 result = this.toExponential();
667 }
668 if (dart.equals(this, 0) && dart.notNull(this[dartx.isNegative]))
669 return `-${result}`;
670 return result;
671 }
672 [dartx.toStringAsPrecision](precision) {
673 _js_helper.checkInt(precision);
674 if (dart.notNull(precision) < 1 || dart.notNull(precision) > 21) {
675 dart.throw(new core.RangeError(precision));
676 }
677 let result = this.toPrecision(precision);
678 if (dart.equals(this, 0) && dart.notNull(this[dartx.isNegative]))
679 return `-${result}`;
680 return result;
681 }
682 [dartx.toRadixString](radix) {
683 _js_helper.checkInt(radix);
684 if (dart.notNull(radix) < 2 || dart.notNull(radix) > 36)
685 dart.throw(new core.RangeError(radix));
686 let result = this.toString(radix);
687 let rightParenCode = 41;
688 if (result[dartx.codeUnitAt](dart.notNull(result[dartx.length]) - 1) != ri ghtParenCode) {
689 return result;
690 }
691 return JSNumber._handleIEtoString(result);
692 }
693 static _handleIEtoString(result) {
694 let match = /^([\da-z]+)(?:\.([\da-z]+))?\(e\+(\d+)\)$/.exec(result);
695 if (match == null) {
696 dart.throw(new core.UnsupportedError(`Unexpected toString result: ${resu lt}`));
697 }
698 result = dart.dindex(match, 1);
699 let exponent = +dart.dindex(match, 3);
700 if (dart.dindex(match, 2) != null) {
701 result = result + dart.dindex(match, 2);
702 exponent = dart.notNull(exponent) - dart.dindex(match, 2).length;
703 }
704 return dart.notNull(result) + "0"[dartx['*']](exponent);
705 }
706 toString() {
707 if (dart.equals(this, 0) && 1 / this < 0) {
708 return '-0.0';
709 } else {
710 return "" + this;
711 }
712 }
713 get hashCode() {
714 return this & 0x1FFFFFFF;
715 }
716 [dartx['unary-']]() {
717 return -this;
718 }
719 [dartx['+']](other) {
720 if (!dart.is(other, core.num))
721 dart.throw(new core.ArgumentError(other));
722 return this + other;
723 }
724 [dartx['-']](other) {
725 if (!dart.is(other, core.num))
726 dart.throw(new core.ArgumentError(other));
727 return this - other;
728 }
729 [dartx['/']](other) {
730 if (!dart.is(other, core.num))
731 dart.throw(new core.ArgumentError(other));
732 return this / other;
733 }
734 [dartx['*']](other) {
735 if (!dart.is(other, core.num))
736 dart.throw(new core.ArgumentError(other));
737 return this * other;
738 }
739 [dartx['%']](other) {
740 if (!dart.is(other, core.num))
741 dart.throw(new core.ArgumentError(other));
742 let result = this % other;
743 if (result == 0)
744 return 0;
745 if (dart.notNull(result) > 0)
746 return result;
747 if (other < 0) {
748 return dart.notNull(result) - other;
749 } else {
750 return dart.notNull(result) + other;
751 }
752 }
753 [_isInt32](value) {
754 return (value | 0) === value;
755 }
756 [dartx['~/']](other) {
757 if (false)
758 this[_tdivFast](other);
759 if (dart.notNull(this[_isInt32](this)) && dart.notNull(this[_isInt32](othe r)) && 0 != other && -1 != other) {
760 return this / other | 0;
761 } else {
762 return this[_tdivSlow](other);
763 }
764 }
765 [_tdivFast](other) {
766 return dart.notNull(this[_isInt32](this)) ? this / other | 0 : (this / oth er)[dartx.toInt]();
767 }
768 [_tdivSlow](other) {
769 if (!dart.is(other, core.num))
770 dart.throw(new core.ArgumentError(other));
771 return (this / other)[dartx.toInt]();
772 }
773 [dartx['<<']](other) {
774 if (!dart.is(other, core.num))
775 dart.throw(new core.ArgumentError(other));
776 if (other < 0)
777 dart.throw(new core.ArgumentError(other));
778 return this[_shlPositive](other);
779 }
780 [_shlPositive](other) {
781 return other > 31 ? 0 : dart.as(this << other >>> 0, core.num);
782 }
783 [dartx['>>']](other) {
784 if (false)
785 this[_shrReceiverPositive](other);
786 if (!dart.is(other, core.num))
787 dart.throw(new core.ArgumentError(other));
788 if (other < 0)
789 dart.throw(new core.ArgumentError(other));
790 return this[_shrOtherPositive](other);
791 }
792 [_shrOtherPositive](other) {
793 return this > 0 ? this[_shrBothPositive](other) : dart.as(this >> (dart.no tNull(other) > 31 ? 31 : other) >>> 0, core.num);
794 }
795 [_shrReceiverPositive](other) {
796 if (other < 0)
797 dart.throw(new core.ArgumentError(other));
798 return this[_shrBothPositive](other);
799 }
800 [_shrBothPositive](other) {
801 return other > 31 ? 0 : dart.as(this >>> other, core.num);
802 }
803 [dartx['&']](other) {
804 if (!dart.is(other, core.num))
805 dart.throw(new core.ArgumentError(other));
806 return dart.as((this & other) >>> 0, core.num);
807 }
808 [dartx['|']](other) {
809 if (!dart.is(other, core.num))
810 dart.throw(new core.ArgumentError(other));
811 return dart.as((this | other) >>> 0, core.num);
812 }
813 [dartx['^']](other) {
814 if (!dart.is(other, core.num))
815 dart.throw(new core.ArgumentError(other));
816 return dart.as((this ^ other) >>> 0, core.num);
817 }
818 [dartx['<']](other) {
819 if (!dart.is(other, core.num))
820 dart.throw(new core.ArgumentError(other));
821 return this < other;
822 }
823 [dartx['>']](other) {
824 if (!dart.is(other, core.num))
825 dart.throw(new core.ArgumentError(other));
826 return this > other;
827 }
828 [dartx['<=']](other) {
829 if (!dart.is(other, core.num))
830 dart.throw(new core.ArgumentError(other));
831 return this <= other;
832 }
833 [dartx['>=']](other) {
834 if (!dart.is(other, core.num))
835 dart.throw(new core.ArgumentError(other));
836 return this >= other;
837 }
838 get runtimeType() {
839 return core.num;
840 }
841 }
842 JSNumber[dart.implements] = () => [core.num];
843 dart.setSignature(JSNumber, {
844 constructors: () => ({JSNumber: [JSNumber, []]}),
845 methods: () => ({
846 [dartx.compareTo]: [core.int, [core.num]],
847 [dartx.remainder]: [core.num, [core.num]],
848 [dartx.abs]: [core.num, []],
849 [dartx.toInt]: [core.int, []],
850 [dartx.truncate]: [core.int, []],
851 [dartx.ceil]: [core.int, []],
852 [dartx.floor]: [core.int, []],
853 [dartx.round]: [core.int, []],
854 [dartx.ceilToDouble]: [core.double, []],
855 [dartx.floorToDouble]: [core.double, []],
856 [dartx.roundToDouble]: [core.double, []],
857 [dartx.truncateToDouble]: [core.double, []],
858 [dartx.clamp]: [core.num, [core.num, core.num]],
859 [dartx.toDouble]: [core.double, []],
860 [dartx.toStringAsFixed]: [core.String, [core.int]],
861 [dartx.toStringAsExponential]: [core.String, [], [core.int]],
862 [dartx.toStringAsPrecision]: [core.String, [core.int]],
863 [dartx.toRadixString]: [core.String, [core.int]],
864 [dartx['unary-']]: [core.num, []],
865 [dartx['+']]: [core.num, [core.num]],
866 [dartx['-']]: [core.num, [core.num]],
867 [dartx['/']]: [core.double, [core.num]],
868 [dartx['*']]: [core.num, [core.num]],
869 [dartx['%']]: [core.num, [core.num]],
870 [_isInt32]: [core.bool, [dart.dynamic]],
871 [dartx['~/']]: [core.int, [core.num]],
872 [_tdivFast]: [core.int, [core.num]],
873 [_tdivSlow]: [core.int, [core.num]],
874 [dartx['<<']]: [core.num, [core.num]],
875 [_shlPositive]: [core.num, [core.num]],
876 [dartx['>>']]: [core.num, [core.num]],
877 [_shrOtherPositive]: [core.num, [core.num]],
878 [_shrReceiverPositive]: [core.num, [core.num]],
879 [_shrBothPositive]: [core.num, [core.num]],
880 [dartx['&']]: [core.num, [core.num]],
881 [dartx['|']]: [core.num, [core.num]],
882 [dartx['^']]: [core.num, [core.num]],
883 [dartx['<']]: [core.bool, [core.num]],
884 [dartx['>']]: [core.bool, [core.num]],
885 [dartx['<=']]: [core.bool, [core.num]],
886 [dartx['>=']]: [core.bool, [core.num]]
887 }),
888 statics: () => ({_handleIEtoString: [core.String, [core.String]]}),
889 names: ['_handleIEtoString']
890 });
891 JSNumber._MIN_INT32 = -2147483648;
892 JSNumber._MAX_INT32 = 2147483647;
893 dart.defineExtensionNames([
894 'isEven',
895 'isOdd',
896 'toUnsigned',
897 'toSigned',
898 'bitLength',
899 'runtimeType',
900 '~'
901 ]);
902 class JSInt extends JSNumber {
903 JSInt() {
904 super.JSNumber();
905 }
906 get [dartx.isEven]() {
907 return this[dartx['&']](1) == 0;
908 }
909 get [dartx.isOdd]() {
910 return this[dartx['&']](1) == 1;
911 }
912 [dartx.toUnsigned](width) {
913 return this[dartx['&']]((1 << dart.notNull(width)) - 1);
914 }
915 [dartx.toSigned](width) {
916 let signMask = 1 << dart.notNull(width) - 1;
917 return dart.notNull(this[dartx['&']](dart.notNull(signMask) - 1)) - dart.n otNull(this[dartx['&']](signMask));
918 }
919 get [dartx.bitLength]() {
920 let nonneg = dart.notNull(this[dartx['<']](0)) ? dart.notNull(this[dartx[' unary-']]()) - 1 : this;
921 if (dart.notNull(nonneg) >= 4294967296) {
922 nonneg = (dart.notNull(nonneg) / 4294967296)[dartx.truncate]();
923 return dart.notNull(JSInt._bitCount(JSInt._spread(nonneg))) + 32;
924 }
925 return JSInt._bitCount(JSInt._spread(nonneg));
926 }
927 static _bitCount(i) {
928 i = dart.notNull(JSInt._shru(i, 0)) - (dart.notNull(JSInt._shru(i, 1)) & 1 431655765);
929 i = (dart.notNull(i) & 858993459) + (dart.notNull(JSInt._shru(i, 2)) & 858 993459);
930 i = 252645135 & dart.notNull(i) + dart.notNull(JSInt._shru(i, 4));
931 i = dart.notNull(i) + dart.notNull(JSInt._shru(i, 8));
932 i = dart.notNull(i) + dart.notNull(JSInt._shru(i, 16));
933 return dart.notNull(i) & 63;
934 }
935 static _shru(value, shift) {
936 return value >>> shift;
937 }
938 static _shrs(value, shift) {
939 return value >> shift;
940 }
941 static _ors(a, b) {
942 return a | b;
943 }
944 static _spread(i) {
945 i = JSInt._ors(i, JSInt._shrs(i, 1));
946 i = JSInt._ors(i, JSInt._shrs(i, 2));
947 i = JSInt._ors(i, JSInt._shrs(i, 4));
948 i = JSInt._ors(i, JSInt._shrs(i, 8));
949 i = JSInt._shru(JSInt._ors(i, JSInt._shrs(i, 16)), 0);
950 return i;
951 }
952 get runtimeType() {
953 return core.int;
954 }
955 [dartx['~']]() {
956 return dart.as(~this >>> 0, core.int);
957 }
958 }
959 JSInt[dart.implements] = () => [core.int, core.double];
960 dart.setSignature(JSInt, {
961 constructors: () => ({JSInt: [JSInt, []]}),
962 methods: () => ({
963 [dartx.toUnsigned]: [core.int, [core.int]],
964 [dartx.toSigned]: [core.int, [core.int]],
965 [dartx['~']]: [core.int, []]
966 }),
967 statics: () => ({
968 _bitCount: [core.int, [core.int]],
969 _shru: [core.int, [core.int, core.int]],
970 _shrs: [core.int, [core.int, core.int]],
971 _ors: [core.int, [core.int, core.int]],
972 _spread: [core.int, [core.int]]
973 }),
974 names: ['_bitCount', '_shru', '_shrs', '_ors', '_spread']
975 });
976 JSInt[dart.metadata] = () => [dart.const(new _js_helper.JsPeerInterface({name: 'Number'}))];
977 dart.registerExtension(dart.global.Number, JSInt);
978 dart.defineExtensionNames([
979 'runtimeType'
980 ]);
981 class JSDouble extends JSNumber {
982 JSDouble() {
983 super.JSNumber();
984 }
985 get runtimeType() {
986 return core.double;
987 }
988 }
989 JSDouble[dart.implements] = () => [core.double];
990 dart.setSignature(JSDouble, {
991 constructors: () => ({JSDouble: [JSDouble, []]})
992 });
993 class JSPositiveInt extends JSInt {
994 JSPositiveInt() {
995 super.JSInt();
996 }
997 }
998 class JSUInt32 extends JSPositiveInt {}
999 class JSUInt31 extends JSUInt32 {}
1000 let _defaultSplit = Symbol('_defaultSplit');
1001 dart.defineExtensionNames([
1002 'codeUnitAt',
1003 'allMatches',
1004 'matchAsPrefix',
1005 '+',
1006 'endsWith',
1007 'replaceAll',
1008 'replaceAllMapped',
1009 'splitMapJoin',
1010 'replaceFirst',
1011 'split',
1012 'startsWith',
1013 'substring',
1014 'toLowerCase',
1015 'toUpperCase',
1016 'trim',
1017 'trimLeft',
1018 'trimRight',
1019 '*',
1020 'padLeft',
1021 'padRight',
1022 'codeUnits',
1023 'runes',
1024 'indexOf',
1025 'lastIndexOf',
1026 'contains',
1027 'isEmpty',
1028 'isNotEmpty',
1029 'compareTo',
1030 'toString',
1031 'hashCode',
1032 'runtimeType',
1033 'length',
1034 'get'
1035 ]);
1036 class JSString extends Interceptor {
1037 JSString() {
1038 super.Interceptor();
1039 }
1040 [dartx.codeUnitAt](index) {
1041 if (!(typeof index == 'number'))
1042 dart.throw(new core.ArgumentError(index));
1043 if (dart.notNull(index) < 0)
1044 dart.throw(new core.RangeError.value(index));
1045 if (dart.notNull(index) >= dart.notNull(this[dartx.length]))
1046 dart.throw(new core.RangeError.value(index));
1047 return dart.as(this.charCodeAt(index), core.int);
1048 }
1049 [dartx.allMatches](string, start) {
1050 if (start === void 0)
1051 start = 0;
1052 _js_helper.checkString(string);
1053 _js_helper.checkInt(start);
1054 if (0 > dart.notNull(start) || dart.notNull(start) > dart.notNull(string[d artx.length])) {
1055 dart.throw(new core.RangeError.range(start, 0, string[dartx.length]));
1056 }
1057 return _js_helper.allMatchesInStringUnchecked(this, string, start);
1058 }
1059 [dartx.matchAsPrefix](string, start) {
1060 if (start === void 0)
1061 start = 0;
1062 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(string[d artx.length])) {
1063 dart.throw(new core.RangeError.range(start, 0, string[dartx.length]));
1064 }
1065 if (dart.notNull(start) + dart.notNull(this[dartx.length]) > dart.notNull( string[dartx.length]))
1066 return null;
1067 for (let i = 0; dart.notNull(i) < dart.notNull(this[dartx.length]); i = da rt.notNull(i) + 1) {
1068 if (string[dartx.codeUnitAt](dart.notNull(start) + dart.notNull(i)) != t his[dartx.codeUnitAt](i)) {
1069 return null;
1070 }
1071 }
1072 return new _js_helper.StringMatch(start, string, this);
1073 }
1074 [dartx['+']](other) {
1075 if (!(typeof other == 'string'))
1076 dart.throw(new core.ArgumentError(other));
1077 return this + other;
1078 }
1079 [dartx.endsWith](other) {
1080 _js_helper.checkString(other);
1081 let otherLength = other[dartx.length];
1082 if (dart.notNull(otherLength) > dart.notNull(this[dartx.length]))
1083 return false;
1084 return other == this[dartx.substring](dart.notNull(this[dartx.length]) - d art.notNull(otherLength));
1085 }
1086 [dartx.replaceAll](from, to) {
1087 _js_helper.checkString(to);
1088 return dart.as(_js_helper.stringReplaceAllUnchecked(this, from, to), core. String);
1089 }
1090 [dartx.replaceAllMapped](from, convert) {
1091 return this[dartx.splitMapJoin](from, {onMatch: convert});
1092 }
1093 [dartx.splitMapJoin](from, opts) {
1094 let onMatch = opts && 'onMatch' in opts ? opts.onMatch : null;
1095 let onNonMatch = opts && 'onNonMatch' in opts ? opts.onNonMatch : null;
1096 return dart.as(_js_helper.stringReplaceAllFuncUnchecked(this, from, onMatc h, onNonMatch), core.String);
1097 }
1098 [dartx.replaceFirst](from, to, startIndex) {
1099 if (startIndex === void 0)
1100 startIndex = 0;
1101 _js_helper.checkString(to);
1102 _js_helper.checkInt(startIndex);
1103 if (dart.notNull(startIndex) < 0 || dart.notNull(startIndex) > dart.notNul l(this[dartx.length])) {
1104 dart.throw(new core.RangeError.range(startIndex, 0, this[dartx.length])) ;
1105 }
1106 return dart.as(_js_helper.stringReplaceFirstUnchecked(this, from, to, star tIndex), core.String);
1107 }
1108 [dartx.split](pattern) {
1109 _js_helper.checkNull(pattern);
1110 if (typeof pattern == 'string') {
1111 return dart.as(this.split(pattern), core.List$(core.String));
1112 } else if (dart.is(pattern, _js_helper.JSSyntaxRegExp) && _js_helper.regEx pCaptureCount(pattern) == 0) {
1113 let re = _js_helper.regExpGetNative(pattern);
1114 return dart.as(this.split(re), core.List$(core.String));
1115 } else {
1116 return this[_defaultSplit](pattern);
1117 }
1118 }
1119 [_defaultSplit](pattern) {
1120 let result = dart.list([], core.String);
1121 let start = 0;
1122 let length = 1;
1123 for (let match of pattern[dartx.allMatches](this)) {
1124 let matchStart = match.start;
1125 let matchEnd = match.end;
1126 length = dart.notNull(matchEnd) - dart.notNull(matchStart);
1127 if (length == 0 && start == matchStart) {
1128 continue;
1129 }
1130 let end = matchStart;
1131 result[dartx.add](this[dartx.substring](start, end));
1132 start = matchEnd;
1133 }
1134 if (dart.notNull(start) < dart.notNull(this[dartx.length]) || dart.notNull (length) > 0) {
1135 result[dartx.add](this[dartx.substring](start));
1136 }
1137 return result;
1138 }
1139 [dartx.startsWith](pattern, index) {
1140 if (index === void 0)
1141 index = 0;
1142 _js_helper.checkInt(index);
1143 if (dart.notNull(index) < 0 || dart.notNull(index) > dart.notNull(this[dar tx.length])) {
1144 dart.throw(new core.RangeError.range(index, 0, this[dartx.length]));
1145 }
1146 if (typeof pattern == 'string') {
1147 let other = pattern;
1148 let otherLength = other[dartx.length];
1149 let endIndex = dart.notNull(index) + dart.notNull(otherLength);
1150 if (dart.notNull(endIndex) > dart.notNull(this[dartx.length]))
1151 return false;
1152 return other == this.substring(index, endIndex);
1153 }
1154 return pattern[dartx.matchAsPrefix](this, index) != null;
1155 }
1156 [dartx.substring](startIndex, endIndex) {
1157 if (endIndex === void 0)
1158 endIndex = null;
1159 _js_helper.checkInt(startIndex);
1160 if (endIndex == null)
1161 endIndex = this[dartx.length];
1162 _js_helper.checkInt(endIndex);
1163 if (dart.notNull(startIndex) < 0)
1164 dart.throw(new core.RangeError.value(startIndex));
1165 if (dart.notNull(startIndex) > dart.notNull(endIndex))
1166 dart.throw(new core.RangeError.value(startIndex));
1167 if (dart.notNull(endIndex) > dart.notNull(this[dartx.length]))
1168 dart.throw(new core.RangeError.value(endIndex));
1169 return this.substring(startIndex, endIndex);
1170 }
1171 [dartx.toLowerCase]() {
1172 return this.toLowerCase();
1173 }
1174 [dartx.toUpperCase]() {
1175 return this.toUpperCase();
1176 }
1177 static _isWhitespace(codeUnit) {
1178 if (dart.notNull(codeUnit) < 256) {
1179 switch (codeUnit) {
1180 case 9:
1181 case 10:
1182 case 11:
1183 case 12:
1184 case 13:
1185 case 32:
1186 case 133:
1187 case 160:
1188 {
1189 return true;
1190 }
1191 default:
1192 {
1193 return false;
1194 }
1195 }
1196 }
1197 switch (codeUnit) {
1198 case 5760:
1199 case 6158:
1200 case 8192:
1201 case 8193:
1202 case 8194:
1203 case 8195:
1204 case 8196:
1205 case 8197:
1206 case 8198:
1207 case 8199:
1208 case 8200:
1209 case 8201:
1210 case 8202:
1211 case 8232:
1212 case 8233:
1213 case 8239:
1214 case 8287:
1215 case 12288:
1216 case 65279:
1217 {
1218 return true;
1219 }
1220 default:
1221 {
1222 return false;
1223 }
1224 }
1225 }
1226 static _skipLeadingWhitespace(string, index) {
1227 let SPACE = 32;
1228 let CARRIAGE_RETURN = 13;
1229 while (dart.notNull(index) < dart.notNull(string[dartx.length])) {
1230 let codeUnit = string[dartx.codeUnitAt](index);
1231 if (codeUnit != SPACE && codeUnit != CARRIAGE_RETURN && !dart.notNull(JS String._isWhitespace(codeUnit))) {
1232 break;
1233 }
1234 index = dart.notNull(index) + 1;
1235 }
1236 return index;
1237 }
1238 static _skipTrailingWhitespace(string, index) {
1239 let SPACE = 32;
1240 let CARRIAGE_RETURN = 13;
1241 while (dart.notNull(index) > 0) {
1242 let codeUnit = string[dartx.codeUnitAt](dart.notNull(index) - 1);
1243 if (codeUnit != SPACE && codeUnit != CARRIAGE_RETURN && !dart.notNull(JS String._isWhitespace(codeUnit))) {
1244 break;
1245 }
1246 index = dart.notNull(index) - 1;
1247 }
1248 return index;
1249 }
1250 [dartx.trim]() {
1251 let NEL = 133;
1252 let result = this.trim();
1253 if (result[dartx.length] == 0)
1254 return result;
1255 let firstCode = result[dartx.codeUnitAt](0);
1256 let startIndex = 0;
1257 if (firstCode == NEL) {
1258 startIndex = JSString._skipLeadingWhitespace(result, 1);
1259 if (startIndex == result[dartx.length])
1260 return "";
1261 }
1262 let endIndex = result[dartx.length];
1263 let lastCode = result[dartx.codeUnitAt](dart.notNull(endIndex) - 1);
1264 if (lastCode == NEL) {
1265 endIndex = JSString._skipTrailingWhitespace(result, dart.notNull(endInde x) - 1);
1266 }
1267 if (startIndex == 0 && endIndex == result[dartx.length])
1268 return result;
1269 return result.substring(startIndex, endIndex);
1270 }
1271 [dartx.trimLeft]() {
1272 let NEL = 133;
1273 let result = null;
1274 let startIndex = 0;
1275 if (typeof this.trimLeft != "undefined") {
1276 result = this.trimLeft();
1277 if (result[dartx.length] == 0)
1278 return result;
1279 let firstCode = result[dartx.codeUnitAt](0);
1280 if (firstCode == NEL) {
1281 startIndex = JSString._skipLeadingWhitespace(result, 1);
1282 }
1283 } else {
1284 result = this;
1285 startIndex = JSString._skipLeadingWhitespace(this, 0);
1286 }
1287 if (startIndex == 0)
1288 return result;
1289 if (startIndex == result[dartx.length])
1290 return "";
1291 return result.substring(startIndex);
1292 }
1293 [dartx.trimRight]() {
1294 let NEL = 133;
1295 let result = null;
1296 let endIndex = null;
1297 if (typeof this.trimRight != "undefined") {
1298 result = this.trimRight();
1299 endIndex = result[dartx.length];
1300 if (endIndex == 0)
1301 return result;
1302 let lastCode = result[dartx.codeUnitAt](dart.notNull(endIndex) - 1);
1303 if (lastCode == NEL) {
1304 endIndex = JSString._skipTrailingWhitespace(result, dart.notNull(endIn dex) - 1);
1305 }
1306 } else {
1307 result = this;
1308 endIndex = JSString._skipTrailingWhitespace(this, this[dartx.length]);
1309 }
1310 if (endIndex == result[dartx.length])
1311 return result;
1312 if (endIndex == 0)
1313 return "";
1314 return result.substring(0, endIndex);
1315 }
1316 [dartx['*']](times) {
1317 if (0 >= dart.notNull(times))
1318 return '';
1319 if (times == 1 || this[dartx.length] == 0)
1320 return this;
1321 if (!dart.equals(times, times >>> 0)) {
1322 dart.throw(dart.const(new core.OutOfMemoryError()));
1323 }
1324 let result = '';
1325 let s = this;
1326 while (true) {
1327 if ((dart.notNull(times) & 1) == 1)
1328 result = s[dartx['+']](result);
1329 times = dart.as(times >>> 1, core.int);
1330 if (times == 0)
1331 break;
1332 s = s[dartx['+']](s);
1333 }
1334 return result;
1335 }
1336 [dartx.padLeft](width, padding) {
1337 if (padding === void 0)
1338 padding = ' ';
1339 let delta = dart.notNull(width) - dart.notNull(this[dartx.length]);
1340 if (dart.notNull(delta) <= 0)
1341 return this;
1342 return padding[dartx['*']](delta) + this;
1343 }
1344 [dartx.padRight](width, padding) {
1345 if (padding === void 0)
1346 padding = ' ';
1347 let delta = dart.notNull(width) - dart.notNull(this[dartx.length]);
1348 if (dart.notNull(delta) <= 0)
1349 return this;
1350 return this[dartx['+']](padding[dartx['*']](delta));
1351 }
1352 get [dartx.codeUnits]() {
1353 return new _CodeUnits(this);
1354 }
1355 get [dartx.runes]() {
1356 return new core.Runes(this);
1357 }
1358 [dartx.indexOf](pattern, start) {
1359 if (start === void 0)
1360 start = 0;
1361 _js_helper.checkNull(pattern);
1362 if (!(typeof start == 'number'))
1363 dart.throw(new core.ArgumentError(start));
1364 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(this[dar tx.length])) {
1365 dart.throw(new core.RangeError.range(start, 0, this[dartx.length]));
1366 }
1367 if (typeof pattern == 'string') {
1368 return this.indexOf(pattern, start);
1369 }
1370 if (dart.is(pattern, _js_helper.JSSyntaxRegExp)) {
1371 let re = pattern;
1372 let match = _js_helper.firstMatchAfter(re, this, start);
1373 return match == null ? -1 : match.start;
1374 }
1375 for (let i = start; dart.notNull(i) <= dart.notNull(this[dartx.length]); i = dart.notNull(i) + 1) {
1376 if (pattern[dartx.matchAsPrefix](this, i) != null)
1377 return i;
1378 }
1379 return -1;
1380 }
1381 [dartx.lastIndexOf](pattern, start) {
1382 if (start === void 0)
1383 start = null;
1384 _js_helper.checkNull(pattern);
1385 if (start == null) {
1386 start = this[dartx.length];
1387 } else if (!(typeof start == 'number')) {
1388 dart.throw(new core.ArgumentError(start));
1389 } else if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(t his[dartx.length])) {
1390 dart.throw(new core.RangeError.range(start, 0, this[dartx.length]));
1391 }
1392 if (typeof pattern == 'string') {
1393 let other = pattern;
1394 if (dart.notNull(start) + dart.notNull(other[dartx.length]) > dart.notNu ll(this[dartx.length])) {
1395 start = dart.notNull(this[dartx.length]) - dart.notNull(other[dartx.le ngth]);
1396 }
1397 return dart.as(_js_helper.stringLastIndexOfUnchecked(this, other, start) , core.int);
1398 }
1399 for (let i = start; dart.notNull(i) >= 0; i = dart.notNull(i) - 1) {
1400 if (pattern[dartx.matchAsPrefix](this, i) != null)
1401 return i;
1402 }
1403 return -1;
1404 }
1405 [dartx.contains](other, startIndex) {
1406 if (startIndex === void 0)
1407 startIndex = 0;
1408 _js_helper.checkNull(other);
1409 if (dart.notNull(startIndex) < 0 || dart.notNull(startIndex) > dart.notNul l(this[dartx.length])) {
1410 dart.throw(new core.RangeError.range(startIndex, 0, this[dartx.length])) ;
1411 }
1412 return dart.as(_js_helper.stringContainsUnchecked(this, other, startIndex) , core.bool);
1413 }
1414 get [dartx.isEmpty]() {
1415 return this[dartx.length] == 0;
1416 }
1417 get [dartx.isNotEmpty]() {
1418 return !dart.notNull(this[dartx.isEmpty]);
1419 }
1420 [dartx.compareTo](other) {
1421 if (!(typeof other == 'string'))
1422 dart.throw(new core.ArgumentError(other));
1423 return dart.equals(this, other) ? 0 : this < other ? -1 : 1;
1424 }
1425 toString() {
1426 return this;
1427 }
1428 get hashCode() {
1429 let hash = 0;
1430 for (let i = 0; dart.notNull(i) < dart.notNull(this[dartx.length]); i = da rt.notNull(i) + 1) {
1431 hash = 536870911 & dart.notNull(hash) + this.charCodeAt(i);
1432 hash = 536870911 & dart.notNull(hash) + ((524287 & dart.notNull(hash)) < < 10);
1433 hash = hash ^ hash >> 6;
1434 }
1435 hash = 536870911 & dart.notNull(hash) + ((67108863 & dart.notNull(hash)) < < 3);
1436 hash = hash ^ hash >> 11;
1437 return 536870911 & dart.notNull(hash) + ((16383 & dart.notNull(hash)) << 1 5);
1438 }
1439 get runtimeType() {
1440 return core.String;
1441 }
1442 get [dartx.length]() {
1443 return this.length;
1444 }
1445 [dartx.get](index) {
1446 if (!(typeof index == 'number'))
1447 dart.throw(new core.ArgumentError(index));
1448 if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notNul l(index) < 0)
1449 dart.throw(new core.RangeError.value(index));
1450 return this[index];
1451 }
1452 }
1453 JSString[dart.implements] = () => [core.String, JSIndexable];
1454 dart.setSignature(JSString, {
1455 constructors: () => ({JSString: [JSString, []]}),
1456 methods: () => ({
1457 [dartx.codeUnitAt]: [core.int, [core.int]],
1458 [dartx.allMatches]: [core.Iterable$(core.Match), [core.String], [core.int] ],
1459 [dartx.matchAsPrefix]: [core.Match, [core.String], [core.int]],
1460 [dartx['+']]: [core.String, [core.String]],
1461 [dartx.endsWith]: [core.bool, [core.String]],
1462 [dartx.replaceAll]: [core.String, [core.Pattern, core.String]],
1463 [dartx.replaceAllMapped]: [core.String, [core.Pattern, dart.functionType(c ore.String, [core.Match])]],
1464 [dartx.splitMapJoin]: [core.String, [core.Pattern], {onMatch: dart.functio nType(core.String, [core.Match]), onNonMatch: dart.functionType(core.String, [co re.String])}],
1465 [dartx.replaceFirst]: [core.String, [core.Pattern, core.String], [core.int ]],
1466 [dartx.split]: [core.List$(core.String), [core.Pattern]],
1467 [_defaultSplit]: [core.List$(core.String), [core.Pattern]],
1468 [dartx.startsWith]: [core.bool, [core.Pattern], [core.int]],
1469 [dartx.substring]: [core.String, [core.int], [core.int]],
1470 [dartx.toLowerCase]: [core.String, []],
1471 [dartx.toUpperCase]: [core.String, []],
1472 [dartx.trim]: [core.String, []],
1473 [dartx.trimLeft]: [core.String, []],
1474 [dartx.trimRight]: [core.String, []],
1475 [dartx['*']]: [core.String, [core.int]],
1476 [dartx.padLeft]: [core.String, [core.int], [core.String]],
1477 [dartx.padRight]: [core.String, [core.int], [core.String]],
1478 [dartx.indexOf]: [core.int, [core.Pattern], [core.int]],
1479 [dartx.lastIndexOf]: [core.int, [core.Pattern], [core.int]],
1480 [dartx.contains]: [core.bool, [core.Pattern], [core.int]],
1481 [dartx.compareTo]: [core.int, [core.String]],
1482 [dartx.get]: [core.String, [core.int]]
1483 }),
1484 statics: () => ({
1485 _isWhitespace: [core.bool, [core.int]],
1486 _skipLeadingWhitespace: [core.int, [core.String, core.int]],
1487 _skipTrailingWhitespace: [core.int, [core.String, core.int]]
1488 }),
1489 names: ['_isWhitespace', '_skipLeadingWhitespace', '_skipTrailingWhitespace' ]
1490 });
1491 JSString[dart.metadata] = () => [dart.const(new _js_helper.JsPeerInterface({na me: 'String'}))];
1492 dart.registerExtension(dart.global.String, JSString);
1493 let _string = Symbol('_string');
1494 class _CodeUnits extends _internal.UnmodifiableListBase$(core.int) {
1495 _CodeUnits(string) {
1496 this[_string] = string;
1497 }
1498 get length() {
1499 return this[_string][dartx.length];
1500 }
1501 get(i) {
1502 return this[_string][dartx.codeUnitAt](i);
1503 }
1504 }
1505 dart.setSignature(_CodeUnits, {
1506 constructors: () => ({_CodeUnits: [_CodeUnits, [core.String]]}),
1507 methods: () => ({get: [core.int, [core.int]]})
1508 });
1509 dart.defineExtensionMembers(_CodeUnits, ['get', 'length']);
1510 function getInterceptor(obj) {
1511 return obj;
1512 }
1513 dart.fn(getInterceptor);
1514 dart.defineExtensionNames([
1515 'toString',
1516 'hashCode',
1517 'runtimeType'
1518 ]);
1519 class JSBool extends Interceptor {
1520 JSBool() {
1521 super.Interceptor();
1522 }
1523 toString() {
1524 return String(this);
1525 }
1526 get hashCode() {
1527 return this ? 2 * 3 * 23 * 3761 : 269 * 811;
1528 }
1529 get runtimeType() {
1530 return core.bool;
1531 }
1532 }
1533 JSBool[dart.implements] = () => [core.bool];
1534 dart.setSignature(JSBool, {
1535 constructors: () => ({JSBool: [JSBool, []]})
1536 });
1537 JSBool[dart.metadata] = () => [dart.const(new _js_helper.JsPeerInterface({name : 'Boolean'}))];
1538 dart.registerExtension(dart.global.Boolean, JSBool);
1539 class JSIndexable extends core.Object {}
1540 class JSMutableIndexable extends JSIndexable {}
1541 class JSObject extends core.Object {}
1542 class JavaScriptObject extends Interceptor {
1543 JavaScriptObject() {
1544 super.Interceptor();
1545 }
1546 get hashCode() {
1547 return 0;
1548 }
1549 get runtimeType() {
1550 return JSObject;
1551 }
1552 }
1553 JavaScriptObject[dart.implements] = () => [JSObject];
1554 dart.setSignature(JavaScriptObject, {
1555 constructors: () => ({JavaScriptObject: [JavaScriptObject, []]})
1556 });
1557 class PlainJavaScriptObject extends JavaScriptObject {
1558 PlainJavaScriptObject() {
1559 super.JavaScriptObject();
1560 }
1561 }
1562 dart.setSignature(PlainJavaScriptObject, {
1563 constructors: () => ({PlainJavaScriptObject: [PlainJavaScriptObject, []]})
1564 });
1565 class UnknownJavaScriptObject extends JavaScriptObject {
1566 UnknownJavaScriptObject() {
1567 super.JavaScriptObject();
1568 }
1569 toString() {
1570 return String(this);
1571 }
1572 }
1573 dart.setSignature(UnknownJavaScriptObject, {
1574 constructors: () => ({UnknownJavaScriptObject: [UnknownJavaScriptObject, []] })
1575 });
1576 // Exports:
1577 exports.JSArray$ = JSArray$;
1578 exports.JSArray = JSArray;
1579 exports.JSMutableArray$ = JSMutableArray$;
1580 exports.JSMutableArray = JSMutableArray;
1581 exports.JSFixedArray$ = JSFixedArray$;
1582 exports.JSFixedArray = JSFixedArray;
1583 exports.JSExtendableArray$ = JSExtendableArray$;
1584 exports.JSExtendableArray = JSExtendableArray;
1585 exports.Interceptor = Interceptor;
1586 exports.JSNumber = JSNumber;
1587 exports.JSInt = JSInt;
1588 exports.JSDouble = JSDouble;
1589 exports.JSPositiveInt = JSPositiveInt;
1590 exports.JSUInt32 = JSUInt32;
1591 exports.JSUInt31 = JSUInt31;
1592 exports.JSString = JSString;
1593 exports.getInterceptor = getInterceptor;
1594 exports.JSBool = JSBool;
1595 exports.JSIndexable = JSIndexable;
1596 exports.JSMutableIndexable = JSMutableIndexable;
1597 exports.JSObject = JSObject;
1598 exports.JavaScriptObject = JavaScriptObject;
1599 exports.PlainJavaScriptObject = PlainJavaScriptObject;
1600 exports.UnknownJavaScriptObject = UnknownJavaScriptObject;
1601 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698