Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 2010143002: Resynthesize some more types lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 new ClassElementImpl.forSerialized(serializedClass, unit); 1805 new ClassElementImpl.forSerialized(serializedClass, unit);
1806 classElement.hasBeenInferred = summaryResynthesizer.strongMode; 1806 classElement.hasBeenInferred = summaryResynthesizer.strongMode;
1807 InterfaceTypeImpl correspondingType = 1807 InterfaceTypeImpl correspondingType =
1808 new InterfaceTypeImpl(handle ?? classElement); 1808 new InterfaceTypeImpl(handle ?? classElement);
1809 if (serializedClass.supertype != null) { 1809 if (serializedClass.supertype != null) {
1810 classElement.supertype = 1810 classElement.supertype =
1811 buildType(serializedClass.supertype, classElement); 1811 buildType(serializedClass.supertype, classElement);
1812 } else if (!libraryResynthesizer.isCoreLibrary) { 1812 } else if (!libraryResynthesizer.isCoreLibrary) {
1813 classElement.supertype = typeProvider.objectType; 1813 classElement.supertype = typeProvider.objectType;
1814 } 1814 }
1815 classElement.interfaces = serializedClass.interfaces
1816 .map((EntityRef t) => buildType(t, classElement))
1817 .toList();
1818 classElement.mixins = serializedClass.mixins
1819 .map((EntityRef t) => buildType(t, classElement))
1820 .toList();
1821 // TODO(scheglov) move to ClassElementImpl 1815 // TODO(scheglov) move to ClassElementImpl
1822 correspondingType.typeArguments = classElement.typeParameterTypes; 1816 correspondingType.typeArguments = classElement.typeParameterTypes;
1823 classElement.type = correspondingType; 1817 classElement.type = correspondingType;
1824 assert(currentTypeParameters.isEmpty); 1818 assert(currentTypeParameters.isEmpty);
1825 // TODO(scheglov) Somehow Observatory shows too much time spent here 1819 // TODO(scheglov) Somehow Observatory shows too much time spent here
1826 // during DDC run on the large codebase. I would expect only Object here. 1820 // during DDC run on the large codebase. I would expect only Object here.
1827 if (handle == null) { 1821 if (handle == null) {
1828 buildClassExecutables(classElement, serializedClass); 1822 buildClassExecutables(classElement, serializedClass);
1829 } 1823 }
1830 fields = null; 1824 fields = null;
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
2437 * [unitHolder]. 2431 * [unitHolder].
2438 */ 2432 */
2439 void buildTypedef(UnlinkedTypedef serializedTypedef) { 2433 void buildTypedef(UnlinkedTypedef serializedTypedef) {
2440 FunctionTypeAliasElementImpl functionTypeAliasElement = 2434 FunctionTypeAliasElementImpl functionTypeAliasElement =
2441 new FunctionTypeAliasElementImpl.forSerialized(serializedTypedef, unit); 2435 new FunctionTypeAliasElementImpl.forSerialized(serializedTypedef, unit);
2442 // TODO(scheglov) remove this after delaying parameters and their types 2436 // TODO(scheglov) remove this after delaying parameters and their types
2443 currentTypeParameters.add(functionTypeAliasElement.typeParameters); 2437 currentTypeParameters.add(functionTypeAliasElement.typeParameters);
2444 functionTypeAliasElement.parameters = serializedTypedef.parameters 2438 functionTypeAliasElement.parameters = serializedTypedef.parameters
2445 .map((p) => buildParameter(p, functionTypeAliasElement)) 2439 .map((p) => buildParameter(p, functionTypeAliasElement))
2446 .toList(); 2440 .toList();
2447 functionTypeAliasElement.type =
2448 new FunctionTypeImpl.forTypedef(functionTypeAliasElement);
2449 unitHolder.addTypeAlias(functionTypeAliasElement); 2441 unitHolder.addTypeAlias(functionTypeAliasElement);
2450 // TODO(scheglov) remove this after delaying parameters and their types 2442 // TODO(scheglov) remove this after delaying parameters and their types
2451 currentTypeParameters.removeLast(); 2443 currentTypeParameters.removeLast();
2452 assert(currentTypeParameters.isEmpty); 2444 assert(currentTypeParameters.isEmpty);
2453 } 2445 }
2454 2446
2455 /** 2447 /**
2456 * Resynthesize a [TypeParameterElement], handling all parts of its except 2448 * Resynthesize a [TypeParameterElement], handling all parts of its except
2457 * its bound. 2449 * its bound.
2458 * 2450 *
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2607 buildImplicitAccessors(element, holder); 2599 buildImplicitAccessors(element, holder);
2608 fields[element.name] = element; 2600 fields[element.name] = element;
2609 } 2601 }
2610 } 2602 }
2611 2603
2612 /** 2604 /**
2613 * Handle the parts that are common to variables. 2605 * Handle the parts that are common to variables.
2614 */ 2606 */
2615 void buildVariableCommonParts( 2607 void buildVariableCommonParts(
2616 VariableElementImpl element, UnlinkedVariable serializedVariable) { 2608 VariableElementImpl element, UnlinkedVariable serializedVariable) {
2617 element.type = buildLinkedType(serializedVariable.inferredTypeSlot,
2618 element.typeParameterContext) ??
2619 buildType(serializedVariable.type, element.typeParameterContext);
2620 buildVariableInitializer(element, serializedVariable.initializer); 2609 buildVariableInitializer(element, serializedVariable.initializer);
2621 } 2610 }
2622 2611
2623 /** 2612 /**
2624 * If the given [serializedInitializer] is not `null`, create the 2613 * If the given [serializedInitializer] is not `null`, create the
2625 * corresponding [FunctionElementImpl] and set it for the [variable]. 2614 * corresponding [FunctionElementImpl] and set it for the [variable].
2626 */ 2615 */
2627 void buildVariableInitializer( 2616 void buildVariableInitializer(
2628 VariableElementImpl variable, UnlinkedExecutable serializedInitializer) { 2617 VariableElementImpl variable, UnlinkedExecutable serializedInitializer) {
2629 if (serializedInitializer == null) { 2618 if (serializedInitializer == null) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2901 static String _getElementIdentifier(String name, ReferenceKind kind) { 2890 static String _getElementIdentifier(String name, ReferenceKind kind) {
2902 if (kind == ReferenceKind.topLevelPropertyAccessor || 2891 if (kind == ReferenceKind.topLevelPropertyAccessor ||
2903 kind == ReferenceKind.propertyAccessor) { 2892 kind == ReferenceKind.propertyAccessor) {
2904 if (!name.endsWith('=')) { 2893 if (!name.endsWith('=')) {
2905 return name + '?'; 2894 return name + '?';
2906 } 2895 }
2907 } 2896 }
2908 return name; 2897 return name;
2909 } 2898 }
2910 } 2899 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698