| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart_backend; | 5 part of dart_backend; |
| 6 | 6 |
| 7 Function get _compareNodes => | 7 Function get _compareNodes => |
| 8 compareBy((n) => n.getBeginToken().charOffset); | 8 compareBy((n) => n.getBeginToken().charOffset); |
| 9 | 9 |
| 10 typedef String _Renamer(Renamable renamable); | 10 typedef String _Renamer(Renamable renamable); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 return result.toString(); | 104 return result.toString(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 String renameConstructor(Element element, ConstructorPlaceholder placeholder, | 107 String renameConstructor(Element element, ConstructorPlaceholder placeholder, |
| 108 Function renameString, Function renameElement) { | 108 Function renameString, Function renameElement) { |
| 109 assert(element.isConstructor()); | 109 assert(element.isConstructor()); |
| 110 StringBuffer result = new StringBuffer(); | 110 StringBuffer result = new StringBuffer(); |
| 111 String name = element.name.slowToString(); | 111 String name = element.name.slowToString(); |
| 112 if (element.name != element.getEnclosingClass().name) { | 112 if (element.name != const SourceString('')) { |
| 113 // Named constructor or factory. Is there a more reliable way to check | 113 // Named constructor or factory. Is there a more reliable way to check |
| 114 // this case? | 114 // this case? |
| 115 if (!placeholder.isRedirectingCall) { | 115 if (!placeholder.isRedirectingCall) { |
| 116 result.write(renameType(placeholder.type, renameElement)); | 116 result.write(renameType(placeholder.type, renameElement)); |
| 117 result.write('.'); | 117 result.write('.'); |
| 118 } | 118 } |
| 119 String prefix = '${element.getEnclosingClass().name.slowToString()}\$'; | |
| 120 if (!name.startsWith(prefix)) { | |
| 121 // Factory for another interface (that is going away soon). | |
| 122 compiler.internalErrorOnElement(element, | |
| 123 "Factory constructors for external interfaces are not supported."); | |
| 124 } | |
| 125 name = name.substring(prefix.length); | |
| 126 if (!element.getLibrary().isPlatformLibrary) { | 119 if (!element.getLibrary().isPlatformLibrary) { |
| 127 name = renameString(element.getLibrary(), name); | 120 name = renameString(element.getLibrary(), name); |
| 128 } | 121 } |
| 129 result.write(name); | 122 result.write(name); |
| 130 } else { | 123 } else { |
| 131 assert(!placeholder.isRedirectingCall); | 124 assert(!placeholder.isRedirectingCall); |
| 132 result.write(renameType(placeholder.type, renameElement)); | 125 result.write(renameType(placeholder.type, renameElement)); |
| 133 } | 126 } |
| 134 return result.toString(); | 127 return result.toString(); |
| 135 } | 128 } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 index ~/= firstCharAlphabet.length; | 347 index ~/= firstCharAlphabet.length; |
| 355 int length = otherCharsAlphabet.length; | 348 int length = otherCharsAlphabet.length; |
| 356 while (index >= length) { | 349 while (index >= length) { |
| 357 resultBuilder.write(otherCharsAlphabet[index % length]); | 350 resultBuilder.write(otherCharsAlphabet[index % length]); |
| 358 index ~/= length; | 351 index ~/= length; |
| 359 } | 352 } |
| 360 resultBuilder.write(otherCharsAlphabet[index]); | 353 resultBuilder.write(otherCharsAlphabet[index]); |
| 361 return resultBuilder.toString(); | 354 return resultBuilder.toString(); |
| 362 } | 355 } |
| 363 } | 356 } |
| OLD | NEW |