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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 throwNoSuchMethod(obj, name, args); | 89 throwNoSuchMethod(obj, name, args); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 // If f is a function, but not a method (no method type) | 92 // If f is a function, but not a method (no method type) |
| 93 // then it should have been a function valued field, so | 93 // then it should have been a function valued field, so |
| 94 // get the type from the function. | 94 // get the type from the function. |
| 95 if (ftype === void 0) { | 95 if (ftype === void 0) { |
| 96 ftype = _getFunctionType(f); | 96 ftype = _getFunctionType(f); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // TODO(leafp): Allow JS objects to go through? | 99 if (!ftype) { |
| 100 if (!ftype) throw "Unable to find a type for applicand"; | 100 // TODO(leafp): Allow JS objects to go through? |
| 101 // This includes the DOM. | |
| 102 return f.apply(obj, args); | |
|
vsm
2015/05/26 13:40:58
We were breaking in a DOM call - no function type
Leaf
2015/05/26 18:19:45
Yes, if we have types for these that could be usef
| |
| 103 } | |
| 101 | 104 |
| 102 if (ftype.checkApply(args)) return f.apply(obj, args); | 105 if (ftype.checkApply(args)) { |
| 106 return f.apply(obj, args); | |
| 107 } | |
| 108 | |
| 103 // TODO(leafp): throw a type error (rather than NSM) | 109 // TODO(leafp): throw a type error (rather than NSM) |
| 104 // if the arity matches but the types are wrong. | 110 // if the arity matches but the types are wrong. |
| 105 throwNoSuchMethod(obj, name, args, f); | 111 throwNoSuchMethod(obj, name, args, f); |
| 106 } | 112 } |
| 107 | 113 |
| 108 function dcall(f/*, ...args*/) { | 114 function dcall(f/*, ...args*/) { |
| 109 let args = Array.prototype.slice.call(arguments, 1); | 115 let args = Array.prototype.slice.call(arguments, 1); |
| 110 let ftype = _getFunctionType(f); | 116 let ftype = _getFunctionType(f); |
| 111 return checkAndCall(f, ftype, void 0, args, 'call'); | 117 return checkAndCall(f, ftype, void 0, args, 'call'); |
| 112 } | 118 } |
| (...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1309 Number.prototype['>'] = function(arg) { return this.valueOf() > arg; }; | 1315 Number.prototype['>'] = function(arg) { return this.valueOf() > arg; }; |
| 1310 Number.prototype['+'] = function(arg) { return this.valueOf() + arg; }; | 1316 Number.prototype['+'] = function(arg) { return this.valueOf() + arg; }; |
| 1311 | 1317 |
| 1312 // TODO(vsm): DOM facades? | 1318 // TODO(vsm): DOM facades? |
| 1313 // See: https://github.com/dart-lang/dev_compiler/issues/173 | 1319 // See: https://github.com/dart-lang/dev_compiler/issues/173 |
| 1314 NodeList.prototype.get = function(i) { return this[i]; }; | 1320 NodeList.prototype.get = function(i) { return this[i]; }; |
| 1315 NamedNodeMap.prototype.get = function(i) { return this[i]; }; | 1321 NamedNodeMap.prototype.get = function(i) { return this[i]; }; |
| 1316 DOMTokenList.prototype.get = function(i) { return this[i]; }; | 1322 DOMTokenList.prototype.get = function(i) { return this[i]; }; |
| 1317 | 1323 |
| 1318 })(dart || (dart = {})); | 1324 })(dart || (dart = {})); |
| OLD | NEW |