OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 var dart, _js_helper, _js_primitives; | 5 var dart, _js_helper, _js_primitives; |
6 (function (dart) { | 6 (function (dart) { |
7 'use strict'; | 7 'use strict'; |
8 | 8 |
9 // TODO(vsm): This is referenced (as init.globalState) from | 9 // TODO(vsm): This is referenced (as init.globalState) from |
10 // isolate_helper.dart. Where should it go? | 10 // isolate_helper.dart. Where should it go? |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 return checkAndCall(f, ftype, obj, args, method); | 144 return checkAndCall(f, ftype, obj, args, method); |
145 } | 145 } |
146 dart.dsend = dsend; | 146 dart.dsend = dsend; |
147 | 147 |
148 function dindex(obj, index) { | 148 function dindex(obj, index) { |
149 // TODO(jmesserly): remove this special case once Array extensions are | 149 // TODO(jmesserly): remove this special case once Array extensions are |
150 // hooked up. | 150 // hooked up. |
151 if (obj instanceof Array && realRuntimeType(index) == core.int) { | 151 if (obj instanceof Array && realRuntimeType(index) == core.int) { |
152 return obj[index]; | 152 return obj[index]; |
153 } | 153 } |
154 return checkAndCall(obj.get, obj, [index], '[]'); | 154 return checkAndCall(obj.get, void 0, obj, [index], '[]'); |
155 } | 155 } |
156 dart.dindex = dindex; | 156 dart.dindex = dindex; |
157 | 157 |
158 function dsetindex(obj, index, value) { | 158 function dsetindex(obj, index, value) { |
159 return checkAndCall(obj.set, obj, [index, value], '[]='); | 159 return checkAndCall(obj.set, void 0, obj, [index, value], '[]='); |
160 } | 160 } |
161 dart.dsetindex = dsetindex; | 161 dart.dsetindex = dsetindex; |
162 | 162 |
163 function typeToString(type) { | 163 function typeToString(type) { |
164 if (typeof(type) == "function") { | 164 if (typeof(type) == "function") { |
165 var name = type.name; | 165 var name = type.name; |
166 var args = type[dart.typeArguments]; | 166 var args = type[dart.typeArguments]; |
167 if (args) { | 167 if (args) { |
168 name += '<'; | 168 name += '<'; |
169 for (var i = 0; i < args.length; ++i) { | 169 for (var i = 0; i < args.length; ++i) { |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
903 * | 903 * |
904 * Otherwise an array should be used, for example `map([1, 2, 3, 4])` will | 904 * Otherwise an array should be used, for example `map([1, 2, 3, 4])` will |
905 * create a map with keys [1, 3] and values [2, 4]. Each key-value pair | 905 * create a map with keys [1, 3] and values [2, 4]. Each key-value pair |
906 * should be adjacent entries in the array. | 906 * should be adjacent entries in the array. |
907 * | 907 * |
908 * For a map with no keys the function can be called with no arguments, for | 908 * For a map with no keys the function can be called with no arguments, for |
909 * example `map()`. | 909 * example `map()`. |
910 */ | 910 */ |
911 // TODO(jmesserly): this could be faster | 911 // TODO(jmesserly): this could be faster |
912 function map(values) { | 912 function map(values) { |
913 let map = new collection.LinkedHashMap(); | 913 let map = collection.LinkedHashMap.new(); |
vsm
2015/05/29 21:08:58
Hmm, it's too bad the JS user has to now keep trac
Jennifer Messerly
2015/05/29 21:32:17
yeah, seems kind of okay because:
* the only way
| |
914 if (Array.isArray(values)) { | 914 if (Array.isArray(values)) { |
915 for (let i = 0, end = values.length - 1; i < end; i += 2) { | 915 for (let i = 0, end = values.length - 1; i < end; i += 2) { |
916 let key = values[i]; | 916 let key = values[i]; |
917 let value = values[i + 1]; | 917 let value = values[i + 1]; |
918 map.set(key, value); | 918 map.set(key, value); |
919 } | 919 } |
920 } else if (typeof values === 'object') { | 920 } else if (typeof values === 'object') { |
921 for (let key of getOwnPropertyNames(values)) { | 921 for (let key of getOwnPropertyNames(values)) { |
922 map.set(key, values[key]); | 922 map.set(key, values[key]); |
923 } | 923 } |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1316 Number.prototype['>'] = function(arg) { return this.valueOf() > arg; }; | 1316 Number.prototype['>'] = function(arg) { return this.valueOf() > arg; }; |
1317 Number.prototype['+'] = function(arg) { return this.valueOf() + arg; }; | 1317 Number.prototype['+'] = function(arg) { return this.valueOf() + arg; }; |
1318 | 1318 |
1319 // TODO(vsm): DOM facades? | 1319 // TODO(vsm): DOM facades? |
1320 // See: https://github.com/dart-lang/dev_compiler/issues/173 | 1320 // See: https://github.com/dart-lang/dev_compiler/issues/173 |
1321 NodeList.prototype.get = function(i) { return this[i]; }; | 1321 NodeList.prototype.get = function(i) { return this[i]; }; |
1322 NamedNodeMap.prototype.get = function(i) { return this[i]; }; | 1322 NamedNodeMap.prototype.get = function(i) { return this[i]; }; |
1323 DOMTokenList.prototype.get = function(i) { return this[i]; }; | 1323 DOMTokenList.prototype.get = function(i) { return this[i]; }; |
1324 | 1324 |
1325 })(dart || (dart = {})); | 1325 })(dart || (dart = {})); |
OLD | NEW |