Chromium Code Reviews| 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 String emitCode( | 7 String emitCode( |
| 8 Unparser unparser, | 8 Unparser unparser, |
| 9 Map<LibraryElement, String> imports, | 9 Map<LibraryElement, String> imports, |
| 10 Iterable<Node> topLevelNodes, | 10 Iterable<Node> topLevelNodes, |
| 11 Map<ClassNode, Iterable<Node>> classMembers) { | 11 Map<ClassNode, Iterable<Node>> classMembers) { |
| 12 imports.forEach((libraryElement, prefix) { | 12 imports.forEach((libraryElement, prefix) { |
| 13 unparser.unparseImportTag('${libraryElement.canonicalUri}', prefix); | 13 unparser.unparseImportTag('${libraryElement.canonicalUri}', prefix); |
| 14 }); | 14 }); |
| 15 | 15 |
| 16 | |
|
ahe
2013/08/12 15:43:21
Extra line.
| |
| 17 bool isTopLevelMain(Node node) => | |
|
ahe
2013/08/12 15:43:21
In dart2js, we tend to perfer '{ return expr; }' w
ahe
2013/08/12 15:43:21
I'm not at all sure about this method. What is it
| |
| 18 (node is FunctionExpression && | |
|
ahe
2013/08/12 15:43:21
FunctionExpression functionExpression = node.asFun
| |
| 19 (node as FunctionExpression).name.asIdentifier().source. | |
|
ahe
2013/08/12 15:43:21
....source == const SourceString('main')
| |
| 20 stringValue == 'main'); | |
| 21 | |
| 16 for (final node in topLevelNodes) { | 22 for (final node in topLevelNodes) { |
| 17 if (node is ClassNode) { | 23 if ((unparser is MirrorRenamerUnparser) && isTopLevelMain(node)) { |
| 24 (unparser as MirrorRenamerUnparser).unparseTopLevelMain(node); | |
|
ahe
2013/08/12 15:43:21
Don't use casts, they are slow and unnecessary. In
| |
| 25 } else if (node is ClassNode) { | |
| 18 // TODO(smok): Filter out default constructors here. | 26 // TODO(smok): Filter out default constructors here. |
| 19 unparser.unparseClassWithBody(node, classMembers[node]); | 27 unparser.unparseClassWithBody(node, classMembers[node]); |
| 20 } else { | 28 } else { |
| 21 unparser.unparse(node); | 29 unparser.unparse(node); |
| 22 } | 30 } |
| 23 } | 31 } |
| 24 } | 32 } |
| OLD | NEW |