OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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.util; | 5 library dart2js.util; |
6 | 6 |
7 import 'util_implementation.dart'; | 7 import 'util_implementation.dart'; |
8 import 'characters.dart'; | 8 import 'characters.dart'; |
9 | 9 |
10 export 'setlet.dart'; | 10 export 'setlet.dart'; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 if (isAbstract) builder.addLast('abstract'); | 158 if (isAbstract) builder.addLast('abstract'); |
159 if (isFinal) builder.addLast('final'); | 159 if (isFinal) builder.addLast('final'); |
160 if (isVar) builder.addLast('var'); | 160 if (isVar) builder.addLast('var'); |
161 if (isConst) builder.addLast('const'); | 161 if (isConst) builder.addLast('const'); |
162 if (isFactory) builder.addLast('factory'); | 162 if (isFactory) builder.addLast('factory'); |
163 if (isExternal) builder.addLast('external'); | 163 if (isExternal) builder.addLast('external'); |
164 StringBuffer buffer = new StringBuffer(); | 164 StringBuffer buffer = new StringBuffer(); |
165 builder.toLink().printOn(buffer, ', '); | 165 builder.toLink().printOn(buffer, ', '); |
166 return buffer.toString(); | 166 return buffer.toString(); |
167 } | 167 } |
| 168 |
| 169 // Returns suggestedName if it is not in usedNames. Otherwise concatenates |
| 170 // the smallest number that makes it not appear in usedNames. |
| 171 // Adds the result to usedNames. |
| 172 String makeUnique(String suggestedName, Set<String> usedNames) { |
| 173 String result = suggestedName; |
| 174 if (usedNames.contains(suggestedName)) { |
| 175 int counter = 0; |
| 176 while (usedNames.contains(result)) { |
| 177 counter++; |
| 178 result = "$suggestedName$counter"; |
| 179 } |
| 180 } |
| 181 usedNames.add(result); |
| 182 return result; |
| 183 } |
OLD | NEW |