Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 typedef bool IsSafeToRemoveTypeDeclarations( | 7 typedef bool IsSafeToRemoveTypeDeclarations( |
| 8 Map<ClassElement, Iterable<Element>> classMembers); | 8 Map<ClassElement, Iterable<Element>> classMembers); |
| 9 typedef void ElementCallback<E>(E element); | 9 typedef void ElementCallback<E>(E element); |
| 10 typedef void ElementPostProcessFunction( | 10 typedef void ElementPostProcessFunction( |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 } | 280 } |
| 281 | 281 |
| 282 // Map to keep track of names of enum classes. Since these cannot be renamed | 282 // Map to keep track of names of enum classes. Since these cannot be renamed |
| 283 // we ensure that they are unique. | 283 // we ensure that they are unique. |
| 284 Map<String, ClassElement> enumClassMap = <String, ClassElement>{}; | 284 Map<String, ClassElement> enumClassMap = <String, ClassElement>{}; |
| 285 | 285 |
| 286 // As of now names of named optionals are not renamed. Therefore add all | 286 // As of now names of named optionals are not renamed. Therefore add all |
| 287 // field names used as named optionals into [fixedMemberNames]. | 287 // field names used as named optionals into [fixedMemberNames]. |
| 288 for (final element in resolvedElements) { | 288 for (final element in resolvedElements) { |
| 289 if (!element.isConstructor) continue; | 289 if (!element.isConstructor) continue; |
| 290 Link<Element> optionalParameters = | 290 for (ParameterElement parameter in element.parameters) { |
| 291 element.functionSignature.optionalParameters; | 291 if (parameter.isInitializingFormal && parameter.isNamed) { |
| 292 for (final optional in optionalParameters) { | 292 fixedDynamicNames.add(parameter.name); |
| 293 if (!optional.isInitializingFormal) continue; | 293 } |
| 294 fixedDynamicNames.add(optional.name); | |
| 295 } | 294 } |
| 296 ClassElement cls = element.enclosingClass; | 295 ClassElement cls = element.enclosingClass; |
| 297 if (cls != null && cls.isEnumClass) { | 296 if (cls != null && cls.isEnumClass) { |
| 298 fixedDynamicNames.add('index'); | 297 fixedDynamicNames.add('index'); |
| 299 | 298 |
| 300 ClassElement existingEnumClass = | 299 ClassElement existingEnumClass = |
| 301 enumClassMap.putIfAbsent(cls.name, () => cls); | 300 enumClassMap.putIfAbsent(cls.name, () => cls); |
| 302 if (existingEnumClass != cls) { | 301 if (existingEnumClass != cls) { |
| 303 listener.reportError(cls, MessageKind.GENERIC, | 302 listener.reportError(cls, MessageKind.GENERIC, |
| 304 {'text': "Duplicate enum names are not supported in dart2dart."}); | 303 {'text': "Duplicate enum names are not supported in dart2dart."}); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 | 427 |
| 429 void newClassElementCallback(ClassElement classElement) { | 428 void newClassElementCallback(ClassElement classElement) { |
| 430 if (!shouldOutput(classElement)) return; | 429 if (!shouldOutput(classElement)) return; |
| 431 addClass(classElement); | 430 addClass(classElement); |
| 432 } | 431 } |
| 433 | 432 |
| 434 void addMember(element) { | 433 void addMember(element) { |
| 435 if (element.isClassMember) { | 434 if (element.isClassMember) { |
| 436 ClassElement enclosingClass = element.enclosingClass; | 435 ClassElement enclosingClass = element.enclosingClass; |
| 437 assert(enclosingClass.isClass); | 436 assert(enclosingClass.isClass); |
| 438 assert(enclosingClass.isTopLevel); | |
|
Johnni Winther
2015/01/28 13:38:02
Redundant.
| |
| 439 assert(shouldOutput(enclosingClass)); | 437 assert(shouldOutput(enclosingClass)); |
| 440 addClass(enclosingClass); | 438 addClass(enclosingClass); |
| 441 classMembers[enclosingClass].add(element); | 439 classMembers[enclosingClass].add(element); |
| 442 if (enclosingClass.isEnumClass) return; | 440 if (enclosingClass.isEnumClass) return; |
| 443 processElement(element, parseElementAst(element)); | 441 processElement(element, parseElementAst(element)); |
| 444 } else { | 442 } else { |
| 445 if (element.isTopLevel) { | 443 if (element.isTopLevel) { |
| 446 addTopLevel(element, parseElementAst(element)); | 444 addTopLevel(element, parseElementAst(element)); |
| 447 } | 445 } |
| 448 } | 446 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 591 outputProvider("", "dart") | 589 outputProvider("", "dart") |
| 592 ..add(code) | 590 ..add(code) |
| 593 ..close(); | 591 ..close(); |
| 594 | 592 |
| 595 totalSize = code.length; | 593 totalSize = code.length; |
| 596 } | 594 } |
| 597 | 595 |
| 598 return totalSize; | 596 return totalSize; |
| 599 } | 597 } |
| 600 } | 598 } |
| OLD | NEW |