OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.library_builder; | 5 library fasta.library_builder; |
6 | 6 |
7 import '../combinator.dart' show Combinator; | 7 import '../combinator.dart' show Combinator; |
8 | 8 |
9 import '../errors.dart' show InputError, internalError, printUnexpected; | 9 import '../errors.dart' show InputError, internalError, printUnexpected; |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 /// Returns true if the export scope was modified. | 92 /// Returns true if the export scope was modified. |
93 bool addToExportScope(String name, Builder member) { | 93 bool addToExportScope(String name, Builder member) { |
94 if (name.startsWith("_")) return false; | 94 if (name.startsWith("_")) return false; |
95 if (member is PrefixBuilder) return false; | 95 if (member is PrefixBuilder) return false; |
96 Map<String, Builder> map = | 96 Map<String, Builder> map = |
97 member.isSetter ? exports.setters : exports.local; | 97 member.isSetter ? exports.setters : exports.local; |
98 Builder existing = map[name]; | 98 Builder existing = map[name]; |
99 if (existing == member) return false; | 99 if (existing == member) return false; |
100 if (existing != null) { | 100 if (existing != null) { |
101 // For each entry mapping key `k` to declaration `d` in `NS` an entry | |
102 // mapping `k` to `d` is added to the exported namespace of `L` unless a | |
103 // top-level declaration with the name `k` exists in `L`. | |
104 if (existing.parent == this) return false; | |
105 | |
106 Builder result = | 101 Builder result = |
107 buildAmbiguousBuilder(name, existing, member, -1, isExport: true); | 102 buildAmbiguousBuilder(name, existing, member, -1, isExport: true); |
108 map[name] = result; | 103 map[name] = result; |
109 return result != existing; | 104 return result != existing; |
110 } else { | 105 } else { |
111 map[name] = member; | 106 map[name] = member; |
112 } | 107 } |
113 return true; | 108 return true; |
114 } | 109 } |
115 | 110 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 /// Don't use for scope lookup. Only use when an element is known to exist | 162 /// Don't use for scope lookup. Only use when an element is known to exist |
168 /// (and not a setter). | 163 /// (and not a setter). |
169 Builder operator [](String name) { | 164 Builder operator [](String name) { |
170 return scope.local[name] ?? internalError("Not found: '$name'."); | 165 return scope.local[name] ?? internalError("Not found: '$name'."); |
171 } | 166 } |
172 | 167 |
173 Builder lookup(String name, int charOffset, Uri fileUri) { | 168 Builder lookup(String name, int charOffset, Uri fileUri) { |
174 return scope.lookup(name, charOffset, fileUri); | 169 return scope.lookup(name, charOffset, fileUri); |
175 } | 170 } |
176 } | 171 } |
OLD | NEW |