OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library kernel.ast_to_text; | 4 library kernel.ast_to_text; |
5 | 5 |
6 import '../ast.dart'; | 6 import '../ast.dart'; |
7 import '../import_table.dart'; | 7 import '../import_table.dart'; |
8 | 8 |
9 class Namer<T> { | 9 class Namer<T> { |
10 int index = 0; | 10 int index = 0; |
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 | 1391 |
1392 visitVariableDeclaration(VariableDeclaration node) { | 1392 visitVariableDeclaration(VariableDeclaration node) { |
1393 writeIndentation(); | 1393 writeIndentation(); |
1394 writeVariableDeclaration(node, useVarKeyword: true); | 1394 writeVariableDeclaration(node, useVarKeyword: true); |
1395 endLine(';'); | 1395 endLine(';'); |
1396 } | 1396 } |
1397 | 1397 |
1398 visitFunctionDeclaration(FunctionDeclaration node) { | 1398 visitFunctionDeclaration(FunctionDeclaration node) { |
1399 writeIndentation(); | 1399 writeIndentation(); |
1400 writeWord('function'); | 1400 writeWord('function'); |
1401 writeFunction(node.function, name: getVariableName(node.variable)); | 1401 if (node.function != null) { |
| 1402 writeFunction(node.function, name: getVariableName(node.variable)); |
| 1403 } else { |
| 1404 writeWord(getVariableName(node.variable)); |
| 1405 endLine('...;'); |
| 1406 } |
1402 } | 1407 } |
1403 | 1408 |
1404 void writeVariableDeclaration(VariableDeclaration node, | 1409 void writeVariableDeclaration(VariableDeclaration node, |
1405 {bool useVarKeyword: false}) { | 1410 {bool useVarKeyword: false}) { |
1406 if (showOffsets) writeWord("[${node.fileOffset}]"); | 1411 if (showOffsets) writeWord("[${node.fileOffset}]"); |
1407 writeModifier(node.isFinal, 'final'); | 1412 writeModifier(node.isFinal, 'final'); |
1408 writeModifier(node.isConst, 'const'); | 1413 writeModifier(node.isConst, 'const'); |
1409 if (node.type != null) { | 1414 if (node.type != null) { |
1410 writeAnnotatedType(node.type, annotator?.annotateVariable(this, node)); | 1415 writeAnnotatedType(node.type, annotator?.annotateVariable(this, node)); |
1411 } | 1416 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 } | 1660 } |
1656 throw 'illegal ProcedureKind: $kind'; | 1661 throw 'illegal ProcedureKind: $kind'; |
1657 } | 1662 } |
1658 | 1663 |
1659 class ExpressionPrinter { | 1664 class ExpressionPrinter { |
1660 final Printer writeer; | 1665 final Printer writeer; |
1661 final int minimumPrecedence; | 1666 final int minimumPrecedence; |
1662 | 1667 |
1663 ExpressionPrinter(this.writeer, this.minimumPrecedence); | 1668 ExpressionPrinter(this.writeer, this.minimumPrecedence); |
1664 } | 1669 } |
OLD | NEW |