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

Side by Side Diff: runtime/vm/parser.cc

Issue 11745028: Fix incorrect desugaring of cascades. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
« no previous file with comments | « no previous file | tests/language/cascade_2_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 6894 matching lines...) Expand 10 before | Expand all | Expand 10 after
6905 EnsureExpressionTemp(); 6905 EnsureExpressionTemp();
6906 } 6906 }
6907 return result; 6907 return result;
6908 } 6908 }
6909 6909
6910 6910
6911 AstNode* Parser::ParseCascades(AstNode* expr) { 6911 AstNode* Parser::ParseCascades(AstNode* expr) {
6912 intptr_t cascade_pos = TokenPos(); 6912 intptr_t cascade_pos = TokenPos();
6913 LocalVariable* cascade_receiver_var = 6913 LocalVariable* cascade_receiver_var =
6914 CreateTempConstVariable(cascade_pos, "casc"); 6914 CreateTempConstVariable(cascade_pos, "casc");
6915 SequenceNode* cascade = new SequenceNode(cascade_pos, NULL);
Ivan Posva 2013/01/04 17:31:56 Can you please explain why this is not a hack? You
Kevin Millikin (Google) 2013/01/07 09:14:14 I think it is a hack. I'll add a comment here, at
6915 StoreLocalNode* save_cascade = 6916 StoreLocalNode* save_cascade =
6916 new StoreLocalNode(cascade_pos, cascade_receiver_var, expr); 6917 new StoreLocalNode(cascade_pos, cascade_receiver_var, expr);
6917 current_block_->statements->Add(save_cascade); 6918 cascade->Add(save_cascade);
6918 while (CurrentToken() == Token::kCASCADE) { 6919 while (CurrentToken() == Token::kCASCADE) {
6919 cascade_pos = TokenPos(); 6920 cascade_pos = TokenPos();
6920 LoadLocalNode* load_cascade_receiver = 6921 LoadLocalNode* load_cascade_receiver =
6921 new LoadLocalNode(cascade_pos, cascade_receiver_var); 6922 new LoadLocalNode(cascade_pos, cascade_receiver_var);
6922 if (Token::IsIdentifier(LookaheadToken(1))) { 6923 if (Token::IsIdentifier(LookaheadToken(1))) {
6923 // Replace .. with . for ParseSelectors(). 6924 // Replace .. with . for ParseSelectors().
6924 token_kind_ = Token::kPERIOD; 6925 token_kind_ = Token::kPERIOD;
6925 } else if (LookaheadToken(1) == Token::kLBRACK) { 6926 } else if (LookaheadToken(1) == Token::kLBRACK) {
6926 ConsumeToken(); 6927 ConsumeToken();
6927 } else { 6928 } else {
(...skipping 17 matching lines...) Expand all
6945 right_expr = 6946 right_expr =
6946 ExpandAssignableOp(assignment_pos, assignment_op, expr, right_expr); 6947 ExpandAssignableOp(assignment_pos, assignment_op, expr, right_expr);
6947 AstNode* assign_expr = CreateAssignmentNode(left_expr, right_expr); 6948 AstNode* assign_expr = CreateAssignmentNode(left_expr, right_expr);
6948 if (assign_expr == NULL) { 6949 if (assign_expr == NULL) {
6949 ErrorMsg(assignment_pos, 6950 ErrorMsg(assignment_pos,
6950 "left hand side of '%s' is not assignable", 6951 "left hand side of '%s' is not assignable",
6951 Token::Str(assignment_op)); 6952 Token::Str(assignment_op));
6952 } 6953 }
6953 expr = assign_expr; 6954 expr = assign_expr;
6954 } 6955 }
6955 current_block_->statements->Add(expr); 6956 cascade->Add(expr);
6956 } 6957 }
6957 // Result of the cascade is the receiver. 6958 // Result of the cascade is the receiver.
6958 return new LoadLocalNode(cascade_pos, cascade_receiver_var); 6959 return new LoadLocalNode(cascade_pos, cascade_receiver_var, cascade);
6959 } 6960 }
6960 6961
6961 6962
6962 AstNode* Parser::ParseExpr(bool require_compiletime_const, 6963 AstNode* Parser::ParseExpr(bool require_compiletime_const,
6963 bool consume_cascades) { 6964 bool consume_cascades) {
6964 TRACE_PARSER("ParseExpr"); 6965 TRACE_PARSER("ParseExpr");
6965 const intptr_t expr_pos = TokenPos(); 6966 const intptr_t expr_pos = TokenPos();
6966 6967
6967 if (CurrentToken() == Token::kTHROW) { 6968 if (CurrentToken() == Token::kTHROW) {
6968 ConsumeToken(); 6969 ConsumeToken();
(...skipping 2729 matching lines...) Expand 10 before | Expand all | Expand 10 after
9698 void Parser::SkipQualIdent() { 9699 void Parser::SkipQualIdent() {
9699 ASSERT(IsIdentifier()); 9700 ASSERT(IsIdentifier());
9700 ConsumeToken(); 9701 ConsumeToken();
9701 if (CurrentToken() == Token::kPERIOD) { 9702 if (CurrentToken() == Token::kPERIOD) {
9702 ConsumeToken(); // Consume the kPERIOD token. 9703 ConsumeToken(); // Consume the kPERIOD token.
9703 ExpectIdentifier("identifier expected after '.'"); 9704 ExpectIdentifier("identifier expected after '.'");
9704 } 9705 }
9705 } 9706 }
9706 9707
9707 } // namespace dart 9708 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/cascade_2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698