| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.common; | 5 library dart2js.resolution.common; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/resolution.dart' show Resolution; | 8 import '../common/resolution.dart' show Resolution; |
| 9 import '../common/tasks.dart' show DeferredAction; | |
| 10 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
| 11 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| 12 import '../tree/tree.dart'; | 11 import '../tree/tree.dart'; |
| 13 | 12 |
| 14 import 'registry.dart' show ResolutionRegistry; | 13 import 'registry.dart' show ResolutionRegistry; |
| 15 import 'scope.dart' show Scope; | 14 import 'scope.dart' show Scope; |
| 16 import 'type_resolver.dart' show TypeResolver; | 15 import 'type_resolver.dart' show TypeResolver; |
| 17 | 16 |
| 18 class CommonResolverVisitor<R> extends Visitor<R> { | 17 class CommonResolverVisitor<R> extends Visitor<R> { |
| 19 final Compiler compiler; | 18 final Compiler compiler; |
| 20 | 19 |
| 21 CommonResolverVisitor(Compiler this.compiler); | 20 CommonResolverVisitor(Compiler this.compiler); |
| 22 | 21 |
| 23 DiagnosticReporter get reporter => compiler.reporter; | 22 DiagnosticReporter get reporter => compiler.reporter; |
| 24 | 23 |
| 25 Resolution get resolution => compiler.resolution; | 24 Resolution get resolution => compiler.resolution; |
| 26 | 25 |
| 27 R visitNode(Node node) { | 26 R visitNode(Node node) { |
| 28 return reporter.internalError( | 27 return reporter.internalError( |
| 29 node, 'internal error: Unhandled node: ${node.getObjectDescription()}'); | 28 node, 'internal error: Unhandled node: ${node.getObjectDescription()}'); |
| 30 } | 29 } |
| 31 | 30 |
| 32 R visitEmptyStatement(Node node) => null; | 31 R visitEmptyStatement(Node node) => null; |
| 33 | 32 |
| 34 /** Convenience method for visiting nodes that may be null. */ | 33 /** Convenience method for visiting nodes that may be null. */ |
| 35 R visit(Node node) => (node == null) ? null : node.accept(this); | 34 R visit(Node node) => (node == null) ? null : node.accept(this); |
| 36 | 35 |
| 37 void addDeferredAction(Element element, DeferredAction action) { | 36 void addDeferredAction(Element element, void action()) { |
| 38 compiler.enqueuer.resolution.addDeferredAction(element, action); | 37 compiler.enqueuer.resolution.addDeferredAction(element, action); |
| 39 } | 38 } |
| 40 } | 39 } |
| 41 | 40 |
| 42 /** | 41 /** |
| 43 * Common supertype for resolver visitors that record resolutions in a | 42 * Common supertype for resolver visitors that record resolutions in a |
| 44 * [ResolutionRegistry]. | 43 * [ResolutionRegistry]. |
| 45 */ | 44 */ |
| 46 abstract class MappingVisitor<T> extends CommonResolverVisitor<T> { | 45 abstract class MappingVisitor<T> extends CommonResolverVisitor<T> { |
| 47 final ResolutionRegistry registry; | 46 final ResolutionRegistry registry; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 String name, Spannable definition, Spannable existing) { | 92 String name, Spannable definition, Spannable existing) { |
| 94 reporter.reportError( | 93 reporter.reportError( |
| 95 reporter.createMessage( | 94 reporter.createMessage( |
| 96 definition, MessageKind.DUPLICATE_DEFINITION, {'name': name}), | 95 definition, MessageKind.DUPLICATE_DEFINITION, {'name': name}), |
| 97 <DiagnosticMessage>[ | 96 <DiagnosticMessage>[ |
| 98 reporter.createMessage( | 97 reporter.createMessage( |
| 99 existing, MessageKind.EXISTING_DEFINITION, {'name': name}), | 98 existing, MessageKind.EXISTING_DEFINITION, {'name': name}), |
| 100 ]); | 99 ]); |
| 101 } | 100 } |
| 102 } | 101 } |
| OLD | NEW |