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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 /// | 310 /// |
311 /// This class implements a naming scheme by counting the distance from | 311 /// This class implements a naming scheme by counting the distance from |
312 /// a given constructor to [Object], where distance is the number of | 312 /// a given constructor to [Object], where distance is the number of |
313 /// constructors declared along the inheritance chain. | 313 /// constructors declared along the inheritance chain. |
314 class _ConstructorBodyNamingScope { | 314 class _ConstructorBodyNamingScope { |
315 final int _startIndex; | 315 final int _startIndex; |
316 final List _constructors; | 316 final List _constructors; |
317 | 317 |
318 int get numberOfConstructors => _constructors.length; | 318 int get numberOfConstructors => _constructors.length; |
319 | 319 |
320 _ConstructorBodyNamingScope _superScope; | |
321 | |
322 _ConstructorBodyNamingScope.rootScope(ClassElement cls) | 320 _ConstructorBodyNamingScope.rootScope(ClassElement cls) |
323 : _superScope = null, | 321 : _startIndex = 0, |
324 _startIndex = 0, | |
325 _constructors = cls.constructors.toList(growable: false); | 322 _constructors = cls.constructors.toList(growable: false); |
326 | 323 |
327 _ConstructorBodyNamingScope.forClass( | 324 _ConstructorBodyNamingScope.forClass( |
328 ClassElement cls, _ConstructorBodyNamingScope superScope) | 325 ClassElement cls, _ConstructorBodyNamingScope superScope) |
329 : _superScope = superScope, | 326 : _startIndex = superScope._startIndex + superScope.numberOfConstructors, |
330 _startIndex = superScope._startIndex + superScope.numberOfConstructors, | |
331 _constructors = cls.constructors.toList(growable: false); | 327 _constructors = cls.constructors.toList(growable: false); |
332 | 328 |
333 // Mixin Applications have constructors but we never generate code for them, | 329 // Mixin Applications have constructors but we never generate code for them, |
334 // so they do not count in the inheritance chain. | 330 // so they do not count in the inheritance chain. |
335 _ConstructorBodyNamingScope.forMixinApplication( | 331 _ConstructorBodyNamingScope.forMixinApplication( |
336 ClassElement cls, _ConstructorBodyNamingScope superScope) | 332 ClassElement cls, _ConstructorBodyNamingScope superScope) |
337 : _superScope = superScope, | 333 : _startIndex = superScope._startIndex + superScope.numberOfConstructors, |
338 _startIndex = superScope._startIndex + superScope.numberOfConstructors, | |
339 _constructors = const []; | 334 _constructors = const []; |
340 | 335 |
341 factory _ConstructorBodyNamingScope(ClassElement cls, | 336 factory _ConstructorBodyNamingScope(ClassElement cls, |
342 Map<ClassElement, _ConstructorBodyNamingScope> registry) { | 337 Map<ClassElement, _ConstructorBodyNamingScope> registry) { |
343 return registry.putIfAbsent(cls, () { | 338 return registry.putIfAbsent(cls, () { |
344 if (cls.superclass == null) { | 339 if (cls.superclass == null) { |
345 return new _ConstructorBodyNamingScope.rootScope(cls); | 340 return new _ConstructorBodyNamingScope.rootScope(cls); |
346 } else if (cls.isMixinApplication) { | 341 } else if (cls.isMixinApplication) { |
347 return new _ConstructorBodyNamingScope.forMixinApplication( | 342 return new _ConstructorBodyNamingScope.forMixinApplication( |
348 cls, new _ConstructorBodyNamingScope(cls.superclass, registry)); | 343 cls, new _ConstructorBodyNamingScope(cls.superclass, registry)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 String prefix = | 381 String prefix = |
387 selector.isGetter ? r"$get" : selector.isSetter ? r"$set" : ""; | 382 selector.isGetter ? r"$get" : selector.isSetter ? r"$set" : ""; |
388 String callSuffix = selector.isCall | 383 String callSuffix = selector.isCall |
389 ? callSuffixForStructure(selector.callStructure).join() | 384 ? callSuffixForStructure(selector.callStructure).join() |
390 : ""; | 385 : ""; |
391 String suffix = suffixForGetInterceptor(classes); | 386 String suffix = suffixForGetInterceptor(classes); |
392 String fullName = "\$intercepted$prefix\$$root$callSuffix\$$suffix"; | 387 String fullName = "\$intercepted$prefix\$$root$callSuffix\$$suffix"; |
393 return _disambiguateInternalGlobal(fullName); | 388 return _disambiguateInternalGlobal(fullName); |
394 } | 389 } |
395 } | 390 } |
OLD | NEW |