Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Side by Side Diff: pkg/compiler/lib/src/resolution/resolution_common.dart

Issue 2123073003: remove dependency on compiler from resolution (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 '../compiler.dart' show Compiler;
10 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
11 import '../tree/tree.dart'; 10 import '../tree/tree.dart';
12
13 import 'registry.dart' show ResolutionRegistry; 11 import 'registry.dart' show ResolutionRegistry;
14 import 'scope.dart' show Scope; 12 import 'scope.dart' show Scope;
15 import 'type_resolver.dart' show TypeResolver; 13 import 'type_resolver.dart' show TypeResolver;
16 14
17 class CommonResolverVisitor<R> extends Visitor<R> { 15 class CommonResolverVisitor<R> extends Visitor<R> {
18 final Compiler compiler; 16 final Resolution resolution;
19 17
20 CommonResolverVisitor(Compiler this.compiler); 18 CommonResolverVisitor(this.resolution);
21 19
22 DiagnosticReporter get reporter => compiler.reporter; 20 DiagnosticReporter get reporter => resolution.reporter;
23
24 Resolution get resolution => compiler.resolution;
25 21
26 R visitNode(Node node) { 22 R visitNode(Node node) {
27 return reporter.internalError( 23 return reporter.internalError(
28 node, 'internal error: Unhandled node: ${node.getObjectDescription()}'); 24 node, 'internal error: Unhandled node: ${node.getObjectDescription()}');
29 } 25 }
30 26
31 R visitEmptyStatement(Node node) => null; 27 R visitEmptyStatement(Node node) => null;
32 28
33 /** Convenience method for visiting nodes that may be null. */ 29 /** Convenience method for visiting nodes that may be null. */
34 R visit(Node node) => (node == null) ? null : node.accept(this); 30 R visit(Node node) => (node == null) ? null : node.accept(this);
35 31
36 void addDeferredAction(Element element, void action()) { 32 void addDeferredAction(Element element, void action()) {
37 compiler.enqueuer.resolution.addDeferredAction(element, action); 33 resolution.enqueuer.addDeferredAction(element, action);
38 } 34 }
39 } 35 }
40 36
41 /** 37 /**
42 * Common supertype for resolver visitors that record resolutions in a 38 * Common supertype for resolver visitors that record resolutions in a
43 * [ResolutionRegistry]. 39 * [ResolutionRegistry].
44 */ 40 */
45 abstract class MappingVisitor<T> extends CommonResolverVisitor<T> { 41 abstract class MappingVisitor<T> extends CommonResolverVisitor<T> {
46 final ResolutionRegistry registry; 42 final ResolutionRegistry registry;
47 final TypeResolver typeResolver; 43 final TypeResolver typeResolver;
48 44
49 /// The current enclosing element for the visited AST nodes. 45 /// The current enclosing element for the visited AST nodes.
50 Element get enclosingElement; 46 Element get enclosingElement;
51 47
52 /// The current scope of the visitor. 48 /// The current scope of the visitor.
53 Scope get scope; 49 Scope get scope;
54 50
55 MappingVisitor(Compiler compiler, ResolutionRegistry this.registry) 51 MappingVisitor(Resolution resolution, this.registry)
56 : typeResolver = new TypeResolver(compiler), 52 : typeResolver = new TypeResolver(resolution),
57 super(compiler); 53 super(resolution);
58 54
59 AsyncMarker get currentAsyncMarker => AsyncMarker.SYNC; 55 AsyncMarker get currentAsyncMarker => AsyncMarker.SYNC;
60 56
61 /// Add [element] to the current scope and check for duplicate definitions. 57 /// Add [element] to the current scope and check for duplicate definitions.
62 void addToScope(Element element) { 58 void addToScope(Element element) {
63 Element existing = scope.add(element); 59 Element existing = scope.add(element);
64 if (existing != element) { 60 if (existing != element) {
65 reportDuplicateDefinition(element.name, element, existing); 61 reportDuplicateDefinition(element.name, element, existing);
66 } 62 }
67 } 63 }
(...skipping 24 matching lines...) Expand all
92 String name, Spannable definition, Spannable existing) { 88 String name, Spannable definition, Spannable existing) {
93 reporter.reportError( 89 reporter.reportError(
94 reporter.createMessage( 90 reporter.createMessage(
95 definition, MessageKind.DUPLICATE_DEFINITION, {'name': name}), 91 definition, MessageKind.DUPLICATE_DEFINITION, {'name': name}),
96 <DiagnosticMessage>[ 92 <DiagnosticMessage>[
97 reporter.createMessage( 93 reporter.createMessage(
98 existing, MessageKind.EXISTING_DEFINITION, {'name': name}), 94 existing, MessageKind.EXISTING_DEFINITION, {'name': name}),
99 ]); 95 ]);
100 } 96 }
101 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698