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

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

Issue 1383483006: Extract DiagnosticReporter implementation from Compiler. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixes after rebase. Created 5 years, 2 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.variables; 5 library dart2js.resolution.variables;
6 6
7 import '../compiler.dart' show 7 import '../compiler.dart' show
8 Compiler; 8 Compiler;
9 import '../diagnostics/messages.dart' show 9 import '../diagnostics/messages.dart' show
10 MessageKind; 10 MessageKind;
(...skipping 28 matching lines...) Expand all
39 ResolutionRegistry get registry => resolver.registry; 39 ResolutionRegistry get registry => resolver.registry;
40 40
41 Identifier visitSendSet(SendSet node) { 41 Identifier visitSendSet(SendSet node) {
42 assert(node.arguments.tail.isEmpty); // Sanity check 42 assert(node.arguments.tail.isEmpty); // Sanity check
43 Identifier identifier = node.selector; 43 Identifier identifier = node.selector;
44 String name = identifier.source; 44 String name = identifier.source;
45 VariableDefinitionScope scope = 45 VariableDefinitionScope scope =
46 new VariableDefinitionScope(resolver.scope, name); 46 new VariableDefinitionScope(resolver.scope, name);
47 resolver.visitIn(node.arguments.head, scope); 47 resolver.visitIn(node.arguments.head, scope);
48 if (scope.variableReferencedInInitializer) { 48 if (scope.variableReferencedInInitializer) {
49 compiler.reportErrorMessage( 49 reporter.reportErrorMessage(
50 identifier, MessageKind.REFERENCE_IN_INITIALIZATION, 50 identifier, MessageKind.REFERENCE_IN_INITIALIZATION,
51 {'variableName': name}); 51 {'variableName': name});
52 } 52 }
53 return identifier; 53 return identifier;
54 } 54 }
55 55
56 Identifier visitIdentifier(Identifier node) { 56 Identifier visitIdentifier(Identifier node) {
57 // The variable is initialized to null. 57 // The variable is initialized to null.
58 registry.registerInstantiatedClass(compiler.nullClass); 58 registry.registerInstantiatedClass(compiler.nullClass);
59 if (definitions.modifiers.isConst) { 59 if (definitions.modifiers.isConst) {
60 compiler.reportErrorMessage( 60 reporter.reportErrorMessage(
61 node, MessageKind.CONST_WITHOUT_INITIALIZER); 61 node, MessageKind.CONST_WITHOUT_INITIALIZER);
62 } 62 }
63 if (definitions.modifiers.isFinal && 63 if (definitions.modifiers.isFinal &&
64 !resolver.allowFinalWithoutInitializer) { 64 !resolver.allowFinalWithoutInitializer) {
65 compiler.reportErrorMessage( 65 reporter.reportErrorMessage(
66 node, MessageKind.FINAL_WITHOUT_INITIALIZER); 66 node, MessageKind.FINAL_WITHOUT_INITIALIZER);
67 } 67 }
68 return node; 68 return node;
69 } 69 }
70 70
71 visitNodeList(NodeList node) { 71 visitNodeList(NodeList node) {
72 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) { 72 for (Link<Node> link = node.nodes; !link.isEmpty; link = link.tail) {
73 Identifier name = visit(link.head); 73 Identifier name = visit(link.head);
74 LocalVariableElementX element = new LocalVariableElementX( 74 LocalVariableElementX element = new LocalVariableElementX(
75 name.source, resolver.enclosingElement, 75 name.source, resolver.enclosingElement,
76 variables, name.token); 76 variables, name.token);
77 resolver.defineLocalVariable(link.head, element); 77 resolver.defineLocalVariable(link.head, element);
78 resolver.addToScope(element); 78 resolver.addToScope(element);
79 if (definitions.modifiers.isConst) { 79 if (definitions.modifiers.isConst) {
80 compiler.enqueuer.resolution.addDeferredAction(element, () { 80 compiler.enqueuer.resolution.addDeferredAction(element, () {
81 element.constant = 81 element.constant =
82 compiler.resolver.constantCompiler.compileConstant(element); 82 compiler.resolver.constantCompiler.compileConstant(element);
83 }); 83 });
84 } 84 }
85 } 85 }
86 } 86 }
87 } 87 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/typedefs.dart ('k') | pkg/compiler/lib/src/scanner/scanner_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698