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

Side by Side Diff: pkg/compiler/lib/src/dart_backend/placeholder_collector.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart_backend; 5 part of dart_backend;
6 6
7 class LocalPlaceholder { 7 class LocalPlaceholder {
8 final String identifier; 8 final String identifier;
9 final Set<Node> nodes; 9 final Set<Node> nodes;
10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); 10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>();
11 int get hashCode => identifier.hashCode; 11 int get hashCode => identifier.hashCode;
12 String toString() => 12 String toString() => 'local_placeholder[id($identifier), nodes($nodes)]';
13 'local_placeholder[id($identifier), nodes($nodes)]';
14 } 13 }
15 14
16 class FunctionScope { 15 class FunctionScope {
17 final Set<String> parameterIdentifiers; 16 final Set<String> parameterIdentifiers;
18 final Set<LocalPlaceholder> localPlaceholders; 17 final Set<LocalPlaceholder> localPlaceholders;
19 FunctionScope() 18 FunctionScope()
20 : parameterIdentifiers = new Set<String>(), 19 : parameterIdentifiers = new Set<String>(),
21 localPlaceholders = new Set<LocalPlaceholder>(); 20 localPlaceholders = new Set<LocalPlaceholder>();
22 void registerParameter(Identifier node) { 21 void registerParameter(Identifier node) {
23 parameterIdentifiers.add(node.source); 22 parameterIdentifiers.add(node.source);
24 } 23 }
25 } 24 }
26 25
27 class ConstructorPlaceholder { 26 class ConstructorPlaceholder {
28 final Identifier node; 27 final Identifier node;
29 final ConstructorElement element; 28 final ConstructorElement element;
30 29
31 ConstructorPlaceholder(this.node, this.element); 30 ConstructorPlaceholder(this.node, this.element);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 collector.tryMakeLocalPlaceholder(element, node.selector); 125 collector.tryMakeLocalPlaceholder(element, node.selector);
127 } else { 126 } else {
128 assert(node.selector is FunctionExpression); 127 assert(node.selector is FunctionExpression);
129 } 128 }
130 } 129 }
131 } 130 }
132 } 131 }
133 132
134 visitStaticSend(Send node) { 133 visitStaticSend(Send node) {
135 Element element = elements[node]; 134 Element element = elements[node];
136 collector.mirrorRenamer.registerStaticSend( 135 collector.mirrorRenamer
137 collector.currentElement, element, node); 136 .registerStaticSend(collector.currentElement, element, node);
138 137
139 if (Elements.isUnresolved(element) 138 if (Elements.isUnresolved(element) || element.isDeferredLoaderGetter) {
140 || element.isDeferredLoaderGetter) {
141 return; 139 return;
142 } 140 }
143 if (element.isConstructor || element.isFactoryConstructor) { 141 if (element.isConstructor || element.isFactoryConstructor) {
144 // Rename named constructor in redirection position: 142 // Rename named constructor in redirection position:
145 // class C { C.named(); C.redirecting() : this.named(); } 143 // class C { C.named(); C.redirecting() : this.named(); }
146 if (node.receiver is Identifier 144 if (node.receiver is Identifier &&
147 && node.receiver.asIdentifier().isThis()) { 145 node.receiver.asIdentifier().isThis()) {
148 assert(node.selector is Identifier); 146 assert(node.selector is Identifier);
149 collector.tryMakeConstructorPlaceholder(node, element); 147 collector.tryMakeConstructorPlaceholder(node, element);
150 } 148 }
151 return; 149 return;
152 } 150 }
153 collector.makeElementPlaceholder(node.selector, element); 151 collector.makeElementPlaceholder(node.selector, element);
154 // Another ugly case: <lib prefix>.<top level> is represented as 152 // Another ugly case: <lib prefix>.<top level> is represented as
155 // receiver: lib prefix, selector: top level. 153 // receiver: lib prefix, selector: top level.
156 if (element.isTopLevel && node.receiver != null) { 154 if (element.isTopLevel && node.receiver != null) {
157 assert(elements[node.receiver].isPrefix); 155 assert(elements[node.receiver].isPrefix);
(...skipping 13 matching lines...) Expand all
171 169
172 class PlaceholderCollector extends Visitor { 170 class PlaceholderCollector extends Visitor {
173 final DiagnosticReporter reporter; 171 final DiagnosticReporter reporter;
174 final MirrorRenamer mirrorRenamer; 172 final MirrorRenamer mirrorRenamer;
175 final FunctionElement mainFunction; 173 final FunctionElement mainFunction;
176 final Set<String> fixedMemberNames; // member names which cannot be renamed. 174 final Set<String> fixedMemberNames; // member names which cannot be renamed.
177 final Map<Element, ElementAst> elementAsts; 175 final Map<Element, ElementAst> elementAsts;
178 final Set<Node> prefixNodesToErase = new Set<Node>(); 176 final Set<Node> prefixNodesToErase = new Set<Node>();
179 final Set<Node> unresolvedNodes = new Set<Node>(); 177 final Set<Node> unresolvedNodes = new Set<Node>();
180 final Map<Element, Set<Node>> elementNodes = new Map<Element, Set<Node>>(); 178 final Map<Element, Set<Node>> elementNodes = new Map<Element, Set<Node>>();
181 final Map<FunctionElement, FunctionScope> functionScopes 179 final Map<FunctionElement, FunctionScope> functionScopes =
182 = new Map<FunctionElement, FunctionScope>(); 180 new Map<FunctionElement, FunctionScope>();
183 final Map<LibraryElement, Set<Identifier>> privateNodes = 181 final Map<LibraryElement, Set<Identifier>> privateNodes =
184 new Map<LibraryElement, Set<Identifier>>(); 182 new Map<LibraryElement, Set<Identifier>>();
185 final List<DeclarationTypePlaceholder> declarationTypePlaceholders 183 final List<DeclarationTypePlaceholder> declarationTypePlaceholders =
186 = new List<DeclarationTypePlaceholder>(); 184 new List<DeclarationTypePlaceholder>();
187 final Map<String, Set<Identifier>> memberPlaceholders 185 final Map<String, Set<Identifier>> memberPlaceholders =
188 = new Map<String, Set<Identifier>>(); 186 new Map<String, Set<Identifier>>();
189 final List<ConstructorPlaceholder> constructorPlaceholders 187 final List<ConstructorPlaceholder> constructorPlaceholders =
190 = new List<ConstructorPlaceholder>(); 188 new List<ConstructorPlaceholder>();
191 Map<String, LocalPlaceholder> currentLocalPlaceholders; 189 Map<String, LocalPlaceholder> currentLocalPlaceholders;
192 Element currentElement; 190 Element currentElement;
193 FunctionElement topmostEnclosingFunction; 191 FunctionElement topmostEnclosingFunction;
194 TreeElements treeElements; 192 TreeElements treeElements;
195 193
196 get currentFunctionScope => functionScopes.putIfAbsent( 194 get currentFunctionScope => functionScopes.putIfAbsent(
197 topmostEnclosingFunction, () => new FunctionScope()); 195 topmostEnclosingFunction, () => new FunctionScope());
198 196
199 PlaceholderCollector(this.reporter, this.mirrorRenamer, 197 PlaceholderCollector(this.reporter, this.mirrorRenamer, this.fixedMemberNames,
200 this.fixedMemberNames, this.elementAsts, 198 this.elementAsts, this.mainFunction);
201 this.mainFunction);
202 199
203 void collectFunctionDeclarationPlaceholders( 200 void collectFunctionDeclarationPlaceholders(
204 FunctionElement element, FunctionExpression node) { 201 FunctionElement element, FunctionExpression node) {
205 if (element.isConstructor) { 202 if (element.isConstructor) {
206 ConstructorElement constructor = element; 203 ConstructorElement constructor = element;
207 tryMakeConstructorPlaceholder(node.name, element); 204 tryMakeConstructorPlaceholder(node.name, element);
208 RedirectingFactoryBody bodyAsRedirectingFactoryBody = 205 RedirectingFactoryBody bodyAsRedirectingFactoryBody =
209 node.body.asRedirectingFactoryBody(); 206 node.body.asRedirectingFactoryBody();
210 if (bodyAsRedirectingFactoryBody != null) { 207 if (bodyAsRedirectingFactoryBody != null) {
211 // Factory redirection. 208 // Factory redirection.
212 FunctionElement redirectTarget = constructor.immediateRedirectionTarget; 209 FunctionElement redirectTarget = constructor.immediateRedirectionTarget;
213 assert(redirectTarget != null && redirectTarget != element); 210 assert(redirectTarget != null && redirectTarget != element);
214 tryMakeConstructorPlaceholder( 211 tryMakeConstructorPlaceholder(
215 bodyAsRedirectingFactoryBody.constructorReference, 212 bodyAsRedirectingFactoryBody.constructorReference, redirectTarget);
216 redirectTarget);
217 } 213 }
218 } else if (Elements.isStaticOrTopLevel(element)) { 214 } else if (Elements.isStaticOrTopLevel(element)) {
219 // Note: this code should only rename private identifiers for class' 215 // Note: this code should only rename private identifiers for class'
220 // fields/getters/setters/methods. Top-level identifiers are renamed 216 // fields/getters/setters/methods. Top-level identifiers are renamed
221 // just to escape conflicts and that should be enough as we shouldn't 217 // just to escape conflicts and that should be enough as we shouldn't
222 // be able to resolve private identifiers for other libraries. 218 // be able to resolve private identifiers for other libraries.
223 makeElementPlaceholder(node.name, element); 219 makeElementPlaceholder(node.name, element);
224 } else if (element.isClassMember) { 220 } else if (element.isClassMember) {
225 if (node.name is Identifier) { 221 if (node.name is Identifier) {
226 tryMakeMemberPlaceholder(node.name); 222 tryMakeMemberPlaceholder(node.name);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 void tryMakeLocalPlaceholder(Element element, Identifier node) { 270 void tryMakeLocalPlaceholder(Element element, Identifier node) {
275 bool isNamedOptionalParameter() { 271 bool isNamedOptionalParameter() {
276 FunctionTypedElement function = element.enclosingElement; 272 FunctionTypedElement function = element.enclosingElement;
277 FunctionSignature signature = function.functionSignature; 273 FunctionSignature signature = function.functionSignature;
278 if (!signature.optionalParametersAreNamed) return false; 274 if (!signature.optionalParametersAreNamed) return false;
279 for (Element parameter in signature.optionalParameters) { 275 for (Element parameter in signature.optionalParameters) {
280 if (identical(parameter, element)) return true; 276 if (identical(parameter, element)) return true;
281 } 277 }
282 return false; 278 return false;
283 } 279 }
284 if (element.isParameter && !isTypedefParameter(element) && 280 if (element.isParameter &&
281 !isTypedefParameter(element) &&
285 isNamedOptionalParameter()) { 282 isNamedOptionalParameter()) {
286 currentFunctionScope.registerParameter(node); 283 currentFunctionScope.registerParameter(node);
287 } else if (Elements.isLocal(element) && !isTypedefParameter(element)) { 284 } else if (Elements.isLocal(element) && !isTypedefParameter(element)) {
288 makeLocalPlaceholder(node); 285 makeLocalPlaceholder(node);
289 } 286 }
290 } 287 }
291 288
292 void tryMakeMemberPlaceholder(Identifier node) { 289 void tryMakeMemberPlaceholder(Identifier node) {
293 assert(node != null); 290 assert(node != null);
294 if (node is Operator) return; 291 if (node is Operator) return;
295 String identifier = node.source; 292 String identifier = node.source;
296 if (fixedMemberNames.contains(identifier)) return; 293 if (fixedMemberNames.contains(identifier)) return;
297 memberPlaceholders.putIfAbsent( 294 memberPlaceholders
298 identifier, () => new Set<Identifier>()).add(node); 295 .putIfAbsent(identifier, () => new Set<Identifier>())
296 .add(node);
299 } 297 }
300 298
301 void makeTypePlaceholder(Node node, DartType type) { 299 void makeTypePlaceholder(Node node, DartType type) {
302 Send send = node.asSend(); 300 Send send = node.asSend();
303 if (send != null) { 301 if (send != null) {
304 // Prefix. 302 // Prefix.
305 assert(send.receiver is Identifier); 303 assert(send.receiver is Identifier);
306 assert(send.selector is Identifier); 304 assert(send.selector is Identifier);
307 makeErasePrefixPlaceholder(send.receiver); 305 makeErasePrefixPlaceholder(send.receiver);
308 node = send.selector; 306 node = send.selector;
309 } 307 }
310 makeElementPlaceholder(node, type.element); 308 makeElementPlaceholder(node, type.element);
311 } 309 }
312 310
313 void makeTypeVariablePlaceholder(Node node, TypeVariableType type) { 311 void makeTypeVariablePlaceholder(Node node, TypeVariableType type) {
314 Send send = node.asSend(); 312 Send send = node.asSend();
315 if (send != null) { 313 if (send != null) {
316 // Prefix. 314 // Prefix.
317 assert(send.receiver is Identifier); 315 assert(send.receiver is Identifier);
318 assert(send.selector is Identifier); 316 assert(send.selector is Identifier);
319 makeErasePrefixPlaceholder(send.receiver); 317 makeErasePrefixPlaceholder(send.receiver);
320 node = send.selector; 318 node = send.selector;
321 } 319 }
322 tryMakeMemberPlaceholder(node); 320 tryMakeMemberPlaceholder(node);
323 } 321 }
324 322
325 void makeOmitDeclarationTypePlaceholder(TypeAnnotation type) { 323 void makeOmitDeclarationTypePlaceholder(TypeAnnotation type) {
326 if (type == null) return; 324 if (type == null) return;
327 declarationTypePlaceholders.add( 325 declarationTypePlaceholders
328 new DeclarationTypePlaceholder(type, false)); 326 .add(new DeclarationTypePlaceholder(type, false));
329 } 327 }
330 328
331 void makeVarDeclarationTypePlaceholder(VariableDefinitions node) { 329 void makeVarDeclarationTypePlaceholder(VariableDefinitions node) {
332 // TODO(smok): Maybe instead of calling this method and 330 // TODO(smok): Maybe instead of calling this method and
333 // makeDeclaratioTypePlaceholder have type declaration placeholder 331 // makeDeclaratioTypePlaceholder have type declaration placeholder
334 // collector logic in visitVariableDefinitions when resolver becomes better 332 // collector logic in visitVariableDefinitions when resolver becomes better
335 // and/or catch syntax changes. 333 // and/or catch syntax changes.
336 if (node.type == null) return; 334 if (node.type == null) return;
337 bool requiresVar = !node.modifiers.isFinalOrConst; 335 bool requiresVar = !node.modifiers.isFinalOrConst;
338 declarationTypePlaceholders.add( 336 declarationTypePlaceholders
339 new DeclarationTypePlaceholder(node.type, requiresVar)); 337 .add(new DeclarationTypePlaceholder(node.type, requiresVar));
340 } 338 }
341 339
342 /// Marks [node] to be erased in the output. 340 /// Marks [node] to be erased in the output.
343 /// This is done for library prefixes because they are not used in the output 341 /// This is done for library prefixes because they are not used in the output
344 /// because all imports are flattened and conflicts are renamed away. 342 /// because all imports are flattened and conflicts are renamed away.
345 void makeErasePrefixPlaceholder(Node node) { 343 void makeErasePrefixPlaceholder(Node node) {
346 assert(node is Identifier || node is Send); 344 assert(node is Identifier || node is Send);
347 prefixNodesToErase.add(node); 345 prefixNodesToErase.add(node);
348 } 346 }
349 347
(...skipping 21 matching lines...) Expand all
371 elementNodes.putIfAbsent(element, () => new Set<Node>()).add(node); 369 elementNodes.putIfAbsent(element, () => new Set<Node>()).add(node);
372 } 370 }
373 371
374 /// Marks [node] to be renamed per-library if it names an instance member 372 /// Marks [node] to be renamed per-library if it names an instance member
375 /// and has a private name. 373 /// and has a private name.
376 void tryMakePrivateIdentifier(Node node, Element element) { 374 void tryMakePrivateIdentifier(Node node, Element element) {
377 if (node is Identifier && 375 if (node is Identifier &&
378 !Elements.isStaticOrTopLevel(element) && 376 !Elements.isStaticOrTopLevel(element) &&
379 !Elements.isLocal(element) && 377 !Elements.isLocal(element) &&
380 Name.isPrivateName(node.source)) { 378 Name.isPrivateName(node.source)) {
381 privateNodes.putIfAbsent( 379 privateNodes
382 currentElement.library, () => new Set<Identifier>()).add(node); 380 .putIfAbsent(currentElement.library, () => new Set<Identifier>())
381 .add(node);
383 } 382 }
384 } 383 }
385 384
386 void makeUnresolvedPlaceholder(Node node) { 385 void makeUnresolvedPlaceholder(Node node) {
387 unresolvedNodes.add(node); 386 unresolvedNodes.add(node);
388 } 387 }
389 388
390 void makeLocalPlaceholder(Identifier identifier) { 389 void makeLocalPlaceholder(Identifier identifier) {
391 LocalPlaceholder getLocalPlaceholder() { 390 LocalPlaceholder getLocalPlaceholder() {
392 String name = identifier.source; 391 String name = identifier.source;
(...skipping 29 matching lines...) Expand all
422 // First deconstruct the constructor, there are 4 possibilities: 421 // First deconstruct the constructor, there are 4 possibilities:
423 // ClassName() 422 // ClassName()
424 // prefix.ClassName() 423 // prefix.ClassName()
425 // ClassName.constructorName() 424 // ClassName.constructorName()
426 // prefix.ClassName.constructorName() 425 // prefix.ClassName.constructorName()
427 if (node is Send) { 426 if (node is Send) {
428 if (node.receiver is Send) { 427 if (node.receiver is Send) {
429 Send receiver = node.receiver; 428 Send receiver = node.receiver;
430 // prefix.ClassName.constructorName() 429 // prefix.ClassName.constructorName()
431 assert(treeElements[receiver.receiver] != null && 430 assert(treeElements[receiver.receiver] != null &&
432 treeElements[receiver.receiver].isPrefix); 431 treeElements[receiver.receiver].isPrefix);
433 prefix = receiver.receiver; 432 prefix = receiver.receiver;
434 className = receiver.selector; 433 className = receiver.selector;
435 constructorName = node.selector; 434 constructorName = node.selector;
436 } else { 435 } else {
437 Element receiverElement = treeElements[node.receiver]; 436 Element receiverElement = treeElements[node.receiver];
438 if (receiverElement != null && receiverElement.isPrefix) { 437 if (receiverElement != null && receiverElement.isPrefix) {
439 // prefix.ClassName() 438 // prefix.ClassName()
440 prefix = node.receiver; 439 prefix = node.receiver;
441 className = node.selector; 440 className = node.selector;
442 } else { 441 } else {
(...skipping 18 matching lines...) Expand all
461 } else if (className.isThis() || className.isSuper()) { 460 } else if (className.isThis() || className.isSuper()) {
462 // Do not rename super and this. 461 // Do not rename super and this.
463 } else if (className is Identifier) { 462 } else if (className is Identifier) {
464 makeElementPlaceholder(className, element.contextClass); 463 makeElementPlaceholder(className, element.contextClass);
465 } else { 464 } else {
466 throw "Bad type of constructor name $className"; 465 throw "Bad type of constructor name $className";
467 } 466 }
468 467
469 if (constructorName != null) { 468 if (constructorName != null) {
470 Element definingConstructor = findDefiningConstructor(element); 469 Element definingConstructor = findDefiningConstructor(element);
471 constructorPlaceholders.add(new ConstructorPlaceholder(constructorName, 470 constructorPlaceholders.add(
472 definingConstructor)); 471 new ConstructorPlaceholder(constructorName, definingConstructor));
473 tryMakePrivateIdentifier(constructorName, element); 472 tryMakePrivateIdentifier(constructorName, element);
474 } 473 }
475 } 474 }
476 475
477 void internalError(String reason, {Node node}) { 476 void internalError(String reason, {Node node}) {
478 reporter.internalError(node, reason); 477 reporter.internalError(node, reason);
479 } 478 }
480 479
481 visit(Node node) => (node == null) ? null : node.accept(this); 480 visit(Node node) => (node == null) ? null : node.accept(this);
482 481
483 visitNode(Node node) { node.visitChildren(this); } // We must go deeper. 482 visitNode(Node node) {
483 node.visitChildren(this);
484 } // We must go deeper.
484 485
485 visitNewExpression(NewExpression node) { 486 visitNewExpression(NewExpression node) {
486 Send send = node.send; 487 Send send = node.send;
487 DartType type = treeElements.getType(node); 488 DartType type = treeElements.getType(node);
488 assert(type != null); 489 assert(type != null);
489 Element constructor = treeElements[send]; 490 Element constructor = treeElements[send];
490 assert(constructor != null); 491 assert(constructor != null);
491 assert(send.receiver == null); 492 assert(send.receiver == null);
492 if (!Elements.isMalformed(constructor)) { 493 if (!Elements.isMalformed(constructor)) {
493 tryMakeConstructorPlaceholder(node.send.selector, constructor); 494 tryMakeConstructorPlaceholder(node.send.selector, constructor);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // that is needed to rename the construct properly. 538 // that is needed to rename the construct properly.
538 element = treeElements[send.selector]; 539 element = treeElements[send.selector];
539 } 540 }
540 tryMakePrivateIdentifier(send.selector, element); 541 tryMakePrivateIdentifier(send.selector, element);
541 if (element == null) { 542 if (element == null) {
542 if (send.receiver != null) tryMakeMemberPlaceholder(send.selector); 543 if (send.receiver != null) tryMakeMemberPlaceholder(send.selector);
543 } else if (!element.isMalformed) { 544 } else if (!element.isMalformed) {
544 if (Elements.isStaticOrTopLevel(element)) { 545 if (Elements.isStaticOrTopLevel(element)) {
545 // TODO(smok): Worth investigating why sometimes we get getter/setter 546 // TODO(smok): Worth investigating why sometimes we get getter/setter
546 // here and sometimes abstract field. 547 // here and sometimes abstract field.
547 assert(element.isClass || element is VariableElement || 548 assert(element.isClass ||
548 element.isAccessor || element.isAbstractField || 549 element is VariableElement ||
549 element.isFunction || element.isTypedef || 550 element.isAccessor ||
550 element is TypeVariableElement); 551 element.isAbstractField ||
552 element.isFunction ||
553 element.isTypedef ||
554 element is TypeVariableElement);
551 makeElementPlaceholder(send.selector, element); 555 makeElementPlaceholder(send.selector, element);
552 } else { 556 } else {
553 Identifier identifier = send.selector.asIdentifier(); 557 Identifier identifier = send.selector.asIdentifier();
554 if (identifier == null) { 558 if (identifier == null) {
555 // Handle optional function expression parameters with default values. 559 // Handle optional function expression parameters with default values.
556 identifier = send.selector.asFunctionExpression().name; 560 identifier = send.selector.asFunctionExpression().name;
557 } 561 }
558 if (Elements.isInstanceField(element)) { 562 if (Elements.isInstanceField(element)) {
559 tryMakeMemberPlaceholder(identifier); 563 tryMakeMemberPlaceholder(identifier);
560 } else { 564 } else {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 // definitionElement may be null if we're inside variable definitions 597 // definitionElement may be null if we're inside variable definitions
594 // of a function that is a parameter of another function. 598 // of a function that is a parameter of another function.
595 // TODO(smok): Fix this when resolver correctly deals with 599 // TODO(smok): Fix this when resolver correctly deals with
596 // such cases. 600 // such cases.
597 if (definitionElement == null) continue; 601 if (definitionElement == null) continue;
598 602
599 Send send = definition.asSend(); 603 Send send = definition.asSend();
600 Identifier identifier = definition is Identifier 604 Identifier identifier = definition is Identifier
601 ? definition 605 ? definition
602 : definition is Send 606 : definition is Send
603 ? (send.selector is Identifier 607 ? (send.selector is Identifier ? send.selector : null)
604 ? send.selector
605 : null)
606 : null; 608 : null;
607 609
608 tryMakePrivateIdentifier(identifier, definitionElement); 610 tryMakePrivateIdentifier(identifier, definitionElement);
609 611
610 if (send != null) { 612 if (send != null) {
611 // May get FunctionExpression here in definition.selector 613 // May get FunctionExpression here in definition.selector
612 // in case of A(int this.f()); 614 // in case of A(int this.f());
613 if (send.selector is Identifier) { 615 if (send.selector is Identifier) {
614 if (definitionElement.isInitializingFormal) { 616 if (definitionElement.isInitializingFormal) {
615 tryMakeMemberPlaceholder(send.selector); 617 tryMakeMemberPlaceholder(send.selector);
616 } else { 618 } else {
617 tryMakeLocalPlaceholder(definitionElement, send.selector); 619 tryMakeLocalPlaceholder(definitionElement, send.selector);
618 } 620 }
619 } else { 621 } else {
620 assert(send.selector is FunctionExpression); 622 assert(send.selector is FunctionExpression);
621 if (definitionElement.isInitializingFormal) { 623 if (definitionElement.isInitializingFormal) {
622 tryMakeMemberPlaceholder( 624 tryMakeMemberPlaceholder(send.selector.asFunctionExpression().name);
623 send.selector.asFunctionExpression().name);
624 } 625 }
625 } 626 }
626 } else if (definition is Identifier) { 627 } else if (definition is Identifier) {
627 tryMakeLocalPlaceholder(definitionElement, definition); 628 tryMakeLocalPlaceholder(definitionElement, definition);
628 } else if (definition is FunctionExpression) { 629 } else if (definition is FunctionExpression) {
629 // Skip, it will be processed in visitFunctionExpression. 630 // Skip, it will be processed in visitFunctionExpression.
630 } else { 631 } else {
631 internalError('Unexpected definition structure $definition'); 632 internalError('Unexpected definition structure $definition');
632 } 633 }
633 } 634 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 715
715 visitBlock(Block node) { 716 visitBlock(Block node) {
716 for (Node statement in node.statements.nodes) { 717 for (Node statement in node.statements.nodes) {
717 if (statement is VariableDefinitions) { 718 if (statement is VariableDefinitions) {
718 makeVarDeclarationTypePlaceholder(statement); 719 makeVarDeclarationTypePlaceholder(statement);
719 } 720 }
720 } 721 }
721 node.visitChildren(this); 722 node.visitChildren(this);
722 } 723 }
723 } 724 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/outputter.dart ('k') | pkg/compiler/lib/src/dart_backend/renamer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698