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

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

Issue 1156993015: fixes #193, factory constructors as static methods (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 var _js_helper = dart.defineLibrary(_js_helper, {}); 1 var _js_helper = dart.defineLibrary(_js_helper, {});
2 var core = dart.import(core); 2 var core = dart.import(core);
3 var collection = dart.import(collection); 3 var collection = dart.import(collection);
4 var _internal = dart.import(_internal); 4 var _internal = dart.import(_internal);
5 var _foreign_helper = dart.import(_foreign_helper); 5 var _foreign_helper = dart.import(_foreign_helper);
6 var _js_embedded_names = dart.import(_js_embedded_names); 6 var _js_embedded_names = dart.import(_js_embedded_names);
7 var _interceptors = dart.lazyImport(_interceptors); 7 var _interceptors = dart.lazyImport(_interceptors);
8 var _js_names = dart.import(_js_names); 8 var _js_names = dart.import(_js_names);
9 var async = dart.import(async); 9 var async = dart.import(async);
10 var _isolate_helper = dart.lazyImport(_isolate_helper); 10 var _isolate_helper = dart.lazyImport(_isolate_helper);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 let keys = this[_keys]; 135 let keys = this[_keys];
136 for (let i = 0; dart.notNull(i) < dart.notNull(dart.as(dart.dload(keys, 'length'), core.num)); i = dart.notNull(i) + 1) { 136 for (let i = 0; dart.notNull(i) < dart.notNull(dart.as(dart.dload(keys, 'length'), core.num)); i = dart.notNull(i) + 1) {
137 let key = dart.dindex(keys, i); 137 let key = dart.dindex(keys, i);
138 f(dart.as(key, K), dart.as(this[_fetch](key), V)); 138 f(dart.as(key, K), dart.as(this[_fetch](key), V));
139 } 139 }
140 } 140 }
141 get keys() { 141 get keys() {
142 return new (_ConstantMapKeyIterable$(K))(this); 142 return new (_ConstantMapKeyIterable$(K))(this);
143 } 143 }
144 get values() { 144 get values() {
145 return new (_internal.MappedIterable$(K, V))(this[_keys], dart.fn((key = > dart.as(this[_fetch](key), V)).bind(this), V, [core.Object])); 145 return _internal.MappedIterable$(K, V).new(this[_keys], dart.fn((key => dart.as(this[_fetch](key), V)).bind(this), V, [core.Object]));
146 } 146 }
147 } 147 }
148 ConstantStringMap[dart.implements] = () => [_internal.EfficientLength]; 148 ConstantStringMap[dart.implements] = () => [_internal.EfficientLength];
149 dart.defineNamedConstructor(ConstantStringMap, '_'); 149 dart.defineNamedConstructor(ConstantStringMap, '_');
150 dart.setSignature(ConstantStringMap, { 150 dart.setSignature(ConstantStringMap, {
151 constructors: () => ({_: [ConstantStringMap$(K, V), [core.int, core.Object , core.List$(K)]]}), 151 constructors: () => ({_: [ConstantStringMap$(K, V), [core.int, core.Object , core.List$(K)]]}),
152 methods: () => ({ 152 methods: () => ({
153 containsValue: [core.bool, [core.Object]], 153 containsValue: [core.bool, [core.Object]],
154 containsKey: [core.bool, [core.Object]], 154 containsKey: [core.bool, [core.Object]],
155 get: [V, [core.Object]], 155 get: [V, [core.Object]],
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 let _jsData = Symbol('_jsData'); 208 let _jsData = Symbol('_jsData');
209 let _getMap = Symbol('_getMap'); 209 let _getMap = Symbol('_getMap');
210 let GeneralConstantMap$ = dart.generic(function(K, V) { 210 let GeneralConstantMap$ = dart.generic(function(K, V) {
211 class GeneralConstantMap extends ConstantMap$(K, V) { 211 class GeneralConstantMap extends ConstantMap$(K, V) {
212 GeneralConstantMap(jsData) { 212 GeneralConstantMap(jsData) {
213 this[_jsData] = jsData; 213 this[_jsData] = jsData;
214 super._(); 214 super._();
215 } 215 }
216 [_getMap]() { 216 [_getMap]() {
217 if (!this.$map) { 217 if (!this.$map) {
218 let backingMap = new (collection.LinkedHashMap$(K, V))(); 218 let backingMap = collection.LinkedHashMap$(K, V).new();
219 this.$map = fillLiteralMap(this[_jsData], backingMap); 219 this.$map = fillLiteralMap(this[_jsData], backingMap);
220 } 220 }
221 return dart.as(this.$map, core.Map$(K, V)); 221 return dart.as(this.$map, core.Map$(K, V));
222 } 222 }
223 containsValue(needle) { 223 containsValue(needle) {
224 return this[_getMap]().containsValue(needle); 224 return this[_getMap]().containsValue(needle);
225 } 225 }
226 containsKey(key) { 226 containsKey(key) {
227 return this[_getMap]().containsKey(key); 227 return this[_getMap]().containsKey(key);
228 } 228 }
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 get groupCount() { 777 get groupCount() {
778 return 0; 778 return 0;
779 } 779 }
780 group(group_) { 780 group(group_) {
781 if (group_ != 0) { 781 if (group_ != 0) {
782 throw new core.RangeError.value(group_); 782 throw new core.RangeError.value(group_);
783 } 783 }
784 return this.pattern; 784 return this.pattern;
785 } 785 }
786 groups(groups_) { 786 groups(groups_) {
787 let result = new (core.List$(core.String))(); 787 let result = core.List$(core.String).new();
788 for (let g of groups_) { 788 for (let g of groups_) {
789 result[core.$add](this.group(g)); 789 result[core.$add](this.group(g));
790 } 790 }
791 return result; 791 return result;
792 } 792 }
793 } 793 }
794 StringMatch[dart.implements] = () => [core.Match]; 794 StringMatch[dart.implements] = () => [core.Match];
795 dart.setSignature(StringMatch, { 795 dart.setSignature(StringMatch, {
796 constructors: () => ({StringMatch: [StringMatch, [core.int, core.String, cor e.String]]}), 796 constructors: () => ({StringMatch: [StringMatch, [core.int, core.String, cor e.String]]}),
797 methods: () => ({ 797 methods: () => ({
798 get: [core.String, [core.int]], 798 get: [core.String, [core.int]],
799 group: [core.String, [core.int]], 799 group: [core.String, [core.int]],
800 groups: [core.List$(core.String), [core.List$(core.int)]] 800 groups: [core.List$(core.String), [core.List$(core.int)]]
801 }) 801 })
802 }); 802 });
803 function allMatchesInStringUnchecked(needle, haystack, startIndex) { 803 function allMatchesInStringUnchecked(needle, haystack, startIndex) {
804 let result = new (core.List$(core.Match))(); 804 let result = core.List$(core.Match).new();
805 let length = haystack.length; 805 let length = haystack.length;
806 let patternLength = needle.length; 806 let patternLength = needle.length;
807 while (true) { 807 while (true) {
808 let position = haystack.indexOf(needle, startIndex); 808 let position = haystack.indexOf(needle, startIndex);
809 if (position == -1) { 809 if (position == -1) {
810 break; 810 break;
811 } 811 }
812 result[core.$add](new StringMatch(position, haystack, needle)); 812 result[core.$add](new StringMatch(position, haystack, needle));
813 let endIndex = dart.notNull(position) + dart.notNull(patternLength); 813 let endIndex = dart.notNull(position) + dart.notNull(patternLength);
814 if (endIndex == length) { 814 if (endIndex == length) {
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1570 } 1570 }
1571 return dart.as(makeLiteralListConst(list), core.List); 1571 return dart.as(makeLiteralListConst(list), core.List);
1572 } 1572 }
1573 get namedArguments() { 1573 get namedArguments() {
1574 if (this.isAccessor) 1574 if (this.isAccessor)
1575 return dart.map(); 1575 return dart.map();
1576 let namedArgumentCount = this[_namedArgumentNames][core.$length]; 1576 let namedArgumentCount = this[_namedArgumentNames][core.$length];
1577 let namedArgumentsStartIndex = dart.notNull(this[_arguments][core.$length] ) - dart.notNull(namedArgumentCount); 1577 let namedArgumentsStartIndex = dart.notNull(this[_arguments][core.$length] ) - dart.notNull(namedArgumentCount);
1578 if (namedArgumentCount == 0) 1578 if (namedArgumentCount == 0)
1579 return dart.map(); 1579 return dart.map();
1580 let map = new (core.Map$(core.Symbol, core.Object))(); 1580 let map = core.Map$(core.Symbol, core.Object).new();
1581 for (let i = 0; dart.notNull(i) < dart.notNull(namedArgumentCount); i = da rt.notNull(i) + 1) { 1581 for (let i = 0; dart.notNull(i) < dart.notNull(namedArgumentCount); i = da rt.notNull(i) + 1) {
1582 map.set(new _internal.Symbol.unvalidated(dart.as(this[_namedArgumentName s][core.$get](i), core.String)), this[_arguments][core.$get](dart.notNull(namedA rgumentsStartIndex) + dart.notNull(i))); 1582 map.set(new _internal.Symbol.unvalidated(dart.as(this[_namedArgumentName s][core.$get](i), core.String)), this[_arguments][core.$get](dart.notNull(namedA rgumentsStartIndex) + dart.notNull(i)));
1583 } 1583 }
1584 return map; 1584 return map;
1585 } 1585 }
1586 [_getCachedInvocation](object) { 1586 [_getCachedInvocation](object) {
1587 let interceptor = _interceptors.getInterceptor(object); 1587 let interceptor = _interceptors.getInterceptor(object);
1588 let receiver = object; 1588 let receiver = object;
1589 let name = this[_internalName]; 1589 let name = this[_internalName];
1590 let arguments$ = this[_arguments]; 1590 let arguments$ = this[_arguments];
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 get isNoSuchMethod() { 1660 get isNoSuchMethod() {
1661 return false; 1661 return false;
1662 } 1662 }
1663 get isGetterStub() { 1663 get isGetterStub() {
1664 return !!this.jsFunction.$getterStub; 1664 return !!this.jsFunction.$getterStub;
1665 } 1665 }
1666 invokeOn(victim, arguments$) { 1666 invokeOn(victim, arguments$) {
1667 let receiver = victim; 1667 let receiver = victim;
1668 if (!dart.notNull(this.isIntercepted)) { 1668 if (!dart.notNull(this.isIntercepted)) {
1669 if (!dart.is(arguments$, _interceptors.JSArray)) 1669 if (!dart.is(arguments$, _interceptors.JSArray))
1670 arguments$ = new core.List.from(arguments$); 1670 arguments$ = core.List.from(arguments$);
1671 } else { 1671 } else {
1672 let _ = [victim]; 1672 let _ = [victim];
1673 _[core.$addAll](arguments$); 1673 _[core.$addAll](arguments$);
1674 arguments$ = _; 1674 arguments$ = _;
1675 if (this.cachedInterceptor != null) 1675 if (this.cachedInterceptor != null)
1676 receiver = this.cachedInterceptor; 1676 receiver = this.cachedInterceptor;
1677 } 1677 }
1678 return this.jsFunction.apply(receiver, arguments$); 1678 return this.jsFunction.apply(receiver, arguments$);
1679 } 1679 }
1680 } 1680 }
1681 dart.setSignature(CachedInvocation, { 1681 dart.setSignature(CachedInvocation, {
1682 constructors: () => ({CachedInvocation: [CachedInvocation, [core.String, cor e.Object, core.bool, _interceptors.Interceptor]]}), 1682 constructors: () => ({CachedInvocation: [CachedInvocation, [core.String, cor e.Object, core.bool, _interceptors.Interceptor]]}),
1683 methods: () => ({invokeOn: [core.Object, [core.Object, core.List]]}) 1683 methods: () => ({invokeOn: [core.Object, [core.Object, core.List]]})
1684 }); 1684 });
1685 class CachedCatchAllInvocation extends CachedInvocation { 1685 class CachedCatchAllInvocation extends CachedInvocation {
1686 CachedCatchAllInvocation(name, jsFunction, isIntercepted, cachedInterceptor) { 1686 CachedCatchAllInvocation(name, jsFunction, isIntercepted, cachedInterceptor) {
1687 this.info = new ReflectionInfo(jsFunction); 1687 this.info = ReflectionInfo.new(jsFunction);
1688 super.CachedInvocation(name, jsFunction, isIntercepted, cachedInterceptor) ; 1688 super.CachedInvocation(name, jsFunction, isIntercepted, cachedInterceptor) ;
1689 } 1689 }
1690 get isGetterStub() { 1690 get isGetterStub() {
1691 return false; 1691 return false;
1692 } 1692 }
1693 invokeOn(victim, arguments$) { 1693 invokeOn(victim, arguments$) {
1694 let receiver = victim; 1694 let receiver = victim;
1695 let providedArgumentCount = null; 1695 let providedArgumentCount = null;
1696 let fullParameterCount = dart.notNull(this.info.requiredParameterCount) + dart.notNull(this.info.optionalParameterCount); 1696 let fullParameterCount = dart.notNull(this.info.requiredParameterCount) + dart.notNull(this.info.optionalParameterCount);
1697 if (!dart.notNull(this.isIntercepted)) { 1697 if (!dart.notNull(this.isIntercepted)) {
1698 if (dart.is(arguments$, _interceptors.JSArray)) { 1698 if (dart.is(arguments$, _interceptors.JSArray)) {
1699 providedArgumentCount = arguments$[core.$length]; 1699 providedArgumentCount = arguments$[core.$length];
1700 if (dart.notNull(providedArgumentCount) < dart.notNull(fullParameterCo unt)) { 1700 if (dart.notNull(providedArgumentCount) < dart.notNull(fullParameterCo unt)) {
1701 arguments$ = new core.List.from(arguments$); 1701 arguments$ = core.List.from(arguments$);
1702 } 1702 }
1703 } else { 1703 } else {
1704 arguments$ = new core.List.from(arguments$); 1704 arguments$ = core.List.from(arguments$);
1705 providedArgumentCount = arguments$[core.$length]; 1705 providedArgumentCount = arguments$[core.$length];
1706 } 1706 }
1707 } else { 1707 } else {
1708 let _ = [victim]; 1708 let _ = [victim];
1709 _[core.$addAll](arguments$); 1709 _[core.$addAll](arguments$);
1710 arguments$ = _; 1710 arguments$ = _;
1711 if (this.cachedInterceptor != null) 1711 if (this.cachedInterceptor != null)
1712 receiver = this.cachedInterceptor; 1712 receiver = this.cachedInterceptor;
1713 providedArgumentCount = dart.notNull(arguments$[core.$length]) - 1; 1713 providedArgumentCount = dart.notNull(arguments$[core.$length]) - 1;
1714 } 1714 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 internal(jsFunction, data, isAccessor, requiredParameterCount, optionalParam eterCount, areOptionalParametersNamed, functionType) { 1751 internal(jsFunction, data, isAccessor, requiredParameterCount, optionalParam eterCount, areOptionalParametersNamed, functionType) {
1752 this.jsFunction = jsFunction; 1752 this.jsFunction = jsFunction;
1753 this.data = data; 1753 this.data = data;
1754 this.isAccessor = isAccessor; 1754 this.isAccessor = isAccessor;
1755 this.requiredParameterCount = requiredParameterCount; 1755 this.requiredParameterCount = requiredParameterCount;
1756 this.optionalParameterCount = optionalParameterCount; 1756 this.optionalParameterCount = optionalParameterCount;
1757 this.areOptionalParametersNamed = areOptionalParametersNamed; 1757 this.areOptionalParametersNamed = areOptionalParametersNamed;
1758 this.functionType = functionType; 1758 this.functionType = functionType;
1759 this.cachedSortedIndices = null; 1759 this.cachedSortedIndices = null;
1760 } 1760 }
1761 ReflectionInfo(jsFunction) { 1761 static new(jsFunction) {
1762 let data = dart.as(jsFunction.$reflectionInfo, core.List); 1762 let data = dart.as(jsFunction.$reflectionInfo, core.List);
1763 if (data == null) 1763 if (data == null)
1764 return null; 1764 return null;
1765 data = _interceptors.JSArray.markFixedList(data); 1765 data = _interceptors.JSArray.markFixedList(data);
1766 let requiredParametersInfo = data[ReflectionInfo.REQUIRED_PARAMETERS_INFO] ; 1766 let requiredParametersInfo = data[ReflectionInfo.REQUIRED_PARAMETERS_INFO] ;
1767 let requiredParameterCount = requiredParametersInfo >> 1; 1767 let requiredParameterCount = requiredParametersInfo >> 1;
1768 let isAccessor = (dart.notNull(requiredParametersInfo) & 1) == 1; 1768 let isAccessor = (dart.notNull(requiredParametersInfo) & 1) == 1;
1769 let optionalParametersInfo = data[ReflectionInfo.OPTIONAL_PARAMETERS_INFO] ; 1769 let optionalParametersInfo = data[ReflectionInfo.OPTIONAL_PARAMETERS_INFO] ;
1770 let optionalParameterCount = optionalParametersInfo >> 1; 1770 let optionalParameterCount = optionalParametersInfo >> 1;
1771 let areOptionalParametersNamed = (dart.notNull(optionalParametersInfo) & 1 ) == 1; 1771 let areOptionalParametersNamed = (dart.notNull(optionalParametersInfo) & 1 ) == 1;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 if (dart.notNull(parameter) < dart.notNull(this.requiredParameterCount)) 1807 if (dart.notNull(parameter) < dart.notNull(this.requiredParameterCount))
1808 return null; 1808 return null;
1809 if (!dart.notNull(this.areOptionalParametersNamed) || this.optionalParamet erCount == 1) { 1809 if (!dart.notNull(this.areOptionalParametersNamed) || this.optionalParamet erCount == 1) {
1810 return this.parameterName(parameter); 1810 return this.parameterName(parameter);
1811 } 1811 }
1812 let index = this.sortedIndex(dart.notNull(parameter) - dart.notNull(this.r equiredParameterCount)); 1812 let index = this.sortedIndex(dart.notNull(parameter) - dart.notNull(this.r equiredParameterCount));
1813 return this.parameterName(index); 1813 return this.parameterName(index);
1814 } 1814 }
1815 sortedIndex(unsortedIndex) { 1815 sortedIndex(unsortedIndex) {
1816 if (this.cachedSortedIndices == null) { 1816 if (this.cachedSortedIndices == null) {
1817 this.cachedSortedIndices = new core.List(this.optionalParameterCount); 1817 this.cachedSortedIndices = core.List.new(this.optionalParameterCount);
1818 let positions = dart.map(); 1818 let positions = dart.map();
1819 for (let i = 0; dart.notNull(i) < dart.notNull(this.optionalParameterCou nt); i = dart.notNull(i) + 1) { 1819 for (let i = 0; dart.notNull(i) < dart.notNull(this.optionalParameterCou nt); i = dart.notNull(i) + 1) {
1820 let index = dart.notNull(this.requiredParameterCount) + dart.notNull(i ); 1820 let index = dart.notNull(this.requiredParameterCount) + dart.notNull(i );
1821 positions.set(this.parameterName(index), index); 1821 positions.set(this.parameterName(index), index);
1822 } 1822 }
1823 let index = 0; 1823 let index = 0;
1824 (() => { 1824 (() => {
1825 let _ = positions.keys[core.$toList](); 1825 let _ = positions.keys[core.$toList]();
1826 _[core.$sort](); 1826 _[core.$sort]();
1827 return _; 1827 return _;
(...skipping 19 matching lines...) Expand all
1847 } 1847 }
1848 } 1848 }
1849 get reflectionName() { 1849 get reflectionName() {
1850 return this.jsFunction.$reflectionName; 1850 return this.jsFunction.$reflectionName;
1851 } 1851 }
1852 } 1852 }
1853 dart.defineNamedConstructor(ReflectionInfo, 'internal'); 1853 dart.defineNamedConstructor(ReflectionInfo, 'internal');
1854 dart.setSignature(ReflectionInfo, { 1854 dart.setSignature(ReflectionInfo, {
1855 constructors: () => ({ 1855 constructors: () => ({
1856 internal: [ReflectionInfo, [core.Object, core.List, core.bool, core.int, c ore.int, core.bool, core.Object]], 1856 internal: [ReflectionInfo, [core.Object, core.List, core.bool, core.int, c ore.int, core.bool, core.Object]],
1857 ReflectionInfo: [ReflectionInfo, [core.Object]] 1857 new: [ReflectionInfo, [core.Object]]
1858 }), 1858 }),
1859 methods: () => ({ 1859 methods: () => ({
1860 parameterName: [core.String, [core.int]], 1860 parameterName: [core.String, [core.int]],
1861 parameterMetadataAnnotations: [core.List$(core.int), [core.int]], 1861 parameterMetadataAnnotations: [core.List$(core.int), [core.int]],
1862 defaultValue: [core.int, [core.int]], 1862 defaultValue: [core.int, [core.int]],
1863 defaultValueInOrder: [core.int, [core.int]], 1863 defaultValueInOrder: [core.int, [core.int]],
1864 parameterNameInOrder: [core.String, [core.int]], 1864 parameterNameInOrder: [core.String, [core.int]],
1865 sortedIndex: [core.int, [core.int]], 1865 sortedIndex: [core.int, [core.int]],
1866 computeFunctionRti: [core.Object, [core.Object]] 1866 computeFunctionRti: [core.Object, [core.Object]]
1867 }) 1867 })
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 static applyFunction(func, positionalArguments, namedArguments) { 2195 static applyFunction(func, positionalArguments, namedArguments) {
2196 return namedArguments == null ? Primitives.applyFunctionWithPositionalArgu ments(func, positionalArguments) : Primitives.applyFunctionWithNamedArguments(fu nc, positionalArguments, namedArguments); 2196 return namedArguments == null ? Primitives.applyFunctionWithPositionalArgu ments(func, positionalArguments) : Primitives.applyFunctionWithNamedArguments(fu nc, positionalArguments, namedArguments);
2197 } 2197 }
2198 static applyFunctionWithPositionalArguments(func, positionalArguments) { 2198 static applyFunctionWithPositionalArguments(func, positionalArguments) {
2199 let argumentCount = 0; 2199 let argumentCount = 0;
2200 let arguments$ = null; 2200 let arguments$ = null;
2201 if (positionalArguments != null) { 2201 if (positionalArguments != null) {
2202 if (positionalArguments instanceof Array) { 2202 if (positionalArguments instanceof Array) {
2203 arguments$ = positionalArguments; 2203 arguments$ = positionalArguments;
2204 } else { 2204 } else {
2205 arguments$ = new core.List.from(positionalArguments); 2205 arguments$ = core.List.from(positionalArguments);
2206 } 2206 }
2207 argumentCount = arguments$.length; 2207 argumentCount = arguments$.length;
2208 } else { 2208 } else {
2209 arguments$ = []; 2209 arguments$ = [];
2210 } 2210 }
2211 let selectorName = `${_foreign_helper.JS_GET_NAME("CALL_PREFIX")}$${argume ntCount}`; 2211 let selectorName = `${_foreign_helper.JS_GET_NAME("CALL_PREFIX")}$${argume ntCount}`;
2212 let jsFunction = func[selectorName]; 2212 let jsFunction = func[selectorName];
2213 if (jsFunction == null) { 2213 if (jsFunction == null) {
2214 return Primitives.functionNoSuchMethod(func, positionalArguments, null); 2214 return Primitives.functionNoSuchMethod(func, positionalArguments, null);
2215 } 2215 }
2216 return jsFunction.apply(func, arguments$); 2216 return jsFunction.apply(func, arguments$);
2217 } 2217 }
2218 static applyFunctionWithNamedArguments(func, positionalArguments, namedArgum ents) { 2218 static applyFunctionWithNamedArguments(func, positionalArguments, namedArgum ents) {
2219 if (namedArguments.isEmpty) { 2219 if (namedArguments.isEmpty) {
2220 return Primitives.applyFunctionWithPositionalArguments(func, positionalA rguments); 2220 return Primitives.applyFunctionWithPositionalArguments(func, positionalA rguments);
2221 } 2221 }
2222 let interceptor = _interceptors.getInterceptor(func); 2222 let interceptor = _interceptors.getInterceptor(func);
2223 let jsFunction = interceptor["call*"]; 2223 let jsFunction = interceptor["call*"];
2224 if (jsFunction == null) { 2224 if (jsFunction == null) {
2225 return Primitives.functionNoSuchMethod(func, positionalArguments, namedA rguments); 2225 return Primitives.functionNoSuchMethod(func, positionalArguments, namedA rguments);
2226 } 2226 }
2227 let info = new ReflectionInfo(jsFunction); 2227 let info = ReflectionInfo.new(jsFunction);
2228 if (dart.notNull(info == null) || !dart.notNull(info.areOptionalParameters Named)) { 2228 if (dart.notNull(info == null) || !dart.notNull(info.areOptionalParameters Named)) {
2229 return Primitives.functionNoSuchMethod(func, positionalArguments, namedA rguments); 2229 return Primitives.functionNoSuchMethod(func, positionalArguments, namedA rguments);
2230 } 2230 }
2231 if (positionalArguments != null) { 2231 if (positionalArguments != null) {
2232 positionalArguments = new core.List.from(positionalArguments); 2232 positionalArguments = core.List.from(positionalArguments);
2233 } else { 2233 } else {
2234 positionalArguments = []; 2234 positionalArguments = [];
2235 } 2235 }
2236 if (info.requiredParameterCount != positionalArguments[core.$length]) { 2236 if (info.requiredParameterCount != positionalArguments[core.$length]) {
2237 return Primitives.functionNoSuchMethod(func, positionalArguments, namedA rguments); 2237 return Primitives.functionNoSuchMethod(func, positionalArguments, namedA rguments);
2238 } 2238 }
2239 let defaultArguments = new core.Map(); 2239 let defaultArguments = core.Map.new();
2240 for (let i = 0; dart.notNull(i) < dart.notNull(info.optionalParameterCount ); i = dart.notNull(i) + 1) { 2240 for (let i = 0; dart.notNull(i) < dart.notNull(info.optionalParameterCount ); i = dart.notNull(i) + 1) {
2241 let index = dart.notNull(i) + dart.notNull(info.requiredParameterCount); 2241 let index = dart.notNull(i) + dart.notNull(info.requiredParameterCount);
2242 let parameterName = info.parameterNameInOrder(index); 2242 let parameterName = info.parameterNameInOrder(index);
2243 let value = info.defaultValueInOrder(index); 2243 let value = info.defaultValueInOrder(index);
2244 let defaultValue = getMetadata(value); 2244 let defaultValue = getMetadata(value);
2245 defaultArguments.set(parameterName, defaultValue); 2245 defaultArguments.set(parameterName, defaultValue);
2246 } 2246 }
2247 let bad = false; 2247 let bad = false;
2248 namedArguments.forEach(dart.fn((parameter, value) => { 2248 namedArguments.forEach(dart.fn((parameter, value) => {
2249 if (defaultArguments.containsKey(parameter)) { 2249 if (defaultArguments.containsKey(parameter)) {
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
2806 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, dart.fn(() => dart.dcal l(closure))); 2806 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, dart.fn(() => dart.dcal l(closure)));
2807 } else if (numberOfArguments == 1) { 2807 } else if (numberOfArguments == 1) {
2808 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, dart.fn(() => dart.dcal l(closure, arg1))); 2808 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, dart.fn(() => dart.dcal l(closure, arg1)));
2809 } else if (numberOfArguments == 2) { 2809 } else if (numberOfArguments == 2) {
2810 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, dart.fn(() => dart.dcal l(closure, arg1, arg2))); 2810 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, dart.fn(() => dart.dcal l(closure, arg1, arg2)));
2811 } else if (numberOfArguments == 3) { 2811 } else if (numberOfArguments == 3) {
2812 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, dart.fn(() => dart.dcal l(closure, arg1, arg2, arg3))); 2812 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, dart.fn(() => dart.dcal l(closure, arg1, arg2, arg3)));
2813 } else if (numberOfArguments == 4) { 2813 } else if (numberOfArguments == 4) {
2814 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, dart.fn(() => dart.dcal l(closure, arg1, arg2, arg3, arg4))); 2814 return _foreign_helper.JS_CALL_IN_ISOLATE(isolate, dart.fn(() => dart.dcal l(closure, arg1, arg2, arg3, arg4)));
2815 } else { 2815 } else {
2816 throw new core.Exception('Unsupported number of arguments for wrapped clos ure'); 2816 throw core.Exception.new('Unsupported number of arguments for wrapped clos ure');
2817 } 2817 }
2818 } 2818 }
2819 dart.fn(invokeClosure, core.Object, [core.Function, core.Object, core.int, cor e.Object, core.Object, core.Object, core.Object]); 2819 dart.fn(invokeClosure, core.Object, [core.Function, core.Object, core.int, cor e.Object, core.Object, core.Object, core.Object]);
2820 function convertDartClosureToJS(closure, arity) { 2820 function convertDartClosureToJS(closure, arity) {
2821 return closure; 2821 return closure;
2822 } 2822 }
2823 dart.fn(convertDartClosureToJS, core.Object, [core.Object, core.int]); 2823 dart.fn(convertDartClosureToJS, core.Object, [core.Object, core.int]);
2824 class Closure extends core.Object { 2824 class Closure extends core.Object {
2825 Closure() { 2825 Closure() {
2826 } 2826 }
2827 static fromTearOff(receiver, functions, reflectionInfo, isStatic, jsArgument s, propertyName) { 2827 static fromTearOff(receiver, functions, reflectionInfo, isStatic, jsArgument s, propertyName) {
2828 _foreign_helper.JS_EFFECT(dart.fn(() => { 2828 _foreign_helper.JS_EFFECT(dart.fn(() => {
2829 BoundClosure.receiverOf(dart.as(void 0, BoundClosure)); 2829 BoundClosure.receiverOf(dart.as(void 0, BoundClosure));
2830 BoundClosure.selfOf(dart.as(void 0, BoundClosure)); 2830 BoundClosure.selfOf(dart.as(void 0, BoundClosure));
2831 })); 2831 }));
2832 let func = functions[0]; 2832 let func = functions[0];
2833 let name = dart.as(func.$stubName, core.String); 2833 let name = dart.as(func.$stubName, core.String);
2834 let callName = dart.as(func.$callName, core.String); 2834 let callName = dart.as(func.$callName, core.String);
2835 func.$reflectionInfo = reflectionInfo; 2835 func.$reflectionInfo = reflectionInfo;
2836 let info = new ReflectionInfo(func); 2836 let info = ReflectionInfo.new(func);
2837 let functionType = info.functionType; 2837 let functionType = info.functionType;
2838 let prototype = isStatic ? Object.create(new TearOffClosure().constructor. prototype) : Object.create(new BoundClosure(null, null, null, null).constructor. prototype); 2838 let prototype = isStatic ? Object.create(new TearOffClosure().constructor. prototype) : Object.create(new BoundClosure(null, null, null, null).constructor. prototype);
2839 prototype.$initialize = prototype.constructor; 2839 prototype.$initialize = prototype.constructor;
2840 let constructor = isStatic ? function() { 2840 let constructor = isStatic ? function() {
2841 this.$initialize(); 2841 this.$initialize();
2842 } : Closure.isCsp ? function(a, b, c, d) { 2842 } : Closure.isCsp ? function(a, b, c, d) {
2843 this.$initialize(a, b, c, d); 2843 this.$initialize(a, b, c, d);
2844 } : new Function("a", "b", "c", "d", "this.$initialize(a,b,c,d);" + (() => { 2844 } : new Function("a", "b", "c", "d", "this.$initialize(a,b,c,d);" + (() => {
2845 let x = Closure.functionCounter; 2845 let x = Closure.functionCounter;
2846 Closure.functionCounter = dart.notNull(x) + 1; 2846 Closure.functionCounter = dart.notNull(x) + 1;
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
3543 if (!(typeof condition == 'boolean')) { 3543 if (!(typeof condition == 'boolean')) {
3544 throw new TypeErrorImplementation(condition, 'bool'); 3544 throw new TypeErrorImplementation(condition, 'bool');
3545 } 3545 }
3546 } 3546 }
3547 if (!dart.equals(true, condition)) 3547 if (!dart.equals(true, condition))
3548 throw new core.AssertionError(); 3548 throw new core.AssertionError();
3549 } 3549 }
3550 dart.fn(assertHelper, dart.void, [core.Object]); 3550 dart.fn(assertHelper, dart.void, [core.Object]);
3551 function throwNoSuchMethod(obj, name, arguments$, expectedArgumentNames) { 3551 function throwNoSuchMethod(obj, name, arguments$, expectedArgumentNames) {
3552 let memberName = new _internal.Symbol.unvalidated(dart.as(name, core.String) ); 3552 let memberName = new _internal.Symbol.unvalidated(dart.as(name, core.String) );
3553 throw new core.NoSuchMethodError(obj, memberName, dart.as(arguments$, core.L ist), new (core.Map$(core.Symbol, core.Object))(), dart.as(expectedArgumentNames , core.List)); 3553 throw new core.NoSuchMethodError(obj, memberName, dart.as(arguments$, core.L ist), core.Map$(core.Symbol, core.Object).new(), dart.as(expectedArgumentNames, core.List));
3554 } 3554 }
3555 dart.fn(throwNoSuchMethod, dart.void, [core.Object, core.Object, core.Object, core.Object]); 3555 dart.fn(throwNoSuchMethod, dart.void, [core.Object, core.Object, core.Object, core.Object]);
3556 function throwCyclicInit(staticName) { 3556 function throwCyclicInit(staticName) {
3557 throw new core.CyclicInitializationError(`Cyclic initialization for static $ {staticName}`); 3557 throw new core.CyclicInitializationError(`Cyclic initialization for static $ {staticName}`);
3558 } 3558 }
3559 dart.fn(throwCyclicInit, dart.void, [core.String]); 3559 dart.fn(throwCyclicInit, dart.void, [core.String]);
3560 class RuntimeError extends core.Error { 3560 class RuntimeError extends core.Error {
3561 RuntimeError(message) { 3561 RuntimeError(message) {
3562 this.message = message; 3562 this.message = message;
3563 super.Error(); 3563 super.Error();
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
4022 let LoadLibraryFunctionType = dart.typedef('LoadLibraryFunctionType', () => da rt.functionType(async.Future$(core.Null), [])); 4022 let LoadLibraryFunctionType = dart.typedef('LoadLibraryFunctionType', () => da rt.functionType(async.Future$(core.Null), []));
4023 function _loadLibraryWrapper(loadId) { 4023 function _loadLibraryWrapper(loadId) {
4024 return dart.fn(() => loadDeferredLibrary(loadId), async.Future$(core.Null), []); 4024 return dart.fn(() => loadDeferredLibrary(loadId), async.Future$(core.Null), []);
4025 } 4025 }
4026 dart.fn(_loadLibraryWrapper, LoadLibraryFunctionType, [core.String]); 4026 dart.fn(_loadLibraryWrapper, LoadLibraryFunctionType, [core.String]);
4027 dart.defineLazyProperties(exports, { 4027 dart.defineLazyProperties(exports, {
4028 get _loadingLibraries() { 4028 get _loadingLibraries() {
4029 return dart.map(); 4029 return dart.map();
4030 }, 4030 },
4031 get _loadedLibraries() { 4031 get _loadedLibraries() {
4032 return new (core.Set$(core.String))(); 4032 return core.Set$(core.String).new();
4033 } 4033 }
4034 }); 4034 });
4035 let DeferredLoadCallback = dart.typedef('DeferredLoadCallback', () => dart.fun ctionType(dart.void, [])); 4035 let DeferredLoadCallback = dart.typedef('DeferredLoadCallback', () => dart.fun ctionType(dart.void, []));
4036 exports.deferredLoadHook = null; 4036 exports.deferredLoadHook = null;
4037 function loadDeferredLibrary(loadId) { 4037 function loadDeferredLibrary(loadId) {
4038 let urisMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DEFE RRED_LIBRARY_URIS); 4038 let urisMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DEFE RRED_LIBRARY_URIS);
4039 let uris = dart.as(urisMap[loadId], core.List$(core.String)); 4039 let uris = dart.as(urisMap[loadId], core.List$(core.String));
4040 let hashesMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DE FERRED_LIBRARY_HASHES); 4040 let hashesMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DE FERRED_LIBRARY_HASHES);
4041 let hashes = dart.as(hashesMap[loadId], core.List$(core.String)); 4041 let hashes = dart.as(hashesMap[loadId], core.List$(core.String));
4042 if (uris == null) 4042 if (uris == null)
4043 return new (async.Future$(core.Null)).value(null); 4043 return async.Future$(core.Null).value(null);
4044 let indices = new (core.List$(core.int)).generate(uris[core.$length], dart.f n(i => dart.as(i, core.int), core.int, [core.Object])); 4044 let indices = core.List$(core.int).generate(uris[core.$length], dart.fn(i => dart.as(i, core.int), core.int, [core.Object]));
4045 let isHunkLoaded = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names .IS_HUNK_LOADED); 4045 let isHunkLoaded = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names .IS_HUNK_LOADED);
4046 let isHunkInitialized = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_ names.IS_HUNK_INITIALIZED); 4046 let isHunkInitialized = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_ names.IS_HUNK_INITIALIZED);
4047 let indicesToLoad = indices[core.$where](dart.fn(i => !isHunkLoaded(hashes[c ore.$get](i)), core.bool, [core.int]))[core.$toList](); 4047 let indicesToLoad = indices[core.$where](dart.fn(i => !isHunkLoaded(hashes[c ore.$get](i)), core.bool, [core.int]))[core.$toList]();
4048 return dart.as(async.Future.wait(dart.as(indicesToLoad[core.$map](dart.fn(i => _loadHunk(uris[core.$get](i)), async.Future$(core.Null), [core.int])), core.I terable$(async.Future))).then(dart.fn(_ => { 4048 return dart.as(async.Future.wait(dart.as(indicesToLoad[core.$map](dart.fn(i => _loadHunk(uris[core.$get](i)), async.Future$(core.Null), [core.int])), core.I terable$(async.Future))).then(dart.fn(_ => {
4049 let indicesToInitialize = indices[core.$where](dart.fn(i => !isHunkInitial ized(hashes[core.$get](i)), core.bool, [core.int]))[core.$toList](); 4049 let indicesToInitialize = indices[core.$where](dart.fn(i => !isHunkInitial ized(hashes[core.$get](i)), core.bool, [core.int]))[core.$toList]();
4050 for (let i of indicesToInitialize) { 4050 for (let i of indicesToInitialize) {
4051 let initializer = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_na mes.INITIALIZE_LOADED_HUNK); 4051 let initializer = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_na mes.INITIALIZE_LOADED_HUNK);
4052 initializer(hashes[core.$get](i)); 4052 initializer(hashes[core.$get](i));
4053 } 4053 }
4054 let updated = exports._loadedLibraries.add(loadId); 4054 let updated = exports._loadedLibraries.add(loadId);
4055 if (dart.notNull(updated) && dart.notNull(exports.deferredLoadHook != null )) { 4055 if (dart.notNull(updated) && dart.notNull(exports.deferredLoadHook != null )) {
4056 exports.deferredLoadHook(); 4056 exports.deferredLoadHook();
4057 } 4057 }
4058 })), async.Future$(core.Null)); 4058 })), async.Future$(core.Null));
4059 } 4059 }
4060 dart.fn(loadDeferredLibrary, async.Future$(core.Null), [core.String]); 4060 dart.fn(loadDeferredLibrary, async.Future$(core.Null), [core.String]);
4061 function _loadHunk(hunkName) { 4061 function _loadHunk(hunkName) {
4062 let future = exports._loadingLibraries.get(hunkName); 4062 let future = exports._loadingLibraries.get(hunkName);
4063 if (future != null) { 4063 if (future != null) {
4064 return dart.as(future.then(dart.fn(_ => null, dart.bottom, [core.Object])) , async.Future$(core.Null)); 4064 return dart.as(future.then(dart.fn(_ => null, dart.bottom, [core.Object])) , async.Future$(core.Null));
4065 } 4065 }
4066 let uri = _isolate_helper.IsolateNatives.thisScript; 4066 let uri = _isolate_helper.IsolateNatives.thisScript;
4067 let index = uri.lastIndexOf('/'); 4067 let index = uri.lastIndexOf('/');
4068 uri = `${uri.substring(0, dart.notNull(index) + 1)}${hunkName}`; 4068 uri = `${uri.substring(0, dart.notNull(index) + 1)}${hunkName}`;
4069 if (dart.notNull(Primitives.isJsshell) || dart.notNull(Primitives.isD8)) { 4069 if (dart.notNull(Primitives.isJsshell) || dart.notNull(Primitives.isD8)) {
4070 return exports._loadingLibraries.set(hunkName, new (async.Future$(core.Nul l))(dart.fn(() => { 4070 return exports._loadingLibraries.set(hunkName, async.Future$(core.Null).ne w(dart.fn(() => {
4071 try { 4071 try {
4072 new Function(`load("${uri}")`)(); 4072 new Function(`load("${uri}")`)();
4073 } catch (error) { 4073 } catch (error) {
4074 let stackTrace = dart.stackTrace(error); 4074 let stackTrace = dart.stackTrace(error);
4075 throw new async.DeferredLoadException(`Loading ${uri} failed.`); 4075 throw new async.DeferredLoadException(`Loading ${uri} failed.`);
4076 } 4076 }
4077 4077
4078 return null; 4078 return null;
4079 }))); 4079 })));
4080 } else if (_isolate_helper.isWorker()) { 4080 } else if (_isolate_helper.isWorker()) {
4081 return exports._loadingLibraries.set(hunkName, new (async.Future$(core.Nul l))(dart.fn(() => { 4081 return exports._loadingLibraries.set(hunkName, async.Future$(core.Null).ne w(dart.fn(() => {
4082 let completer = new (async.Completer$(core.Null))(); 4082 let completer = async.Completer$(core.Null).new();
4083 _isolate_helper.enterJsAsync(); 4083 _isolate_helper.enterJsAsync();
4084 let leavingFuture = dart.as(completer.future.whenComplete(dart.fn(() => { 4084 let leavingFuture = dart.as(completer.future.whenComplete(dart.fn(() => {
4085 _isolate_helper.leaveJsAsync(); 4085 _isolate_helper.leaveJsAsync();
4086 })), async.Future$(core.Null)); 4086 })), async.Future$(core.Null));
4087 let index = uri.lastIndexOf('/'); 4087 let index = uri.lastIndexOf('/');
4088 uri = `${uri.substring(0, dart.notNull(index) + 1)}${hunkName}`; 4088 uri = `${uri.substring(0, dart.notNull(index) + 1)}${hunkName}`;
4089 let xhr = new XMLHttpRequest(); 4089 let xhr = new XMLHttpRequest();
4090 xhr.open("GET", uri); 4090 xhr.open("GET", uri);
4091 xhr.addEventListener("load", convertDartClosureToJS(dart.fn(event => { 4091 xhr.addEventListener("load", convertDartClosureToJS(dart.fn(event => {
4092 if (xhr.status != 200) { 4092 if (xhr.status != 200) {
(...skipping 13 matching lines...) Expand all
4106 }), 1), false); 4106 }), 1), false);
4107 let fail = convertDartClosureToJS(dart.fn(event => { 4107 let fail = convertDartClosureToJS(dart.fn(event => {
4108 new async.DeferredLoadException(`Loading ${uri} failed.`); 4108 new async.DeferredLoadException(`Loading ${uri} failed.`);
4109 }), 1); 4109 }), 1);
4110 xhr.addEventListener("error", fail, false); 4110 xhr.addEventListener("error", fail, false);
4111 xhr.addEventListener("abort", fail, false); 4111 xhr.addEventListener("abort", fail, false);
4112 xhr.send(); 4112 xhr.send();
4113 return leavingFuture; 4113 return leavingFuture;
4114 }))); 4114 })));
4115 } 4115 }
4116 return exports._loadingLibraries.set(hunkName, new (async.Future$(core.Null) )(dart.fn(() => { 4116 return exports._loadingLibraries.set(hunkName, async.Future$(core.Null).new( dart.fn(() => {
4117 let completer = new (async.Completer$(core.Null))(); 4117 let completer = async.Completer$(core.Null).new();
4118 let script = document.createElement("script"); 4118 let script = document.createElement("script");
4119 script.type = "text/javascript"; 4119 script.type = "text/javascript";
4120 script.src = uri; 4120 script.src = uri;
4121 script.addEventListener("load", convertDartClosureToJS(dart.fn(event => { 4121 script.addEventListener("load", convertDartClosureToJS(dart.fn(event => {
4122 completer.complete(null); 4122 completer.complete(null);
4123 }), 1), false); 4123 }), 1), false);
4124 script.addEventListener("error", convertDartClosureToJS(dart.fn(event => { 4124 script.addEventListener("error", convertDartClosureToJS(dart.fn(event => {
4125 completer.completeError(new async.DeferredLoadException(`Loading ${uri} failed.`)); 4125 completer.completeError(new async.DeferredLoadException(`Loading ${uri} failed.`));
4126 }), 1), false); 4126 }), 1), false);
4127 document.body.appendChild(script); 4127 document.body.appendChild(script);
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
4380 exports.jsonEncodeNative = jsonEncodeNative; 4380 exports.jsonEncodeNative = jsonEncodeNative;
4381 exports.getIsolateAffinityTag = getIsolateAffinityTag; 4381 exports.getIsolateAffinityTag = getIsolateAffinityTag;
4382 exports.LoadLibraryFunctionType = LoadLibraryFunctionType; 4382 exports.LoadLibraryFunctionType = LoadLibraryFunctionType;
4383 exports.DeferredLoadCallback = DeferredLoadCallback; 4383 exports.DeferredLoadCallback = DeferredLoadCallback;
4384 exports.loadDeferredLibrary = loadDeferredLibrary; 4384 exports.loadDeferredLibrary = loadDeferredLibrary;
4385 exports.MainError = MainError; 4385 exports.MainError = MainError;
4386 exports.missingMain = missingMain; 4386 exports.missingMain = missingMain;
4387 exports.badMain = badMain; 4387 exports.badMain = badMain;
4388 exports.mainHasTooManyParameters = mainHasTooManyParameters; 4388 exports.mainHasTooManyParameters = mainHasTooManyParameters;
4389 })(_js_helper, core, collection, _internal, _foreign_helper, _js_embedded_names, _interceptors, _js_names, async, _isolate_helper); 4389 })(_js_helper, core, collection, _internal, _foreign_helper, _js_embedded_names, _interceptors, _js_names, async, _isolate_helper);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698