| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import '../closure.dart'; | 5 import '../closure.dart'; |
| 6 import '../common.dart'; | 6 import '../common.dart'; |
| 7 import '../common_elements.dart'; | 7 import '../common_elements.dart'; |
| 8 import '../compiler.dart'; | 8 import '../compiler.dart'; |
| 9 import '../constants/values.dart'; | 9 import '../constants/values.dart'; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 ResolutionWorldBuilder worldBuilder, ClosedWorld closedWorld) { | 266 ResolutionWorldBuilder worldBuilder, ClosedWorld closedWorld) { |
| 267 if (_membersNeededForReflection != null) return; | 267 if (_membersNeededForReflection != null) return; |
| 268 if (closedWorld.commonElements.mirrorsLibrary == null) { | 268 if (closedWorld.commonElements.mirrorsLibrary == null) { |
| 269 _membersNeededForReflection = const ImmutableEmptySet<Element>(); | 269 _membersNeededForReflection = const ImmutableEmptySet<Element>(); |
| 270 return; | 270 return; |
| 271 } | 271 } |
| 272 // Compute a mapping from class to the closures it contains, so we | 272 // Compute a mapping from class to the closures it contains, so we |
| 273 // can include the correct ones when including the class. | 273 // can include the correct ones when including the class. |
| 274 Map<ClassElement, List<LocalFunctionElement>> closureMap = | 274 Map<ClassElement, List<LocalFunctionElement>> closureMap = |
| 275 new Map<ClassElement, List<LocalFunctionElement>>(); | 275 new Map<ClassElement, List<LocalFunctionElement>>(); |
| 276 for (LocalFunctionElement closure in worldBuilder.allClosures) { | 276 for (LocalFunctionElement closure in worldBuilder.localFunctions) { |
| 277 closureMap.putIfAbsent(closure.enclosingClass, () => []).add(closure); | 277 closureMap.putIfAbsent(closure.enclosingClass, () => []).add(closure); |
| 278 } | 278 } |
| 279 bool foundClosure = false; | 279 bool foundClosure = false; |
| 280 Set<Element> reflectableMembers = new Set<Element>(); | 280 Set<Element> reflectableMembers = new Set<Element>(); |
| 281 for (ClassElement cls in worldBuilder.directlyInstantiatedClasses) { | 281 for (ClassElement cls in worldBuilder.directlyInstantiatedClasses) { |
| 282 // Do not process internal classes. | 282 // Do not process internal classes. |
| 283 if (cls.library.isInternalLibrary || cls.isInjected) continue; | 283 if (cls.library.isInternalLibrary || cls.isInjected) continue; |
| 284 if (referencedFromMirrorSystem(cls)) { | 284 if (referencedFromMirrorSystem(cls)) { |
| 285 Set<Name> memberNames = new Set<Name>(); | 285 Set<Name> memberNames = new Set<Name>(); |
| 286 // 1) the class (should be resolved) | 286 // 1) the class (should be resolved) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 foundClosure = true; | 377 foundClosure = true; |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 } | 380 } |
| 381 // As we do not think about closures as classes, yet, we have to make sure | 381 // As we do not think about closures as classes, yet, we have to make sure |
| 382 // their superclasses are available for reflection manually. | 382 // their superclasses are available for reflection manually. |
| 383 if (foundClosure) { | 383 if (foundClosure) { |
| 384 ClassElement cls = _helpers.closureClass; | 384 ClassElement cls = _helpers.closureClass; |
| 385 reflectableMembers.add(cls); | 385 reflectableMembers.add(cls); |
| 386 } | 386 } |
| 387 Set<Element> closurizedMembers = worldBuilder.closurizedMembers; | 387 Set<MethodElement> closurizedMembers = worldBuilder.closurizedMembers; |
| 388 if (closurizedMembers.any(reflectableMembers.contains)) { | 388 if (closurizedMembers.any(reflectableMembers.contains)) { |
| 389 ClassElement cls = _helpers.boundClosureClass; | 389 ClassElement cls = _helpers.boundClosureClass; |
| 390 reflectableMembers.add(cls); | 390 reflectableMembers.add(cls); |
| 391 } | 391 } |
| 392 // Add typedefs. | 392 // Add typedefs. |
| 393 reflectableMembers | 393 reflectableMembers |
| 394 .addAll(closedWorld.allTypedefs.where(referencedFromMirrorSystem)); | 394 .addAll(closedWorld.allTypedefs.where(referencedFromMirrorSystem)); |
| 395 // Register all symbols of reflectable elements | 395 // Register all symbols of reflectable elements |
| 396 for (Element element in reflectableMembers) { | 396 for (Element element in reflectableMembers) { |
| 397 symbolsUsed.add(element.name); | 397 symbolsUsed.add(element.name); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 411 } | 411 } |
| 412 | 412 |
| 413 /// Called when [:const Symbol(name):] is seen. | 413 /// Called when [:const Symbol(name):] is seen. |
| 414 void registerConstSymbol(String name) { | 414 void registerConstSymbol(String name) { |
| 415 symbolsUsed.add(name); | 415 symbolsUsed.add(name); |
| 416 if (name.endsWith('=')) { | 416 if (name.endsWith('=')) { |
| 417 symbolsUsed.add(name.substring(0, name.length - 1)); | 417 symbolsUsed.add(name.substring(0, name.length - 1)); |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 } | 420 } |
| OLD | NEW |