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; | 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 function throwNoSuchMethod(obj, name, args, opt_func) { | 54 function throwNoSuchMethod(obj, name, args, opt_func) { |
| 55 if (obj === void 0) obj = opt_func; | 55 if (obj === void 0) obj = opt_func; |
| 56 throw new core.NoSuchMethodError(obj, name, args); | 56 throw new core.NoSuchMethodError(obj, name, args); |
| 57 } | 57 } |
| 58 | 58 |
| 59 function checkAndCall(f, obj, args, name) { | 59 function checkAndCall(f, obj, args, name) { |
| 60 if (!(f instanceof Function)) { | 60 if (!(f instanceof Function)) { |
| 61 // Grab the `call` method if it's not a function. | 61 // Grab the `call` method if it's not a function. |
| 62 if (f !== null) f = f.call; | 62 if (f !== null) f = f.call; |
| 63 if (!(f instanceof Function)) { | 63 if (!(f instanceof Function)) { |
| 64 throwNoSuchMethod(obj, method, args); | 64 throwNoSuchMethod(obj, name, args); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 // TODO(jmesserly): enable this when we can fix => and methods. | 67 // TODO(jmesserly): enable this when we can fix => and methods. |
| 68 /* | 68 /* |
| 69 let formals = formalParameterList(f); | 69 let formals = formalParameterList(f); |
| 70 // TODO(vsm): Type check args! We need to encode sufficient type info on f. | 70 // TODO(vsm): Type check args! We need to encode sufficient type info on f. |
| 71 if (formals.length < args.length) { | 71 if (formals.length < args.length) { |
| 72 throwNoSuchMethod(obj, name, args, f); | 72 throwNoSuchMethod(obj, name, args, f); |
| 73 } else if (formals.length > args.length) { | 73 } else if (formals.length > args.length) { |
| 74 for (let i = args.length; i < formals.length; ++i) { | 74 for (let i = args.length; i < formals.length; ++i) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 // See if we already know the answer | 200 // See if we already know the answer |
| 201 // TODO(jmesserly): general purpose memoize function? | 201 // TODO(jmesserly): general purpose memoize function? |
| 202 let map = subtypeMap.get(t1); | 202 let map = subtypeMap.get(t1); |
| 203 let result; | 203 let result; |
| 204 if (map) { | 204 if (map) { |
| 205 result = map.get(t2); | 205 result = map.get(t2); |
| 206 if (result !== void 0) return result; | 206 if (result !== void 0) return result; |
| 207 } else { | 207 } else { |
| 208 subtypeMap.set(t1, map = new Map()); | 208 subtypeMap.set(t1, map = new Map()); |
| 209 } | 209 } |
| 210 map.set(t2, result = isSubtype_(t1, t2)); | 210 if (t2 == core.Type) { |
| 211 // Special case Types. | |
| 212 result = t1.prototype instanceof core.Type || | |
|
Jennifer Messerly
2015/04/24 00:43:14
any reason not to include this in isSubtype_ ? I w
vsm
2015/04/24 13:25:44
Yes - the helper is recursive with t2 staying cons
| |
| 213 t1 instanceof AbstractFunctionType || | |
| 214 isSubtype_(t1, t2); | |
| 215 } else { | |
| 216 result = isSubtype_(t1, t2) | |
| 217 } | |
| 218 map.set(t2, result); | |
| 211 return result; | 219 return result; |
| 212 } | 220 } |
| 213 dart.isSubtype = isSubtype; | 221 dart.isSubtype = isSubtype; |
| 214 | 222 |
| 215 function _isBottom(type, dynamicIsBottom) { | 223 function _isBottom(type, dynamicIsBottom) { |
| 216 return (type == dart.dynamic && dynamicIsBottom) || type == dart.bottom; | 224 return (type == dart.dynamic && dynamicIsBottom) || type == dart.bottom; |
| 217 } | 225 } |
| 218 | 226 |
| 219 function _isTop(type, dynamicIsBottom) { | 227 function _isTop(type, dynamicIsBottom) { |
| 220 return type == core.Object || (type == dart.dynamic && !dynamicIsBottom); | 228 return type == core.Object || (type == dart.dynamic && !dynamicIsBottom); |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 931 dart.bottom = { toString() { return 'bottom'; } }; | 939 dart.bottom = { toString() { return 'bottom'; } }; |
| 932 | 940 |
| 933 dart.global = window || global; | 941 dart.global = window || global; |
| 934 dart.JsSymbol = Symbol; | 942 dart.JsSymbol = Symbol; |
| 935 | 943 |
| 936 // TODO(jmesserly): hack to bootstrap the SDK | 944 // TODO(jmesserly): hack to bootstrap the SDK |
| 937 _js_helper = _js_helper || {}; | 945 _js_helper = _js_helper || {}; |
| 938 _js_helper.checkNum = notNull; | 946 _js_helper.checkNum = notNull; |
| 939 | 947 |
| 940 })(dart || (dart = {})); | 948 })(dart || (dart = {})); |
| OLD | NEW |