Chromium Code Reviews| 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 function fn(closure/* ...args*/) { | 558 function fn(closure/* ...args*/) { |
| 559 // Closure and a lazy type constructor | 559 // Closure and a lazy type constructor |
| 560 if (arguments.length == 2) { | 560 if (arguments.length == 2) { |
| 561 defineLazyProperty(closure, _runtimeType, {get : arguments[1]}); | 561 defineLazyProperty(closure, _runtimeType, {get : arguments[1]}); |
| 562 return closure; | 562 return closure; |
| 563 } | 563 } |
| 564 var t; | 564 var t; |
| 565 if (arguments.length == 1) { | 565 if (arguments.length == 1) { |
| 566 // No type arguments, it's all dynamic | 566 // No type arguments, it's all dynamic |
| 567 let len = closure.length; | 567 let len = closure.length; |
| 568 let args = Array.apply(null, new Array(len)).map(() => dart.dynamic); | 568 function build() { |
| 569 t = functionType(dart.dynamic, args); | 569 let args = Array.apply(null, new Array(len)).map(() => core.Object); |
| 570 return functionType(core.Object, args); | |
| 571 } | |
| 572 // We could be called before Object is defined. | |
| 573 if (core.Object === void 0) return fn(closure, build); | |
| 574 t = build(); | |
|
vsm
2015/05/20 23:03:10
yikes ... perhaps we should move Object to this fi
Leaf
2015/05/20 23:35:28
Yes, figuring out some way to architect things so
| |
| 570 } else { | 575 } else { |
| 571 // We're passed the piecewise components of the function type, | 576 // We're passed the piecewise components of the function type, |
| 572 // construct it. | 577 // construct it. |
| 573 let args = Array.prototype.slice.call(arguments, 1); | 578 let args = Array.prototype.slice.call(arguments, 1); |
| 574 t = functionType.apply(functionType, args); | 579 t = functionType.apply(functionType, args); |
| 575 } | 580 } |
| 576 setRuntimeType(closure, t); | 581 setRuntimeType(closure, t); |
| 577 return closure; | 582 return closure; |
| 578 } | 583 } |
| 579 dart.fn = fn; | 584 dart.fn = fn; |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 951 function generic(typeConstructor) { | 956 function generic(typeConstructor) { |
| 952 let length = typeConstructor.length; | 957 let length = typeConstructor.length; |
| 953 if (length < 1) throw Error('must have at least one generic type argument'); | 958 if (length < 1) throw Error('must have at least one generic type argument'); |
| 954 | 959 |
| 955 let resultMap = new Map(); | 960 let resultMap = new Map(); |
| 956 function makeGenericType(/*...arguments*/) { | 961 function makeGenericType(/*...arguments*/) { |
| 957 if (arguments.length != length && arguments.length != 0) { | 962 if (arguments.length != length && arguments.length != 0) { |
| 958 throw Error('requires ' + length + ' or 0 type arguments'); | 963 throw Error('requires ' + length + ' or 0 type arguments'); |
| 959 } | 964 } |
| 960 let args = Array.prototype.slice.call(arguments); | 965 let args = Array.prototype.slice.call(arguments); |
| 966 // TODO(leafp): This should really be core.Object for | |
| 967 // consistency, but Object is not attached to core | |
| 968 // until the entire core library has been processed, | |
| 969 // which is too late. | |
| 961 while (args.length < length) args.push(dart.dynamic); | 970 while (args.length < length) args.push(dart.dynamic); |
| 962 | 971 |
| 963 let value = resultMap; | 972 let value = resultMap; |
| 964 for (let i = 0; i < length; i++) { | 973 for (let i = 0; i < length; i++) { |
| 965 let arg = args[i]; | 974 let arg = args[i]; |
| 966 if (arg == null) { | 975 if (arg == null) { |
| 967 throw Error('type arguments should not be null: ' + typeConstructor); | 976 throw Error('type arguments should not be null: ' + typeConstructor); |
| 968 } | 977 } |
| 969 let map = value; | 978 let map = value; |
| 970 value = map.get(arg); | 979 value = map.get(arg); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1270 Number.prototype['>'] = function(arg) { return this.valueOf() > arg; }; | 1279 Number.prototype['>'] = function(arg) { return this.valueOf() > arg; }; |
| 1271 Number.prototype['+'] = function(arg) { return this.valueOf() + arg; }; | 1280 Number.prototype['+'] = function(arg) { return this.valueOf() + arg; }; |
| 1272 | 1281 |
| 1273 // TODO(vsm): DOM facades? | 1282 // TODO(vsm): DOM facades? |
| 1274 // See: https://github.com/dart-lang/dev_compiler/issues/173 | 1283 // See: https://github.com/dart-lang/dev_compiler/issues/173 |
| 1275 NodeList.prototype.get = function(i) { return this[i]; }; | 1284 NodeList.prototype.get = function(i) { return this[i]; }; |
| 1276 NamedNodeMap.prototype.get = function(i) { return this[i]; }; | 1285 NamedNodeMap.prototype.get = function(i) { return this[i]; }; |
| 1277 DOMTokenList.prototype.get = function(i) { return this[i]; }; | 1286 DOMTokenList.prototype.get = function(i) { return this[i]; }; |
| 1278 | 1287 |
| 1279 })(dart || (dart = {})); | 1288 })(dart || (dart = {})); |
| OLD | NEW |