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 | 4 |
5 library fasta.body_builder; | 5 library fasta.body_builder; |
6 | 6 |
7 import 'package:front_end/src/fasta/parser/parser.dart' | 7 import 'package:front_end/src/fasta/parser/parser.dart' |
8 show FormalParameterType, optional; | 8 show FormalParameterType, optional; |
9 | 9 |
10 import 'package:front_end/src/fasta/parser/error_kind.dart' show ErrorKind; | 10 import 'package:front_end/src/fasta/parser/error_kind.dart' show ErrorKind; |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 push(new StringConcatenation(expressions ?? parts)); | 834 push(new StringConcatenation(expressions ?? parts)); |
835 } | 835 } |
836 | 836 |
837 @override | 837 @override |
838 void handleLiteralInt(Token token) { | 838 void handleLiteralInt(Token token) { |
839 debugEvent("LiteralInt"); | 839 debugEvent("LiteralInt"); |
840 push(new IntLiteral(int.parse(token.value))); | 840 push(new IntLiteral(int.parse(token.value))); |
841 } | 841 } |
842 | 842 |
843 @override | 843 @override |
| 844 void endExpressionFunctionBody(Token arrowToken, Token endToken) { |
| 845 debugEvent("ExpressionFunctionBody"); |
| 846 endReturnStatement(true, arrowToken, endToken); |
| 847 } |
| 848 |
| 849 @override |
844 void endReturnStatement( | 850 void endReturnStatement( |
845 bool hasExpression, Token beginToken, Token endToken) { | 851 bool hasExpression, Token beginToken, Token endToken) { |
846 debugEvent("ReturnStatement"); | 852 debugEvent("ReturnStatement"); |
847 Expression expression = hasExpression ? popForValue() : null; | 853 Expression expression = hasExpression ? popForValue() : null; |
848 if (expression != null && inConstructor) { | 854 if (expression != null && inConstructor) { |
849 push(buildCompileTimeErrorStatement( | 855 push(buildCompileTimeErrorStatement( |
850 "Can't return from a constructor.", beginToken.charOffset)); | 856 "Can't return from a constructor.", beginToken.charOffset)); |
851 } else { | 857 } else { |
852 push(new ReturnStatement(expression)); | 858 push(new ReturnStatement(expression)); |
853 } | 859 } |
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2672 } else if (node is TypeDeclarationBuilder) { | 2678 } else if (node is TypeDeclarationBuilder) { |
2673 return node.name; | 2679 return node.name; |
2674 } else if (node is PrefixBuilder) { | 2680 } else if (node is PrefixBuilder) { |
2675 return node.name; | 2681 return node.name; |
2676 } else if (node is ThisPropertyAccessor) { | 2682 } else if (node is ThisPropertyAccessor) { |
2677 return node.name.name; | 2683 return node.name.name; |
2678 } else { | 2684 } else { |
2679 return internalError("Unhandled: ${node.runtimeType}"); | 2685 return internalError("Unhandled: ${node.runtimeType}"); |
2680 } | 2686 } |
2681 } | 2687 } |
OLD | NEW |