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 deferred_load; | 5 library deferred_load; |
| 6 | 6 |
| 7 import 'constants/expressions.dart'; | 7 import 'constants/expressions.dart'; |
| 8 import 'constants/values.dart' show | 8 import 'constants/values.dart' show |
| 9 ConstantValue, | 9 ConstantValue, |
| 10 ConstructedConstantValue, | 10 ConstructedConstantValue, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 /// | 67 /// |
| 68 /// Whenever a deferred Element is shared between several deferred imports it is | 68 /// Whenever a deferred Element is shared between several deferred imports it is |
| 69 /// in an output unit with those imports in the [imports] Set. | 69 /// in an output unit with those imports in the [imports] Set. |
| 70 /// | 70 /// |
| 71 /// OutputUnits are equal if their [imports] are equal. | 71 /// OutputUnits are equal if their [imports] are equal. |
| 72 class OutputUnit { | 72 class OutputUnit { |
| 73 /// The deferred imports that will load this output unit when one of them is | 73 /// The deferred imports that will load this output unit when one of them is |
| 74 /// loaded. | 74 /// loaded. |
| 75 final Setlet<Import> imports = new Setlet<Import>(); | 75 final Setlet<Import> imports = new Setlet<Import>(); |
| 76 | 76 |
| 77 /// `true` is this the output unit for the main output file. | |
|
floitsch
2015/01/09 16:35:19
Not english.
Johnni Winther
2015/01/13 08:53:05
Done.
| |
| 78 final bool isMainOutput; | |
| 79 | |
| 77 /// A unique name representing this [OutputUnit]. | 80 /// A unique name representing this [OutputUnit]. |
| 78 /// Based on the set of [imports]. | 81 /// Based on the set of [imports]. |
| 79 String name; | 82 String name; |
| 80 | 83 |
| 84 OutputUnit({this.isMainOutput: false}); | |
| 85 | |
| 81 String toString() => "OutputUnit($name)"; | 86 String toString() => "OutputUnit($name)"; |
| 82 | 87 |
| 83 bool operator==(OutputUnit other) { | 88 bool operator==(OutputUnit other) { |
| 84 return imports.length == other.imports.length && | 89 return imports.length == other.imports.length && |
| 85 imports.containsAll(other.imports); | 90 imports.containsAll(other.imports); |
| 86 } | 91 } |
| 87 | 92 |
| 88 int get hashCode { | 93 int get hashCode { |
| 89 int sum = 0; | 94 int sum = 0; |
| 90 for (Import import in imports) { | 95 for (Import import in imports) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 103 | 108 |
| 104 /// DeferredLibrary from dart:async | 109 /// DeferredLibrary from dart:async |
| 105 ClassElement get deferredLibraryClass => compiler.deferredLibraryClass; | 110 ClassElement get deferredLibraryClass => compiler.deferredLibraryClass; |
| 106 | 111 |
| 107 /// A synthetic [Import] representing the loading of the main | 112 /// A synthetic [Import] representing the loading of the main |
| 108 /// program. | 113 /// program. |
| 109 final Import _fakeMainImport = new Import(null, new LiteralString(null, | 114 final Import _fakeMainImport = new Import(null, new LiteralString(null, |
| 110 new LiteralDartString("main")), null, null, null); | 115 new LiteralDartString("main")), null, null, null); |
| 111 | 116 |
| 112 /// The OutputUnit that will be loaded when the program starts. | 117 /// The OutputUnit that will be loaded when the program starts. |
| 113 final OutputUnit mainOutputUnit = new OutputUnit(); | 118 final OutputUnit mainOutputUnit = new OutputUnit(isMainOutput: true); |
| 114 | 119 |
| 115 /// A set containing (eventually) all output units that will result from the | 120 /// A set containing (eventually) all output units that will result from the |
| 116 /// program. | 121 /// program. |
| 117 final Set<OutputUnit> allOutputUnits = new Set<OutputUnit>(); | 122 final Set<OutputUnit> allOutputUnits = new Set<OutputUnit>(); |
| 118 | 123 |
| 119 /// Will be `true` if the program contains deferred libraries. | 124 /// Will be `true` if the program contains deferred libraries. |
| 120 bool isProgramSplit = false; | 125 bool isProgramSplit = false; |
| 121 | 126 |
| 122 /// A mapping from the name of a defer import to all the output units it | 127 /// A mapping from the name of a defer import to all the output units it |
| 123 /// depends on in a list of lists to be loaded in the order they appear. | 128 /// depends on in a list of lists to be loaded in the order they appear. |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 758 Element maybePrefix = elements[identifier]; | 763 Element maybePrefix = elements[identifier]; |
| 759 if (maybePrefix != null && maybePrefix.isPrefix) { | 764 if (maybePrefix != null && maybePrefix.isPrefix) { |
| 760 PrefixElement prefixElement = maybePrefix; | 765 PrefixElement prefixElement = maybePrefix; |
| 761 if (prefixElement.isDeferred) { | 766 if (prefixElement.isDeferred) { |
| 762 return prefixElement; | 767 return prefixElement; |
| 763 } | 768 } |
| 764 } | 769 } |
| 765 return null; | 770 return null; |
| 766 } | 771 } |
| 767 } | 772 } |
| OLD | NEW |