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