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

Side by Side Diff: pkg/analyzer/lib/src/dart/constant/evaluation.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
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 analyzer.src.dart.constant.evaluation; 5 library analyzer.src.dart.constant.evaluation;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/context/declared_variables.dart'; 9 import 'package:analyzer/context/declared_variables.dart';
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 * given, is used to verify correct dependency analysis when running unit 87 * given, is used to verify correct dependency analysis when running unit
88 * tests. 88 * tests.
89 */ 89 */
90 ConstantEvaluationEngine(TypeProvider typeProvider, this._declaredVariables, 90 ConstantEvaluationEngine(TypeProvider typeProvider, this._declaredVariables,
91 {ConstantEvaluationValidator validator, TypeSystem typeSystem}) 91 {ConstantEvaluationValidator validator, TypeSystem typeSystem})
92 : typeProvider = typeProvider, 92 : typeProvider = typeProvider,
93 strongMode = 93 strongMode =
94 typeProvider.objectType.element.context.analysisOptions.strongMode, 94 typeProvider.objectType.element.context.analysisOptions.strongMode,
95 validator = 95 validator =
96 validator ?? new ConstantEvaluationValidator_ForProduction(), 96 validator ?? new ConstantEvaluationValidator_ForProduction(),
97 typeSystem = typeSystem ?? new TypeSystemImpl(); 97 typeSystem = typeSystem ?? new TypeSystemImpl(typeProvider);
98 98
99 /** 99 /**
100 * Check that the arguments to a call to fromEnvironment() are correct. The 100 * Check that the arguments to a call to fromEnvironment() are correct. The
101 * [arguments] are the AST nodes of the arguments. The [argumentValues] are 101 * [arguments] are the AST nodes of the arguments. The [argumentValues] are
102 * the values of the unnamed arguments. The [namedArgumentValues] are the 102 * the values of the unnamed arguments. The [namedArgumentValues] are the
103 * values of the named arguments. The [expectedDefaultValueType] is the 103 * values of the named arguments. The [expectedDefaultValueType] is the
104 * allowed type of the "defaultValue" parameter (if present). Note: 104 * allowed type of the "defaultValue" parameter (if present). Note:
105 * "defaultValue" is always allowed to be null. Return `true` if the arguments 105 * "defaultValue" is always allowed to be null. Return `true` if the arguments
106 * are correct, `false` if there is an error. 106 * are correct, `false` if there is an error.
107 */ 107 */
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 return conditionResult; 1286 return conditionResult;
1287 } 1287 }
1288 if (conditionResult.toBoolValue() == true) { 1288 if (conditionResult.toBoolValue() == true) {
1289 return thenResult; 1289 return thenResult;
1290 } else if (conditionResult.toBoolValue() == false) { 1290 } else if (conditionResult.toBoolValue() == false) {
1291 return elseResult; 1291 return elseResult;
1292 } 1292 }
1293 ParameterizedType thenType = thenResult.type; 1293 ParameterizedType thenType = thenResult.type;
1294 ParameterizedType elseType = elseResult.type; 1294 ParameterizedType elseType = elseResult.type;
1295 return new DartObjectImpl.validWithUnknownValue( 1295 return new DartObjectImpl.validWithUnknownValue(
1296 _typeSystem.getLeastUpperBound(_typeProvider, thenType, elseType) 1296 _typeSystem.getLeastUpperBound(thenType, elseType) as InterfaceType);
1297 as InterfaceType);
1298 } 1297 }
1299 1298
1300 @override 1299 @override
1301 DartObjectImpl visitDoubleLiteral(DoubleLiteral node) => 1300 DartObjectImpl visitDoubleLiteral(DoubleLiteral node) =>
1302 new DartObjectImpl(_typeProvider.doubleType, new DoubleState(node.value)); 1301 new DartObjectImpl(_typeProvider.doubleType, new DoubleState(node.value));
1303 1302
1304 @override 1303 @override
1305 DartObjectImpl visitInstanceCreationExpression( 1304 DartObjectImpl visitInstanceCreationExpression(
1306 InstanceCreationExpression node) { 1305 InstanceCreationExpression node) {
1307 if (!node.isConst) { 1306 if (!node.isConst) {
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 } 2080 }
2082 2081
2083 @override 2082 @override
2084 String toString() { 2083 String toString() {
2085 if (value == null) { 2084 if (value == null) {
2086 return "error"; 2085 return "error";
2087 } 2086 }
2088 return value.toString(); 2087 return value.toString();
2089 } 2088 }
2090 } 2089 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_method.dart ('k') | pkg/analyzer/lib/src/dart/element/type.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698