| 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 '../constants/values.dart' as values; | 7 import '../constants/values.dart' as values; |
| 8 import '../dart_types.dart' as types; | 8 import '../dart_types.dart' as types; |
| 9 import '../dart2jslib.dart' as dart2js; | 9 import '../dart2jslib.dart' as dart2js; |
| 10 import '../elements/elements.dart' as elements; | 10 import '../elements/elements.dart' as elements; |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 semicolon, | 833 semicolon, |
| 834 stmt.expression == null ? null : makeExpression(stmt.expression)); | 834 stmt.expression == null ? null : makeExpression(stmt.expression)); |
| 835 } else if (stmt is Switch) { | 835 } else if (stmt is Switch) { |
| 836 return new tree.SwitchStatement( | 836 return new tree.SwitchStatement( |
| 837 parenthesize(makeExpression(stmt.expression)), | 837 parenthesize(makeExpression(stmt.expression)), |
| 838 braceList('', stmt.cases.map(makeSwitchCase)), | 838 braceList('', stmt.cases.map(makeSwitchCase)), |
| 839 switchToken); | 839 switchToken); |
| 840 } else if (stmt is Try) { | 840 } else if (stmt is Try) { |
| 841 return new tree.TryStatement( | 841 return new tree.TryStatement( |
| 842 makeBlock(stmt.tryBlock), | 842 makeBlock(stmt.tryBlock), |
| 843 braceList('', stmt.catchBlocks.map(makeCatchBlock)), | 843 makeList(null, stmt.catchBlocks.map(makeCatchBlock)), |
| 844 stmt.finallyBlock == null ? null : makeBlock(stmt.finallyBlock), | 844 stmt.finallyBlock == null ? null : makeBlock(stmt.finallyBlock), |
| 845 tryToken, | 845 tryToken, |
| 846 finallyToken); | 846 stmt.finallyBlock == null ? null : finallyToken); |
| 847 } else if (stmt is VariableDeclarations) { | 847 } else if (stmt is VariableDeclarations) { |
| 848 return makeVariableDeclarations(stmt, useVar: true, endToken: semicolon); | 848 return makeVariableDeclarations(stmt, useVar: true, endToken: semicolon); |
| 849 } else if (stmt is While) { | 849 } else if (stmt is While) { |
| 850 return new tree.While( | 850 return new tree.While( |
| 851 parenthesize(makeExpression(stmt.condition)), | 851 parenthesize(makeExpression(stmt.condition)), |
| 852 makeStatement(stmt.body, shortIf: shortIf), | 852 makeStatement(stmt.body, shortIf: shortIf), |
| 853 whileToken); | 853 whileToken); |
| 854 } else { | 854 } else { |
| 855 throw "Unrecognized statement: ${stmt}"; | 855 throw "Unrecognized statement: ${stmt}"; |
| 856 } | 856 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 883 isFinal: decl.isFinal, | 883 isFinal: decl.isFinal, |
| 884 useVar: useVar && decl.type == null), | 884 useVar: useVar && decl.type == null), |
| 885 makeList(',', | 885 makeList(',', |
| 886 decl.declarations.map(makeVariableDeclaration), | 886 decl.declarations.map(makeVariableDeclaration), |
| 887 close: endToken)); | 887 close: endToken)); |
| 888 } | 888 } |
| 889 | 889 |
| 890 tree.CatchBlock makeCatchBlock(CatchBlock block) { | 890 tree.CatchBlock makeCatchBlock(CatchBlock block) { |
| 891 List<tree.VariableDefinitions> formals = []; | 891 List<tree.VariableDefinitions> formals = []; |
| 892 if (block.exceptionVar != null) { | 892 if (block.exceptionVar != null) { |
| 893 tree.Node exceptionName = makeIdentifier(block.exceptionVar.name); |
| 894 setElement(exceptionName, block.exceptionVar.element, block.exceptionVar); |
| 893 formals.add(new tree.VariableDefinitions( | 895 formals.add(new tree.VariableDefinitions( |
| 894 null, | 896 null, |
| 895 makeEmptyModifiers(), | 897 makeEmptyModifiers(), |
| 896 singleton(makeIdentifier(block.exceptionVar)))); | 898 singleton(exceptionName))); |
| 897 } | 899 } |
| 898 if (block.stackVar != null) { | 900 if (block.stackVar != null) { |
| 901 tree.Node stackTraceName = makeIdentifier(block.stackVar.name); |
| 902 setElement(stackTraceName, block.stackVar.element, block.stackVar); |
| 899 formals.add(new tree.VariableDefinitions( | 903 formals.add(new tree.VariableDefinitions( |
| 900 null, | 904 null, |
| 901 makeEmptyModifiers(), | 905 makeEmptyModifiers(), |
| 902 singleton(makeIdentifier(block.stackVar)))); | 906 singleton(stackTraceName))); |
| 903 } | 907 } |
| 904 return new tree.CatchBlock( | 908 return new tree.CatchBlock( |
| 905 block.onType == null ? null : makeType(block.onType), | 909 block.onType == null ? null : makeType(block.onType), |
| 906 block.exceptionVar == null ? null : argList(formals), | 910 block.exceptionVar == null ? null : argList(formals), |
| 907 makeBlock(block.body), | 911 makeBlock(block.body), |
| 908 block.onType == null ? null : onToken, | 912 block.onType == null ? null : onToken, |
| 909 block.exceptionVar == null ? null : catchToken); | 913 block.exceptionVar == null ? null : catchToken); |
| 910 } | 914 } |
| 911 | 915 |
| 912 tree.SwitchCase makeSwitchCase(SwitchCase caze) { | 916 tree.SwitchCase makeSwitchCase(SwitchCase caze) { |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 printStringChunk(chunk.previous), | 1334 printStringChunk(chunk.previous), |
| 1331 node); | 1335 node); |
| 1332 } else { | 1336 } else { |
| 1333 return node; | 1337 return node; |
| 1334 } | 1338 } |
| 1335 } | 1339 } |
| 1336 return printStringChunk(output.chunk); | 1340 return printStringChunk(output.chunk); |
| 1337 } | 1341 } |
| 1338 | 1342 |
| 1339 } | 1343 } |
| OLD | NEW |