| 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); |
| 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 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 Number.prototype['>'] = function(arg) { return this.valueOf() > arg; }; | 1316 Number.prototype['>'] = function(arg) { return this.valueOf() > arg; }; |
| 1311 Number.prototype['+'] = function(arg) { return this.valueOf() + arg; }; | 1317 Number.prototype['+'] = function(arg) { return this.valueOf() + arg; }; |
| 1312 | 1318 |
| 1313 // TODO(vsm): DOM facades? | 1319 // TODO(vsm): DOM facades? |
| 1314 // See: https://github.com/dart-lang/dev_compiler/issues/173 | 1320 // See: https://github.com/dart-lang/dev_compiler/issues/173 |
| 1315 NodeList.prototype.get = function(i) { return this[i]; }; | 1321 NodeList.prototype.get = function(i) { return this[i]; }; |
| 1316 NamedNodeMap.prototype.get = function(i) { return this[i]; }; | 1322 NamedNodeMap.prototype.get = function(i) { return this[i]; }; |
| 1317 DOMTokenList.prototype.get = function(i) { return this[i]; }; | 1323 DOMTokenList.prototype.get = function(i) { return this[i]; }; |
| 1318 | 1324 |
| 1319 })(dart || (dart = {})); | 1325 })(dart || (dart = {})); |
| OLD | NEW |