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

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

Issue 2590883004: Put a TypeProvider on the TypeSystem implementations. (Closed)
Patch Set: Rebase Created 3 years, 11 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | pkg/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2538 matching lines...) Expand 10 before | Expand all | Expand 10 after
2549 Map<String, DartType> namedParameterTypes = 2549 Map<String, DartType> namedParameterTypes =
2550 rawMethodType.namedParameterTypes; 2550 rawMethodType.namedParameterTypes;
2551 namedArgTypes.forEach((String name, DartType argType) { 2551 namedArgTypes.forEach((String name, DartType argType) {
2552 DartType parameterType = namedParameterTypes[name]; 2552 DartType parameterType = namedParameterTypes[name];
2553 if (parameterType != null) { 2553 if (parameterType != null) {
2554 paramTypes.add(parameterType); 2554 paramTypes.add(parameterType);
2555 argTypes.add(argType); 2555 argTypes.add(argType);
2556 } 2556 }
2557 }); 2557 });
2558 // Perform inference. 2558 // Perform inference.
2559 FunctionType inferred = ts.inferGenericFunctionCall( 2559 FunctionType inferred = ts.inferGenericFunctionCall(rawMethodType,
2560 typeProvider, 2560 paramTypes, argTypes, rawMethodType.returnType, null);
2561 rawMethodType,
2562 paramTypes,
2563 argTypes,
2564 rawMethodType.returnType,
2565 null);
2566 return inferred; 2561 return inferred;
2567 } 2562 }
2568 } 2563 }
2569 // Not a generic function type, use the raw type. 2564 // Not a generic function type, use the raw type.
2570 return rawMethodType; 2565 return rawMethodType;
2571 } 2566 }
2572 2567
2573 DartType _leastUpperBound(DartType s, DartType t) { 2568 DartType _leastUpperBound(DartType s, DartType t) {
2574 return linker.typeSystem.getLeastUpperBound(typeProvider, s, t); 2569 return linker.typeSystem.getLeastUpperBound(s, t);
2575 } 2570 }
2576 2571
2577 List<DartType> _popList(int n) { 2572 List<DartType> _popList(int n) {
2578 List<DartType> result = stack.sublist(stack.length - n, stack.length); 2573 List<DartType> result = stack.sublist(stack.length - n, stack.length);
2579 stack.length -= n; 2574 stack.length -= n;
2580 return result; 2575 return result;
2581 } 2576 }
2582 2577
2583 void _pushBinaryOperatorType( 2578 void _pushBinaryOperatorType(
2584 DartType left, TokenType operator, DartType right) { 2579 DartType left, TokenType operator, DartType right) {
2585 if (left is InterfaceType) { 2580 if (left is InterfaceType) {
2586 MethodElement method = 2581 MethodElement method =
2587 left.lookUpInheritedMethod(operator.lexeme, library: library); 2582 left.lookUpInheritedMethod(operator.lexeme, library: library);
2588 if (method != null) { 2583 if (method != null) {
2589 DartType type = method.returnType; 2584 DartType type = method.returnType;
2590 type = linker.typeSystem.refineBinaryExpressionType( 2585 type = linker.typeSystem
2591 typeProvider, left, operator, right, type); 2586 .refineBinaryExpressionType(left, operator, right, type);
2592 stack.add(type); 2587 stack.add(type);
2593 return; 2588 return;
2594 } 2589 }
2595 } 2590 }
2596 stack.add(DynamicTypeImpl.instance); 2591 stack.add(DynamicTypeImpl.instance);
2597 } 2592 }
2598 2593
2599 /** 2594 /**
2600 * Extract the property with the given [propertyName], apply the operator 2595 * Extract the property with the given [propertyName], apply the operator
2601 * with the given [operandType], push the type of applying operand of the 2596 * with the given [operandType], push the type of applying operand of the
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
3647 3642
3648 /** 3643 /**
3649 * Get an instance of [TypeProvider] for use during linking. 3644 * Get an instance of [TypeProvider] for use during linking.
3650 */ 3645 */
3651 TypeProviderForLink get typeProvider => 3646 TypeProviderForLink get typeProvider =>
3652 _typeProvider ??= new TypeProviderForLink(this); 3647 _typeProvider ??= new TypeProviderForLink(this);
3653 3648
3654 /** 3649 /**
3655 * Get an instance of [TypeSystem] for use during linking. 3650 * Get an instance of [TypeSystem] for use during linking.
3656 */ 3651 */
3657 TypeSystem get typeSystem => _typeSystem ??= 3652 TypeSystem get typeSystem => _typeSystem ??= strongMode
3658 strongMode ? new StrongTypeSystemImpl() : new TypeSystemImpl(); 3653 ? new StrongTypeSystemImpl(typeProvider)
3654 : new TypeSystemImpl(typeProvider);
3659 3655
3660 /** 3656 /**
3661 * Get the element representing `void`. 3657 * Get the element representing `void`.
3662 */ 3658 */
3663 SpecialTypeElementForLink get voidElement => _voidElement ??= 3659 SpecialTypeElementForLink get voidElement => _voidElement ??=
3664 new SpecialTypeElementForLink(this, VoidTypeImpl.instance); 3660 new SpecialTypeElementForLink(this, VoidTypeImpl.instance);
3665 3661
3666 /** 3662 /**
3667 * Get the library element for the library having the given [uri]. 3663 * Get the library element for the library having the given [uri].
3668 */ 3664 */
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after
4953 * there are no type parameters in scope. 4949 * there are no type parameters in scope.
4954 */ 4950 */
4955 TypeParameterizedElementMixin get _typeParameterContext; 4951 TypeParameterizedElementMixin get _typeParameterContext;
4956 4952
4957 @override 4953 @override
4958 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 4954 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
4959 4955
4960 @override 4956 @override
4961 String toString() => '$enclosingElement.$name'; 4957 String toString() => '$enclosingElement.$name';
4962 } 4958 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/type_system.dart ('k') | pkg/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698