| 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; | 5 var dart, _js_helper; |
| 6 (function (dart) { | 6 (function (dart) { |
| 7 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 let defineProperty = Object.defineProperty; | 9 let defineProperty = Object.defineProperty; |
| 10 let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | 10 let getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 function checkAndCall(f, obj, args, name) { | 49 function checkAndCall(f, obj, args, name) { |
| 50 if (!(f instanceof Function)) { | 50 if (!(f instanceof Function)) { |
| 51 // Grab the `call` method if it's not a function. | 51 // Grab the `call` method if it's not a function. |
| 52 if (f !== null) f = f.call; | 52 if (f !== null) f = f.call; |
| 53 if (!(f instanceof Function)) { | 53 if (!(f instanceof Function)) { |
| 54 throwNoSuchMethod(obj, method, args); | 54 throwNoSuchMethod(obj, method, args); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 // TODO(jmesserly): enable this when we can fix => and methods. |
| 58 /* |
| 57 let formals = formalParameterList(f); | 59 let formals = formalParameterList(f); |
| 58 // TODO(vsm): Type check args! We need to encode sufficient type info on f. | 60 // TODO(vsm): Type check args! We need to encode sufficient type info on f. |
| 59 if (formals.length < args.length) { | 61 if (formals.length < args.length) { |
| 60 throwNoSuchMethod(obj, name, args, f); | 62 throwNoSuchMethod(obj, name, args, f); |
| 61 } else if (formals.length > args.length) { | 63 } else if (formals.length > args.length) { |
| 62 for (let i = args.length; i < formals.length; ++i) { | 64 for (let i = args.length; i < formals.length; ++i) { |
| 63 if (formals[i].indexOf("opt$") != 0) { | 65 if (formals[i].indexOf("opt$") != 0) { |
| 64 throwNoSuchMethod(obj, name, args, f); | 66 throwNoSuchMethod(obj, name, args, f); |
| 65 } | 67 } |
| 66 } | 68 } |
| 67 } | 69 } |
| 70 */ |
| 68 return f.apply(obj, args); | 71 return f.apply(obj, args); |
| 69 } | 72 } |
| 70 | 73 |
| 71 function dcall(f/*, ...args*/) { | 74 function dcall(f/*, ...args*/) { |
| 72 let args = Array.prototype.slice.call(arguments, 1); | 75 let args = Array.prototype.slice.call(arguments, 1); |
| 73 return checkAndCall(f, void 0, args, 'call'); | 76 return checkAndCall(f, void 0, args, 'call'); |
| 74 } | 77 } |
| 75 dart.dcall = dcall; | 78 dart.dcall = dcall; |
| 76 | 79 |
| 77 function dsend(obj, method/*, ...args*/) { | 80 function dsend(obj, method/*, ...args*/) { |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 // TODO(vsm): How should we encode the runtime type? | 754 // TODO(vsm): How should we encode the runtime type? |
| 752 dart.runtimeType = Symbol('runtimeType'); | 755 dart.runtimeType = Symbol('runtimeType'); |
| 753 | 756 |
| 754 dart.JsSymbol = Symbol; | 757 dart.JsSymbol = Symbol; |
| 755 | 758 |
| 756 // TODO(jmesserly): hack to bootstrap the SDK | 759 // TODO(jmesserly): hack to bootstrap the SDK |
| 757 _js_helper = _js_helper || {}; | 760 _js_helper = _js_helper || {}; |
| 758 _js_helper.checkNum = notNull; | 761 _js_helper.checkNum = notNull; |
| 759 | 762 |
| 760 })(dart || (dart = {})); | 763 })(dart || (dart = {})); |
| OLD | NEW |