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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1507933002: Refactor strong mode to remove duplicate TypeRules (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | « no previous file | pkg/analyzer/lib/src/generated/type_system.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 engine.resolver; 5 library engine.resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import '../task/strong/info.dart' show InferredType, StaticInfo; 9 import '../task/strong/info.dart' show InferredType, StaticInfo;
10 import '../task/strong/rules.dart' show TypeRules;
11 import 'ast.dart'; 10 import 'ast.dart';
12 import 'constant.dart'; 11 import 'constant.dart';
13 import 'element.dart'; 12 import 'element.dart';
14 import 'element_resolver.dart'; 13 import 'element_resolver.dart';
15 import 'engine.dart'; 14 import 'engine.dart';
16 import 'error.dart'; 15 import 'error.dart';
17 import 'error_verifier.dart'; 16 import 'error_verifier.dart';
18 import 'html.dart' as ht; 17 import 'html.dart' as ht;
19 import 'java_core.dart'; 18 import 'java_core.dart';
20 import 'java_engine.dart'; 19 import 'java_engine.dart';
(...skipping 5764 matching lines...) Expand 10 before | Expand all | Expand 10 after
5785 * Type provider, needed for type matching. 5784 * Type provider, needed for type matching.
5786 */ 5785 */
5787 final TypeProvider _typeProvider; 5786 final TypeProvider _typeProvider;
5788 5787
5789 /** 5788 /**
5790 * The type system in use. 5789 * The type system in use.
5791 */ 5790 */
5792 final TypeSystem _typeSystem; 5791 final TypeSystem _typeSystem;
5793 5792
5794 /** 5793 /**
5795 * The DDC type rules, used to create the inference info nodes.
5796 */
5797 final TypeRules _rules;
5798
5799 /**
5800 * A stack of return types for all of the enclosing 5794 * A stack of return types for all of the enclosing
5801 * functions and methods. 5795 * functions and methods.
5802 */ 5796 */
5803 List<DartType> _returnStack = <DartType>[]; 5797 List<DartType> _returnStack = <DartType>[];
5804 5798
5805 InferenceContext._(this._errorListener, TypeProvider typeProvider, 5799 InferenceContext._(this._errorListener, TypeProvider typeProvider,
5806 this._typeSystem, this._inferenceHints) 5800 this._typeSystem, this._inferenceHints)
5807 : _typeProvider = typeProvider, 5801 : _typeProvider = typeProvider;
5808 _rules = new TypeRules(typeProvider);
5809 5802
5810 /** 5803 /**
5811 * Get the return type of the current enclosing function, if any. 5804 * Get the return type of the current enclosing function, if any.
5812 */ 5805 */
5813 DartType get returnContext => 5806 DartType get returnContext =>
5814 (_returnStack.isNotEmpty) ? _returnStack.last : null; 5807 (_returnStack.isNotEmpty) ? _returnStack.last : null;
5815 5808
5816 /** 5809 /**
5817 * Match type [t1] against type [t2] as follows. 5810 * Match type [t1] against type [t2] as follows.
5818 * If `t1 = I<dynamic, ..., dynamic>`, then look for a supertype 5811 * If `t1 = I<dynamic, ..., dynamic>`, then look for a supertype
(...skipping 20 matching lines...) Expand all
5839 */ 5832 */
5840 void pushReturnContext(DartType returnType) { 5833 void pushReturnContext(DartType returnType) {
5841 _returnStack.add(returnType); 5834 _returnStack.add(returnType);
5842 } 5835 }
5843 5836
5844 /** 5837 /**
5845 * Place an info node into the error stream indicating that a 5838 * Place an info node into the error stream indicating that a
5846 * [type] has been inferred as the type of [node]. 5839 * [type] has been inferred as the type of [node].
5847 */ 5840 */
5848 void recordInference(Expression node, DartType type) { 5841 void recordInference(Expression node, DartType type) {
5849 StaticInfo info = InferredType.create(_rules, node, type); 5842 StaticInfo info = InferredType.create(_typeSystem, node, type);
5850 if (!_inferenceHints || info == null) { 5843 if (!_inferenceHints || info == null) {
5851 return; 5844 return;
5852 } 5845 }
5853 AnalysisError error = info.toAnalysisError(); 5846 AnalysisError error = info.toAnalysisError();
5854 _errorListener.onError(error); 5847 _errorListener.onError(error);
5855 } 5848 }
5856 5849
5857 List<DartType> _matchTypes(InterfaceType t1, InterfaceType t2) { 5850 List<DartType> _matchTypes(InterfaceType t1, InterfaceType t2) {
5858 if (t1 == t2) { 5851 if (t1 == t2) {
5859 return t2.typeArguments; 5852 return t2.typeArguments;
(...skipping 10211 matching lines...) Expand 10 before | Expand all | Expand 10 after
16071 nonFields.add(node); 16064 nonFields.add(node);
16072 return null; 16065 return null;
16073 } 16066 }
16074 16067
16075 @override 16068 @override
16076 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 16069 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
16077 16070
16078 @override 16071 @override
16079 Object visitWithClause(WithClause node) => null; 16072 Object visitWithClause(WithClause node) => null;
16080 } 16073 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698