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 // TODO(jmesserly): rename to dcall? | 74 // TODO(jmesserly): rename to dcall? |
72 function dinvokef(f/*, ...args*/) { | 75 function dinvokef(f/*, ...args*/) { |
73 let args = Array.prototype.slice.call(arguments, 1); | 76 let args = Array.prototype.slice.call(arguments, 1); |
74 return checkAndCall(f, void 0, args, 'call'); | 77 return checkAndCall(f, void 0, args, 'call'); |
75 } | 78 } |
76 dart.dinvokef = dinvokef; | 79 dart.dinvokef = dinvokef; |
77 | 80 |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 // TODO(vsm): How should we encode the runtime type? | 755 // TODO(vsm): How should we encode the runtime type? |
753 dart.runtimeType = Symbol('runtimeType'); | 756 dart.runtimeType = Symbol('runtimeType'); |
754 | 757 |
755 dart.JsSymbol = Symbol; | 758 dart.JsSymbol = Symbol; |
756 | 759 |
757 // TODO(jmesserly): hack to bootstrap the SDK | 760 // TODO(jmesserly): hack to bootstrap the SDK |
758 _js_helper = _js_helper || {}; | 761 _js_helper = _js_helper || {}; |
759 _js_helper.checkNum = notNull; | 762 _js_helper.checkNum = notNull; |
760 | 763 |
761 })(dart || (dart = {})); | 764 })(dart || (dart = {})); |
OLD | NEW |