| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library kernel.analyzer.ast_from_analyzer; | 4 library kernel.analyzer.ast_from_analyzer; |
| 5 | 5 |
| 6 import '../ast.dart' as ast; | 6 import '../ast.dart' as ast; |
| 7 import '../frontend/accessors.dart'; | 7 import '../frontend/accessors.dart'; |
| 8 import '../frontend/super_initializers.dart'; | 8 import '../frontend/super_initializers.dart'; |
| 9 import '../log.dart'; | 9 import '../log.dart'; |
| 10 import '../type_algebra.dart'; | 10 import '../type_algebra.dart'; |
| (...skipping 2720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2731 | 2731 |
| 2732 visitConstructorDeclaration(ConstructorDeclaration node) { | 2732 visitConstructorDeclaration(ConstructorDeclaration node) { |
| 2733 if (node.factoryKeyword != null) { | 2733 if (node.factoryKeyword != null) { |
| 2734 buildFactoryConstructor(node); | 2734 buildFactoryConstructor(node); |
| 2735 } else { | 2735 } else { |
| 2736 buildGenerativeConstructor(node); | 2736 buildGenerativeConstructor(node); |
| 2737 } | 2737 } |
| 2738 } | 2738 } |
| 2739 | 2739 |
| 2740 void buildGenerativeConstructor(ConstructorDeclaration node) { | 2740 void buildGenerativeConstructor(ConstructorDeclaration node) { |
| 2741 if (currentMember is! ast.Constructor) { |
| 2742 buildBrokenMember(); |
| 2743 return; |
| 2744 } |
| 2741 addAnnotations(node.metadata); | 2745 addAnnotations(node.metadata); |
| 2742 ast.Constructor constructor = currentMember; | 2746 ast.Constructor constructor = currentMember; |
| 2743 constructor.function = scope.buildFunctionNode(node.parameters, node.body, | 2747 constructor.function = scope.buildFunctionNode(node.parameters, node.body, |
| 2744 inferredReturnType: const ast.VoidType())..parent = constructor; | 2748 inferredReturnType: const ast.VoidType())..parent = constructor; |
| 2745 handleNativeBody(node.body); | 2749 handleNativeBody(node.body); |
| 2746 if (node.body is EmptyFunctionBody && !constructor.isExternal) { | 2750 if (node.body is EmptyFunctionBody && !constructor.isExternal) { |
| 2747 var function = constructor.function; | 2751 var function = constructor.function; |
| 2748 function.body = new ast.EmptyStatement()..parent = function; | 2752 function.body = new ast.EmptyStatement()..parent = function; |
| 2749 } | 2753 } |
| 2750 for (var parameter in node.parameters.parameterElements) { | 2754 for (var parameter in node.parameters.parameterElements) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2783 ? new ast.InvalidInitializer() | 2787 ? new ast.InvalidInitializer() |
| 2784 : new ast.SuperInitializer( | 2788 : new ast.SuperInitializer( |
| 2785 target, new ast.Arguments(<ast.Expression>[])); | 2789 target, new ast.Arguments(<ast.Expression>[])); |
| 2786 constructor.initializers.add(initializer..parent = constructor); | 2790 constructor.initializers.add(initializer..parent = constructor); |
| 2787 } else { | 2791 } else { |
| 2788 moveSuperInitializerLast(constructor); | 2792 moveSuperInitializerLast(constructor); |
| 2789 } | 2793 } |
| 2790 } | 2794 } |
| 2791 | 2795 |
| 2792 void buildFactoryConstructor(ConstructorDeclaration node) { | 2796 void buildFactoryConstructor(ConstructorDeclaration node) { |
| 2797 if (currentMember is! ast.Procedure) { |
| 2798 buildBrokenMember(); |
| 2799 return; |
| 2800 } |
| 2793 addAnnotations(node.metadata); | 2801 addAnnotations(node.metadata); |
| 2794 ast.Procedure procedure = currentMember; | 2802 ast.Procedure procedure = currentMember; |
| 2795 ClassElement classElement = resolutionMap | 2803 ClassElement classElement = resolutionMap |
| 2796 .elementDeclaredByConstructorDeclaration(node) | 2804 .elementDeclaredByConstructorDeclaration(node) |
| 2797 .enclosingElement; | 2805 .enclosingElement; |
| 2798 ast.Class classNode = procedure.enclosingClass; | 2806 ast.Class classNode = procedure.enclosingClass; |
| 2799 var types = getFreshTypeParameters(classNode.typeParameters); | 2807 var types = getFreshTypeParameters(classNode.typeParameters); |
| 2800 for (int i = 0; i < classElement.typeParameters.length; ++i) { | 2808 for (int i = 0; i < classElement.typeParameters.length; ++i) { |
| 2801 scope.localTypeParameters[classElement.typeParameters[i]] = | 2809 scope.localTypeParameters[classElement.typeParameters[i]] = |
| 2802 types.freshTypeParameters[i]; | 2810 types.freshTypeParameters[i]; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2985 if (list[i - 1].compareTo(item) == 0) { | 2993 if (list[i - 1].compareTo(item) == 0) { |
| 2986 ++deleted; | 2994 ++deleted; |
| 2987 } else if (deleted > 0) { | 2995 } else if (deleted > 0) { |
| 2988 list[i - deleted] = item; | 2996 list[i - deleted] = item; |
| 2989 } | 2997 } |
| 2990 } | 2998 } |
| 2991 if (deleted > 0) { | 2999 if (deleted > 0) { |
| 2992 list.length -= deleted; | 3000 list.length -= deleted; |
| 2993 } | 3001 } |
| 2994 } | 3002 } |
| OLD | NEW |