| 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 import '../type_propagation/type_propagation.dart'; | 8 import '../type_propagation/type_propagation.dart'; |
| 9 | 9 |
| 10 class Namer<T> { | 10 class Namer<T> { |
| (...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 writeWord('null'); | 962 writeWord('null'); |
| 963 } | 963 } |
| 964 | 964 |
| 965 visitLet(Let node) { | 965 visitLet(Let node) { |
| 966 writeWord('let'); | 966 writeWord('let'); |
| 967 writeVariableDeclaration(node.variable); | 967 writeVariableDeclaration(node.variable); |
| 968 writeSpaced('in'); | 968 writeSpaced('in'); |
| 969 writeExpression(node.body); | 969 writeExpression(node.body); |
| 970 } | 970 } |
| 971 | 971 |
| 972 visitBlockExpression(BlockExpression node) { | |
| 973 int savedColumn = column; | |
| 974 | |
| 975 var savedState = state; | |
| 976 int savedIndentation = indentation; | |
| 977 String spaces = ' ' * savedColumn; | |
| 978 | |
| 979 writeWord('|{'); | |
| 980 endLine(); | |
| 981 state = SPACE; | |
| 982 indentation = (savedColumn + 4) ~/ 2; | |
| 983 for (var statement in node.body.statements) { | |
| 984 statement.accept(this); | |
| 985 } | |
| 986 write('$spaces => '); | |
| 987 writeExpression(node.value); | |
| 988 endLine(); | |
| 989 write('$spaces'); | |
| 990 | |
| 991 indentation = savedIndentation; | |
| 992 state = savedState; | |
| 993 column = savedColumn; | |
| 994 | |
| 995 write('}|'); | |
| 996 } | |
| 997 | |
| 998 defaultExpression(Expression node) { | 972 defaultExpression(Expression node) { |
| 999 writeWord('${node.runtimeType}'); | 973 writeWord('${node.runtimeType}'); |
| 1000 } | 974 } |
| 1001 | 975 |
| 1002 visitVariableGet(VariableGet node) { | 976 visitVariableGet(VariableGet node) { |
| 1003 writeVariableReference(node.variable); | 977 writeVariableReference(node.variable); |
| 1004 } | 978 } |
| 1005 | 979 |
| 1006 visitVariableSet(VariableSet node) { | 980 visitVariableSet(VariableSet node) { |
| 1007 writeVariableReference(node.variable); | 981 writeVariableReference(node.variable); |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 int visitVariableSet(VariableSet node) => EXPRESSION; | 1498 int visitVariableSet(VariableSet node) => EXPRESSION; |
| 1525 int visitPropertyGet(PropertyGet node) => PRIMARY; | 1499 int visitPropertyGet(PropertyGet node) => PRIMARY; |
| 1526 int visitPropertySet(PropertySet node) => EXPRESSION; | 1500 int visitPropertySet(PropertySet node) => EXPRESSION; |
| 1527 int visitSuperPropertyGet(SuperPropertyGet node) => PRIMARY; | 1501 int visitSuperPropertyGet(SuperPropertyGet node) => PRIMARY; |
| 1528 int visitSuperPropertySet(SuperPropertySet node) => EXPRESSION; | 1502 int visitSuperPropertySet(SuperPropertySet node) => EXPRESSION; |
| 1529 int visitDirectPropertyGet(DirectPropertyGet node) => PRIMARY; | 1503 int visitDirectPropertyGet(DirectPropertyGet node) => PRIMARY; |
| 1530 int visitDirectPropertySet(DirectPropertySet node) => EXPRESSION; | 1504 int visitDirectPropertySet(DirectPropertySet node) => EXPRESSION; |
| 1531 int visitStaticGet(StaticGet node) => PRIMARY; | 1505 int visitStaticGet(StaticGet node) => PRIMARY; |
| 1532 int visitStaticSet(StaticSet node) => EXPRESSION; | 1506 int visitStaticSet(StaticSet node) => EXPRESSION; |
| 1533 int visitLet(Let node) => EXPRESSION; | 1507 int visitLet(Let node) => EXPRESSION; |
| 1534 int visitBlockExpression(BlockExpression node) => EXPRESSION; | |
| 1535 } | 1508 } |
| 1536 | 1509 |
| 1537 String procedureKindToString(ProcedureKind kind) { | 1510 String procedureKindToString(ProcedureKind kind) { |
| 1538 switch (kind) { | 1511 switch (kind) { |
| 1539 case ProcedureKind.Method: | 1512 case ProcedureKind.Method: |
| 1540 return 'method'; | 1513 return 'method'; |
| 1541 case ProcedureKind.Getter: | 1514 case ProcedureKind.Getter: |
| 1542 return 'get'; | 1515 return 'get'; |
| 1543 case ProcedureKind.Setter: | 1516 case ProcedureKind.Setter: |
| 1544 return 'set'; | 1517 return 'set'; |
| 1545 case ProcedureKind.Operator: | 1518 case ProcedureKind.Operator: |
| 1546 return 'operator'; | 1519 return 'operator'; |
| 1547 case ProcedureKind.Factory: | 1520 case ProcedureKind.Factory: |
| 1548 return 'factory'; | 1521 return 'factory'; |
| 1549 } | 1522 } |
| 1550 throw 'illegal ProcedureKind: $kind'; | 1523 throw 'illegal ProcedureKind: $kind'; |
| 1551 } | 1524 } |
| 1552 | 1525 |
| 1553 class ExpressionPrinter { | 1526 class ExpressionPrinter { |
| 1554 final Printer writeer; | 1527 final Printer writeer; |
| 1555 final int minimumPrecedence; | 1528 final int minimumPrecedence; |
| 1556 | 1529 |
| 1557 ExpressionPrinter(this.writeer, this.minimumPrecedence); | 1530 ExpressionPrinter(this.writeer, this.minimumPrecedence); |
| 1558 } | 1531 } |
| OLD | NEW |