| 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:dart_parser/src/parser.dart' show | 7 import 'package:dart_parser/src/parser.dart' show |
| 8 FormalParameterType, | 8 FormalParameterType, |
| 9 optional; | 9 optional; |
| 10 | 10 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 void push(Object node) { | 162 void push(Object node) { |
| 163 isFirstIdentifier = false; | 163 isFirstIdentifier = false; |
| 164 inInitializer = false; | 164 inInitializer = false; |
| 165 super.push(node); | 165 super.push(node); |
| 166 } | 166 } |
| 167 | 167 |
| 168 Expression popForValue() => toValue(pop()); | 168 Expression popForValue() => toValue(pop()); |
| 169 | 169 |
| 170 Expression popForEffect() => toEffect(pop()); | 170 Expression popForEffect() => toEffect(pop()); |
| 171 | 171 |
| 172 Expression popForValueIfNotNull(Object value) { |
| 173 return value == null ? null : popForValue(); |
| 174 } |
| 175 |
| 172 @override | 176 @override |
| 173 Expression toValue(Object node) { | 177 Expression toValue(Object node) { |
| 174 if (node is UnresolvedIdentifier) { | 178 if (node is UnresolvedIdentifier) { |
| 175 return throwNoSuchMethodError(node.name.name, new Arguments.empty(), | 179 return throwNoSuchMethodError(node.name.name, new Arguments.empty(), |
| 176 node.fileOffset, isGetter: true); | 180 node.fileOffset, isGetter: true); |
| 177 } else if (node is BuilderAccessor) { | 181 } else if (node is BuilderAccessor) { |
| 178 return node.buildSimpleRead(); | 182 return node.buildSimpleRead(); |
| 179 } else if (node is TypeVariableBuilder) { | 183 } else if (node is TypeVariableBuilder) { |
| 180 TypeParameterType type = node.buildTypesWithBuiltArguments(null); | 184 TypeParameterType type = node.buildTypesWithBuiltArguments(null); |
| 181 if (!isInstanceContext && type.parameter.parent is Class) { | 185 if (!isInstanceContext && type.parameter.parent is Class) { |
| (...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 @override | 1908 @override |
| 1905 void handleEmptyStatement(Token token) { | 1909 void handleEmptyStatement(Token token) { |
| 1906 debugEvent("EmptyStatement"); | 1910 debugEvent("EmptyStatement"); |
| 1907 push(new EmptyStatement()); | 1911 push(new EmptyStatement()); |
| 1908 } | 1912 } |
| 1909 | 1913 |
| 1910 @override | 1914 @override |
| 1911 void handleAssertStatement( | 1915 void handleAssertStatement( |
| 1912 Token assertKeyword, Token commaToken, Token semicolonToken) { | 1916 Token assertKeyword, Token commaToken, Token semicolonToken) { |
| 1913 debugEvent("AssertStatement"); | 1917 debugEvent("AssertStatement"); |
| 1914 Expression message = popIfNotNull(commaToken); | 1918 Expression message = popForValueIfNotNull(commaToken); |
| 1915 Expression condition = popForValue(); | 1919 Expression condition = popForValue(); |
| 1916 push(new AssertStatement(condition, message)); | 1920 push(new AssertStatement(condition, message)); |
| 1917 } | 1921 } |
| 1918 | 1922 |
| 1919 @override | 1923 @override |
| 1920 void endYieldStatement(Token yieldToken, Token starToken, Token endToken) { | 1924 void endYieldStatement(Token yieldToken, Token starToken, Token endToken) { |
| 1921 debugEvent("YieldStatement"); | 1925 debugEvent("YieldStatement"); |
| 1922 push(new YieldStatement(popForValue(), isYieldStar: starToken != null)); | 1926 push(new YieldStatement(popForValue(), isYieldStar: starToken != null)); |
| 1923 } | 1927 } |
| 1924 | 1928 |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2640 } else if (node is TypeDeclarationBuilder) { | 2644 } else if (node is TypeDeclarationBuilder) { |
| 2641 return node.name; | 2645 return node.name; |
| 2642 } else if (node is PrefixBuilder) { | 2646 } else if (node is PrefixBuilder) { |
| 2643 return node.name; | 2647 return node.name; |
| 2644 } else if (node is ThisPropertyAccessor) { | 2648 } else if (node is ThisPropertyAccessor) { |
| 2645 return node.name.name; | 2649 return node.name.name; |
| 2646 } else { | 2650 } else { |
| 2647 return internalError("Unhandled: ${node.runtimeType}"); | 2651 return internalError("Unhandled: ${node.runtimeType}"); |
| 2648 } | 2652 } |
| 2649 } | 2653 } |
| OLD | NEW |