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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart

Issue 12294028: Fix warnings spotted by dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | Annotate | Revision Log
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 // TODO(ahe): This class is simply wrong. This backend should use 7 // TODO(ahe): This class is simply wrong. This backend should use
8 // elements when it can, not AST nodes. Perhaps a [Map<Element, 8 // elements when it can, not AST nodes. Perhaps a [Map<Element,
9 // TreeElements>] is what is needed. 9 // TreeElements>] is what is needed.
10 class ElementAst { 10 class ElementAst {
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 final sortedTopLevels = sortElements(topLevelElements); 433 final sortedTopLevels = sortElements(topLevelElements);
434 final sortedClassMembers = new Map<ClassElement, List<Element>>(); 434 final sortedClassMembers = new Map<ClassElement, List<Element>>();
435 classMembers.forEach((classElement, members) { 435 classMembers.forEach((classElement, members) {
436 sortedClassMembers[classElement] = sortElements(members); 436 sortedClassMembers[classElement] = sortElements(members);
437 }); 437 });
438 438
439 if (outputAst) { 439 if (outputAst) {
440 // TODO(antonm): Ideally XML should be a separate backend. 440 // TODO(antonm): Ideally XML should be a separate backend.
441 // TODO(antonm): obey renames and minification, at least as an option. 441 // TODO(antonm): obey renames and minification, at least as an option.
442 StringBuffer sb = new StringBuffer(); 442 StringBuffer sb = new StringBuffer();
443 outputElement(element) { sb.add(parse(element).toDebugString()); } 443 outputElement(element) { sb.write(parse(element).toDebugString()); }
444 444
445 // Emit XML for AST instead of the program. 445 // Emit XML for AST instead of the program.
446 for (final topLevel in sortedTopLevels) { 446 for (final topLevel in sortedTopLevels) {
447 if (topLevel.isClass()) { 447 if (topLevel.isClass()) {
448 // TODO(antonm): add some class info. 448 // TODO(antonm): add some class info.
449 sortedClassMembers[topLevel].forEach(outputElement); 449 sortedClassMembers[topLevel].forEach(outputElement);
450 } else { 450 } else {
451 outputElement(topLevel); 451 outputElement(topLevel);
452 } 452 }
453 } 453 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 log(String message) => compiler.log('[DartBackend] $message'); 495 log(String message) => compiler.log('[DartBackend] $message');
496 } 496 }
497 497
498 class EmitterUnparser extends Unparser { 498 class EmitterUnparser extends Unparser {
499 final Map<Node, String> renames; 499 final Map<Node, String> renames;
500 500
501 EmitterUnparser(this.renames); 501 EmitterUnparser(this.renames);
502 502
503 visit(Node node) { 503 visit(Node node) {
504 if (node != null && renames.containsKey(node)) { 504 if (node != null && renames.containsKey(node)) {
505 sb.add(renames[node]); 505 sb.write(renames[node]);
506 } else { 506 } else {
507 super.visit(node); 507 super.visit(node);
508 } 508 }
509 } 509 }
510 510
511 unparseSendReceiver(Send node, {bool spacesNeeded: false}) { 511 unparseSendReceiver(Send node, {bool spacesNeeded: false}) {
512 // TODO(smok): Remove ugly hack for library prefices. 512 // TODO(smok): Remove ugly hack for library prefices.
513 if (node.receiver != null && renames[node.receiver] == '') return; 513 if (node.receiver != null && renames[node.receiver] == '') return;
514 super.unparseSendReceiver(node, spacesNeeded: spacesNeeded); 514 super.unparseSendReceiver(node, spacesNeeded: spacesNeeded);
515 } 515 }
516 516
517 unparseFunctionName(Node name) { 517 unparseFunctionName(Node name) {
518 if (name != null && renames.containsKey(name)) { 518 if (name != null && renames.containsKey(name)) {
519 sb.add(renames[name]); 519 sb.write(renames[name]);
520 } else { 520 } else {
521 super.unparseFunctionName(name); 521 super.unparseFunctionName(name);
522 } 522 }
523 } 523 }
524 } 524 }
525 525
526 526
527 /** 527 /**
528 * Some elements are not recorded by resolver now, 528 * Some elements are not recorded by resolver now,
529 * for example, typedefs or classes which are only 529 * for example, typedefs or classes which are only
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 } 583 }
584 584
585 compareElements(e0, e1) { 585 compareElements(e0, e1) {
586 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); 586 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1);
587 if (result != 0) return result; 587 if (result != 0) return result;
588 return compareBy((e) => e.position().charOffset)(e0, e1); 588 return compareBy((e) => e.position().charOffset)(e0, e1);
589 } 589 }
590 590
591 List<Element> sortElements(Iterable<Element> elements) => 591 List<Element> sortElements(Iterable<Element> elements) =>
592 sorted(elements, compareElements); 592 sorted(elements, compareElements);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698