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

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: Update tests. Fix scanner. 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 if (token.stringValue === '.' || token.stringValue == '..') {
ahe 2012/04/16 08:55:23 Please store the stringValue in a temporary.
Lasse Reichstein Nielsen 2012/04/16 12:41:38 Done.
1014 if (argument is !Send) internalError(node: argument); 1020 if (argument is !Send) internalError(node: argument);
1015 if (argument.asSend().receiver !== null) internalError(node: argument); 1021 if (argument.asSend().receiver !== null) internalError(node: argument);
1016 if (argument is SendSet) internalError(node: argument); 1022 if (argument is SendSet) internalError(node: argument);
1017 pushNode(argument.asSend().copyWithReceiver(receiver)); 1023 pushNode(argument.asSend().copyWithReceiver(receiver));
1018 } else { 1024 } else {
1019 NodeList arguments = new NodeList.singleton(argument); 1025 NodeList arguments = new NodeList.singleton(argument);
1020 pushNode(new Send(receiver, new Operator(token), arguments)); 1026 pushNode(new Send(receiver, new Operator(token), arguments));
1021 } 1027 }
1022 } 1028 }
1023 1029
1030 void beginCascade(Token token) {
1031 pushNode(new CascadeReceiver(popNode(), token));
1032 }
1033
1034 void endCascade() {
1035 pushNode(new Cascade(popNode()));
1036 }
1037
1024 void handleAssignmentExpression(Token token) { 1038 void handleAssignmentExpression(Token token) {
1025 Node arg = popNode(); 1039 Node arg = popNode();
1026 Node node = popNode(); 1040 Node node = popNode();
1027 Send send = node.asSend(); 1041 Send send = node.asSend();
1028 if (send === null) internalError(node: node); 1042 if (send === null) internalError(node: node);
1029 if (!(send.isPropertyAccess || send.isIndex)) internalError(node: send); 1043 if (!(send.isPropertyAccess || send.isIndex)) internalError(node: send);
1030 if (send.asSendSet() !== null) internalError(node: send); 1044 if (send.asSendSet() !== null) internalError(node: send);
1031 NodeList arguments; 1045 NodeList arguments;
1032 if (send.isIndex) { 1046 if (send.isIndex) {
1033 Link<Node> link = new Link<Node>(arg); 1047 Link<Node> link = new Link<Node>(arg);
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 1481
1468 Node parse(DiagnosticListener diagnosticListener, 1482 Node parse(DiagnosticListener diagnosticListener,
1469 CompilationUnitElement element, 1483 CompilationUnitElement element,
1470 doParse(Parser parser)) { 1484 doParse(Parser parser)) {
1471 NodeListener listener = new NodeListener(diagnosticListener, element); 1485 NodeListener listener = new NodeListener(diagnosticListener, element);
1472 doParse(new Parser(listener)); 1486 doParse(new Parser(listener));
1473 Node node = listener.popNode(); 1487 Node node = listener.popNode();
1474 assert(listener.nodes.isEmpty()); 1488 assert(listener.nodes.isEmpty());
1475 return node; 1489 return node;
1476 } 1490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698