| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.parser.node_listener; | 5 library dart2js.parser.node_listener; |
| 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; | 8 show FormalParameterType, MemberKind; |
| 9 import 'package:front_end/src/fasta/parser/identifier_context.dart' | 9 import 'package:front_end/src/fasta/parser/identifier_context.dart' |
| 10 show IdentifierContext; | 10 show IdentifierContext; |
| 11 import 'package:front_end/src/fasta/scanner.dart' show SymbolToken, Token; | 11 import 'package:front_end/src/fasta/scanner.dart' show SymbolToken, Token; |
| 12 import 'package:front_end/src/scanner/token.dart' show TokenType; | 12 import 'package:front_end/src/scanner/token.dart' show TokenType; |
| 13 | 13 |
| 14 import '../common.dart'; | 14 import '../common.dart'; |
| 15 import '../elements/elements.dart' show CompilationUnitElement; | 15 import '../elements/elements.dart' show CompilationUnitElement; |
| 16 import '../tree/tree.dart'; | 16 import '../tree/tree.dart'; |
| 17 import '../util/util.dart' show Link; | 17 import '../util/util.dart' show Link; |
| 18 import 'element_listener.dart' show ElementListener, ScannerOptions; | 18 import 'element_listener.dart' show ElementListener, ScannerOptions; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 NodeList formals = popNode(); | 222 NodeList formals = popNode(); |
| 223 NodeList typeVariables = popNode(); | 223 NodeList typeVariables = popNode(); |
| 224 Identifier name = popNode(); | 224 Identifier name = popNode(); |
| 225 TypeAnnotation type = popNode(); | 225 TypeAnnotation type = popNode(); |
| 226 Modifiers modifiers = popNode(); | 226 Modifiers modifiers = popNode(); |
| 227 pushNode(new FunctionExpression(name, typeVariables, formals, body, type, | 227 pushNode(new FunctionExpression(name, typeVariables, formals, body, type, |
| 228 modifiers, null, getOrSet, asyncModifier)); | 228 modifiers, null, getOrSet, asyncModifier)); |
| 229 } | 229 } |
| 230 | 230 |
| 231 @override | 231 @override |
| 232 void endFormalParameter(Token covariantKeyword, Token thisKeyword, | 232 void endFormalParameter(Token thisKeyword, Token nameToken, |
| 233 Token nameToken, FormalParameterType kind) { | 233 FormalParameterType kind, MemberKind memberKind) { |
| 234 Expression name = popNode(); | 234 Expression name = popNode(); |
| 235 if (thisKeyword != null) { | 235 if (thisKeyword != null) { |
| 236 Identifier thisIdentifier = new Identifier(thisKeyword); | 236 Identifier thisIdentifier = new Identifier(thisKeyword); |
| 237 if (name.asSend() == null) { | 237 if (name.asSend() == null) { |
| 238 name = new Send(thisIdentifier, name); | 238 name = new Send(thisIdentifier, name); |
| 239 } else { | 239 } else { |
| 240 name = name.asSend().copyWithReceiver(thisIdentifier, false); | 240 name = name.asSend().copyWithReceiver(thisIdentifier, false); |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 TypeAnnotation type = popNode(); | 243 TypeAnnotation type = popNode(); |
| 244 Modifiers modifiers = popNode(); | 244 Modifiers modifiers = popNode(); |
| 245 NodeList metadata = popNode(); | 245 NodeList metadata = popNode(); |
| 246 pushNode(new VariableDefinitions.forParameter( | 246 pushNode(new VariableDefinitions.forParameter( |
| 247 metadata, type, modifiers, new NodeList.singleton(name))); | 247 metadata, type, modifiers, new NodeList.singleton(name))); |
| 248 } | 248 } |
| 249 | 249 |
| 250 @override | 250 @override |
| 251 void endFormalParameters(int count, Token beginToken, Token endToken) { | 251 void endFormalParameters( |
| 252 int count, Token beginToken, Token endToken, MemberKind kind) { |
| 252 pushNode(makeNodeList(count, beginToken, endToken, ",")); | 253 pushNode(makeNodeList(count, beginToken, endToken, ",")); |
| 253 } | 254 } |
| 254 | 255 |
| 255 @override | 256 @override |
| 256 void handleNoFormalParameters(Token token) { | 257 void handleNoFormalParameters(Token token, MemberKind kind) { |
| 257 pushNode(null); | 258 pushNode(null); |
| 258 } | 259 } |
| 259 | 260 |
| 260 @override | 261 @override |
| 261 void endArguments(int count, Token beginToken, Token endToken) { | 262 void endArguments(int count, Token beginToken, Token endToken) { |
| 262 pushNode(makeNodeList(count, beginToken, endToken, ",")); | 263 pushNode(makeNodeList(count, beginToken, endToken, ",")); |
| 263 } | 264 } |
| 264 | 265 |
| 265 @override | 266 @override |
| 266 void handleNoArguments(Token token) { | 267 void handleNoArguments(Token token) { |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 void endMember() { | 662 void endMember() { |
| 662 // TODO(sigmund): consider moving metadata into each declaration | 663 // TODO(sigmund): consider moving metadata into each declaration |
| 663 // element instead. | 664 // element instead. |
| 664 Node node = popNode(); // member | 665 Node node = popNode(); // member |
| 665 popNode(); // Discard metadata | 666 popNode(); // Discard metadata |
| 666 pushNode(node); | 667 pushNode(node); |
| 667 super.endMember(); | 668 super.endMember(); |
| 668 } | 669 } |
| 669 | 670 |
| 670 @override | 671 @override |
| 671 void endFields( | 672 void endFields(int count, Token beginToken, Token endToken) { |
| 672 int count, Token covariantKeyword, Token beginToken, Token endToken) { | |
| 673 NodeList variables = makeNodeList(count, null, endToken, ","); | 673 NodeList variables = makeNodeList(count, null, endToken, ","); |
| 674 TypeAnnotation type = popNode(); | 674 TypeAnnotation type = popNode(); |
| 675 Modifiers modifiers = popNode(); | 675 Modifiers modifiers = popNode(); |
| 676 pushNode(new VariableDefinitions(type, modifiers, variables)); | 676 pushNode(new VariableDefinitions(type, modifiers, variables)); |
| 677 } | 677 } |
| 678 | 678 |
| 679 @override | 679 @override |
| 680 void endMethod(Token getOrSet, Token beginToken, Token endToken) { | 680 void endMethod(Token getOrSet, Token beginToken, Token endToken) { |
| 681 Statement body = popNode(); | 681 Statement body = popNode(); |
| 682 AsyncModifier asyncModifier = popNode(); | 682 AsyncModifier asyncModifier = popNode(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 } | 761 } |
| 762 | 762 |
| 763 @override | 763 @override |
| 764 void endOptionalFormalParameters( | 764 void endOptionalFormalParameters( |
| 765 int count, Token beginToken, Token endToken) { | 765 int count, Token beginToken, Token endToken) { |
| 766 pushNode(makeNodeList(count, beginToken, endToken, ',')); | 766 pushNode(makeNodeList(count, beginToken, endToken, ',')); |
| 767 } | 767 } |
| 768 | 768 |
| 769 @override | 769 @override |
| 770 void endFunctionTypedFormalParameter( | 770 void endFunctionTypedFormalParameter( |
| 771 Token covariantKeyword, Token thisKeyword, FormalParameterType kind) { | 771 Token thisKeyword, FormalParameterType kind) { |
| 772 NodeList formals = popNode(); | 772 NodeList formals = popNode(); |
| 773 NodeList typeVariables = popNode(); | 773 NodeList typeVariables = popNode(); |
| 774 Identifier name = popNode(); | 774 Identifier name = popNode(); |
| 775 TypeAnnotation returnType = popNode(); | 775 TypeAnnotation returnType = popNode(); |
| 776 pushNode(null); // Signal "no type" to endFormalParameter. | 776 pushNode(null); // Signal "no type" to endFormalParameter. |
| 777 pushNode(new FunctionExpression(name, typeVariables, formals, null, | 777 pushNode(new FunctionExpression(name, typeVariables, formals, null, |
| 778 returnType, Modifiers.EMPTY, null, null, null)); | 778 returnType, Modifiers.EMPTY, null, null, null)); |
| 779 } | 779 } |
| 780 | 780 |
| 781 @override | 781 @override |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 } | 1035 } |
| 1036 lastErrorWasNativeFunctionBody = false; | 1036 lastErrorWasNativeFunctionBody = false; |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 void internalError({Token token, Node node}) { | 1039 void internalError({Token token, Node node}) { |
| 1040 // TODO(ahe): This should call reporter.internalError. | 1040 // TODO(ahe): This should call reporter.internalError. |
| 1041 Spannable spannable = (token == null) ? node : token; | 1041 Spannable spannable = (token == null) ? node : token; |
| 1042 throw new SpannableAssertionFailure(spannable, 'Internal error in parser.'); | 1042 throw new SpannableAssertionFailure(spannable, 'Internal error in parser.'); |
| 1043 } | 1043 } |
| 1044 } | 1044 } |
| OLD | NEW |