OLD | NEW |
1 dart_library.library('dart/_interceptors', null, /* Imports */[ | 1 dart_library.library('dart/_interceptors', null, /* Imports */[ |
2 "dart/_runtime", | 2 "dart/_runtime", |
3 'dart/core', | 3 'dart/core', |
4 'dart/_internal', | 4 'dart/_internal', |
5 'dart/collection', | 5 'dart/collection', |
6 'dart/math' | 6 'dart/math' |
7 ], /* Lazy imports */[ | 7 ], /* Lazy imports */[ |
8 'dart/_js_helper' | 8 'dart/_js_helper' |
9 ], function(exports, dart, core, _internal, collection, math, _js_helper) { | 9 ], function(exports, dart, core, _internal, collection, math, _js_helper) { |
10 'use strict'; | 10 'use strict'; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 class JSArray extends core.Object { | 71 class JSArray extends core.Object { |
72 JSArray() { | 72 JSArray() { |
73 } | 73 } |
74 static typed(allocation) { | 74 static typed(allocation) { |
75 return dart.list(allocation, E); | 75 return dart.list(allocation, E); |
76 } | 76 } |
77 static markFixed(allocation) { | 77 static markFixed(allocation) { |
78 return JSArray$(E).typed(JSArray$().markFixedList(dart.as(allocation, co
re.List))); | 78 return JSArray$(E).typed(JSArray$().markFixedList(dart.as(allocation, co
re.List))); |
79 } | 79 } |
80 static markGrowable(allocation) { | 80 static markGrowable(allocation) { |
81 return JSArray$().typed(allocation); | 81 return JSArray$(E).typed(allocation); |
82 } | 82 } |
83 static markFixedList(list) { | 83 static markFixedList(list) { |
84 list.fixed$length = Array; | 84 list.fixed$length = Array; |
85 return list; | 85 return list; |
86 } | 86 } |
87 [dartx.checkGrowable](reason) { | 87 [dartx.checkGrowable](reason) { |
88 if (this.fixed$length) { | 88 if (this.fixed$length) { |
89 dart.throw(new core.UnsupportedError(dart.as(reason, core.String))); | 89 dart.throw(new core.UnsupportedError(dart.as(reason, core.String))); |
90 } | 90 } |
91 } | 91 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 [dartx.skip](n) { | 192 [dartx.skip](n) { |
193 return new (_internal.IterableMixinWorkaround$(E))().skipList(this, n); | 193 return new (_internal.IterableMixinWorkaround$(E))().skipList(this, n); |
194 } | 194 } |
195 [dartx.skipWhile](test) { | 195 [dartx.skipWhile](test) { |
196 dart.as(test, dart.functionType(core.bool, [E])); | 196 dart.as(test, dart.functionType(core.bool, [E])); |
197 return new (_internal.IterableMixinWorkaround$(E))().skipWhile(this, tes
t); | 197 return new (_internal.IterableMixinWorkaround$(E))().skipWhile(this, tes
t); |
198 } | 198 } |
199 [dartx.reduce](combine) { | 199 [dartx.reduce](combine) { |
200 dart.as(combine, dart.functionType(E, [E, E])); | 200 dart.as(combine, dart.functionType(E, [E, E])); |
201 return dart.as(_internal.IterableMixinWorkaround.reduce(this, combine),
E); | 201 return _internal.IterableMixinWorkaround.reduce(this, combine); |
202 } | 202 } |
203 [dartx.fold](initialValue, combine) { | 203 [dartx.fold](initialValue, combine) { |
204 dart.as(combine, dart.functionType(dart.dynamic, [dart.dynamic, E])); | 204 dart.as(combine, dart.functionType(dart.dynamic, [dart.dynamic, E])); |
205 return _internal.IterableMixinWorkaround.fold(this, initialValue, combin
e); | 205 return _internal.IterableMixinWorkaround.fold(this, initialValue, combin
e); |
206 } | 206 } |
207 [dartx.firstWhere](test, opts) { | 207 [dartx.firstWhere](test, opts) { |
208 dart.as(test, dart.functionType(core.bool, [E])); | 208 dart.as(test, dart.functionType(core.bool, [E])); |
209 let orElse = opts && 'orElse' in opts ? opts.orElse : null; | 209 let orElse = opts && 'orElse' in opts ? opts.orElse : null; |
210 dart.as(orElse, dart.functionType(E, [])); | 210 dart.as(orElse, dart.functionType(E, [])); |
211 return dart.as(_internal.IterableMixinWorkaround.firstWhere(this, test,
orElse), E); | 211 return _internal.IterableMixinWorkaround.firstWhere(this, test, orElse); |
212 } | 212 } |
213 [dartx.lastWhere](test, opts) { | 213 [dartx.lastWhere](test, opts) { |
214 dart.as(test, dart.functionType(core.bool, [E])); | 214 dart.as(test, dart.functionType(core.bool, [E])); |
215 let orElse = opts && 'orElse' in opts ? opts.orElse : null; | 215 let orElse = opts && 'orElse' in opts ? opts.orElse : null; |
216 dart.as(orElse, dart.functionType(E, [])); | 216 dart.as(orElse, dart.functionType(E, [])); |
217 return dart.as(_internal.IterableMixinWorkaround.lastWhereList(this, tes
t, orElse), E); | 217 return _internal.IterableMixinWorkaround.lastWhereList(this, test, orEls
e); |
218 } | 218 } |
219 [dartx.singleWhere](test) { | 219 [dartx.singleWhere](test) { |
220 dart.as(test, dart.functionType(core.bool, [E])); | 220 dart.as(test, dart.functionType(core.bool, [E])); |
221 return dart.as(_internal.IterableMixinWorkaround.singleWhere(this, test)
, E); | 221 return _internal.IterableMixinWorkaround.singleWhere(this, test); |
222 } | 222 } |
223 [dartx.elementAt](index) { | 223 [dartx.elementAt](index) { |
224 return this[dartx.get](index); | 224 return this[dartx.get](index); |
225 } | 225 } |
226 [dartx.sublist](start, end) { | 226 [dartx.sublist](start, end) { |
227 if (end === void 0) end = null; | 227 if (end === void 0) end = null; |
228 _js_helper.checkNull(start); | 228 _js_helper.checkNull(start); |
229 if (!(typeof start == 'number')) dart.throw(new core.ArgumentError(start
)); | 229 if (!(typeof start == 'number')) dart.throw(new core.ArgumentError(start
)); |
230 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(this[d
artx.length])) { | 230 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(this[d
artx.length])) { |
231 dart.throw(new core.RangeError.range(start, 0, this[dartx.length])); | 231 dart.throw(new core.RangeError.range(start, 0, this[dartx.length])); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 ]); | 513 ]); |
514 class JSNumber extends Interceptor { | 514 class JSNumber extends Interceptor { |
515 JSNumber() { | 515 JSNumber() { |
516 super.Interceptor(); | 516 super.Interceptor(); |
517 } | 517 } |
518 [dartx.compareTo](b) { | 518 [dartx.compareTo](b) { |
519 if (this < dart.notNull(b)) { | 519 if (this < dart.notNull(b)) { |
520 return -1; | 520 return -1; |
521 } else if (this > dart.notNull(b)) { | 521 } else if (this > dart.notNull(b)) { |
522 return 1; | 522 return 1; |
523 } else if (dart.equals(this, b)) { | 523 } else if (this == b) { |
524 if (dart.equals(this, 0)) { | 524 if (this == 0) { |
525 let bIsNegative = b[dartx.isNegative]; | 525 let bIsNegative = b[dartx.isNegative]; |
526 if (this[dartx.isNegative] == bIsNegative) return 0; | 526 if (this[dartx.isNegative] == bIsNegative) return 0; |
527 if (dart.notNull(this[dartx.isNegative])) return -1; | 527 if (dart.notNull(this[dartx.isNegative])) return -1; |
528 return 1; | 528 return 1; |
529 } | 529 } |
530 return 0; | 530 return 0; |
531 } else if (dart.notNull(this[dartx.isNaN])) { | 531 } else if (dart.notNull(this[dartx.isNaN])) { |
532 if (dart.notNull(b[dartx.isNaN])) { | 532 if (dart.notNull(b[dartx.isNaN])) { |
533 return 0; | 533 return 0; |
534 } | 534 } |
535 return 1; | 535 return 1; |
536 } else { | 536 } else { |
537 return -1; | 537 return -1; |
538 } | 538 } |
539 } | 539 } |
540 get [dartx.isNegative]() { | 540 get [dartx.isNegative]() { |
541 return dart.equals(this, 0) ? 1 / this < 0 : this < 0; | 541 return this == 0 ? 1 / this < 0 : this < 0; |
542 } | 542 } |
543 get [dartx.isNaN]() { | 543 get [dartx.isNaN]() { |
544 return isNaN(this); | 544 return isNaN(this); |
545 } | 545 } |
546 get [dartx.isInfinite]() { | 546 get [dartx.isInfinite]() { |
547 return this == Infinity || this == -Infinity; | 547 return this == Infinity || this == -Infinity; |
548 } | 548 } |
549 get [dartx.isFinite]() { | 549 get [dartx.isFinite]() { |
550 return isFinite(this); | 550 return isFinite(this); |
551 } | 551 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 } | 606 } |
607 [dartx.toDouble]() { | 607 [dartx.toDouble]() { |
608 return this; | 608 return this; |
609 } | 609 } |
610 [dartx.toStringAsFixed](fractionDigits) { | 610 [dartx.toStringAsFixed](fractionDigits) { |
611 _js_helper.checkInt(fractionDigits); | 611 _js_helper.checkInt(fractionDigits); |
612 if (dart.notNull(fractionDigits) < 0 || dart.notNull(fractionDigits) > 20)
{ | 612 if (dart.notNull(fractionDigits) < 0 || dart.notNull(fractionDigits) > 20)
{ |
613 dart.throw(new core.RangeError(fractionDigits)); | 613 dart.throw(new core.RangeError(fractionDigits)); |
614 } | 614 } |
615 let result = this.toFixed(fractionDigits); | 615 let result = this.toFixed(fractionDigits); |
616 if (dart.equals(this, 0) && dart.notNull(this[dartx.isNegative])) return `
-${result}`; | 616 if (this == 0 && dart.notNull(this[dartx.isNegative])) return `-${result}`
; |
617 return result; | 617 return result; |
618 } | 618 } |
619 [dartx.toStringAsExponential](fractionDigits) { | 619 [dartx.toStringAsExponential](fractionDigits) { |
620 if (fractionDigits === void 0) fractionDigits = null; | 620 if (fractionDigits === void 0) fractionDigits = null; |
621 let result = null; | 621 let result = null; |
622 if (fractionDigits != null) { | 622 if (fractionDigits != null) { |
623 _js_helper.checkInt(fractionDigits); | 623 _js_helper.checkInt(fractionDigits); |
624 if (dart.notNull(fractionDigits) < 0 || dart.notNull(fractionDigits) > 2
0) { | 624 if (dart.notNull(fractionDigits) < 0 || dart.notNull(fractionDigits) > 2
0) { |
625 dart.throw(new core.RangeError(fractionDigits)); | 625 dart.throw(new core.RangeError(fractionDigits)); |
626 } | 626 } |
627 result = this.toExponential(fractionDigits); | 627 result = this.toExponential(fractionDigits); |
628 } else { | 628 } else { |
629 result = this.toExponential(); | 629 result = this.toExponential(); |
630 } | 630 } |
631 if (dart.equals(this, 0) && dart.notNull(this[dartx.isNegative])) return `
-${result}`; | 631 if (this == 0 && dart.notNull(this[dartx.isNegative])) return `-${result}`
; |
632 return result; | 632 return result; |
633 } | 633 } |
634 [dartx.toStringAsPrecision](precision) { | 634 [dartx.toStringAsPrecision](precision) { |
635 _js_helper.checkInt(precision); | 635 _js_helper.checkInt(precision); |
636 if (dart.notNull(precision) < 1 || dart.notNull(precision) > 21) { | 636 if (dart.notNull(precision) < 1 || dart.notNull(precision) > 21) { |
637 dart.throw(new core.RangeError(precision)); | 637 dart.throw(new core.RangeError(precision)); |
638 } | 638 } |
639 let result = this.toPrecision(precision); | 639 let result = this.toPrecision(precision); |
640 if (dart.equals(this, 0) && dart.notNull(this[dartx.isNegative])) return `
-${result}`; | 640 if (this == 0 && dart.notNull(this[dartx.isNegative])) return `-${result}`
; |
641 return result; | 641 return result; |
642 } | 642 } |
643 [dartx.toRadixString](radix) { | 643 [dartx.toRadixString](radix) { |
644 _js_helper.checkInt(radix); | 644 _js_helper.checkInt(radix); |
645 if (dart.notNull(radix) < 2 || dart.notNull(radix) > 36) dart.throw(new co
re.RangeError(radix)); | 645 if (dart.notNull(radix) < 2 || dart.notNull(radix) > 36) dart.throw(new co
re.RangeError(radix)); |
646 let result = this.toString(radix); | 646 let result = this.toString(radix); |
647 let rightParenCode = 41; | 647 let rightParenCode = 41; |
648 if (result[dartx.codeUnitAt](dart.notNull(result[dartx.length]) - 1) != ri
ghtParenCode) { | 648 if (result[dartx.codeUnitAt](dart.notNull(result[dartx.length]) - 1) != ri
ghtParenCode) { |
649 return result; | 649 return result; |
650 } | 650 } |
651 return JSNumber._handleIEtoString(result); | 651 return JSNumber._handleIEtoString(result); |
652 } | 652 } |
653 static _handleIEtoString(result) { | 653 static _handleIEtoString(result) { |
654 let match = /^([\da-z]+)(?:\.([\da-z]+))?\(e\+(\d+)\)$/.exec(result); | 654 let match = /^([\da-z]+)(?:\.([\da-z]+))?\(e\+(\d+)\)$/.exec(result); |
655 if (match == null) { | 655 if (match == null) { |
656 dart.throw(new core.UnsupportedError(`Unexpected toString result: ${resu
lt}`)); | 656 dart.throw(new core.UnsupportedError(`Unexpected toString result: ${resu
lt}`)); |
657 } | 657 } |
658 result = dart.dindex(match, 1); | 658 result = dart.dindex(match, 1); |
659 let exponent = +dart.dindex(match, 3); | 659 let exponent = +dart.dindex(match, 3); |
660 if (dart.dindex(match, 2) != null) { | 660 if (dart.dindex(match, 2) != null) { |
661 result = result + dart.dindex(match, 2); | 661 result = result + dart.dindex(match, 2); |
662 exponent = dart.notNull(exponent) - dart.dindex(match, 2).length; | 662 exponent = dart.notNull(exponent) - dart.dindex(match, 2).length; |
663 } | 663 } |
664 return dart.notNull(result) + "0"[dartx['*']](exponent); | 664 return dart.notNull(result) + "0"[dartx['*']](exponent); |
665 } | 665 } |
666 toString() { | 666 toString() { |
667 if (dart.equals(this, 0) && 1 / this < 0) { | 667 if (this == 0 && 1 / this < 0) { |
668 return '-0.0'; | 668 return '-0.0'; |
669 } else { | 669 } else { |
670 return "" + this; | 670 return "" + this; |
671 } | 671 } |
672 } | 672 } |
673 get hashCode() { | 673 get hashCode() { |
674 return this & 0x1FFFFFFF; | 674 return this & 0x1FFFFFFF; |
675 } | 675 } |
676 [dartx['unary-']]() { | 676 [dartx['unary-']]() { |
677 return -this; | 677 return -this; |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 exports.JSString = JSString; | 1421 exports.JSString = JSString; |
1422 exports.getInterceptor = getInterceptor; | 1422 exports.getInterceptor = getInterceptor; |
1423 exports.JSBool = JSBool; | 1423 exports.JSBool = JSBool; |
1424 exports.JSIndexable = JSIndexable; | 1424 exports.JSIndexable = JSIndexable; |
1425 exports.JSMutableIndexable = JSMutableIndexable; | 1425 exports.JSMutableIndexable = JSMutableIndexable; |
1426 exports.JSObject = JSObject; | 1426 exports.JSObject = JSObject; |
1427 exports.JavaScriptObject = JavaScriptObject; | 1427 exports.JavaScriptObject = JavaScriptObject; |
1428 exports.PlainJavaScriptObject = PlainJavaScriptObject; | 1428 exports.PlainJavaScriptObject = PlainJavaScriptObject; |
1429 exports.UnknownJavaScriptObject = UnknownJavaScriptObject; | 1429 exports.UnknownJavaScriptObject = UnknownJavaScriptObject; |
1430 }); | 1430 }); |
OLD | NEW |