| 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 | 4 |
| 5 /** | 5 /** |
| 6 * This library is capable of producing linked summaries from unlinked | 6 * This library is capable of producing linked summaries from unlinked |
| 7 * ones (or prelinked ones). It functions by building a miniature | 7 * ones (or prelinked ones). It functions by building a miniature |
| 8 * element model to represent the contents of the summaries, and then | 8 * element model to represent the contents of the summaries, and then |
| 9 * scanning the element model to gather linked information and adding | 9 * scanning the element model to gather linked information and adding |
| 10 * it to the summary data structures. | 10 * it to the summary data structures. |
| (...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2855 _functions ??= _variable.unlinkedVariable.initializer.localFunctions | 2855 _functions ??= _variable.unlinkedVariable.initializer.localFunctions |
| 2856 .map((UnlinkedExecutable ex) => | 2856 .map((UnlinkedExecutable ex) => |
| 2857 new FunctionElementForLink_Local_NonSynthetic( | 2857 new FunctionElementForLink_Local_NonSynthetic( |
| 2858 _variable.compilationUnit, this, ex)) | 2858 _variable.compilationUnit, this, ex)) |
| 2859 .toList(); | 2859 .toList(); |
| 2860 | 2860 |
| 2861 @override | 2861 @override |
| 2862 String get identifier => ''; | 2862 String get identifier => ''; |
| 2863 | 2863 |
| 2864 @override | 2864 @override |
| 2865 bool get isAsynchronous => _unlinkedExecutable.isAsynchronous; |
| 2866 |
| 2867 @override |
| 2865 DartType get returnType { | 2868 DartType get returnType { |
| 2866 // If this is a variable whose type needs inferring, infer it. | 2869 // If this is a variable whose type needs inferring, infer it. |
| 2867 if (_variable.hasImplicitType) { | 2870 if (_variable.hasImplicitType) { |
| 2868 return _variable.inferredType; | 2871 return _variable.inferredType; |
| 2869 } else { | 2872 } else { |
| 2870 // There's no reason linking should need to access the type of | 2873 // There's no reason linking should need to access the type of |
| 2871 // this FunctionElement, since the variable doesn't need its | 2874 // this FunctionElement, since the variable doesn't need its |
| 2872 // type inferred. | 2875 // type inferred. |
| 2873 assert(false); | 2876 assert(false); |
| 2874 // But for robustness, return the dynamic type. | 2877 // But for robustness, return the dynamic type. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2990 Element enclosing = this.enclosingElement; | 2993 Element enclosing = this.enclosingElement; |
| 2991 if (enclosing is ExecutableElement) { | 2994 if (enclosing is ExecutableElement) { |
| 2992 int id = | 2995 int id = |
| 2993 ElementImpl.findElementIndexUsingIdentical(enclosing.functions, this); | 2996 ElementImpl.findElementIndexUsingIdentical(enclosing.functions, this); |
| 2994 identifier += "@$id"; | 2997 identifier += "@$id"; |
| 2995 } | 2998 } |
| 2996 return identifier; | 2999 return identifier; |
| 2997 } | 3000 } |
| 2998 | 3001 |
| 2999 @override | 3002 @override |
| 3003 bool get isAsynchronous => _unlinkedExecutable.isAsynchronous; |
| 3004 |
| 3005 @override |
| 3000 bool get _hasTypeBeenInferred => _inferredReturnType != null; | 3006 bool get _hasTypeBeenInferred => _inferredReturnType != null; |
| 3001 | 3007 |
| 3002 @override | 3008 @override |
| 3003 DartType buildType( | 3009 DartType buildType( |
| 3004 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { | 3010 DartType getTypeArgument(int i), List<int> implicitFunctionTypeIndices) { |
| 3005 assert(implicitFunctionTypeIndices.isEmpty); | 3011 assert(implicitFunctionTypeIndices.isEmpty); |
| 3006 return type; | 3012 return type; |
| 3007 } | 3013 } |
| 3008 | 3014 |
| 3009 @override | 3015 @override |
| (...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4642 List<TypeInferenceNode> dependencies = <TypeInferenceNode>[]; | 4648 List<TypeInferenceNode> dependencies = <TypeInferenceNode>[]; |
| 4643 collectDependencies(dependencies, functionElement._unlinkedExecutable, | 4649 collectDependencies(dependencies, functionElement._unlinkedExecutable, |
| 4644 functionElement.compilationUnit); | 4650 functionElement.compilationUnit); |
| 4645 return dependencies; | 4651 return dependencies; |
| 4646 } | 4652 } |
| 4647 | 4653 |
| 4648 void evaluate(bool inCycle) { | 4654 void evaluate(bool inCycle) { |
| 4649 if (inCycle) { | 4655 if (inCycle) { |
| 4650 functionElement._setInferredType(DynamicTypeImpl.instance); | 4656 functionElement._setInferredType(DynamicTypeImpl.instance); |
| 4651 } else { | 4657 } else { |
| 4652 functionElement | 4658 var bodyType = new ExprTypeComputer(functionElement).compute(); |
| 4653 ._setInferredType(new ExprTypeComputer(functionElement).compute()); | 4659 if (functionElement.isAsynchronous) { |
| 4660 var linker = functionElement.compilationUnit.library._linker; |
| 4661 var typeProvider = linker.typeProvider; |
| 4662 var typeSystem = linker.typeSystem; |
| 4663 bodyType = typeProvider.futureType |
| 4664 .instantiate([bodyType.flattenFutures(typeSystem)]); |
| 4665 } |
| 4666 functionElement._setInferredType(bodyType); |
| 4654 } | 4667 } |
| 4655 } | 4668 } |
| 4656 | 4669 |
| 4657 @override | 4670 @override |
| 4658 String toString() => 'TypeInferenceNode($functionElement)'; | 4671 String toString() => 'TypeInferenceNode($functionElement)'; |
| 4659 } | 4672 } |
| 4660 | 4673 |
| 4661 class TypeProviderForLink extends TypeProviderBase { | 4674 class TypeProviderForLink extends TypeProviderBase { |
| 4662 final Linker _linker; | 4675 final Linker _linker; |
| 4663 | 4676 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4970 * there are no type parameters in scope. | 4983 * there are no type parameters in scope. |
| 4971 */ | 4984 */ |
| 4972 TypeParameterizedElementMixin get _typeParameterContext; | 4985 TypeParameterizedElementMixin get _typeParameterContext; |
| 4973 | 4986 |
| 4974 @override | 4987 @override |
| 4975 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 4988 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 4976 | 4989 |
| 4977 @override | 4990 @override |
| 4978 String toString() => '$enclosingElement.$name'; | 4991 String toString() => '$enclosingElement.$name'; |
| 4979 } | 4992 } |
| OLD | NEW |