| 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 part of dart2js.js_emitter.program_builder; | 5 part of dart2js.js_emitter.program_builder; |
| 6 | 6 |
| 7 /// Maps [LibraryElement]s to their [Element]s. | 7 /// Maps [LibraryElement]s to their [Element]s. |
| 8 /// | 8 /// |
| 9 /// Fundamentally, this class nicely encapsulates a | 9 /// Fundamentally, this class nicely encapsulates a |
| 10 /// `Map<LibraryElement, List<Element>>`. | 10 /// `Map<LibraryElement, List<Element>>`. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 result = _deferredLibrariesMap.putIfAbsent( | 91 result = _deferredLibrariesMap.putIfAbsent( |
| 92 targetUnit, () => new LibrariesMap.deferred(targetUnit, name)); | 92 targetUnit, () => new LibrariesMap.deferred(targetUnit, name)); |
| 93 } | 93 } |
| 94 _lastOutputUnit = targetUnit; | 94 _lastOutputUnit = targetUnit; |
| 95 _lastLibrariesMap = result; | 95 _lastLibrariesMap = result; |
| 96 return result; | 96 return result; |
| 97 } | 97 } |
| 98 | 98 |
| 99 /// Adds all elements to their respective libraries in the correct | 99 /// Adds all elements to their respective libraries in the correct |
| 100 /// libraries map. | 100 /// libraries map. |
| 101 void registerElements(OutputUnit outputUnit, List<Element> elements) { | 101 void registerElements(OutputUnit outputUnit, Iterable<Element> elements) { |
| 102 LibrariesMap targetLibrariesMap = _mapUnitToLibrariesMap(outputUnit); | 102 LibrariesMap targetLibrariesMap = _mapUnitToLibrariesMap(outputUnit); |
| 103 for (Element element in Elements.sortedByPosition(elements)) { | 103 for (Element element in Elements.sortedByPosition(elements)) { |
| 104 targetLibrariesMap.add(element.library, element); | 104 targetLibrariesMap.add(element.library, element); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 void registerConstant(OutputUnit outputUnit, ConstantValue constantValue) { | 108 void registerConstant(OutputUnit outputUnit, ConstantValue constantValue) { |
| 109 // We just need to make sure that the target library map is registered. | 109 // We just need to make sure that the target library map is registered. |
| 110 // Otherwise a library map that contains only constants is not built. | 110 // Otherwise a library map that contains only constants is not built. |
| 111 _mapUnitToLibrariesMap(outputUnit); | 111 _mapUnitToLibrariesMap(outputUnit); |
| 112 } | 112 } |
| 113 | 113 |
| 114 Holder registerHolder(String name) { | 114 Holder registerHolder(String name) { |
| 115 return _holdersMap.putIfAbsent( | 115 return _holdersMap.putIfAbsent( |
| 116 name, | 116 name, |
| 117 () => new Holder(name, _holdersMap.length)); | 117 () => new Holder(name, _holdersMap.length)); |
| 118 } | 118 } |
| 119 } | 119 } |
| OLD | NEW |