OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library summary_resynthesizer; | 5 library summary_resynthesizer; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 currentConstructor.isCycleFree = serializedExecutable.isConst && | 1872 currentConstructor.isCycleFree = serializedExecutable.isConst && |
1873 !constCycles.contains(serializedExecutable.constCycleSlot); | 1873 !constCycles.contains(serializedExecutable.constCycleSlot); |
1874 if (serializedExecutable.name.isEmpty) { | 1874 if (serializedExecutable.name.isEmpty) { |
1875 currentConstructor.nameEnd = | 1875 currentConstructor.nameEnd = |
1876 serializedExecutable.nameOffset + classElement.name.length; | 1876 serializedExecutable.nameOffset + classElement.name.length; |
1877 } else { | 1877 } else { |
1878 currentConstructor.nameEnd = serializedExecutable.nameEnd; | 1878 currentConstructor.nameEnd = serializedExecutable.nameEnd; |
1879 currentConstructor.periodOffset = serializedExecutable.periodOffset; | 1879 currentConstructor.periodOffset = serializedExecutable.periodOffset; |
1880 } | 1880 } |
1881 constructors[serializedExecutable.name] = currentConstructor; | 1881 constructors[serializedExecutable.name] = currentConstructor; |
1882 currentConstructor.returnType = classElement.type; | |
1883 buildExecutableCommonParts(currentConstructor, serializedExecutable); | 1882 buildExecutableCommonParts(currentConstructor, serializedExecutable); |
1884 currentConstructor.constantInitializers = serializedExecutable | 1883 currentConstructor.constantInitializers = serializedExecutable |
1885 .constantInitializers | 1884 .constantInitializers |
1886 .map((i) => buildConstructorInitializer(currentConstructor, i)) | 1885 .map((i) => buildConstructorInitializer(currentConstructor, i)) |
1887 .toList(); | 1886 .toList(); |
1888 if (serializedExecutable.isRedirectedConstructor) { | 1887 if (serializedExecutable.isRedirectedConstructor) { |
1889 if (serializedExecutable.isFactory) { | 1888 if (serializedExecutable.isFactory) { |
1890 EntityRef redirectedConstructor = | 1889 EntityRef redirectedConstructor = |
1891 serializedExecutable.redirectedConstructor; | 1890 serializedExecutable.redirectedConstructor; |
1892 _ReferenceInfo info = getReferenceInfo(redirectedConstructor.reference); | 1891 _ReferenceInfo info = getReferenceInfo(redirectedConstructor.reference); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2100 if (length != 0) { | 2099 if (length != 0) { |
2101 List<ParameterElementImpl> parameters = | 2100 List<ParameterElementImpl> parameters = |
2102 new List<ParameterElementImpl>(length); | 2101 new List<ParameterElementImpl>(length); |
2103 for (int i = 0; i < length; i++) { | 2102 for (int i = 0; i < length; i++) { |
2104 parameters[i] = | 2103 parameters[i] = |
2105 buildParameter(unlinkedParameters[i], executableElement); | 2104 buildParameter(unlinkedParameters[i], executableElement); |
2106 } | 2105 } |
2107 executableElement.parameters = parameters; | 2106 executableElement.parameters = parameters; |
2108 } | 2107 } |
2109 } | 2108 } |
2110 if (serializedExecutable.kind == UnlinkedExecutableKind.constructor) { | |
2111 // Caller handles setting the return type. | |
2112 assert(serializedExecutable.returnType == null); | |
2113 } else { | |
2114 bool isSetter = | |
2115 serializedExecutable.kind == UnlinkedExecutableKind.setter; | |
2116 executableElement.returnType = buildLinkedType( | |
2117 serializedExecutable.inferredReturnTypeSlot, executableElement) ?? | |
2118 buildType(serializedExecutable.returnType, executableElement, | |
2119 defaultVoid: isSetter && summaryResynthesizer.strongMode); | |
2120 } | |
2121 executableElement.type = new FunctionTypeImpl.elementWithNameAndArgs( | 2109 executableElement.type = new FunctionTypeImpl.elementWithNameAndArgs( |
2122 executableElement, null, getCurrentTypeArguments(skipLevels: 1), false); | 2110 executableElement, null, getCurrentTypeArguments(skipLevels: 1), false); |
2123 { | 2111 { |
2124 List<UnlinkedExecutable> unlinkedFunctions = | 2112 List<UnlinkedExecutable> unlinkedFunctions = |
2125 serializedExecutable.localFunctions; | 2113 serializedExecutable.localFunctions; |
2126 int length = unlinkedFunctions.length; | 2114 int length = unlinkedFunctions.length; |
2127 if (length != 0) { | 2115 if (length != 0) { |
2128 List<FunctionElementImpl> localFunctions = | 2116 List<FunctionElementImpl> localFunctions = |
2129 new List<FunctionElementImpl>(length); | 2117 new List<FunctionElementImpl>(length); |
2130 for (int i = 0; i < length; i++) { | 2118 for (int i = 0; i < length; i++) { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2460 * [unitHolder]. | 2448 * [unitHolder]. |
2461 */ | 2449 */ |
2462 void buildTypedef(UnlinkedTypedef serializedTypedef) { | 2450 void buildTypedef(UnlinkedTypedef serializedTypedef) { |
2463 FunctionTypeAliasElementImpl functionTypeAliasElement = | 2451 FunctionTypeAliasElementImpl functionTypeAliasElement = |
2464 new FunctionTypeAliasElementImpl.forSerialized(serializedTypedef, unit); | 2452 new FunctionTypeAliasElementImpl.forSerialized(serializedTypedef, unit); |
2465 // TODO(scheglov) remove this after delaying parameters and their types | 2453 // TODO(scheglov) remove this after delaying parameters and their types |
2466 currentTypeParameters.add(functionTypeAliasElement.typeParameters); | 2454 currentTypeParameters.add(functionTypeAliasElement.typeParameters); |
2467 functionTypeAliasElement.parameters = serializedTypedef.parameters | 2455 functionTypeAliasElement.parameters = serializedTypedef.parameters |
2468 .map((p) => buildParameter(p, functionTypeAliasElement)) | 2456 .map((p) => buildParameter(p, functionTypeAliasElement)) |
2469 .toList(); | 2457 .toList(); |
2470 functionTypeAliasElement.returnType = | |
2471 buildType(serializedTypedef.returnType, functionTypeAliasElement); | |
2472 functionTypeAliasElement.type = | 2458 functionTypeAliasElement.type = |
2473 new FunctionTypeImpl.forTypedef(functionTypeAliasElement); | 2459 new FunctionTypeImpl.forTypedef(functionTypeAliasElement); |
2474 unitHolder.addTypeAlias(functionTypeAliasElement); | 2460 unitHolder.addTypeAlias(functionTypeAliasElement); |
2475 // TODO(scheglov) remove this after delaying parameters and their types | 2461 // TODO(scheglov) remove this after delaying parameters and their types |
2476 currentTypeParameters.removeLast(); | 2462 currentTypeParameters.removeLast(); |
2477 assert(currentTypeParameters.isEmpty); | 2463 assert(currentTypeParameters.isEmpty); |
2478 } | 2464 } |
2479 | 2465 |
2480 /** | 2466 /** |
2481 * Resynthesize a [TypeParameterElement], handling all parts of its except | 2467 * Resynthesize a [TypeParameterElement], handling all parts of its except |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 static String _getElementIdentifier(String name, ReferenceKind kind) { | 2912 static String _getElementIdentifier(String name, ReferenceKind kind) { |
2927 if (kind == ReferenceKind.topLevelPropertyAccessor || | 2913 if (kind == ReferenceKind.topLevelPropertyAccessor || |
2928 kind == ReferenceKind.propertyAccessor) { | 2914 kind == ReferenceKind.propertyAccessor) { |
2929 if (!name.endsWith('=')) { | 2915 if (!name.endsWith('=')) { |
2930 return name + '?'; | 2916 return name + '?'; |
2931 } | 2917 } |
2932 } | 2918 } |
2933 return name; | 2919 return name; |
2934 } | 2920 } |
2935 } | 2921 } |
OLD | NEW |