| 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 | 10 import '../common/names.dart' show |
| 11 Identifiers; | 11 Identifiers; |
| 12 import '../common/resolution.dart' show | 12 import '../common/resolution.dart' show |
| 13 Parsing, | 13 Parsing, |
| 14 Resolution, | 14 Resolution, |
| 15 ResolutionImpact; | 15 ResolutionImpact; |
| 16 import '../common/tasks.dart' show | 16 import '../common/tasks.dart' show |
| 17 CompilerTask, | 17 CompilerTask, |
| 18 DeferredAction; | 18 DeferredAction; |
| 19 import '../compiler.dart' show | 19 import '../compiler.dart' show |
| 20 Compiler; | 20 Compiler; |
| 21 import '../compile_time_constants.dart' show | 21 import '../compile_time_constants.dart' show |
| 22 ConstantCompiler; | 22 ConstantCompiler; |
| 23 import '../constants/values.dart' show | 23 import '../constants/values.dart' show |
| 24 ConstantValue; | 24 ConstantValue; |
| 25 import '../core_types.dart' show |
| 26 CoreTypes; |
| 25 import '../dart_types.dart'; | 27 import '../dart_types.dart'; |
| 26 import '../elements/elements.dart'; | 28 import '../elements/elements.dart'; |
| 27 import '../elements/modelx.dart' show | 29 import '../elements/modelx.dart' show |
| 28 BaseClassElementX, | 30 BaseClassElementX, |
| 29 BaseFunctionElementX, | 31 BaseFunctionElementX, |
| 30 ConstructorElementX, | 32 ConstructorElementX, |
| 31 FieldElementX, | 33 FieldElementX, |
| 32 FunctionElementX, | 34 FunctionElementX, |
| 33 GetterElementX, | 35 GetterElementX, |
| 34 MetadataAnnotationX, | 36 MetadataAnnotationX, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 63 final ConstantCompiler constantCompiler; | 65 final ConstantCompiler constantCompiler; |
| 64 | 66 |
| 65 ResolverTask(Compiler compiler, this.constantCompiler) : super(compiler); | 67 ResolverTask(Compiler compiler, this.constantCompiler) : super(compiler); |
| 66 | 68 |
| 67 String get name => 'Resolver'; | 69 String get name => 'Resolver'; |
| 68 | 70 |
| 69 Resolution get resolution => compiler.resolution; | 71 Resolution get resolution => compiler.resolution; |
| 70 | 72 |
| 71 Parsing get parsing => compiler.parsing; | 73 Parsing get parsing => compiler.parsing; |
| 72 | 74 |
| 75 CoreTypes get coreTypes => compiler.coreTypes; |
| 76 |
| 73 ResolutionImpact resolve(Element element) { | 77 ResolutionImpact resolve(Element element) { |
| 74 return measure(() { | 78 return measure(() { |
| 75 if (Elements.isErroneous(element)) { | 79 if (Elements.isErroneous(element)) { |
| 76 // TODO(johnniwinther): Add a predicate for this. | 80 // TODO(johnniwinther): Add a predicate for this. |
| 77 assert(invariant(element, element is! ErroneousElement, | 81 assert(invariant(element, element is! ErroneousElement, |
| 78 message: "Element $element expected to have parse errors.")); | 82 message: "Element $element expected to have parse errors.")); |
| 79 _ensureTreeElements(element); | 83 _ensureTreeElements(element); |
| 80 return const ResolutionImpact(); | 84 return const ResolutionImpact(); |
| 81 } | 85 } |
| 82 | 86 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 // TODO(johnniwinther): Avoid analyzing initializers if | 361 // TODO(johnniwinther): Avoid analyzing initializers if |
| 358 // [Compiler.analyzeSignaturesOnly] is set. | 362 // [Compiler.analyzeSignaturesOnly] is set. |
| 359 visitor.visit(initializer); | 363 visitor.visit(initializer); |
| 360 } else if (modifiers.isConst) { | 364 } else if (modifiers.isConst) { |
| 361 reporter.reportErrorMessage( | 365 reporter.reportErrorMessage( |
| 362 element, MessageKind.CONST_WITHOUT_INITIALIZER); | 366 element, MessageKind.CONST_WITHOUT_INITIALIZER); |
| 363 } else if (modifiers.isFinal && !element.isInstanceMember) { | 367 } else if (modifiers.isFinal && !element.isInstanceMember) { |
| 364 reporter.reportErrorMessage( | 368 reporter.reportErrorMessage( |
| 365 element, MessageKind.FINAL_WITHOUT_INITIALIZER); | 369 element, MessageKind.FINAL_WITHOUT_INITIALIZER); |
| 366 } else { | 370 } else { |
| 367 registry.registerInstantiatedClass(compiler.nullClass); | 371 registry.registerInstantiatedType(coreTypes.nullType); |
| 368 } | 372 } |
| 369 | 373 |
| 370 if (Elements.isStaticOrTopLevelField(element)) { | 374 if (Elements.isStaticOrTopLevelField(element)) { |
| 371 visitor.addDeferredAction(element, () { | 375 visitor.addDeferredAction(element, () { |
| 372 if (element.modifiers.isConst) { | 376 if (element.modifiers.isConst) { |
| 373 element.constant = constantCompiler.compileConstant(element); | 377 element.constant = constantCompiler.compileConstant(element); |
| 374 } else { | 378 } else { |
| 375 constantCompiler.compileVariable(element); | 379 constantCompiler.compileVariable(element); |
| 376 } | 380 } |
| 377 }); | 381 }); |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 TreeElements get treeElements { | 1079 TreeElements get treeElements { |
| 1076 assert(invariant(this, _treeElements !=null, | 1080 assert(invariant(this, _treeElements !=null, |
| 1077 message: "TreeElements have not been computed for $this.")); | 1081 message: "TreeElements have not been computed for $this.")); |
| 1078 return _treeElements; | 1082 return _treeElements; |
| 1079 } | 1083 } |
| 1080 | 1084 |
| 1081 void reuseElement() { | 1085 void reuseElement() { |
| 1082 _treeElements = null; | 1086 _treeElements = null; |
| 1083 } | 1087 } |
| 1084 } | 1088 } |
| OLD | NEW |