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.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 11 matching lines...) Expand all Loading... |
22 import 'package:analyzer/src/error/codes.dart'; | 22 import 'package:analyzer/src/error/codes.dart'; |
23 import 'package:analyzer/src/generated/engine.dart'; | 23 import 'package:analyzer/src/generated/engine.dart'; |
24 import 'package:analyzer/src/generated/engine.dart' | 24 import 'package:analyzer/src/generated/engine.dart' |
25 show AnalysisEngine, RecordingErrorListener; | 25 show AnalysisEngine, RecordingErrorListener; |
26 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; | 26 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; |
27 import 'package:analyzer/src/generated/type_system.dart' | 27 import 'package:analyzer/src/generated/type_system.dart' |
28 show TypeSystem, TypeSystemImpl; | 28 show TypeSystem, TypeSystemImpl; |
29 import 'package:analyzer/src/generated/utilities_collection.dart'; | 29 import 'package:analyzer/src/generated/utilities_collection.dart'; |
30 import 'package:analyzer/src/generated/utilities_dart.dart' show ParameterKind; | 30 import 'package:analyzer/src/generated/utilities_dart.dart' show ParameterKind; |
31 import 'package:analyzer/src/task/dart.dart'; | 31 import 'package:analyzer/src/task/dart.dart'; |
| 32 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
32 | 33 |
33 /** | 34 /** |
34 * Helper class encapsulating the methods for evaluating constants and | 35 * Helper class encapsulating the methods for evaluating constants and |
35 * constant instance creation expressions. | 36 * constant instance creation expressions. |
36 */ | 37 */ |
37 class ConstantEvaluationEngine { | 38 class ConstantEvaluationEngine { |
38 /** | 39 /** |
39 * Parameter to "fromEnvironment" methods that denotes the default value. | 40 * Parameter to "fromEnvironment" methods that denotes the default value. |
40 */ | 41 */ |
41 static String _DEFAULT_VALUE_PARAM = "defaultValue"; | 42 static String _DEFAULT_VALUE_PARAM = "defaultValue"; |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 } | 711 } |
711 } | 712 } |
712 } | 713 } |
713 // Evaluate explicit or implicit call to super(). | 714 // Evaluate explicit or implicit call to super(). |
714 InterfaceType superclass = definingClass.superclass; | 715 InterfaceType superclass = definingClass.superclass; |
715 if (superclass != null && !superclass.isObject) { | 716 if (superclass != null && !superclass.isObject) { |
716 ConstructorElement superConstructor = | 717 ConstructorElement superConstructor = |
717 superclass.lookUpConstructor(superName, constructor.library); | 718 superclass.lookUpConstructor(superName, constructor.library); |
718 if (superConstructor != null) { | 719 if (superConstructor != null) { |
719 if (superArguments == null) { | 720 if (superArguments == null) { |
720 superArguments = new NodeList<Expression>(null); | 721 superArguments = astFactory.nodeList/*<Expression>*/(null); |
721 } | 722 } |
722 | 723 |
723 evaluateSuperConstructorCall(node, fieldMap, superConstructor, | 724 evaluateSuperConstructorCall(node, fieldMap, superConstructor, |
724 superArguments, initializerVisitor, errorReporter); | 725 superArguments, initializerVisitor, errorReporter); |
725 } | 726 } |
726 } | 727 } |
727 return new DartObjectImpl(definingClass, new GenericState(fieldMap)); | 728 return new DartObjectImpl(definingClass, new GenericState(fieldMap)); |
728 } | 729 } |
729 | 730 |
730 void evaluateSuperConstructorCall( | 731 void evaluateSuperConstructorCall( |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 } | 2081 } |
2081 | 2082 |
2082 @override | 2083 @override |
2083 String toString() { | 2084 String toString() { |
2084 if (value == null) { | 2085 if (value == null) { |
2085 return "error"; | 2086 return "error"; |
2086 } | 2087 } |
2087 return value.toString(); | 2088 return value.toString(); |
2088 } | 2089 } |
2089 } | 2090 } |
OLD | NEW |