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