| 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.analyzer.ast_builder; | 5 library fasta.analyzer.ast_builder; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; | 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; |
| 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; | 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; |
| 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; | 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 push(identifier); | 161 push(identifier); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 void endSend(Token token) { | 165 void endSend(Token token) { |
| 166 debugEvent("Send"); | 166 debugEvent("Send"); |
| 167 MethodInvocation arguments = pop(); | 167 MethodInvocation arguments = pop(); |
| 168 TypeArgumentList typeArguments = pop(); | 168 TypeArgumentList typeArguments = pop(); |
| 169 if (arguments != null) { | 169 if (arguments != null) { |
| 170 if (typeArguments != null) { | 170 doInvocation(token, typeArguments, arguments); |
| 171 arguments.typeArguments = typeArguments; | |
| 172 } | |
| 173 doInvocation(token, arguments); | |
| 174 } else { | 171 } else { |
| 175 doPropertyGet(token); | 172 doPropertyGet(token); |
| 176 } | 173 } |
| 177 } | 174 } |
| 178 | 175 |
| 179 void doInvocation(Token token, MethodInvocation arguments) { | 176 void doInvocation( |
| 177 Token token, TypeArgumentList typeArguments, MethodInvocation arguments) { |
| 180 Expression receiver = pop(); | 178 Expression receiver = pop(); |
| 181 if (receiver is SimpleIdentifier) { | 179 if (receiver is SimpleIdentifier) { |
| 182 arguments.methodName = receiver; | 180 arguments.methodName = receiver; |
| 181 if (typeArguments != null) { |
| 182 arguments.typeArguments = typeArguments; |
| 183 } |
| 183 push(arguments); | 184 push(arguments); |
| 184 } else { | 185 } else { |
| 185 internalError("Unhandled receiver in send: ${receiver.runtimeType}"); | 186 push(ast.functionExpressionInvocation( |
| 187 receiver, typeArguments, arguments.argumentList)); |
| 186 } | 188 } |
| 187 } | 189 } |
| 188 | 190 |
| 189 void doPropertyGet(Token token) {} | 191 void doPropertyGet(Token token) {} |
| 190 | 192 |
| 191 void endExpressionStatement(Token token) { | 193 void endExpressionStatement(Token token) { |
| 192 debugEvent("ExpressionStatement"); | 194 debugEvent("ExpressionStatement"); |
| 193 push(ast.expressionStatement(pop(), toAnalyzerToken(token))); | 195 push(ast.expressionStatement(pop(), toAnalyzerToken(token))); |
| 194 } | 196 } |
| 195 | 197 |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 } else { | 1169 } else { |
| 1168 // TODO(scheglov): Report error. | 1170 // TODO(scheglov): Report error. |
| 1169 internalError("Invalid modifier ($value). Report an error."); | 1171 internalError("Invalid modifier ($value). Report an error."); |
| 1170 } | 1172 } |
| 1171 } | 1173 } |
| 1172 | 1174 |
| 1173 List<Annotation> metadata = pop(); | 1175 List<Annotation> metadata = pop(); |
| 1174 // TODO(paulberry): capture doc comments. See dartbug.com/28851. | 1176 // TODO(paulberry): capture doc comments. See dartbug.com/28851. |
| 1175 Comment comment = null; | 1177 Comment comment = null; |
| 1176 Token period; | 1178 Token period; |
| 1177 void unnamedConstructor(SimpleIdentifier returnType, SimpleIdentifier name)
{ | 1179 void unnamedConstructor( |
| 1180 SimpleIdentifier returnType, SimpleIdentifier name) { |
| 1178 push(ast.constructorDeclaration( | 1181 push(ast.constructorDeclaration( |
| 1179 comment, | 1182 comment, |
| 1180 metadata, | 1183 metadata, |
| 1181 toAnalyzerToken(externalKeyword), | 1184 toAnalyzerToken(externalKeyword), |
| 1182 toAnalyzerToken(constKeyword), | 1185 toAnalyzerToken(constKeyword), |
| 1183 toAnalyzerToken(factoryKeyword), | 1186 toAnalyzerToken(factoryKeyword), |
| 1184 returnType, | 1187 returnType, |
| 1185 toAnalyzerToken(period), | 1188 toAnalyzerToken(period), |
| 1186 name, | 1189 name, |
| 1187 parameters, | 1190 parameters, |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 } | 1400 } |
| 1398 | 1401 |
| 1399 /// Data structure placed on the stack to represent the keyword "operator" | 1402 /// Data structure placed on the stack to represent the keyword "operator" |
| 1400 /// followed by a token. | 1403 /// followed by a token. |
| 1401 class _OperatorName { | 1404 class _OperatorName { |
| 1402 final Token operatorKeyword; | 1405 final Token operatorKeyword; |
| 1403 final SimpleIdentifier name; | 1406 final SimpleIdentifier name; |
| 1404 | 1407 |
| 1405 _OperatorName(this.operatorKeyword, this.name); | 1408 _OperatorName(this.operatorKeyword, this.name); |
| 1406 } | 1409 } |
| OLD | NEW |