Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library dart2js.resolution.registry; | 5 library dart2js.resolution.registry; |
| 6 | 6 |
| 7 import '../common/backend_api.dart' show | 7 import '../common/backend_api.dart' show |
| 8 Backend, | 8 Backend, |
| 9 ForeignResolver; | 9 ForeignResolver; |
| 10 import '../common/resolution.dart' show | |
| 11 Feature, | |
| 12 ListLiteralUse, | |
| 13 MapLiteralUse, | |
| 14 ResolutionWorldImpact; | |
| 10 import '../common/registry.dart' show | 15 import '../common/registry.dart' show |
| 11 Registry; | 16 Registry; |
| 12 import '../compiler.dart' show | 17 import '../compiler.dart' show |
| 13 Compiler; | 18 Compiler; |
| 14 import '../constants/expressions.dart'; | 19 import '../constants/expressions.dart'; |
| 15 import '../dart_types.dart'; | 20 import '../dart_types.dart'; |
| 16 import '../diagnostics/invariant.dart' show | 21 import '../diagnostics/invariant.dart' show |
| 17 invariant; | 22 invariant; |
| 18 import '../enqueue.dart' show | 23 import '../enqueue.dart' show |
| 19 ResolutionEnqueuer, | 24 ResolutionEnqueuer; |
| 20 WorldImpact; | |
| 21 import '../elements/elements.dart'; | 25 import '../elements/elements.dart'; |
| 26 import '../helpers/helpers.dart'; | |
| 22 import '../tree/tree.dart'; | 27 import '../tree/tree.dart'; |
| 23 import '../util/util.dart' show | 28 import '../util/util.dart' show |
| 24 Setlet; | 29 Setlet; |
| 25 import '../universe/call_structure.dart' show | 30 import '../universe/call_structure.dart' show |
| 26 CallStructure; | 31 CallStructure; |
| 27 import '../universe/selector.dart' show | 32 import '../universe/selector.dart' show |
| 28 Selector; | 33 Selector; |
| 29 import '../universe/universe.dart' show | 34 import '../universe/universe.dart' show |
| 30 UniverseSelector; | 35 UniverseSelector; |
| 31 import '../world.dart' show World; | 36 import '../world.dart' show World; |
| 32 | 37 |
| 33 import 'send_structure.dart'; | 38 import 'send_structure.dart'; |
| 34 | 39 |
| 35 import 'members.dart' show | 40 import 'members.dart' show |
| 36 ResolverVisitor; | 41 ResolverVisitor; |
| 37 import 'tree_elements.dart' show | 42 import 'tree_elements.dart' show |
| 38 TreeElementMapping; | 43 TreeElementMapping; |
| 39 | 44 |
| 40 /// [ResolutionRegistry] collects all resolution information. It stores node | 45 // TODO(johnniwinther): Remove this. |
| 41 /// related information in a [TreeElements] mapping and registers calls with | |
| 42 /// [Backend], [World] and [Enqueuer]. | |
| 43 // TODO(johnniwinther): Split this into an interface and implementation class. | |
| 44 | |
| 45 class EagerRegistry implements Registry { | 46 class EagerRegistry implements Registry { |
| 46 final Compiler compiler; | 47 final Compiler compiler; |
| 47 final TreeElementMapping mapping; | 48 final TreeElementMapping mapping; |
| 48 | 49 |
| 49 EagerRegistry(this.compiler, this.mapping); | 50 EagerRegistry(this.compiler, this.mapping); |
| 50 | 51 |
| 51 ResolutionEnqueuer get world => compiler.enqueuer.resolution; | 52 ResolutionEnqueuer get world => compiler.enqueuer.resolution; |
| 52 | 53 |
| 53 @override | 54 @override |
| 54 bool get isForResolution => true; | 55 bool get isForResolution => true; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 | 94 |
| 94 @override | 95 @override |
| 95 void registerStaticInvocation(Element element) { | 96 void registerStaticInvocation(Element element) { |
| 96 registerDependency(element); | 97 registerDependency(element); |
| 97 world.registerStaticUse(element); | 98 world.registerStaticUse(element); |
| 98 } | 99 } |
| 99 | 100 |
| 100 String toString() => 'EagerRegistry for ${mapping.analyzedElement}'; | 101 String toString() => 'EagerRegistry for ${mapping.analyzedElement}'; |
| 101 } | 102 } |
| 102 | 103 |
| 103 class ResolutionWorldImpact implements WorldImpact { | 104 class _ResolutionWorldImpact implements ResolutionWorldImpact { |
| 104 final Registry registry; | 105 final Registry registry; |
| 105 Setlet<UniverseSelector> _dynamicInvocations; | 106 Setlet<UniverseSelector> _dynamicInvocations; |
| 106 Setlet<UniverseSelector> _dynamicGetters; | 107 Setlet<UniverseSelector> _dynamicGetters; |
| 107 Setlet<UniverseSelector> _dynamicSetters; | 108 Setlet<UniverseSelector> _dynamicSetters; |
| 108 Setlet<InterfaceType> _instantiatedTypes; | 109 Setlet<InterfaceType> _instantiatedTypes; |
| 109 Setlet<Element> _staticUses; | 110 Setlet<Element> _staticUses; |
| 110 Setlet<DartType> _checkedTypes; | 111 Setlet<DartType> _isChecks; |
| 112 Setlet<DartType> _asCasts; | |
| 113 Setlet<DartType> _checkedModeChecks; | |
| 111 Setlet<MethodElement> _closurizedFunctions; | 114 Setlet<MethodElement> _closurizedFunctions; |
| 115 Setlet<LocalFunctionElement> _closures; | |
| 116 Setlet<Feature> _features; | |
| 117 // TODO(johnniwinther): This seems to be a union of other sets. | |
| 118 Setlet<DartType> _requiredTypes; | |
| 119 Setlet<MapLiteralUse> _mapLiterals; | |
| 120 Setlet<ListLiteralUse> _listLiterals; | |
| 121 Setlet<DartType> _typeLiterals; | |
| 122 Setlet<String> _constSymbolNames; | |
| 112 | 123 |
| 113 ResolutionWorldImpact(Compiler compiler, TreeElementMapping mapping) | 124 _ResolutionWorldImpact(Compiler compiler, TreeElementMapping mapping) |
| 114 : this.registry = new EagerRegistry(compiler, mapping); | 125 : this.registry = new EagerRegistry(compiler, mapping); |
| 115 | 126 |
| 127 void registerDependency(Element element) { | |
| 128 registry.registerDependency(element); | |
| 129 } | |
| 130 | |
| 116 void registerDynamicGetter(UniverseSelector selector) { | 131 void registerDynamicGetter(UniverseSelector selector) { |
| 117 if (_dynamicGetters == null) { | 132 if (_dynamicGetters == null) { |
| 118 _dynamicGetters = new Setlet<UniverseSelector>(); | 133 _dynamicGetters = new Setlet<UniverseSelector>(); |
| 119 } | 134 } |
| 120 _dynamicGetters.add(selector); | 135 _dynamicGetters.add(selector); |
| 121 } | 136 } |
| 122 | 137 |
| 123 @override | 138 @override |
| 124 Iterable<UniverseSelector> get dynamicGetters { | 139 Iterable<UniverseSelector> get dynamicGetters { |
| 125 return _dynamicGetters != null | 140 return _dynamicGetters != null |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 146 _dynamicSetters.add(selector); | 161 _dynamicSetters.add(selector); |
| 147 } | 162 } |
| 148 | 163 |
| 149 @override | 164 @override |
| 150 Iterable<UniverseSelector> get dynamicSetters { | 165 Iterable<UniverseSelector> get dynamicSetters { |
| 151 return _dynamicSetters != null | 166 return _dynamicSetters != null |
| 152 ? _dynamicSetters : const <UniverseSelector>[]; | 167 ? _dynamicSetters : const <UniverseSelector>[]; |
| 153 } | 168 } |
| 154 | 169 |
| 155 void registerInstantiatedType(InterfaceType type) { | 170 void registerInstantiatedType(InterfaceType type) { |
| 156 // TODO(johnniwinther): Enable this when registration doesn't require a | |
| 157 // [Registry]. | |
| 158 throw new UnsupportedError( | |
| 159 'Lazy registration of instantiated not supported.'); | |
| 160 if (_instantiatedTypes == null) { | 171 if (_instantiatedTypes == null) { |
| 161 _instantiatedTypes = new Setlet<InterfaceType>(); | 172 _instantiatedTypes = new Setlet<InterfaceType>(); |
| 162 } | 173 } |
| 163 _instantiatedTypes.add(type); | 174 _instantiatedTypes.add(type); |
| 164 } | 175 } |
| 165 | 176 |
| 166 @override | 177 @override |
| 167 Iterable<InterfaceType> get instantiatedTypes { | 178 Iterable<InterfaceType> get instantiatedTypes { |
| 168 return _instantiatedTypes != null | 179 return _instantiatedTypes != null |
| 169 ? _instantiatedTypes : const <InterfaceType>[]; | 180 ? _instantiatedTypes : const <InterfaceType>[]; |
| 170 } | 181 } |
| 171 | 182 |
| 183 void registerTypeLiteral(DartType type) { | |
| 184 if (_typeLiterals == null) { | |
| 185 _typeLiterals = new Setlet<DartType>(); | |
| 186 } | |
| 187 _typeLiterals.add(type); | |
| 188 } | |
| 189 | |
| 190 @override | |
| 191 Iterable<DartType> get typeLiterals { | |
| 192 return _typeLiterals != null | |
| 193 ? _typeLiterals : const <DartType>[]; | |
| 194 } | |
| 195 | |
| 196 void registerRequiredType(DartType type) { | |
| 197 if (_requiredTypes == null) { | |
| 198 _requiredTypes = new Setlet<DartType>(); | |
| 199 } | |
| 200 _requiredTypes.add(type); | |
| 201 } | |
| 202 | |
| 203 @override | |
| 204 Iterable<DartType> get requiredTypes { | |
| 205 return _requiredTypes != null | |
| 206 ? _requiredTypes : const <DartType>[]; | |
| 207 } | |
| 208 | |
| 209 void registerMapLiteral(MapLiteralUse mapLiteralUse) { | |
| 210 if (_mapLiterals == null) { | |
| 211 _mapLiterals = new Setlet<MapLiteralUse>(); | |
| 212 } | |
| 213 _mapLiterals.add(mapLiteralUse); | |
| 214 } | |
| 215 | |
| 216 @override | |
| 217 Iterable<MapLiteralUse> get mapLiterals { | |
| 218 return _mapLiterals != null | |
| 219 ? _mapLiterals : const <MapLiteralUse>[]; | |
| 220 } | |
| 221 | |
| 222 void registerListLiteral(ListLiteralUse listLiteralUse) { | |
| 223 if (_listLiterals == null) { | |
| 224 _listLiterals = new Setlet<ListLiteralUse>(); | |
| 225 } | |
| 226 _listLiterals.add(listLiteralUse); | |
| 227 } | |
| 228 | |
| 229 @override | |
| 230 Iterable<ListLiteralUse> get listLiterals { | |
| 231 return _listLiterals != null | |
| 232 ? _listLiterals : const <ListLiteralUse>[]; | |
| 233 } | |
| 234 | |
| 172 void registerStaticUse(Element element) { | 235 void registerStaticUse(Element element) { |
| 173 if (_staticUses == null) { | 236 if (_staticUses == null) { |
| 174 _staticUses = new Setlet<Element>(); | 237 _staticUses = new Setlet<Element>(); |
| 175 } | 238 } |
| 176 _staticUses.add(element); | 239 _staticUses.add(element); |
| 177 } | 240 } |
| 178 | 241 |
| 179 @override | 242 @override |
| 180 Iterable<Element> get staticUses { | 243 Iterable<Element> get staticUses { |
| 181 return _staticUses != null ? _staticUses : const <Element>[]; | 244 return _staticUses != null ? _staticUses : const <Element>[]; |
| 182 } | 245 } |
| 183 | 246 |
| 184 void registerCheckedType(DartType type) { | 247 void registerIsCheck(DartType type) { |
| 185 if (_checkedTypes == null) { | 248 if (_isChecks == null) { |
| 186 _checkedTypes = new Setlet<DartType>(); | 249 _isChecks = new Setlet<DartType>(); |
|
sigurdm
2015/10/06 09:17:14
Is it worth it not just initializing these in the
Johnni Winther
2015/10/06 10:48:43
Maybe. Have to investigate further. Adding a TODO.
| |
| 187 } | 250 } |
| 188 _checkedTypes.add(type); | 251 _isChecks.add(type); |
| 189 } | 252 } |
| 190 | 253 |
| 191 @override | 254 @override |
| 192 Iterable<DartType> get checkedTypes { | 255 Iterable<DartType> get isChecks { |
| 193 return _checkedTypes != null | 256 return _isChecks != null |
| 194 ? _checkedTypes : const <DartType>[]; | 257 ? _isChecks : const <DartType>[]; |
| 258 } | |
| 259 | |
| 260 void registerAsCast(DartType type) { | |
| 261 if (_asCasts == null) { | |
| 262 _asCasts = new Setlet<DartType>(); | |
| 263 } | |
| 264 _asCasts.add(type); | |
| 265 } | |
| 266 | |
| 267 @override | |
| 268 Iterable<DartType> get asCasts { | |
| 269 return _asCasts != null | |
| 270 ? _asCasts : const <DartType>[]; | |
| 271 } | |
| 272 | |
| 273 void registerCheckedModeCheckedType(DartType type) { | |
| 274 if (_checkedModeChecks == null) { | |
| 275 _checkedModeChecks = new Setlet<DartType>(); | |
| 276 } | |
| 277 _checkedModeChecks.add(type); | |
| 278 } | |
| 279 | |
| 280 @override | |
| 281 Iterable<DartType> get checkedModeChecks { | |
| 282 return _checkedModeChecks != null | |
| 283 ? _checkedModeChecks : const <DartType>[]; | |
| 195 } | 284 } |
| 196 | 285 |
| 197 void registerClosurizedFunction(MethodElement element) { | 286 void registerClosurizedFunction(MethodElement element) { |
| 198 if (_closurizedFunctions == null) { | 287 if (_closurizedFunctions == null) { |
| 199 _closurizedFunctions = new Setlet<MethodElement>(); | 288 _closurizedFunctions = new Setlet<MethodElement>(); |
| 200 } | 289 } |
| 201 _closurizedFunctions.add(element); | 290 _closurizedFunctions.add(element); |
| 202 } | 291 } |
| 203 | 292 |
| 204 @override | 293 @override |
| 205 Iterable<MethodElement> get closurizedFunctions { | 294 Iterable<MethodElement> get closurizedFunctions { |
| 206 return _closurizedFunctions != null | 295 return _closurizedFunctions != null |
| 207 ? _closurizedFunctions : const <MethodElement>[]; | 296 ? _closurizedFunctions : const <MethodElement>[]; |
| 208 } | 297 } |
| 298 | |
| 299 void registerClosure(LocalFunctionElement element) { | |
| 300 if (_closures == null) { | |
| 301 _closures = new Setlet<LocalFunctionElement>(); | |
| 302 } | |
| 303 _closures.add(element); | |
| 304 } | |
| 305 | |
| 306 @override | |
| 307 Iterable<LocalFunctionElement> get closures { | |
| 308 return _closures != null | |
| 309 ? _closures : const <LocalFunctionElement>[]; | |
| 310 } | |
| 311 | |
| 312 void registerConstSymbolName(String name) { | |
| 313 if (_constSymbolNames == null) { | |
| 314 _constSymbolNames = new Setlet<String>(); | |
| 315 } | |
| 316 _constSymbolNames.add(name); | |
| 317 } | |
| 318 | |
| 319 @override | |
| 320 Iterable<String> get constSymbolNames { | |
| 321 return _constSymbolNames != null | |
| 322 ? _constSymbolNames : const <String>[]; | |
| 323 } | |
| 324 | |
| 325 void registerFeature(Feature feature) { | |
| 326 if (_features == null) { | |
| 327 _features = new Setlet<Feature>(); | |
| 328 } | |
| 329 _features.add(feature); | |
| 330 } | |
| 331 | |
| 332 @override | |
| 333 Iterable<Feature> get features { | |
| 334 return _features != null ? _features : const <Feature>[]; | |
| 335 } | |
| 336 | |
| 337 String toString() => '$registry'; | |
| 209 } | 338 } |
| 210 | 339 |
| 340 /// [ResolutionRegistry] collects all resolution information. It stores node | |
| 341 /// related information in a [TreeElements] mapping and registers calls with | |
| 342 /// [Backend], [World] and [Enqueuer]. | |
| 343 // TODO(johnniwinther): Split this into an interface and implementation class. | |
| 211 class ResolutionRegistry implements Registry { | 344 class ResolutionRegistry implements Registry { |
| 212 final Compiler compiler; | 345 final Compiler compiler; |
| 213 final TreeElementMapping mapping; | 346 final TreeElementMapping mapping; |
| 214 final ResolutionWorldImpact worldImpact; | 347 final _ResolutionWorldImpact worldImpact; |
| 215 | 348 |
| 216 ResolutionRegistry(Compiler compiler, TreeElementMapping mapping) | 349 ResolutionRegistry(Compiler compiler, TreeElementMapping mapping) |
| 217 : this.compiler = compiler, | 350 : this.compiler = compiler, |
| 218 this.mapping = mapping, | 351 this.mapping = mapping, |
| 219 this.worldImpact = new ResolutionWorldImpact(compiler, mapping); | 352 this.worldImpact = new _ResolutionWorldImpact(compiler, mapping); |
| 220 | 353 |
| 221 bool get isForResolution => true; | 354 bool get isForResolution => true; |
| 222 | 355 |
| 223 ResolutionEnqueuer get world => compiler.enqueuer.resolution; | 356 ResolutionEnqueuer get world => compiler.enqueuer.resolution; |
| 224 | 357 |
| 225 World get universe => compiler.world; | 358 World get universe => compiler.world; |
| 226 | 359 |
| 227 Backend get backend => compiler.backend; | 360 Backend get backend => compiler.backend; |
| 228 | 361 |
| 229 String toString() => 'ResolutionRegistry for ${mapping.analyzedElement}'; | 362 String toString() => 'ResolutionRegistry for ${mapping.analyzedElement}'; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 | 527 |
| 395 ////////////////////////////////////////////////////////////////////////////// | 528 ////////////////////////////////////////////////////////////////////////////// |
| 396 // Various Backend/Enqueuer/World registration. | 529 // Various Backend/Enqueuer/World registration. |
| 397 ////////////////////////////////////////////////////////////////////////////// | 530 ////////////////////////////////////////////////////////////////////////////// |
| 398 | 531 |
| 399 void registerStaticUse(Element element) { | 532 void registerStaticUse(Element element) { |
| 400 worldImpact.registerStaticUse(element); | 533 worldImpact.registerStaticUse(element); |
| 401 } | 534 } |
| 402 | 535 |
| 403 void registerImplicitSuperCall(FunctionElement superConstructor) { | 536 void registerImplicitSuperCall(FunctionElement superConstructor) { |
| 404 universe.registerImplicitSuperCall(this, superConstructor); | 537 registerDependency(superConstructor); |
| 405 } | 538 } |
| 406 | 539 |
| 407 // TODO(johnniwinther): Remove this. | 540 // TODO(johnniwinther): Remove this. |
| 408 // Use [registerInstantiatedType] of `rawType` instead. | 541 // Use [registerInstantiatedType] of `rawType` instead. |
| 409 @deprecated | 542 @deprecated |
| 410 void registerInstantiatedClass(ClassElement element) { | 543 void registerInstantiatedClass(ClassElement element) { |
| 411 element.ensureResolved(compiler.resolution); | 544 element.ensureResolved(compiler.resolution); |
| 412 registerInstantiatedType(element.rawType); | 545 registerInstantiatedType(element.rawType); |
| 413 } | 546 } |
| 414 | 547 |
| 415 void registerLazyField() { | 548 void registerLazyField() { |
| 416 backend.resolutionCallbacks.onLazyField(this); | 549 worldImpact.registerFeature(Feature.LAZY_FIELD); |
| 417 } | 550 } |
| 418 | 551 |
| 419 void registerMetadataConstant(MetadataAnnotation metadata, | 552 void registerMetadataConstant(MetadataAnnotation metadata) { |
| 420 Element annotatedElement) { | 553 backend.registerMetadataConstant(metadata, metadata.annotatedElement, this); |
| 421 backend.registerMetadataConstant(metadata, annotatedElement, this); | |
| 422 } | 554 } |
| 423 | 555 |
| 424 void registerThrowRuntimeError() { | 556 void registerThrowRuntimeError() { |
| 425 backend.resolutionCallbacks.onThrowRuntimeError(this); | 557 worldImpact.registerFeature(Feature.THROW_RUNTIME_ERROR); |
| 426 } | 558 } |
| 427 | 559 |
| 428 void registerCompileTimeError(ErroneousElement error) { | 560 void registerCompileTimeError(ErroneousElement error) { |
| 429 backend.resolutionCallbacks.onCompileTimeError(this, error); | 561 worldImpact.registerFeature(Feature.COMPILE_TIME_ERROR); |
| 430 } | 562 } |
| 431 | 563 |
| 432 void registerTypeVariableBoundCheck() { | 564 void registerTypeVariableBoundCheck() { |
| 433 backend.resolutionCallbacks.onTypeVariableBoundCheck(this); | 565 worldImpact.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK); |
| 434 } | 566 } |
| 435 | 567 |
| 436 void registerThrowNoSuchMethod() { | 568 void registerThrowNoSuchMethod() { |
| 437 backend.resolutionCallbacks.onThrowNoSuchMethod(this); | 569 worldImpact.registerFeature(Feature.THROW_NO_SUCH_METHOD); |
| 438 } | 570 } |
| 439 | 571 |
| 440 void registerIsCheck(DartType type) { | 572 /// Register a checked mode check against [type]. |
| 441 worldImpact.registerCheckedType(type); | 573 void registerCheckedModeCheck(DartType type) { |
| 442 backend.resolutionCallbacks.onIsCheck(type, this); | 574 worldImpact.registerCheckedModeCheckedType(type); |
| 443 mapping.addRequiredType(type); | 575 mapping.addRequiredType(type); |
| 444 } | 576 } |
| 445 | 577 |
| 446 void registerAsCheck(DartType type) { | 578 /// Register an is-test or is-not-test of [type]. |
| 447 registerIsCheck(type); | 579 void registerIsCheck(DartType type) { |
| 448 backend.resolutionCallbacks.onAsCheck(type, this); | 580 worldImpact.registerIsCheck(type); |
| 581 mapping.addRequiredType(type); | |
| 582 } | |
| 583 | |
| 584 /// Register an as-cast of [type]. | |
| 585 void registerAsCast(DartType type) { | |
| 586 worldImpact.registerAsCast(type); | |
| 449 mapping.addRequiredType(type); | 587 mapping.addRequiredType(type); |
| 450 } | 588 } |
| 451 | 589 |
| 452 void registerClosure(LocalFunctionElement element) { | 590 void registerClosure(LocalFunctionElement element) { |
|
sigurdm
2015/10/06 09:17:14
?
Johnni Winther
2015/10/06 10:48:43
Code is moved to .transformImpact
| |
| 453 if (element.computeType(compiler.resolution).containsTypeVariables) { | 591 worldImpact.registerClosure(element); |
| 454 backend.registerClosureWithFreeTypeVariables(element, world, this); | |
| 455 } | |
| 456 world.registerClosure(element); | |
| 457 } | 592 } |
| 458 | 593 |
| 459 void registerSuperUse(Node node) { | 594 void registerSuperUse(Node node) { |
| 460 mapping.addSuperUse(node); | 595 mapping.addSuperUse(node); |
| 461 } | 596 } |
| 462 | 597 |
| 463 void registerDynamicInvocation(UniverseSelector selector) { | 598 void registerDynamicInvocation(UniverseSelector selector) { |
| 464 worldImpact.registerDynamicInvocation(selector); | 599 worldImpact.registerDynamicInvocation(selector); |
| 465 } | 600 } |
| 466 | 601 |
| 467 void registerSuperNoSuchMethod() { | 602 void registerSuperNoSuchMethod() { |
| 468 backend.resolutionCallbacks.onSuperNoSuchMethod(this); | 603 worldImpact.registerFeature(Feature.SUPER_NO_SUCH_METHOD); |
| 469 } | |
| 470 | |
| 471 void registerTypeVariableExpression(TypeVariableElement element) { | |
| 472 backend.resolutionCallbacks.onTypeVariableExpression(this, element); | |
| 473 } | 604 } |
| 474 | 605 |
| 475 void registerTypeLiteral(Send node, DartType type) { | 606 void registerTypeLiteral(Send node, DartType type) { |
| 476 mapping.setType(node, type); | 607 mapping.setType(node, type); |
| 477 backend.resolutionCallbacks.onTypeLiteral(type, this); | 608 worldImpact.registerTypeLiteral(type); |
| 478 backend.registerInstantiatedType(compiler.coreTypes.typeType, world, this); | |
| 479 } | 609 } |
| 480 | 610 |
| 481 void registerMapLiteral(Node node, DartType type, bool isConstant) { | 611 void registerLiteralList(Node node, |
| 612 InterfaceType type, | |
| 613 {bool isConstant, | |
| 614 bool isEmpty}) { | |
| 482 setType(node, type); | 615 setType(node, type); |
| 483 backend.resolutionCallbacks.onMapLiteral(this, type, isConstant); | 616 worldImpact.registerListLiteral( |
| 617 new ListLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); | |
| 618 } | |
| 619 | |
| 620 void registerMapLiteral(Node node, | |
| 621 InterfaceType type, | |
| 622 {bool isConstant, | |
| 623 bool isEmpty}) { | |
| 624 setType(node, type); | |
| 625 worldImpact.registerMapLiteral( | |
| 626 new MapLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty)); | |
| 484 } | 627 } |
| 485 | 628 |
| 486 void registerForeignCall(Node node, | 629 void registerForeignCall(Node node, |
| 487 Element element, | 630 Element element, |
| 488 CallStructure callStructure, | 631 CallStructure callStructure, |
| 489 ResolverVisitor visitor) { | 632 ResolverVisitor visitor) { |
| 490 backend.registerForeignCall( | 633 backend.registerForeignCall( |
| 491 node, element, callStructure, | 634 node, element, callStructure, |
| 492 new ForeignResolutionResolver(visitor, this)); | 635 new ForeignResolutionResolver(visitor, this)); |
| 493 } | 636 } |
| 494 | 637 |
| 495 void registerGetOfStaticFunction(FunctionElement element) { | 638 void registerGetOfStaticFunction(FunctionElement element) { |
| 496 worldImpact.registerClosurizedFunction(element); | 639 worldImpact.registerClosurizedFunction(element); |
| 497 } | 640 } |
| 498 | 641 |
| 499 void registerDynamicGetter(UniverseSelector selector) { | 642 void registerDynamicGetter(UniverseSelector selector) { |
| 500 assert(selector.selector.isGetter); | 643 assert(selector.selector.isGetter); |
| 501 worldImpact.registerDynamicGetter(selector); | 644 worldImpact.registerDynamicGetter(selector); |
| 502 } | 645 } |
| 503 | 646 |
| 504 void registerDynamicSetter(UniverseSelector selector) { | 647 void registerDynamicSetter(UniverseSelector selector) { |
| 505 assert(selector.selector.isSetter); | 648 assert(selector.selector.isSetter); |
| 506 worldImpact.registerDynamicSetter(selector); | 649 worldImpact.registerDynamicSetter(selector); |
| 507 } | 650 } |
| 508 | 651 |
| 509 void registerConstSymbol(String name) { | 652 void registerConstSymbol(String name) { |
| 510 backend.registerConstSymbol(name, this); | 653 worldImpact.registerConstSymbolName(name); |
| 511 } | 654 } |
| 512 | 655 |
| 513 void registerSymbolConstructor() { | 656 void registerSymbolConstructor() { |
| 514 backend.resolutionCallbacks.onSymbolConstructor(this); | 657 worldImpact.registerFeature(Feature.SYMBOL_CONSTRUCTOR); |
| 515 } | 658 } |
| 516 | 659 |
| 517 void registerInstantiatedType(InterfaceType type) { | 660 void registerInstantiatedType(InterfaceType type) { |
| 518 backend.registerInstantiatedType(type, world, this); | 661 worldImpact.registerInstantiatedType(type); |
| 519 mapping.addRequiredType(type); | 662 mapping.addRequiredType(type); |
| 520 } | 663 } |
| 521 | 664 |
| 522 void registerAbstractClassInstantiation() { | 665 void registerAbstractClassInstantiation() { |
| 523 backend.resolutionCallbacks.onAbstractClassInstantiation(this); | 666 worldImpact.registerFeature(Feature.ABSTRACT_CLASS_INSTANTIATION); |
| 524 } | 667 } |
| 525 | 668 |
| 526 void registerNewSymbol() { | 669 void registerNewSymbol() { |
| 527 backend.registerNewSymbol(this); | 670 worldImpact.registerFeature(Feature.NEW_SYMBOL); |
| 528 } | 671 } |
| 529 | 672 |
| 530 void registerRequiredType(DartType type, Element enclosingElement) { | 673 void registerRequiredType(DartType type, Element enclosingElement) { |
| 531 backend.registerRequiredType(type, enclosingElement); | 674 worldImpact.registerRequiredType(type); |
| 532 mapping.addRequiredType(type); | 675 mapping.addRequiredType(type); |
| 533 } | 676 } |
| 534 | 677 |
| 535 void registerStringInterpolation() { | 678 void registerStringInterpolation() { |
| 536 backend.resolutionCallbacks.onStringInterpolation(this); | 679 worldImpact.registerFeature(Feature.STRING_INTERPOLATION); |
| 537 } | 680 } |
| 538 | 681 |
| 539 void registerFallThroughError() { | 682 void registerFallThroughError() { |
| 540 backend.resolutionCallbacks.onFallThroughError(this); | 683 worldImpact.registerFeature(Feature.FALL_THROUGH_ERROR); |
| 541 } | 684 } |
| 542 | 685 |
| 543 void registerCatchStatement() { | 686 void registerCatchStatement() { |
| 544 backend.resolutionCallbacks.onCatchStatement(this); | 687 worldImpact.registerFeature(Feature.CATCH_STATEMENT); |
| 545 } | 688 } |
| 546 | 689 |
| 547 void registerStackTraceInCatch() { | 690 void registerStackTraceInCatch() { |
| 548 backend.resolutionCallbacks.onStackTraceInCatch(this); | 691 worldImpact.registerFeature(Feature.STACK_TRACE_IN_CATCH); |
| 549 } | 692 } |
| 550 | 693 |
| 551 void registerSyncForIn(Node node) { | 694 void registerSyncForIn(Node node) { |
| 552 backend.resolutionCallbacks.onSyncForIn(this); | 695 worldImpact.registerFeature(Feature.SYNC_FOR_IN); |
| 553 } | 696 } |
| 554 | 697 |
| 555 ClassElement defaultSuperclass(ClassElement element) { | 698 ClassElement defaultSuperclass(ClassElement element) { |
| 556 return backend.defaultSuperclass(element); | 699 return backend.defaultSuperclass(element); |
| 557 } | 700 } |
| 558 | 701 |
| 559 void registerMixinUse(MixinApplicationElement mixinApplication, | 702 void registerMixinUse(MixinApplicationElement mixinApplication, |
| 560 ClassElement mixin) { | 703 ClassElement mixin) { |
| 561 universe.registerMixinUse(mixinApplication, mixin); | 704 universe.registerMixinUse(mixinApplication, mixin); |
| 562 } | 705 } |
| 563 | 706 |
| 564 void registerThrowExpression() { | 707 void registerThrowExpression() { |
| 565 backend.resolutionCallbacks.onThrowExpression(this); | 708 worldImpact.registerFeature(Feature.THROW_EXPRESSION); |
| 566 } | 709 } |
| 567 | 710 |
| 568 void registerDependency(Element element) { | 711 void registerDependency(Element element) { |
| 569 mapping.registerDependency(element); | 712 mapping.registerDependency(element); |
| 570 } | 713 } |
| 571 | 714 |
| 572 Setlet<Element> get otherDependencies => mapping.otherDependencies; | 715 Setlet<Element> get otherDependencies => mapping.otherDependencies; |
| 573 | 716 |
| 574 void registerStaticInvocation(Element element) { | 717 void registerStaticInvocation(Element element) { |
| 575 // TODO(johnniwinther): Increase precision of [registerStaticUse] and | 718 // TODO(johnniwinther): Increase precision of [registerStaticUse] and |
| 576 // [registerDependency]. | 719 // [registerDependency]. |
| 577 if (element == null) return; | 720 if (element == null) return; |
| 578 registerStaticUse(element); | 721 registerStaticUse(element); |
| 579 registerDependency(element); | 722 registerDependency(element); |
| 580 } | 723 } |
| 581 | 724 |
| 582 void registerInstantiation(InterfaceType type) { | 725 void registerInstantiation(InterfaceType type) { |
| 583 backend.registerInstantiatedType(type, world, this); | 726 registerInstantiatedType(type); |
| 584 } | 727 } |
| 585 | 728 |
| 586 void registerAssert(bool hasMessage) { | 729 void registerAssert(bool hasMessage) { |
| 587 backend.resolutionCallbacks.onAssert(hasMessage, this); | 730 worldImpact.registerFeature( |
| 731 hasMessage ? Feature.ASSERT_WITH_MESSAGE : Feature.ASSERT); | |
| 588 } | 732 } |
| 589 | 733 |
| 590 void registerSendStructure(Send node, SendStructure sendStructure) { | 734 void registerSendStructure(Send node, SendStructure sendStructure) { |
| 591 mapping.setSendStructure(node, sendStructure); | 735 mapping.setSendStructure(node, sendStructure); |
| 592 } | 736 } |
| 593 | 737 |
| 594 // TODO(johnniwinther): Remove this when [SendStructure]s are part of the | 738 // TODO(johnniwinther): Remove this when [SendStructure]s are part of the |
| 595 // [ResolutionResult]. | 739 // [ResolutionResult]. |
| 596 SendStructure getSendStructure(Send node) { | 740 SendStructure getSendStructure(Send node) { |
| 597 return mapping.getSendStructure(node); | 741 return mapping.getSendStructure(node); |
| 598 } | 742 } |
| 599 | 743 |
| 600 void registerAsyncMarker(FunctionElement element) { | 744 void registerAsyncMarker(FunctionElement element) { |
| 601 backend.registerAsyncMarker(element, world, this); | 745 switch (element.asyncMarker) { |
| 746 case AsyncMarker.SYNC: | |
| 747 break; | |
| 748 case AsyncMarker.SYNC_STAR: | |
| 749 worldImpact.registerFeature(Feature.SYNC_STAR); | |
| 750 break; | |
| 751 case AsyncMarker.ASYNC: | |
| 752 worldImpact.registerFeature(Feature.ASYNC); | |
| 753 break; | |
| 754 case AsyncMarker.ASYNC_STAR: | |
| 755 worldImpact.registerFeature(Feature.ASYNC_STAR); | |
| 756 break; | |
| 757 } | |
| 602 } | 758 } |
| 603 | 759 |
| 604 void registerAsyncForIn(AsyncForIn node) { | 760 void registerAsyncForIn(AsyncForIn node) { |
| 605 backend.resolutionCallbacks.onAsyncForIn(node, this); | 761 worldImpact.registerFeature(Feature.ASYNC_FOR_IN); |
| 606 } | 762 } |
| 607 | 763 |
| 608 void registerIncDecOperation() { | 764 void registerIncDecOperation() { |
| 609 backend.resolutionCallbacks.onIncDecOperation(this); | 765 worldImpact.registerFeature(Feature.INC_DEC_OPERATION); |
| 610 } | 766 } |
| 611 | 767 |
| 612 void registerTryStatement() { | 768 void registerTryStatement() { |
| 613 mapping.containsTryStatement = true; | 769 mapping.containsTryStatement = true; |
| 614 } | 770 } |
| 615 } | 771 } |
| 616 | 772 |
| 617 class ForeignResolutionResolver implements ForeignResolver { | 773 class ForeignResolutionResolver implements ForeignResolver { |
| 618 final ResolverVisitor visitor; | 774 final ResolverVisitor visitor; |
| 619 final ResolutionRegistry registry; | 775 final ResolutionRegistry registry; |
| 620 | 776 |
| 621 ForeignResolutionResolver(this.visitor, this.registry); | 777 ForeignResolutionResolver(this.visitor, this.registry); |
| 622 | 778 |
| 623 @override | 779 @override |
| 624 ConstantExpression getConstant(Node node) { | 780 ConstantExpression getConstant(Node node) { |
| 625 return registry.getConstant(node); | 781 return registry.getConstant(node); |
| 626 } | 782 } |
| 627 | 783 |
| 628 @override | 784 @override |
| 629 void registerInstantiatedType(InterfaceType type) { | 785 void registerInstantiatedType(InterfaceType type) { |
| 630 registry.registerInstantiatedType(type); | 786 registry.registerInstantiatedType(type); |
| 631 } | 787 } |
| 632 | 788 |
| 633 @override | 789 @override |
| 634 DartType resolveTypeFromString(Node node, String typeName) { | 790 DartType resolveTypeFromString(Node node, String typeName) { |
| 635 return visitor.resolveTypeFromString(node, typeName); | 791 return visitor.resolveTypeFromString(node, typeName); |
| 636 } | 792 } |
| 637 } | 793 } |
| OLD | NEW |