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

Side by Side Diff: lib/compiler/implementation/scanner/listener.dart

Issue 9958009: Implement cascaded calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 final bool VERBOSE = false; 5 final bool VERBOSE = false;
6 6
7 class Listener { 7 class Listener {
8 void beginArguments(Token token) { 8 void beginArguments(Token token) {
9 } 9 }
10 10
11 void endArguments(int count, Token beginToken, Token endToken) { 11 void endArguments(int count, Token beginToken, Token endToken) {
12 } 12 }
13 13
14 void beginBlock(Token token) { 14 void beginBlock(Token token) {
15 } 15 }
16 16
17 void endBlock(int count, Token beginToken, Token endToken) { 17 void endBlock(int count, Token beginToken, Token endToken) {
18 } 18 }
19 19
20 void beginCascade(Token token) {
21 }
22
23 void endCascade() {
24 }
25
20 void beginClassBody(Token token) { 26 void beginClassBody(Token token) {
21 } 27 }
22 28
23 void endClassBody(int memberCount, Token beginToken, Token endToken) { 29 void endClassBody(int memberCount, Token beginToken, Token endToken) {
24 } 30 }
25 31
26 void beginClassDeclaration(Token token) { 32 void beginClassDeclaration(Token token) {
27 } 33 }
28 34
29 void endClassDeclaration(int interfacesCount, Token beginToken, 35 void endClassDeclaration(int interfacesCount, Token beginToken,
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 pushNode(new LiteralBool(token, (t, e) => handleOnError(t, e))); 1009 pushNode(new LiteralBool(token, (t, e) => handleOnError(t, e)));
1004 } 1010 }
1005 1011
1006 void handleLiteralNull(Token token) { 1012 void handleLiteralNull(Token token) {
1007 pushNode(new LiteralNull(token)); 1013 pushNode(new LiteralNull(token));
1008 } 1014 }
1009 1015
1010 void handleBinaryExpression(Token token) { 1016 void handleBinaryExpression(Token token) {
1011 Node argument = popNode(); 1017 Node argument = popNode();
1012 Node receiver = popNode(); 1018 Node receiver = popNode();
1013 if (token.stringValue === '.') { 1019 String tokenString = token.stringValue;
1020 if (tokenString === '.' || tokenString === '..') {
1014 if (argument is !Send) internalError(node: argument); 1021 if (argument is !Send) internalError(node: argument);
1015 if (argument.asSend().receiver !== null) internalError(node: argument); 1022 if (argument.asSend().receiver !== null) internalError(node: argument);
1016 if (argument is SendSet) internalError(node: argument); 1023 if (argument is SendSet) internalError(node: argument);
1017 pushNode(argument.asSend().copyWithReceiver(receiver)); 1024 pushNode(argument.asSend().copyWithReceiver(receiver));
1018 } else { 1025 } else {
1019 NodeList arguments = new NodeList.singleton(argument); 1026 NodeList arguments = new NodeList.singleton(argument);
1020 pushNode(new Send(receiver, new Operator(token), arguments)); 1027 pushNode(new Send(receiver, new Operator(token), arguments));
1021 } 1028 }
1022 } 1029 }
1023 1030
1031 void beginCascade(Token token) {
1032 pushNode(new CascadeReceiver(popNode(), token));
1033 }
1034
1035 void endCascade() {
1036 pushNode(new Cascade(popNode()));
1037 }
1038
1024 void handleAssignmentExpression(Token token) { 1039 void handleAssignmentExpression(Token token) {
1025 Node arg = popNode(); 1040 Node arg = popNode();
1026 Node node = popNode(); 1041 Node node = popNode();
1027 Send send = node.asSend(); 1042 Send send = node.asSend();
1028 if (send === null) internalError(node: node); 1043 if (send === null) internalError(node: node);
1029 if (!(send.isPropertyAccess || send.isIndex)) internalError(node: send); 1044 if (!(send.isPropertyAccess || send.isIndex)) internalError(node: send);
1030 if (send.asSendSet() !== null) internalError(node: send); 1045 if (send.asSendSet() !== null) internalError(node: send);
1031 NodeList arguments; 1046 NodeList arguments;
1032 if (send.isIndex) { 1047 if (send.isIndex) {
1033 Link<Node> link = new Link<Node>(arg); 1048 Link<Node> link = new Link<Node>(arg);
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 1482
1468 Node parse(DiagnosticListener diagnosticListener, 1483 Node parse(DiagnosticListener diagnosticListener,
1469 CompilationUnitElement element, 1484 CompilationUnitElement element,
1470 doParse(Parser parser)) { 1485 doParse(Parser parser)) {
1471 NodeListener listener = new NodeListener(diagnosticListener, element); 1486 NodeListener listener = new NodeListener(diagnosticListener, element);
1472 doParse(new Parser(listener)); 1487 doParse(new Parser(listener));
1473 Node node = listener.popNode(); 1488 Node node = listener.popNode();
1474 assert(listener.nodes.isEmpty()); 1489 assert(listener.nodes.isEmpty());
1475 return node; 1490 return node;
1476 } 1491 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/scanner/array_based_scanner.dart ('k') | lib/compiler/implementation/scanner/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698