| OLD | NEW |
| 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.generated.constant; | 5 library analyzer.src.generated.constant; |
| 6 | 6 |
| 7 import 'package:analyzer/context/declared_variables.dart'; | 7 import 'package:analyzer/context/declared_variables.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/src/dart/constant/evaluation.dart'; | 9 import 'package:analyzer/src/dart/constant/evaluation.dart'; |
| 10 import 'package:analyzer/src/dart/constant/value.dart'; | 10 import 'package:analyzer/src/dart/constant/value.dart'; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 * The type system primitives. | 113 * The type system primitives. |
| 114 */ | 114 */ |
| 115 final TypeSystem _typeSystem; | 115 final TypeSystem _typeSystem; |
| 116 | 116 |
| 117 /** | 117 /** |
| 118 * Initialize a newly created evaluator to evaluate expressions in the given | 118 * Initialize a newly created evaluator to evaluate expressions in the given |
| 119 * [source]. The [typeProvider] is the type provider used to access known | 119 * [source]. The [typeProvider] is the type provider used to access known |
| 120 * types. | 120 * types. |
| 121 */ | 121 */ |
| 122 ConstantEvaluator(this._source, this._typeProvider, {TypeSystem typeSystem}) | 122 ConstantEvaluator(this._source, this._typeProvider, {TypeSystem typeSystem}) |
| 123 : _typeSystem = typeSystem != null ? typeSystem : new TypeSystemImpl(); | 123 : _typeSystem = typeSystem ?? new TypeSystemImpl(); |
| 124 | 124 |
| 125 EvaluationResult evaluate(Expression expression) { | 125 EvaluationResult evaluate(Expression expression) { |
| 126 RecordingErrorListener errorListener = new RecordingErrorListener(); | 126 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 127 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); | 127 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); |
| 128 DartObjectImpl result = expression.accept(new ConstantVisitor( | 128 DartObjectImpl result = expression.accept(new ConstantVisitor( |
| 129 new ConstantEvaluationEngine(_typeProvider, new DeclaredVariables(), | 129 new ConstantEvaluationEngine(_typeProvider, new DeclaredVariables(), |
| 130 typeSystem: _typeSystem), | 130 typeSystem: _typeSystem), |
| 131 errorReporter)); | 131 errorReporter)); |
| 132 if (result != null) { | 132 if (result != null) { |
| 133 return EvaluationResult.forValue(result); | 133 return EvaluationResult.forValue(result); |
| 134 } | 134 } |
| 135 return EvaluationResult.forErrors(errorListener.errors); | 135 return EvaluationResult.forErrors(errorListener.errors); |
| 136 } | 136 } |
| 137 } | 137 } |
| OLD | NEW |