OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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.world; | 5 library dart2js.world; |
6 | 6 |
7 import 'closure.dart' show | 7 import 'closure.dart' show |
8 SynthesizedCallMethodElementX; | 8 SynthesizedCallMethodElementX; |
9 import 'common/backend_api.dart' show | 9 import 'common/backend_api.dart' show |
10 Backend; | 10 Backend; |
11 import 'common/registry.dart' show | 11 import 'common/registry.dart' show |
12 Registry; | 12 Registry; |
13 import 'compiler.dart' show | 13 import 'compiler.dart' show |
14 Compiler; | 14 Compiler; |
15 import 'dart_types.dart'; | 15 import 'dart_types.dart'; |
| 16 import 'diagnostics/diagnostic_listener.dart' show |
| 17 DiagnosticReporter; |
16 import 'diagnostics/invariant.dart' show | 18 import 'diagnostics/invariant.dart' show |
17 invariant; | 19 invariant; |
18 import 'elements/elements.dart' show | 20 import 'elements/elements.dart' show |
19 ClassElement, | 21 ClassElement, |
20 Element, | 22 Element, |
21 FunctionElement, | 23 FunctionElement, |
22 MixinApplicationElement, | 24 MixinApplicationElement, |
23 TypedefElement, | 25 TypedefElement, |
24 VariableElement; | 26 VariableElement; |
25 import 'ordered_typeset.dart'; | 27 import 'ordered_typeset.dart'; |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 429 |
428 Set<ClassElement> typesImplementedBySubclassesOf(ClassElement cls) { | 430 Set<ClassElement> typesImplementedBySubclassesOf(ClassElement cls) { |
429 return _typesImplementedBySubclasses[cls.declaration]; | 431 return _typesImplementedBySubclasses[cls.declaration]; |
430 } | 432 } |
431 | 433 |
432 World(Compiler compiler) | 434 World(Compiler compiler) |
433 : allFunctions = new FunctionSet(compiler), | 435 : allFunctions = new FunctionSet(compiler), |
434 this.compiler = compiler, | 436 this.compiler = compiler, |
435 alreadyPopulated = compiler.cacheStrategy.newSet(); | 437 alreadyPopulated = compiler.cacheStrategy.newSet(); |
436 | 438 |
| 439 DiagnosticReporter get reporter => compiler.reporter; |
| 440 |
437 /// Called to add [cls] to the set of known classes. | 441 /// Called to add [cls] to the set of known classes. |
438 /// | 442 /// |
439 /// This ensures that class hierarchy queries can be performed on [cls] and | 443 /// This ensures that class hierarchy queries can be performed on [cls] and |
440 /// classes that extend or implement it. | 444 /// classes that extend or implement it. |
441 void registerClass(ClassElement cls) { | 445 void registerClass(ClassElement cls) { |
442 _ensureClassSet(cls); | 446 _ensureClassSet(cls); |
443 } | 447 } |
444 | 448 |
445 /// Returns [ClassHierarchyNode] for [cls] used to model the class hierarchies | 449 /// Returns [ClassHierarchyNode] for [cls] used to model the class hierarchies |
446 /// of known classes. | 450 /// of known classes. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 cls.superclass, indirectlyInstantiated: true); | 514 cls.superclass, indirectlyInstantiated: true); |
511 } | 515 } |
512 } | 516 } |
513 | 517 |
514 void addSubtypes(ClassElement cls) { | 518 void addSubtypes(ClassElement cls) { |
515 if (compiler.hasIncrementalSupport && !alreadyPopulated.add(cls)) { | 519 if (compiler.hasIncrementalSupport && !alreadyPopulated.add(cls)) { |
516 return; | 520 return; |
517 } | 521 } |
518 assert(cls.isDeclaration); | 522 assert(cls.isDeclaration); |
519 if (!cls.isResolved) { | 523 if (!cls.isResolved) { |
520 compiler.internalError(cls, 'Class "${cls.name}" is not resolved.'); | 524 reporter.internalError(cls, 'Class "${cls.name}" is not resolved.'); |
521 } | 525 } |
522 | 526 |
523 updateClassHierarchyNodeForClass(cls, directlyInstantiated: true); | 527 updateClassHierarchyNodeForClass(cls, directlyInstantiated: true); |
524 | 528 |
525 // Walk through the superclasses, and record the types | 529 // Walk through the superclasses, and record the types |
526 // implemented by that type on the superclasses. | 530 // implemented by that type on the superclasses. |
527 ClassElement superclass = cls.superclass; | 531 ClassElement superclass = cls.superclass; |
528 while (superclass != null) { | 532 while (superclass != null) { |
529 Set<Element> typesImplementedBySubclassesOfCls = | 533 Set<Element> typesImplementedBySubclassesOfCls = |
530 _typesImplementedBySubclasses.putIfAbsent( | 534 _typesImplementedBySubclasses.putIfAbsent( |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 // function expressions's element. | 696 // function expressions's element. |
693 // TODO(herhut): Generate classes for function expressions earlier. | 697 // TODO(herhut): Generate classes for function expressions earlier. |
694 if (element is SynthesizedCallMethodElementX) { | 698 if (element is SynthesizedCallMethodElementX) { |
695 return getMightBePassedToApply(element.expression); | 699 return getMightBePassedToApply(element.expression); |
696 } | 700 } |
697 return functionsThatMightBePassedToApply.contains(element); | 701 return functionsThatMightBePassedToApply.contains(element); |
698 } | 702 } |
699 | 703 |
700 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; | 704 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; |
701 } | 705 } |
OLD | NEW |