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 Constant, | 9 ConstantValue, |
| 10 ConstructedConstant, | 10 ConstructedConstantValue, |
| 11 DeferredConstant, | 11 DeferredConstantValue, |
| 12 StringConstant; | 12 StringConstantValue; |
| 13 | 13 |
| 14 import 'dart2jslib.dart' show | 14 import 'dart2jslib.dart' show |
| 15 Backend, | 15 Backend, |
| 16 Compiler, | 16 Compiler, |
| 17 CompilerTask, | 17 CompilerTask, |
| 18 invariant, | 18 invariant, |
| 19 MessageKind; | 19 MessageKind; |
| 20 | 20 |
| 21 import 'dart_backend/dart_backend.dart' show | 21 import 'dart_backend/dart_backend.dart' show |
| 22 DartBackend; | 22 DartBackend; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 new Map<String, List<OutputUnit>>(); | 130 new Map<String, List<OutputUnit>>(); |
| 131 final Map<Import, String> importDeferName = new Map<Import, String>(); | 131 final Map<Import, String> importDeferName = new Map<Import, String>(); |
| 132 | 132 |
| 133 /// A mapping from elements and constants to their output unit. Query this via | 133 /// A mapping from elements and constants to their output unit. Query this via |
| 134 /// [outputUnitForElement] | 134 /// [outputUnitForElement] |
| 135 final Map<Element, OutputUnit> _elementToOutputUnit = | 135 final Map<Element, OutputUnit> _elementToOutputUnit = |
| 136 new Map<Element, OutputUnit>(); | 136 new Map<Element, OutputUnit>(); |
| 137 | 137 |
| 138 /// A mapping from constants to their output unit. Query this via | 138 /// A mapping from constants to their output unit. Query this via |
| 139 /// [outputUnitForConstant] | 139 /// [outputUnitForConstant] |
| 140 final Map<Constant, OutputUnit> _constantToOutputUnit = | 140 final Map<ConstantValue, OutputUnit> _constantToOutputUnit = |
| 141 new Map<Constant, OutputUnit>(); | 141 new Map<ConstantValue, OutputUnit>(); |
| 142 | 142 |
| 143 /// All the imports with a [DeferredLibrary] annotation, mapped to the | 143 /// All the imports with a [DeferredLibrary] annotation, mapped to the |
| 144 /// [LibraryElement] they import. | 144 /// [LibraryElement] they import. |
| 145 /// The main library is included in this set for convenience. | 145 /// The main library is included in this set for convenience. |
| 146 final Map<Import, LibraryElement> _allDeferredImports = | 146 final Map<Import, LibraryElement> _allDeferredImports = |
| 147 new Map<Import, LibraryElement>(); | 147 new Map<Import, LibraryElement>(); |
| 148 | 148 |
| 149 // For each deferred import we want to know exactly what elements have to | 149 // For each deferred import we want to know exactly what elements have to |
| 150 // be loaded. | 150 // be loaded. |
| 151 Map<Import, Set<Element>> _importedDeferredBy = null; | 151 Map<Import, Set<Element>> _importedDeferredBy = null; |
| 152 Map<Import, Set<Constant>> _constantsDeferredBy = null; | 152 Map<Import, Set<ConstantValue>> _constantsDeferredBy = null; |
| 153 | 153 |
| 154 Set<Element> _mainElements = new Set<Element>(); | 154 Set<Element> _mainElements = new Set<Element>(); |
| 155 | 155 |
| 156 DeferredLoadTask(Compiler compiler) : super(compiler) { | 156 DeferredLoadTask(Compiler compiler) : super(compiler) { |
| 157 mainOutputUnit.imports.add(_fakeMainImport); | 157 mainOutputUnit.imports.add(_fakeMainImport); |
| 158 } | 158 } |
| 159 | 159 |
| 160 Backend get backend => compiler.backend; | 160 Backend get backend => compiler.backend; |
| 161 | 161 |
| 162 /// Returns the [OutputUnit] where [element] belongs. | 162 /// Returns the [OutputUnit] where [element] belongs. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 173 if (element.enclosingElement == null) { | 173 if (element.enclosingElement == null) { |
| 174 _elementToOutputUnit[element] = mainOutputUnit; | 174 _elementToOutputUnit[element] = mainOutputUnit; |
| 175 break; | 175 break; |
| 176 } | 176 } |
| 177 element = element.enclosingElement.implementation; | 177 element = element.enclosingElement.implementation; |
| 178 } | 178 } |
| 179 return _elementToOutputUnit[element]; | 179 return _elementToOutputUnit[element]; |
| 180 } | 180 } |
| 181 | 181 |
| 182 /// Returns the [OutputUnit] where [constant] belongs. | 182 /// Returns the [OutputUnit] where [constant] belongs. |
| 183 OutputUnit outputUnitForConstant(Constant constant) { | 183 OutputUnit outputUnitForConstant(ConstantValue constant) { |
| 184 if (!isProgramSplit) return mainOutputUnit; | 184 if (!isProgramSplit) return mainOutputUnit; |
| 185 | 185 |
| 186 return _constantToOutputUnit[constant]; | 186 return _constantToOutputUnit[constant]; |
| 187 } | 187 } |
| 188 | 188 |
| 189 bool isDeferred(Element element) { | 189 bool isDeferred(Element element) { |
| 190 return outputUnitForElement(element) != mainOutputUnit; | 190 return outputUnitForElement(element) != mainOutputUnit; |
| 191 } | 191 } |
| 192 | 192 |
| 193 /// Returns true if e1 and e2 are in the same output unit. | 193 /// Returns true if e1 and e2 are in the same output unit. |
| 194 bool inSameOutputUnit(Element e1, Element e2) { | 194 bool inSameOutputUnit(Element e1, Element e2) { |
| 195 return outputUnitForElement(e1) == outputUnitForElement(e2); | 195 return outputUnitForElement(e1) == outputUnitForElement(e2); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void registerConstantDeferredUse(DeferredConstant constant, | 198 void registerConstantDeferredUse(DeferredConstantValue constant, |
| 199 PrefixElement prefix) { | 199 PrefixElement prefix) { |
| 200 OutputUnit outputUnit = new OutputUnit(); | 200 OutputUnit outputUnit = new OutputUnit(); |
| 201 outputUnit.imports.add(prefix.deferredImport); | 201 outputUnit.imports.add(prefix.deferredImport); |
| 202 _constantToOutputUnit[constant] = outputUnit; | 202 _constantToOutputUnit[constant] = outputUnit; |
| 203 } | 203 } |
| 204 | 204 |
| 205 /// Answers whether [element] is explicitly deferred when referred to from | 205 /// Answers whether [element] is explicitly deferred when referred to from |
| 206 /// [library]. | 206 /// [library]. |
| 207 bool _isExplicitlyDeferred(Element element, LibraryElement library) { | 207 bool _isExplicitlyDeferred(Element element, LibraryElement library) { |
| 208 Link<Import> imports = _getImports(element, library); | 208 Link<Import> imports = _getImports(element, library); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 227 return library.getImportsFor(element); | 227 return library.getImportsFor(element); |
| 228 } | 228 } |
| 229 | 229 |
| 230 /// Finds all elements and constants that [element] depends directly on. | 230 /// Finds all elements and constants that [element] depends directly on. |
| 231 /// (not the transitive closure.) | 231 /// (not the transitive closure.) |
| 232 /// | 232 /// |
| 233 /// Adds the results to [elements] and [constants]. | 233 /// Adds the results to [elements] and [constants]. |
| 234 void _collectAllElementsAndConstantsResolvedFrom( | 234 void _collectAllElementsAndConstantsResolvedFrom( |
| 235 Element element, | 235 Element element, |
| 236 Set<Element> elements, | 236 Set<Element> elements, |
| 237 Set<Constant> constants, | 237 Set<ConstantValue> constants, |
| 238 isMirrorUsage) { | 238 isMirrorUsage) { |
| 239 | 239 |
| 240 /// Recursively add the constant and its dependencies to [constants]. | 240 /// Recursively add the constant and its dependencies to [constants]. |
| 241 void addConstants(Constant constant) { | 241 void addConstants(ConstantValue constant) { |
| 242 if (constants.contains(constant)) return; | 242 if (constants.contains(constant)) return; |
| 243 constants.add(constant); | 243 constants.add(constant); |
| 244 if (constant is ConstructedConstant) { | 244 if (constant is ConstructedConstantValue) { |
| 245 elements.add(constant.type.element); | 245 elements.add(constant.type.element); |
| 246 } | 246 } |
| 247 constant.getDependencies().forEach(addConstants); | 247 constant.getDependencies().forEach(addConstants); |
| 248 } | 248 } |
| 249 | 249 |
| 250 /// Collects all direct dependencies of [element]. | 250 /// Collects all direct dependencies of [element]. |
| 251 /// | 251 /// |
| 252 /// The collected dependent elements and constants are are added to | 252 /// The collected dependent elements and constants are are added to |
| 253 /// [elements] and [constants] respectively. | 253 /// [elements] and [constants] respectively. |
| 254 void collectDependencies(Element element) { | 254 void collectDependencies(Element element) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 278 treeElements.forEachConstantNode((Node node, _) { | 278 treeElements.forEachConstantNode((Node node, _) { |
| 279 // Explicitly depend on the backend constants. | 279 // Explicitly depend on the backend constants. |
| 280 addConstants( | 280 addConstants( |
| 281 backend.constants.getConstantForNode(node, treeElements).value); | 281 backend.constants.getConstantForNode(node, treeElements).value); |
| 282 }); | 282 }); |
| 283 elements.addAll(treeElements.otherDependencies); | 283 elements.addAll(treeElements.otherDependencies); |
| 284 } | 284 } |
| 285 | 285 |
| 286 // TODO(sigurdm): How is metadata on a patch-class handled? | 286 // TODO(sigurdm): How is metadata on a patch-class handled? |
| 287 for (MetadataAnnotation metadata in element.metadata) { | 287 for (MetadataAnnotation metadata in element.metadata) { |
| 288 ConstExp constant = backend.constants.getConstantForMetadata(metadata); | 288 ConstantExpression constant = backend.constants.getConstantForMetadata(met adata); |
| 289 if (constant != null) { | 289 if (constant != null) { |
| 290 addConstants(constant.value); | 290 addConstants(constant.value); |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 if (element.isClass) { | 293 if (element.isClass) { |
| 294 // If we see a class, add everything its live instance members refer | 294 // If we see a class, add everything its live instance members refer |
| 295 // to. Static members are not relevant, unless we are processing | 295 // to. Static members are not relevant, unless we are processing |
| 296 // extra dependencies due to mirrors. | 296 // extra dependencies due to mirrors. |
| 297 void addLiveInstanceMember(Element element) { | 297 void addLiveInstanceMember(Element element) { |
| 298 if (!compiler.enqueuer.resolution.isLive(element)) return; | 298 if (!compiler.enqueuer.resolution.isLive(element)) return; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 return result; | 359 return result; |
| 360 } | 360 } |
| 361 | 361 |
| 362 /// Recursively traverses the graph of dependencies from [element], mapping | 362 /// Recursively traverses the graph of dependencies from [element], mapping |
| 363 /// deferred imports to each dependency it needs in the sets | 363 /// deferred imports to each dependency it needs in the sets |
| 364 /// [_importedDeferredBy] and [_constantsDeferredBy]. | 364 /// [_importedDeferredBy] and [_constantsDeferredBy]. |
| 365 void _mapDependencies(Element element, Import import, | 365 void _mapDependencies(Element element, Import import, |
| 366 {isMirrorUsage: false}) { | 366 {isMirrorUsage: false}) { |
| 367 Set<Element> elements = _importedDeferredBy.putIfAbsent(import, | 367 Set<Element> elements = _importedDeferredBy.putIfAbsent(import, |
| 368 () => new Set<Element>()); | 368 () => new Set<Element>()); |
| 369 Set<Constant> constants = _constantsDeferredBy.putIfAbsent(import, | 369 Set<ConstantValue> constants = _constantsDeferredBy.putIfAbsent(import, |
| 370 () => new Set<Constant>()); | 370 () => new Set<ConstantValue>()); |
| 371 | 371 |
| 372 // Only process elements once, unless we are doing dependencies due to | 372 // Only process elements once, unless we are doing dependencies due to |
| 373 // mirrors, which are added in additional traversals. | 373 // mirrors, which are added in additional traversals. |
| 374 if (!isMirrorUsage && elements.contains(element)) return; | 374 if (!isMirrorUsage && elements.contains(element)) return; |
| 375 // Anything used directly by main will be loaded from the start | 375 // Anything used directly by main will be loaded from the start |
| 376 // We do not need to traverse it again. | 376 // We do not need to traverse it again. |
| 377 if (import != _fakeMainImport && _mainElements.contains(element)) return; | 377 if (import != _fakeMainImport && _mainElements.contains(element)) return; |
| 378 | 378 |
| 379 // Here we modify [_importedDeferredBy]. | 379 // Here we modify [_importedDeferredBy]. |
| 380 elements.add(element); | 380 elements.add(element); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 } | 414 } |
| 415 | 415 |
| 416 // For each deferred import we analyze all elements reachable from the | 416 // For each deferred import we analyze all elements reachable from the |
| 417 // imported library through non-deferred imports. | 417 // imported library through non-deferred imports. |
| 418 handleLibrary(LibraryElement library, Import deferredImport) { | 418 handleLibrary(LibraryElement library, Import deferredImport) { |
| 419 library.implementation.forEachLocalMember((Element element) { | 419 library.implementation.forEachLocalMember((Element element) { |
| 420 mapDependenciesIfResolved(element, deferredImport); | 420 mapDependenciesIfResolved(element, deferredImport); |
| 421 }); | 421 }); |
| 422 | 422 |
| 423 for (MetadataAnnotation metadata in library.metadata) { | 423 for (MetadataAnnotation metadata in library.metadata) { |
| 424 ConstExp constant = | 424 ConstantExpression constant = |
| 425 backend.constants.getConstantForMetadata(metadata); | 425 backend.constants.getConstantForMetadata(metadata); |
| 426 if (constant != null) { | 426 if (constant != null) { |
| 427 _mapDependencies(constant.value.computeType(compiler).element, | 427 _mapDependencies(constant.value.computeType(compiler).element, |
| 428 deferredImport); | 428 deferredImport); |
| 429 } | 429 } |
| 430 } | 430 } |
| 431 for (LibraryTag tag in library.tags) { | 431 for (LibraryTag tag in library.tags) { |
| 432 for (MetadataAnnotation metadata in tag.metadata) { | 432 for (MetadataAnnotation metadata in tag.metadata) { |
| 433 ConstExp constant = | 433 ConstantExpression constant = |
| 434 backend.constants.getConstantForMetadata(metadata); | 434 backend.constants.getConstantForMetadata(metadata); |
| 435 if (constant != null) { | 435 if (constant != null) { |
| 436 _mapDependencies(constant.value.computeType(compiler).element, | 436 _mapDependencies(constant.value.computeType(compiler).element, |
| 437 deferredImport); | 437 deferredImport); |
| 438 } | 438 } |
| 439 } | 439 } |
| 440 } | 440 } |
| 441 } | 441 } |
| 442 | 442 |
| 443 for (Import deferredImport in _allDeferredImports.keys) { | 443 for (Import deferredImport in _allDeferredImports.keys) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 460 String result; | 460 String result; |
| 461 if (import == _fakeMainImport) { | 461 if (import == _fakeMainImport) { |
| 462 result = "main"; | 462 result = "main"; |
| 463 } else if (import.isDeferred) { | 463 } else if (import.isDeferred) { |
| 464 result = import.prefix.toString(); | 464 result = import.prefix.toString(); |
| 465 } else { | 465 } else { |
| 466 Link<MetadataAnnotation> metadatas = import.metadata; | 466 Link<MetadataAnnotation> metadatas = import.metadata; |
| 467 assert(metadatas != null); | 467 assert(metadatas != null); |
| 468 for (MetadataAnnotation metadata in metadatas) { | 468 for (MetadataAnnotation metadata in metadatas) { |
| 469 metadata.ensureResolved(compiler); | 469 metadata.ensureResolved(compiler); |
| 470 Element element = metadata.constant.value.computeType(compiler).elemen t; | 470 Element element = metadata.constant.value.computeType(compiler).elemen t; |
|
sigurdm
2014/10/01 07:46:47
Not your code, but long line
Johnni Winther
2014/10/01 08:21:23
Done.
| |
| 471 if (element == deferredLibraryClass) { | 471 if (element == deferredLibraryClass) { |
| 472 ConstructedConstant constant = metadata.constant.value; | 472 ConstructedConstantValue constant = metadata.constant.value; |
| 473 StringConstant s = constant.fields[0]; | 473 StringConstantValue s = constant.fields[0]; |
| 474 result = s.value.slowToString(); | 474 result = s.primitiveValue.slowToString(); |
| 475 break; | 475 break; |
| 476 } | 476 } |
| 477 } | 477 } |
| 478 } | 478 } |
| 479 assert(result != null); | 479 assert(result != null); |
| 480 importDeferName[import] = makeUnique(result, usedImportNames);; | 480 importDeferName[import] = makeUnique(result, usedImportNames);; |
| 481 } | 481 } |
| 482 | 482 |
| 483 int counter = 1; | 483 int counter = 1; |
| 484 | 484 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 } | 524 } |
| 525 | 525 |
| 526 void onResolutionComplete(FunctionElement main) { | 526 void onResolutionComplete(FunctionElement main) { |
| 527 if (!isProgramSplit) { | 527 if (!isProgramSplit) { |
| 528 allOutputUnits.add(mainOutputUnit); | 528 allOutputUnits.add(mainOutputUnit); |
| 529 return; | 529 return; |
| 530 } | 530 } |
| 531 if (main == null) return; | 531 if (main == null) return; |
| 532 LibraryElement mainLibrary = main.library; | 532 LibraryElement mainLibrary = main.library; |
| 533 _importedDeferredBy = new Map<Import, Set<Element>>(); | 533 _importedDeferredBy = new Map<Import, Set<Element>>(); |
| 534 _constantsDeferredBy = new Map<Import, Set<Constant>>(); | 534 _constantsDeferredBy = new Map<Import, Set<ConstantValue>>(); |
| 535 _importedDeferredBy[_fakeMainImport] = _mainElements; | 535 _importedDeferredBy[_fakeMainImport] = _mainElements; |
| 536 | 536 |
| 537 measureElement(mainLibrary, () { | 537 measureElement(mainLibrary, () { |
| 538 | 538 |
| 539 // Starting from main, traverse the program and find all dependencies. | 539 // Starting from main, traverse the program and find all dependencies. |
| 540 _mapDependencies(compiler.mainFunction, _fakeMainImport); | 540 _mapDependencies(compiler.mainFunction, _fakeMainImport); |
| 541 | 541 |
| 542 // Also add "global" dependencies to the main OutputUnit. These are | 542 // Also add "global" dependencies to the main OutputUnit. These are |
| 543 // things that the backend need but cannot associate with a particular | 543 // things that the backend need but cannot associate with a particular |
| 544 // element, for example, startRootIsolate. This set also contains | 544 // element, for example, startRootIsolate. This set also contains |
| 545 // elements for which we lack precise information. | 545 // elements for which we lack precise information. |
| 546 for (Element element in compiler.globalDependencies.otherDependencies) { | 546 for (Element element in compiler.globalDependencies.otherDependencies) { |
| 547 _mapDependencies(element, _fakeMainImport); | 547 _mapDependencies(element, _fakeMainImport); |
| 548 } | 548 } |
| 549 | 549 |
| 550 // Now check to see if we have to add more elements due to mirrors. | 550 // Now check to see if we have to add more elements due to mirrors. |
| 551 if (compiler.mirrorsLibrary != null) { | 551 if (compiler.mirrorsLibrary != null) { |
| 552 _addMirrorElements(); | 552 _addMirrorElements(); |
| 553 } | 553 } |
| 554 | 554 |
| 555 // Build the OutputUnits using these two maps. | 555 // Build the OutputUnits using these two maps. |
| 556 Map<Element, OutputUnit> elementToOutputUnitBuilder = | 556 Map<Element, OutputUnit> elementToOutputUnitBuilder = |
| 557 new Map<Element, OutputUnit>(); | 557 new Map<Element, OutputUnit>(); |
| 558 Map<Constant, OutputUnit> constantToOutputUnitBuilder = | 558 Map<ConstantValue, OutputUnit> constantToOutputUnitBuilder = |
| 559 new Map<Constant, OutputUnit>(); | 559 new Map<ConstantValue, OutputUnit>(); |
| 560 | 560 |
| 561 // Reverse the mappings. For each element record an OutputUnit collecting | 561 // Reverse the mappings. For each element record an OutputUnit collecting |
| 562 // all deferred imports mapped to this element. Same for constants. | 562 // all deferred imports mapped to this element. Same for constants. |
| 563 for (Import import in _importedDeferredBy.keys) { | 563 for (Import import in _importedDeferredBy.keys) { |
| 564 for (Element element in _importedDeferredBy[import]) { | 564 for (Element element in _importedDeferredBy[import]) { |
| 565 // Only one file should be loaded when the program starts, so make | 565 // Only one file should be loaded when the program starts, so make |
| 566 // sure that only one OutputUnit is created for [fakeMainImport]. | 566 // sure that only one OutputUnit is created for [fakeMainImport]. |
| 567 if (import == _fakeMainImport) { | 567 if (import == _fakeMainImport) { |
| 568 elementToOutputUnitBuilder[element] = mainOutputUnit; | 568 elementToOutputUnitBuilder[element] = mainOutputUnit; |
| 569 } else { | 569 } else { |
| 570 elementToOutputUnitBuilder | 570 elementToOutputUnitBuilder |
| 571 .putIfAbsent(element, () => new OutputUnit()) | 571 .putIfAbsent(element, () => new OutputUnit()) |
| 572 .imports.add(import); | 572 .imports.add(import); |
| 573 } | 573 } |
| 574 } | 574 } |
| 575 for (Constant constant in _constantsDeferredBy[import]) { | 575 for (ConstantValue constant in _constantsDeferredBy[import]) { |
| 576 // Only one file should be loaded when the program starts, so make | 576 // Only one file should be loaded when the program starts, so make |
| 577 // sure that only one OutputUnit is created for [fakeMainImport]. | 577 // sure that only one OutputUnit is created for [fakeMainImport]. |
| 578 if (import == _fakeMainImport) { | 578 if (import == _fakeMainImport) { |
| 579 constantToOutputUnitBuilder[constant] = mainOutputUnit; | 579 constantToOutputUnitBuilder[constant] = mainOutputUnit; |
| 580 } else { | 580 } else { |
| 581 constantToOutputUnitBuilder | 581 constantToOutputUnitBuilder |
| 582 .putIfAbsent(constant, () => new OutputUnit()) | 582 .putIfAbsent(constant, () => new OutputUnit()) |
| 583 .imports.add(import); | 583 .imports.add(import); |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 } | 586 } |
| 587 | 587 |
| 588 // Release maps; | 588 // Release maps; |
| 589 _importedDeferredBy = null; | 589 _importedDeferredBy = null; |
| 590 _constantsDeferredBy = null; | 590 _constantsDeferredBy = null; |
| 591 | 591 |
| 592 // Find all the output units elements/constants have been mapped to, and | 592 // Find all the output units elements/constants have been mapped to, and |
| 593 // canonicalize them. | 593 // canonicalize them. |
| 594 elementToOutputUnitBuilder.forEach( | 594 elementToOutputUnitBuilder.forEach( |
| 595 (Element element, OutputUnit outputUnit) { | 595 (Element element, OutputUnit outputUnit) { |
| 596 OutputUnit representative = allOutputUnits.lookup(outputUnit); | 596 OutputUnit representative = allOutputUnits.lookup(outputUnit); |
| 597 if (representative == null) { | 597 if (representative == null) { |
| 598 representative = outputUnit; | 598 representative = outputUnit; |
| 599 allOutputUnits.add(representative); | 599 allOutputUnits.add(representative); |
| 600 } | 600 } |
| 601 _elementToOutputUnit[element] = representative; | 601 _elementToOutputUnit[element] = representative; |
| 602 }); | 602 }); |
| 603 constantToOutputUnitBuilder.forEach( | 603 constantToOutputUnitBuilder.forEach( |
| 604 (Constant constant, OutputUnit outputUnit) { | 604 (ConstantValue constant, OutputUnit outputUnit) { |
| 605 OutputUnit representative = allOutputUnits.lookup(outputUnit); | 605 OutputUnit representative = allOutputUnits.lookup(outputUnit); |
| 606 if (representative == null) { | 606 if (representative == null) { |
| 607 representative = outputUnit; | 607 representative = outputUnit; |
| 608 allOutputUnits.add(representative); | 608 allOutputUnits.add(representative); |
| 609 } | 609 } |
| 610 _constantToOutputUnit[constant] = representative; | 610 _constantToOutputUnit[constant] = representative; |
| 611 }); | 611 }); |
| 612 | 612 |
| 613 // Generate a unique name for each OutputUnit. | 613 // Generate a unique name for each OutputUnit. |
| 614 _assignNamesToOutputUnits(allOutputUnits); | 614 _assignNamesToOutputUnits(allOutputUnits); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 Element maybePrefix = elements[identifier]; | 755 Element maybePrefix = elements[identifier]; |
| 756 if (maybePrefix != null && maybePrefix.isPrefix) { | 756 if (maybePrefix != null && maybePrefix.isPrefix) { |
| 757 PrefixElement prefixElement = maybePrefix; | 757 PrefixElement prefixElement = maybePrefix; |
| 758 if (prefixElement.isDeferred) { | 758 if (prefixElement.isDeferred) { |
| 759 return prefixElement; | 759 return prefixElement; |
| 760 } | 760 } |
| 761 } | 761 } |
| 762 return null; | 762 return null; |
| 763 } | 763 } |
| 764 } | 764 } |
| OLD | NEW |