| OLD | NEW |
| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 return statement; | 105 return statement; |
| 106 } | 106 } |
| 107 | 107 |
| 108 NodeList statements = block.statements; | 108 NodeList statements = block.statements; |
| 109 LinkBuilder<Statement> builder = new LinkBuilder<Statement>(); | 109 LinkBuilder<Statement> builder = new LinkBuilder<Statement>(); |
| 110 for (Statement statement in statements.nodes) { | 110 for (Statement statement in statements.nodes) { |
| 111 if (!shouldOmit(statement)) { | 111 if (!shouldOmit(statement)) { |
| 112 builder.addLast(visit(rewriteStatement(statement))); | 112 builder.addLast(visit(rewriteStatement(statement))); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 return new Block(rewriteNodeList(statements, builder.toLink())); | 115 return new Block(rewriteNodeList(statements, builder.toLink()), |
| 116 block.declarations); |
| 116 } | 117 } |
| 117 } | 118 } |
| 118 | 119 |
| 119 class DartBackend extends Backend { | 120 class DartBackend extends Backend { |
| 120 final List<CompilerTask> tasks; | 121 final List<CompilerTask> tasks; |
| 121 final bool forceStripTypes; | 122 final bool forceStripTypes; |
| 122 final bool stripAsserts; | 123 final bool stripAsserts; |
| 123 // TODO(antonm): make available from command-line options. | 124 // TODO(antonm): make available from command-line options. |
| 124 final bool outputAst = false; | 125 final bool outputAst = false; |
| 125 final Map<Node, String> renames; | 126 final Map<Node, String> renames; |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 } | 629 } |
| 629 | 630 |
| 630 compareElements(e0, e1) { | 631 compareElements(e0, e1) { |
| 631 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); | 632 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); |
| 632 if (result != 0) return result; | 633 if (result != 0) return result; |
| 633 return compareBy((e) => e.position().charOffset)(e0, e1); | 634 return compareBy((e) => e.position().charOffset)(e0, e1); |
| 634 } | 635 } |
| 635 | 636 |
| 636 List<Element> sortElements(Iterable<Element> elements) => | 637 List<Element> sortElements(Iterable<Element> elements) => |
| 637 sorted(elements, compareElements); | 638 sorted(elements, compareElements); |
| OLD | NEW |