OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library dart_tree_printer; | 5 library dart_tree_printer; |
6 | 6 |
7 import 'dart_printer.dart'; | 7 import 'dart_printer.dart'; |
8 import '../tree/tree.dart' as tree; | 8 import '../tree/tree.dart' as tree; |
9 import '../scanner/scannerlib.dart'; | 9 import '../scanner/scannerlib.dart'; |
10 import '../util/util.dart'; | 10 import '../util/util.dart'; |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 } else { | 676 } else { |
677 left = makeVariableDeclarations(stmt.leftHandValue); | 677 left = makeVariableDeclarations(stmt.leftHandValue); |
678 } | 678 } |
679 return new tree.ForIn( | 679 return new tree.ForIn( |
680 left, | 680 left, |
681 makeExpression(stmt.expression), | 681 makeExpression(stmt.expression), |
682 makeStatement(stmt.body, shortIf: shortIf), | 682 makeStatement(stmt.body, shortIf: shortIf), |
683 forToken, | 683 forToken, |
684 inToken); | 684 inToken); |
685 } else if (stmt is FunctionDeclaration) { | 685 } else if (stmt is FunctionDeclaration) { |
686 return new tree.FunctionDeclaration(new tree.FunctionExpression( | 686 tree.FunctionExpression function = new tree.FunctionExpression( |
687 stmt.name != null ? makeIdentifier(stmt.name) : null, | 687 stmt.name != null ? makeIdentifier(stmt.name) : null, |
688 makeParameters(stmt.parameters), | 688 makeParameters(stmt.parameters), |
689 makeFunctionBody(stmt.body), | 689 makeFunctionBody(stmt.body), |
690 stmt.returnType != null ? makeType(stmt.returnType) : null, | 690 stmt.returnType != null ? makeType(stmt.returnType) : null, |
691 makeEmptyModifiers(), // TODO(asgerf): Function modifiers? | 691 makeEmptyModifiers(), // TODO(asgerf): Function modifiers? |
692 null, // initializers | 692 null, // initializers |
693 null)); // get/set | 693 null); // get/set |
| 694 setElement(function, stmt.function.element, stmt); |
| 695 return new tree.FunctionDeclaration(function); |
694 } else if (stmt is If) { | 696 } else if (stmt is If) { |
695 if (stmt.elseStatement == null || isEmptyStatement(stmt.elseStatement)) { | 697 if (stmt.elseStatement == null || isEmptyStatement(stmt.elseStatement)) { |
696 tree.Node node = new tree.If( | 698 tree.Node node = new tree.If( |
697 parenthesize(makeExpression(stmt.condition)), | 699 parenthesize(makeExpression(stmt.condition)), |
698 makeStatement(stmt.thenStatement), | 700 makeStatement(stmt.thenStatement), |
699 null, // else statement | 701 null, // else statement |
700 ifToken, | 702 ifToken, |
701 null); // else token | 703 null); // else token |
702 if (shortIf) | 704 if (shortIf) |
703 return node; | 705 return node; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 printStringChunk(chunk.previous), | 1014 printStringChunk(chunk.previous), |
1013 node); | 1015 node); |
1014 } else { | 1016 } else { |
1015 return node; | 1017 return node; |
1016 } | 1018 } |
1017 } | 1019 } |
1018 return printStringChunk(output.chunk); | 1020 return printStringChunk(output.chunk); |
1019 } | 1021 } |
1020 | 1022 |
1021 } | 1023 } |
OLD | NEW |