| 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 /* This library defines the representation of runtime types. | 5 /* This library defines the representation of runtime types. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 dart_library.library('dart_runtime/_types', null, /* Imports */[ | 8 dart_library.library('dart_runtime/_types', null, /* Imports */[ |
| 9 ], /* Lazy Imports */[ | 9 ], /* Lazy Imports */[ |
| 10 'dart/core', | 10 'dart/core', |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 * TODO(leafp): Figure out how to present this to the user. How | 132 * TODO(leafp): Figure out how to present this to the user. How |
| 133 * should these be printed out? | 133 * should these be printed out? |
| 134 */ | 134 */ |
| 135 constructor(definite, returnType, args, optionals, named) { | 135 constructor(definite, returnType, args, optionals, named) { |
| 136 super(); | 136 super(); |
| 137 this.definite = definite; | 137 this.definite = definite; |
| 138 this.returnType = returnType; | 138 this.returnType = returnType; |
| 139 this.args = args; | 139 this.args = args; |
| 140 this.optionals = optionals; | 140 this.optionals = optionals; |
| 141 this.named = named; | 141 this.named = named; |
| 142 |
| 143 // TODO(vsm): This is just parameter metadata for now. |
| 144 this.metadata = []; |
| 145 function process(array, metadata) { |
| 146 var result = []; |
| 147 for (var i = 0; i < array.length; ++i) { |
| 148 var arg = array[i]; |
| 149 if (arg instanceof Array) { |
| 150 metadata.push(arg.slice(1)); |
| 151 result.push(arg[0]); |
| 152 } else { |
| 153 metadata.push([]); |
| 154 result.push(arg); |
| 155 } |
| 156 } |
| 157 return result; |
| 158 } |
| 159 this.args = process(this.args, this.metadata); |
| 160 this.optionals = process(this.optionals, this.metadata); |
| 161 // TODO(vsm): Add named arguments. |
| 142 this._canonize(); | 162 this._canonize(); |
| 143 } | 163 } |
| 144 _canonize() { | 164 _canonize() { |
| 145 if (this.definite) return; | 165 if (this.definite) return; |
| 146 | 166 |
| 147 function replace(a) { | 167 function replace(a) { |
| 148 return (a == dynamicR) ? bottomR : a; | 168 return (a == dynamicR) ? bottomR : a; |
| 149 } | 169 } |
| 150 | 170 |
| 151 this.args = this.args.map(replace); | 171 this.args = this.args.map(replace); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 return this.functionType.args; | 215 return this.functionType.args; |
| 196 } | 216 } |
| 197 | 217 |
| 198 get optionals() { | 218 get optionals() { |
| 199 return this.functionType.optionals; | 219 return this.functionType.optionals; |
| 200 } | 220 } |
| 201 | 221 |
| 202 get named() { | 222 get named() { |
| 203 return this.functionType.named; | 223 return this.functionType.named; |
| 204 } | 224 } |
| 225 |
| 226 get metadata() { |
| 227 return this.functionType.metadata; |
| 228 } |
| 205 } | 229 } |
| 206 | 230 |
| 207 function _functionType(definite, returnType, args, extra) { | 231 function _functionType(definite, returnType, args, extra) { |
| 208 // TODO(vsm): Cache / memomize? | 232 // TODO(vsm): Cache / memomize? |
| 209 let optionals; | 233 let optionals; |
| 210 let named; | 234 let named; |
| 211 if (extra === void 0) { | 235 if (extra === void 0) { |
| 212 optionals = []; | 236 optionals = []; |
| 213 named = {}; | 237 named = {}; |
| 214 } else if (extra instanceof Array) { | 238 } else if (extra instanceof Array) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 let typeArgs = classes.getGenericArgs(type); | 533 let typeArgs = classes.getGenericArgs(type); |
| 510 if (!typeArgs) return true; | 534 if (!typeArgs) return true; |
| 511 for (let t of typeArgs) { | 535 for (let t of typeArgs) { |
| 512 if (t != core.Object && t != dynamicR) return false; | 536 if (t != core.Object && t != dynamicR) return false; |
| 513 } | 537 } |
| 514 return true; | 538 return true; |
| 515 } | 539 } |
| 516 exports.isGroundType = isGroundType; | 540 exports.isGroundType = isGroundType; |
| 517 | 541 |
| 518 }); | 542 }); |
| OLD | NEW |