| 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 part of js_backend.namer; | 5 part of js_backend.namer; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Assigns JavaScript identifiers to Dart variables, class-names and members. | 8 * Assigns JavaScript identifiers to Dart variables, class-names and members. |
| 9 */ | 9 */ |
| 10 class MinifyNamer extends Namer | 10 class MinifyNamer extends Namer |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } else if (cls.isMixinApplication) { | 343 } else if (cls.isMixinApplication) { |
| 344 return new _ConstructorBodyNamingScope.forMixinApplication( | 344 return new _ConstructorBodyNamingScope.forMixinApplication( |
| 345 cls, new _ConstructorBodyNamingScope(cls.superclass, registry)); | 345 cls, new _ConstructorBodyNamingScope(cls.superclass, registry)); |
| 346 } else { | 346 } else { |
| 347 return new _ConstructorBodyNamingScope.forClass( | 347 return new _ConstructorBodyNamingScope.forClass( |
| 348 cls, new _ConstructorBodyNamingScope(cls.superclass, registry)); | 348 cls, new _ConstructorBodyNamingScope(cls.superclass, registry)); |
| 349 } | 349 } |
| 350 }); | 350 }); |
| 351 } | 351 } |
| 352 | 352 |
| 353 String constructorBodyKeyFor(ConstructorBodyElement body) { | 353 String constructorBodyKeyFor(ConstructorBodyEntity body) { |
| 354 int position = _constructors.indexOf(body.constructor); | 354 int position = _constructors.indexOf(body.constructor); |
| 355 assert(position >= 0, failedAt(body, "constructor body missing")); | 355 assert(position >= 0, failedAt(body, "constructor body missing")); |
| 356 return "@constructorBody@${_startIndex + position}"; | 356 return "@constructorBody@${_startIndex + position}"; |
| 357 } | 357 } |
| 358 } | 358 } |
| 359 | 359 |
| 360 abstract class _MinifyConstructorBodyNamer implements Namer { | 360 abstract class _MinifyConstructorBodyNamer implements Namer { |
| 361 Map<ClassElement, _ConstructorBodyNamingScope> _constructorBodyScopes = | 361 Map<ClassElement, _ConstructorBodyNamingScope> _constructorBodyScopes = |
| 362 new Map<ClassElement, _ConstructorBodyNamingScope>(); | 362 new Map<ClassElement, _ConstructorBodyNamingScope>(); |
| 363 | 363 |
| 364 @override | 364 @override |
| 365 jsAst.Name constructorBodyName(FunctionElement method) { | 365 jsAst.Name constructorBodyName(ConstructorBodyEntity method) { |
| 366 _ConstructorBodyNamingScope scope = new _ConstructorBodyNamingScope( | 366 _ConstructorBodyNamingScope scope = new _ConstructorBodyNamingScope( |
| 367 method.enclosingClass, _constructorBodyScopes); | 367 method.enclosingClass, _constructorBodyScopes); |
| 368 String key = scope.constructorBodyKeyFor(method); | 368 String key = scope.constructorBodyKeyFor(method); |
| 369 return _disambiguateMemberByKey( | 369 return _disambiguateMemberByKey( |
| 370 key, () => _proposeNameForConstructorBody(method)); | 370 key, () => _proposeNameForConstructorBody(method)); |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 | 373 |
| 374 abstract class _MinifiedOneShotInterceptorNamer implements Namer { | 374 abstract class _MinifiedOneShotInterceptorNamer implements Namer { |
| 375 /// Property name used for the one-shot interceptor method for the given | 375 /// Property name used for the one-shot interceptor method for the given |
| 376 /// [selector] and return-type specialization. | 376 /// [selector] and return-type specialization. |
| 377 @override | 377 @override |
| 378 jsAst.Name nameForGetOneShotInterceptor( | 378 jsAst.Name nameForGetOneShotInterceptor( |
| 379 Selector selector, Iterable<ClassEntity> classes) { | 379 Selector selector, Iterable<ClassEntity> classes) { |
| 380 String root = selector.isOperator | 380 String root = selector.isOperator |
| 381 ? operatorNameToIdentifier(selector.name) | 381 ? operatorNameToIdentifier(selector.name) |
| 382 : privateName(selector.memberName); | 382 : privateName(selector.memberName); |
| 383 String prefix = | 383 String prefix = |
| 384 selector.isGetter ? r"$get" : selector.isSetter ? r"$set" : ""; | 384 selector.isGetter ? r"$get" : selector.isSetter ? r"$set" : ""; |
| 385 String callSuffix = selector.isCall | 385 String callSuffix = selector.isCall |
| 386 ? callSuffixForStructure(selector.callStructure).join() | 386 ? callSuffixForStructure(selector.callStructure).join() |
| 387 : ""; | 387 : ""; |
| 388 String suffix = suffixForGetInterceptor(classes); | 388 String suffix = suffixForGetInterceptor(classes); |
| 389 String fullName = "\$intercepted$prefix\$$root$callSuffix\$$suffix"; | 389 String fullName = "\$intercepted$prefix\$$root$callSuffix\$$suffix"; |
| 390 return _disambiguateInternalGlobal(fullName); | 390 return _disambiguateInternalGlobal(fullName); |
| 391 } | 391 } |
| 392 } | 392 } |
| OLD | NEW |