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:kernel/ast.dart' | 7 import 'package:kernel/ast.dart' |
8 hide InvalidExpression, InvalidInitializer, InvalidStatement; | 8 hide InvalidExpression, InvalidInitializer, InvalidStatement; |
9 | 9 |
10 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; | 10 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; |
(...skipping 2745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2756 // Since kernel only has asserts in statment form, we convert it to an | 2756 // Since kernel only has asserts in statment form, we convert it to an |
2757 // expression by wrapping it in an anonymous function which we call | 2757 // expression by wrapping it in an anonymous function which we call |
2758 // immediately. | 2758 // immediately. |
2759 // | 2759 // |
2760 // Additionally, kernel has no initializer that evaluates an expression, | 2760 // Additionally, kernel has no initializer that evaluates an expression, |
2761 // but it does have `LocalInitializer` which requires a variable declartion. | 2761 // but it does have `LocalInitializer` which requires a variable declartion. |
2762 // | 2762 // |
2763 // So we produce an initializer like this: | 2763 // So we produce an initializer like this: |
2764 // | 2764 // |
2765 // var #t0 = (() { statement; }) () | 2765 // var #t0 = (() { statement; }) () |
2766 return new LocalInitializer(new VariableDeclaration.forValue( | 2766 return new KernelAssertInitializer( |
2767 buildMethodInvocation( | 2767 new VariableDeclaration.forValue(buildMethodInvocation( |
2768 new FunctionExpression(new FunctionNode(statement)), | 2768 new FunctionExpression(new FunctionNode(statement)), |
2769 callName, | 2769 callName, |
2770 new Arguments.empty(), | 2770 new Arguments.empty(), |
2771 statement.fileOffset, | 2771 statement.fileOffset, |
2772 isConstantExpression: true, | 2772 isConstantExpression: true, |
2773 isImplicitCall: true))); | 2773 isImplicitCall: true)), |
| 2774 statement); |
2774 } | 2775 } |
2775 | 2776 |
2776 @override | 2777 @override |
2777 void endYieldStatement(Token yieldToken, Token starToken, Token endToken) { | 2778 void endYieldStatement(Token yieldToken, Token starToken, Token endToken) { |
2778 debugEvent("YieldStatement"); | 2779 debugEvent("YieldStatement"); |
2779 push(new KernelYieldStatement(popForValue(), isYieldStar: starToken != null) | 2780 push(new KernelYieldStatement(popForValue(), isYieldStar: starToken != null) |
2780 ..fileOffset = yieldToken.charOffset); | 2781 ..fileOffset = yieldToken.charOffset); |
2781 } | 2782 } |
2782 | 2783 |
2783 @override | 2784 @override |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3800 return AsyncMarker.Async; | 3801 return AsyncMarker.Async; |
3801 } else { | 3802 } else { |
3802 assert(identical(starToken.stringValue, "*")); | 3803 assert(identical(starToken.stringValue, "*")); |
3803 return AsyncMarker.AsyncStar; | 3804 return AsyncMarker.AsyncStar; |
3804 } | 3805 } |
3805 } else { | 3806 } else { |
3806 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", | 3807 return unhandled(asyncToken.lexeme, "asyncMarkerFromTokens", |
3807 asyncToken.charOffset, null); | 3808 asyncToken.charOffset, null); |
3808 } | 3809 } |
3809 } | 3810 } |
OLD | NEW |