| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js.resolution; | 5 library dart2js.resolution; |
| 6 | 6 |
| 7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/names.dart' show Identifiers; | 10 import '../common/names.dart' show Identifiers; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 import '../tree/tree.dart'; | 46 import '../tree/tree.dart'; |
| 47 import '../universe/call_structure.dart' show CallStructure; | 47 import '../universe/call_structure.dart' show CallStructure; |
| 48 import '../universe/use.dart' show StaticUse, TypeUse; | 48 import '../universe/use.dart' show StaticUse, TypeUse; |
| 49 import '../universe/world_impact.dart' show WorldImpact; | 49 import '../universe/world_impact.dart' show WorldImpact; |
| 50 import '../util/util.dart' show Link, Setlet; | 50 import '../util/util.dart' show Link, Setlet; |
| 51 import 'class_hierarchy.dart'; | 51 import 'class_hierarchy.dart'; |
| 52 import 'class_members.dart' show MembersCreator; | 52 import 'class_members.dart' show MembersCreator; |
| 53 import 'constructors.dart'; | 53 import 'constructors.dart'; |
| 54 import 'members.dart'; | 54 import 'members.dart'; |
| 55 import 'registry.dart'; | 55 import 'registry.dart'; |
| 56 import 'resolution_result.dart'; |
| 56 import 'signatures.dart'; | 57 import 'signatures.dart'; |
| 57 import 'tree_elements.dart'; | 58 import 'tree_elements.dart'; |
| 58 import 'typedefs.dart'; | 59 import 'typedefs.dart'; |
| 59 | 60 |
| 60 class ResolverTask extends CompilerTask { | 61 class ResolverTask extends CompilerTask { |
| 61 final ConstantCompiler constantCompiler; | 62 final ConstantCompiler constantCompiler; |
| 62 final Compiler compiler; | 63 final Compiler compiler; |
| 63 | 64 |
| 64 ResolverTask(Compiler compiler, this.constantCompiler) | 65 ResolverTask(Compiler compiler, this.constantCompiler) |
| 65 : compiler = compiler, | 66 : compiler = compiler, |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 // happens for enum fields where the type is known but is not in the | 378 // happens for enum fields where the type is known but is not in the |
| 378 // synthesized AST. | 379 // synthesized AST. |
| 379 element.variables.type = const DynamicType(); | 380 element.variables.type = const DynamicType(); |
| 380 } | 381 } |
| 381 | 382 |
| 382 Expression initializer = element.initializer; | 383 Expression initializer = element.initializer; |
| 383 Modifiers modifiers = element.modifiers; | 384 Modifiers modifiers = element.modifiers; |
| 384 if (initializer != null) { | 385 if (initializer != null) { |
| 385 // TODO(johnniwinther): Avoid analyzing initializers if | 386 // TODO(johnniwinther): Avoid analyzing initializers if |
| 386 // [Compiler.analyzeSignaturesOnly] is set. | 387 // [Compiler.analyzeSignaturesOnly] is set. |
| 387 visitor.visit(initializer); | 388 ResolutionResult result = visitor.visit(initializer); |
| 389 if (result.isConstant) { |
| 390 element.constant = result.constant; |
| 391 } |
| 388 } else if (modifiers.isConst) { | 392 } else if (modifiers.isConst) { |
| 389 reporter.reportErrorMessage( | 393 reporter.reportErrorMessage( |
| 390 element, MessageKind.CONST_WITHOUT_INITIALIZER); | 394 element, MessageKind.CONST_WITHOUT_INITIALIZER); |
| 391 } else if (modifiers.isFinal && !element.isInstanceMember) { | 395 } else if (modifiers.isFinal && !element.isInstanceMember) { |
| 392 reporter.reportErrorMessage( | 396 reporter.reportErrorMessage( |
| 393 element, MessageKind.FINAL_WITHOUT_INITIALIZER); | 397 element, MessageKind.FINAL_WITHOUT_INITIALIZER); |
| 394 } else { | 398 } else { |
| 395 // TODO(johnniwinther): Register a feature instead. | 399 // TODO(johnniwinther): Register a feature instead. |
| 396 registry.registerTypeUse(new TypeUse.instantiation(coreTypes.nullType)); | 400 registry.registerTypeUse(new TypeUse.instantiation(coreTypes.nullType)); |
| 397 } | 401 } |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 TreeElements get treeElements { | 1124 TreeElements get treeElements { |
| 1121 assert(invariant(this, _treeElements != null, | 1125 assert(invariant(this, _treeElements != null, |
| 1122 message: "TreeElements have not been computed for $this.")); | 1126 message: "TreeElements have not been computed for $this.")); |
| 1123 return _treeElements; | 1127 return _treeElements; |
| 1124 } | 1128 } |
| 1125 | 1129 |
| 1126 void reuseElement() { | 1130 void reuseElement() { |
| 1127 _treeElements = null; | 1131 _treeElements = null; |
| 1128 } | 1132 } |
| 1129 } | 1133 } |
| OLD | NEW |