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

Side by Side Diff: pkg/kernel/lib/verifier.dart

Issue 2665723002: Implement canonical name scheme in kernel. (Closed)
Patch Set: Remove unintended change in fasta Created 3 years, 10 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library kernel.checks; 4 library kernel.checks;
5 5
6 import 'ast.dart'; 6 import 'ast.dart';
7 import 'transformations/flags.dart'; 7 import 'transformations/flags.dart';
8 8
9 void verifyProgram(Program program) { 9 void verifyProgram(Program program) {
10 VerifyingVisitor.check(program); 10 VerifyingVisitor.check(program);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 for (var library in program.libraries) { 165 for (var library in program.libraries) {
166 library.members.forEach(undeclareMember); 166 library.members.forEach(undeclareMember);
167 for (var class_ in library.classes) { 167 for (var class_ in library.classes) {
168 class_.members.forEach(undeclareMember); 168 class_.members.forEach(undeclareMember);
169 } 169 }
170 } 170 }
171 variableStack.forEach(undeclareVariable); 171 variableStack.forEach(undeclareVariable);
172 } 172 }
173 } 173 }
174 174
175 void checkCanonicalName(CanonicalName name, LinkedNode definition) {
Kevin Millikin (Google) 2017/02/22 09:09:30 Get rid of the function? Or if we sometimes want
asgerf 2017/02/22 10:06:54 Removed the function. I did not intend to upload t
176 // if (name == null) {
177 // throw '$definition has no canonical name';
178 // }
179 // if (name.box.node != definition) {
180 // throw '$definition has name $name, but that is bound to '
181 // '${name.box.node}';
182 // }
183 }
184
175 visitField(Field node) { 185 visitField(Field node) {
186 checkCanonicalName(node.canonicalName, node);
176 currentMember = node; 187 currentMember = node;
177 var oldParent = enterParent(node); 188 var oldParent = enterParent(node);
178 classTypeParametersAreInScope = !node.isStatic; 189 classTypeParametersAreInScope = !node.isStatic;
179 node.initializer?.accept(this); 190 node.initializer?.accept(this);
180 classTypeParametersAreInScope = false; 191 classTypeParametersAreInScope = false;
181 visitList(node.annotations, this); 192 visitList(node.annotations, this);
182 exitParent(oldParent); 193 exitParent(oldParent);
183 currentMember = null; 194 currentMember = null;
184 } 195 }
185 196
186 visitProcedure(Procedure node) { 197 visitProcedure(Procedure node) {
198 checkCanonicalName(node.canonicalName, node);
187 currentMember = node; 199 currentMember = node;
188 var oldParent = enterParent(node); 200 var oldParent = enterParent(node);
189 classTypeParametersAreInScope = !node.isStatic; 201 classTypeParametersAreInScope = !node.isStatic;
190 node.function.accept(this); 202 node.function.accept(this);
191 classTypeParametersAreInScope = false; 203 classTypeParametersAreInScope = false;
192 visitList(node.annotations, this); 204 visitList(node.annotations, this);
193 exitParent(oldParent); 205 exitParent(oldParent);
194 currentMember = null; 206 currentMember = null;
195 } 207 }
196 208
197 visitConstructor(Constructor node) { 209 visitConstructor(Constructor node) {
210 checkCanonicalName(node.canonicalName, node);
198 currentMember = node; 211 currentMember = node;
199 classTypeParametersAreInScope = true; 212 classTypeParametersAreInScope = true;
200 // The constructor member needs special treatment due to parameters being 213 // The constructor member needs special treatment due to parameters being
201 // in scope in the initializer list. 214 // in scope in the initializer list.
202 var oldParent = enterParent(node); 215 var oldParent = enterParent(node);
203 int stackHeight = enterLocalScope(); 216 int stackHeight = enterLocalScope();
204 visitChildren(node.function); 217 visitChildren(node.function);
205 visitList(node.initializers, this); 218 visitList(node.initializers, this);
206 if (!isOutline) { 219 if (!isOutline) {
207 checkInitializers(node); 220 checkInitializers(node);
208 } 221 }
209 exitLocalScope(stackHeight); 222 exitLocalScope(stackHeight);
210 classTypeParametersAreInScope = false; 223 classTypeParametersAreInScope = false;
211 visitList(node.annotations, this); 224 visitList(node.annotations, this);
212 exitParent(oldParent); 225 exitParent(oldParent);
213 classTypeParametersAreInScope = false; 226 classTypeParametersAreInScope = false;
214 currentMember = null; 227 currentMember = null;
215 } 228 }
216 229
217 visitClass(Class node) { 230 visitClass(Class node) {
231 checkCanonicalName(node.canonicalName, node);
218 currentClass = node; 232 currentClass = node;
219 declareTypeParameters(node.typeParameters); 233 declareTypeParameters(node.typeParameters);
220 var oldParent = enterParent(node); 234 var oldParent = enterParent(node);
221 classTypeParametersAreInScope = false; 235 classTypeParametersAreInScope = false;
222 visitList(node.annotations, this); 236 visitList(node.annotations, this);
223 classTypeParametersAreInScope = true; 237 classTypeParametersAreInScope = true;
224 visitList(node.typeParameters, this); 238 visitList(node.typeParameters, this);
225 visitList(node.fields, this); 239 visitList(node.fields, this);
226 visitList(node.constructors, this); 240 visitList(node.constructors, this);
227 visitList(node.procedures, this); 241 visitList(node.procedures, this);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 var oldParent = parent; 493 var oldParent = parent;
480 parent = node; 494 parent = node;
481 node.visitChildren(this); 495 node.visitChildren(this);
482 parent = oldParent; 496 parent = oldParent;
483 } 497 }
484 } 498 }
485 499
486 void checkInitializers(Constructor constructor) { 500 void checkInitializers(Constructor constructor) {
487 // TODO(ahe): I'll add more here in other CLs. 501 // TODO(ahe): I'll add more here in other CLs.
488 } 502 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698