Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: pkg/compiler/lib/src/parser/node_listener.dart

Issue 3003263002: add support for native methods in class
Patch Set: update listeners Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.dart' 7 import 'package:front_end/src/fasta/parser.dart'
8 show FormalParameterKind, IdentifierContext, MemberKind; 8 show FormalParameterKind, IdentifierContext, MemberKind;
9 import 'package:front_end/src/fasta/scanner.dart' show Token; 9 import 'package:front_end/src/fasta/scanner.dart' show Token;
10 import 'package:front_end/src/scanner/token.dart' show TokenType; 10 import 'package:front_end/src/scanner/token.dart' show TokenType;
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 694
695 @override 695 @override
696 void endFields(int count, Token beginToken, Token endToken) { 696 void endFields(int count, Token beginToken, Token endToken) {
697 NodeList variables = makeNodeList(count, null, endToken, ","); 697 NodeList variables = makeNodeList(count, null, endToken, ",");
698 TypeAnnotation type = popNode(); 698 TypeAnnotation type = popNode();
699 Modifiers modifiers = popNode(); 699 Modifiers modifiers = popNode();
700 pushNode(new VariableDefinitions(type, modifiers, variables)); 700 pushNode(new VariableDefinitions(type, modifiers, variables));
701 } 701 }
702 702
703 @override 703 @override
704 void endMethod(Token getOrSet, Token beginToken, Token endToken) { 704 void endMethod(
705 Token getOrSet, Token beginToken, Token nativeToken, Token endToken) {
705 Statement body = popNode(); 706 Statement body = popNode();
706 AsyncModifier asyncModifier = popNode(); 707 AsyncModifier asyncModifier = popNode();
707 NodeList initializers = popNode(); 708 NodeList initializers = popNode();
708 NodeList formalParameters = popNode(); 709 NodeList formalParameters = popNode();
709 NodeList typeVariables = popNode(); 710 NodeList typeVariables = popNode();
710 Expression name = popNode(); 711 Expression name = popNode();
711 TypeAnnotation returnType = popNode(); 712 TypeAnnotation returnType = popNode();
712 Modifiers modifiers = popNode(); 713 Modifiers modifiers = popNode();
714 if (nativeToken != null && body is EmptyStatement) {
715 body = new Block(new NodeList(nativeToken, const Link<Node>()));
716 }
713 pushNode(new FunctionExpression(name, typeVariables, formalParameters, body, 717 pushNode(new FunctionExpression(name, typeVariables, formalParameters, body,
714 returnType, modifiers, initializers, getOrSet, asyncModifier)); 718 returnType, modifiers, initializers, getOrSet, asyncModifier));
715 } 719 }
716 720
717 @override 721 @override
718 void handleLiteralMap( 722 void handleLiteralMap(
719 int count, Token beginToken, Token constKeyword, Token endToken) { 723 int count, Token beginToken, Token constKeyword, Token endToken) {
720 NodeList entries = makeNodeList(count, beginToken, endToken, ','); 724 NodeList entries = makeNodeList(count, beginToken, endToken, ',');
721 NodeList typeArguments = popNode(); 725 NodeList typeArguments = popNode();
722 pushNode(new LiteralMap(typeArguments, entries, constKeyword)); 726 pushNode(new LiteralMap(typeArguments, entries, constKeyword));
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 } 1084 }
1081 lastErrorWasNativeFunctionBody = false; 1085 lastErrorWasNativeFunctionBody = false;
1082 } 1086 }
1083 1087
1084 void internalError({Token token, Node node}) { 1088 void internalError({Token token, Node node}) {
1085 // TODO(ahe): This should call reporter.internalError. 1089 // TODO(ahe): This should call reporter.internalError.
1086 Spannable spannable = (token == null) ? node : token; 1090 Spannable spannable = (token == null) ? node : token;
1087 failedAt(spannable, 'Internal error in parser.'); 1091 failedAt(spannable, 'Internal error in parser.');
1088 } 1092 }
1089 } 1093 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698